Esempio n. 1
0
 public static function get_default_field_results($form_id, $field, $search_criteria, &$offset, $page_size, &$more_remaining = false)
 {
     $field_results = '';
     $sorting = array('key' => 'date_created', 'direction' => 'DESC');
     $c = 0;
     do {
         $paging = array('offset' => $offset, 'page_size' => $page_size);
         $leads = GFFormsModel::search_leads($form_id, $search_criteria, $sorting, $paging);
         foreach ($leads as $lead) {
             $value = RGFormsModel::get_lead_field_value($lead, $field);
             $content = apply_filters('gform_entries_field_value', $value, $form_id, $field->id, $lead);
             if (is_array($content)) {
                 $content = join(' ', $content);
             }
             if (!empty($content)) {
                 $field_results .= "<li>{$content}</li>";
                 $c++;
             }
         }
         $offset += $page_size;
     } while ($c < $page_size && !empty($leads));
     if (!empty($leads)) {
         $more_remaining = true;
     }
     return $field_results;
 }
Esempio n. 2
0
 /**
  * Returns an array of Entry objects for the given search criteria. The search criteria array is constructed as follows:
  *
  *  Filter by status
  *     $search_criteria["status"] = "active";
  *
  *  Filter by date range
  *     $search_criteria["start_date"] = $start_date;
  *     $search_criteria["end_date"] =  $end_date;
  *
  *  Filter by any column in the main table
  *     $search_criteria["field_filters"][] = array("key" => "currency", value => "USD");
  *     $search_criteria["field_filters"][] = array("key" => "is_read", value => true);
  *
  *  Filter by Field Values
  *     $search_criteria["field_filters"][] = array('key' => "1", 'value' => "gquiz159982170");
  *
  *  Filter by a checkbox value (not recommended)
  *     $search_criteria["field_filters"][] = array('key' => "2.2", 'value' => "gquiz246fec995");
  *     note: this will work for checkboxes but it won't work if the checkboxes have been re-ordered - best to use the following example below
  *
  *  Filter by a checkbox value (recommended)
  *     $search_criteria["field_filters"][] = array('key' => "2", 'value' => "gquiz246fec995");
  *
  *  Filter by a global search of values of any form field
  *     $search_criteria["field_filters"][] = array('value' => $search_value);
  *  OR
  *     $search_criteria["field_filters"][] = array('key' => 0, 'value' => $search_value);
  *
  *  Filter entries by Entry meta (added using the gform_entry_meta hook)
  *     $search_criteria["field_filters"][] = array('key' => "gquiz_score", 'value' => "1");
  *     $search_criteria["field_filters"][] = array('key' => "gquiz_is_pass", 'value' => "1");
  *
  *  Filter by ALL / ANY of the field filters
  *     $search_criteria["field_filters"]["mode"] = "all"; // default
  *     $search_criteria["field_filters"]["mode"] = "any";
  *
  *  Sorting: column, field or entry meta
  *     $sorting = array('key' => $sort_field, 'direction' => "ASC" );
  *
  *  Paging
  *     $paging = array('offset' => 0, 'page_size' => 20 );
  *
  *
  *
  * @since  1.8
  * @access public
  * @static
  *
  * @param int|array $form_ids           The ID of the form or an array IDs of the Forms. Zero for all forms.
  * @param array     $search_criteria    Optional. An array containing the search criteria
  * @param array     $sorting            Optional. An array containing the sorting criteria
  * @param array     $paging             Optional. An array containing the paging criteria
  * @param int       $total_count        Optional. An output parameter containing the total number of entries. Pass a non-null value to get the total count.
  *
  * @return mixed Either an array of the Entry objects or a WP_Error instance
  */
 public static function get_entries($form_ids, $search_criteria = array(), $sorting = null, $paging = null, &$total_count = null)
 {
     if (empty($sorting)) {
         $sorting = array('key' => 'id', 'direction' => "DESC", "is_numeric" => true);
     }
     $entries = GFFormsModel::search_leads($form_ids, $search_criteria, $sorting, $paging);
     if (!is_null($total_count)) {
         $total_count = self::count_entries($form_ids, $search_criteria);
     }
     return $entries;
 }
