Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*The first part of this script is required for the WPDatatables serialized PHP to work*/
- $abs_path= __FILE__;
- $get_path=explode('wp-content',$abs_path);
- $path=$get_path[0].'wp-load.php';
- include($path);
- // Initializing the WordPress engine in a stanalone PHP file
- //include('https://ashokan.staging.wpengine.com/wp-blog-header.php');
- header("HTTP/1.1 200 OK"); // Forcing the 200 OK header as WP can return 404 otherwise
- // Preparing a WP_query
- $return_array = array(); // Initializing the array that will be used for the table
- /*End of the required scrip*/
- $i++;
- $form_id=141;// id of gravity form
- $paging = array( 'offset' => 0, 'page_size' => 900 );//limit of gf entries to load, default is set to 20
- $total_count = 0;
- $sorting = array('key' => '66', 'direction' => 'DESC');//add if you want to pre-sort entries by an entry field
- $search_criteria = array(
- 'status' => 'active'
- );//this search can be much more complex if you need to pre-filter your data
- $entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count );//get all the entries that match above criteria
- foreach($entries as $entry){//loop through entries
- if (!empty($entry['13']) && $entry['13'] !== 'Other'){
- $amount2=(int)$entry['13'];
- $amount=str_replace("$","",$amount2);
- }else{
- $amount=$entry['34'];
- }
- if(!empty($entry['46.2'])){
- $street=$entry['46.1'].'<br>'.$entry['46.2'];
- }else{
- $street=$entry['46.1'];
- }
- $grade=array();
- for($i=1;$i<12;$i++){
- if(!empty($entry["33.".$i])){
- $grade[$i]=$entry["33.".$i].'<br>';
- }
- }
- $grades=implode(' ',$grade);
- $address = $street.'<br>'.$entry['46.3'].', '.$entry['46.4'].' ' .$entry['46.5'];
- if($entry['30'] == "Donation Annual Fund"){
- $thank_you='[gravitypdf name="Thank You Letter General" entry="'.$entry['id'].'" type="view" id="5e21b2a124d7e" text="TY Annual"]';
- }else if ($entry['30'] == "Kolber Center"){
- $thank_you='[gravitypdf name="Thank You Letter Kolber" entry="'.$entry['id'].'" type="view" id="5e306833ed4c5" text="TY Kolber"]';
- }
- if($entry['84.1'] == 'Thank you letter sent'){
- $thank_you_sent='Yes';
- }else{
- $thank_you_sent='No';
- }
- if((int)$entry['37'] > 0 || !empty($entry['37'])){
- $amount = $entry['37'];
- }else if((int)$entry['62'] > 0 || !empty($entry['62'])){
- $amount = $entry['62'];
- }else if((int)$entry['17'] > 0 || !empty($entry['17'])){
- $amount = $entry['17'];
- }else if((int)$entry['17'] > 0 || !empty($entry['13'])){
- $amount = $entry['13'];
- }
- /*second part of required script is below. The return array determines the name of columns and their value*/
- $return_array[] = array(
- 'Organization' => $entry['48'],
- 'Year' => $entry['50'],
- 'Name' => $entry['1.3'].' '.$entry['1.6'],
- 'Type' => $entry['47'],
- 'Date' => $entry['66'],
- 'Donation' => $entry['54'],
- 'Household' => $entry['31'],
- 'Phone' => $entry['3'],
- 'Email' => '<a href="mailto:'.$entry['4'].'">'.$entry['4'].'</a>',
- 'Address' => $address,
- 'Amount' => (int)str_replace('$','',$amount),
- 'Grade' => $grades
- );
- }
- echo serialize( $return_array );
- ?>
Add Comment
Please, Sign In to add comment