%PDF- %PDF-
Direktori : /var/www/pn/beta/64801_wp-content/themes/intosai/lib/ |
Current File : /var/www/pn/beta/64801_wp-content/themes/intosai/lib/excel_export.php |
<?php ini_set('display_errors', true); error_reporting(-1); require_once("../../../../wp-load.php"); $date = date('Y-m-d'); $generatedName = "intosai_project-filter_{$date}"; header("Content-Type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename={$generatedName}.xls"); // If you're serving to IE 9, then the following may be needed header('Cache-Control: max-age=1'); $ids = $_POST['projectIDs']; $explodedIDs = explode(',', $ids); $args = array( 'post_type' => 'project', 'posts_per_page' => -1, 'post__in' => $explodedIDs ); $filter_query = new WP_Query($args); if($filter_query->have_posts()) : echo "Id\tProject Name\tStatus of project\tBeneficiary level\tINTOSAI region(s)\tBeneficiary SAI(s)\tDAC Income classification\tProject Description\tHow was the project initiated\tLink to further information on project\tContact person - Beneficiary SAI/Region/Committee\tSource of funding\tCustom: Source of funding\tContact person - Provider of support\tImplementing agency(s)\tContact person - Implementing partner(s)\tDuration from\tDuration to\tTotal budget in US $\tType of support\tSupport modality\tSupport categories covered\tIs support based on beneficiary SAI/INTOSAI region Strategic Plan?\tLinked to other projects/programs\tAny other information\tCreated\n"; while($filter_query->have_posts()) : $filter_query->the_post(); $getTerms = wp_get_post_terms(get_the_ID(), 'wdi'); $projectTerms = ''; foreach($getTerms as $term){ //$termID = $term->term_id; $termName = $term->name; $projectTerms .= $termName. ', '; } $trimmedTerms = rtrim($projectTerms, ', '); $id = get_the_ID(); $name = strip_tags(get_the_title()); $status = htmlspecialchars(strip_tags(get_field('project_status'))); $benlvl = htmlspecialchars(strip_tags(get_field('beneficiary_level'))); $region = htmlspecialchars(strip_tags(get_field('intosai_region'))); $bensai = strip_tags($trimmedTerms); $desc = strip_tags(get_the_content()); $init = htmlspecialchars(strip_tags(get_field('project_initiated'))); $linkFurther = htmlspecialchars(strip_tags(get_field('further_info'))); $cpbrc = htmlspecialchars(strip_tags(get_field('cp_ben-sai_region_committee'))); $sf = htmlspecialchars(strip_tags(get_field('source_funding'))); $sfc = htmlspecialchars(strip_tags(get_field('source_funding_custom'))); $cpd = htmlspecialchars(strip_tags(get_field('cp_donor'))); $ia = htmlspecialchars(strip_tags(get_field('imp_agencys'))); $cpip = htmlspecialchars(strip_tags(get_field('cp_imp-partners'))); $df = htmlspecialchars(strip_tags(get_field('duration_from'))); $dt = htmlspecialchars(strip_tags(get_field('duration_to'))); $budget = htmlspecialchars(strip_tags(get_field('total_budget'))); $tos = htmlspecialchars(strip_tags(get_field('type_of_support'))); $sm = htmlspecialchars(strip_tags(get_field('support_modality'))); $scc = htmlspecialchars(strip_tags(get_field('support_cats_covered'))); $sbsp = htmlspecialchars(strip_tags(get_field('support_based_on'))); $created = htmlspecialchars(strip_tags(get_the_date('d-m-Y H:i', $id))); $connLinks = get_field('project_connections'); if($connLinks){ $implodeLinks = implode(',', $connLinks); }else{ $implodeLinks = ''; } $otherInfo = strip_tags(get_field('other_info')); $desc = preg_replace( "/\r|\n/", "", $desc ); $otherInfo = preg_replace( "/\r|\n/", "", $otherInfo ); if($benlvl == 'Country'){ $singleSAIS = wp_get_post_terms($id, 'wdi'); $saiID = $singleSAIS[0]->term_id; $DAC = get_field('economic_classification', 'term_'.$saiID); }else{ $DAC = ''; } echo "{$id}\t{$name}\t{$status}\t{$benlvl}\t{$region}\t{$bensai}\t$DAC\t{$desc}\t{$init}\t{$linkFurther}\t{$cpbrc}\t{$sf}\t{$sfc}\t{$cpd}\t{$ia}\t{$cpip}\t{$df}\t{$dt}\t{$budget}\t{$tos}\t{$sm}\t{$scc}\t{$sbsp}\t{$implodeLinks}\t{$otherInfo}\t{$created}\n"; endwhile; endif;