function pay_report_calback()
{
    $search_criteria = array('status' => 'active');
    $sdate = '';
    $edate = '';
    if (isset($_POST['start_date'])) {
        $sdate = $_POST['start_date'];
        $search_criteria['start_date'] = wsi_get_gmt_date($sdate . ' 00:00:00');
    }
    if (isset($_POST['end_date'])) {
        $edate = $_POST['end_date'];
        $search_criteria['end_date'] = wsi_get_gmt_date($edate . ' 23:59:59');
    }
    ?>
    <h1>Payment Report</h1>
    <form method="post" style="margin: 5%">
    <table>
        <tr>
            <td>
                <input type="text" placeholder="start date (YYYY-mm-dd)" name="start_date" value="<?php 
    echo $sdate;
    ?>
">
            </td>
            <td>
                <input type="text" placeholder="End date (YYYY-mm-dd)" name="end_date" value="<?php 
    echo $edate;
    ?>
">
            </td>
            <td>
                <input type="submit" value="search" name="search">
            </td>
        </tr>
    </table>
    </form>
    <table border="solid 1px black" style="width: 75%; margin: 5%">
        <tr style="background: silver;color: black">
            <td>Student#</td>
            <td>Student Name</td>
            <td>Amount</td>
            <td>Transaction ID</td>
            <td>Campus</td>
            <td>Date</td>
        </tr>
        <?php 
    global $wpdb;
    date_default_timezone_set('America/New_York');
    $lead_table_name = $wpdb->prefix . "rg_lead";
    $lead_detail_table_name = $wpdb->prefix . "rg_lead_detail";
    $form_id = 19;
    // fetch all the entries for current day from 12:00 am to 11:59pm
    $entries = GFFormsModel::search_leads($form_id, $search_criteria);
    if (!empty($entries)) {
        foreach ($entries as $en) {
            ?>
        <tr>
            <td><?php 
            echo $en[27];
            ?>
</td>
            <td><?php 
            echo $en[14];
            ?>
</td>
            <td><?php 
            echo $en['payment_amount'];
            ?>
</td>
            <td><?php 
            echo $en['transaction_id'];
            ?>
</td>
            <td><?php 
            $campus = explode("|", $en[17]);
            echo $campus[0];
            ?>
</td>
            <td><?php 
            echo wsi_format_date($en['date_created'], TRUE, 'Y-m-d h:i A');
            ?>
</td>
        </tr>
           <?php 
        }
    } else {
        echo '<tr><td colspan="6" align="center">Sorry No matching entry found!!</td></tr>';
    }
    ?>
    </table>
 <?php 
}
 public static function get_default_field_results($form_id, $field, $search_criteria, $offset, $page_size)
 {
     $field_results = "";
     $paging = array('offset' => $offset, 'page_size' => $page_size);
     $sorting = array('key' => "date_created", 'direction' => "DESC");
     $leads = GFFormsModel::search_leads($form_id, $search_criteria, $sorting, $paging);
     foreach ($leads as $lead) {
         $value = RGFormsModel::get_lead_field_value($lead, $field);
         $content = apply_filters("gform_entries_field_value", $value, $form_id, $field["id"], $lead);
         $field_results .= "<li>{$content}</li>";
     }
     return $field_results;
 }
<?php

/* 
 * Create entry object and fetch entries 
 */
$search_criteria = array('start_date' => wsi_get_gmt_date($sdate), 'end_date' => wsi_get_gmt_date($edate), 'status' => 'active');
// fetch all the entries for current day from 12:00 am to 11:59pm
$entries = GFFormsModel::search_leads($form_id, $search_criteria);
// fucntion handles time conversion of UTC to UTC-4 (which is set from setting general)
function wsi_format_date($gmt_datetime, $is_human = true, $date_format = "Y-m-d H:i:s", $include_time = FALSE)
{
    if (empty($gmt_datetime)) {
        return "";
    }
    //adjusting date to local configured Time Zone
    $lead_gmt_time = mysql2date("G", $gmt_datetime);
    $lead_local_time = $lead_gmt_time + get_option('gmt_offset') * 3600;
    if (empty($date_format)) {
        $date_format = get_option('date_format');
    }
    $time_diff = time() - $lead_gmt_time;
    $date_display = $include_time ? sprintf(__('%1$s at %2$s', 'gravityforms'), date_i18n($date_format, $lead_local_time, true), date_i18n(get_option('time_format'), $lead_local_time, true)) : date_i18n($date_format, $lead_local_time, true);
    return $date_display;
}
function wsi_get_gmt_date($local_date)
{
    $local_timestamp = strtotime($local_date);
    $gmt_timestamp = $local_timestamp - get_option('gmt_offset') * 3600;
    $date = gmdate("Y-m-d H:i:s", $gmt_timestamp);
    return $date;
}