PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Daily Report - List Entries

  1. mshussein
    Member

    Hello,

    I am trying to create a report that is run daily via cron which will list all entries for that day.

    I am creating from plain old PHP (ie: i'm not using wordpress/gravity forms functions whatsoever).

    All is well, I can get all the data, but how do I get the NAMES of the fields?

    How do I know what each 'field_number' means?

    Do I need to look at a meta table and unserialize some text into a PHP array?

    $result = mysql_query("
            SELECT wp_rg_lead.id,
                   wp_rg_lead.form_id,
                   wp_rg_lead.post_id,
                   wp_rg_lead.date_created,
                   wp_rg_lead.ip,
                   wp_rg_lead.source_url,
                   wp_rg_lead.user_agent ,
                   wp_rg_lead_detail.field_number,
                   wp_rg_lead_detail.value,
                   wp_rg_lead_detail_long.value as long_value
            FROM wp_rg_lead LEFT JOIN wp_rg_lead_detail ON wp_rg_lead.id = wp_rg_lead_detail.lead_id
                            LEFT JOIN wp_rg_lead_detail_long ON wp_rg_lead_detail.id = wp_rg_lead_detail_long.lead_detail_id
            ORDER BY date_created DESC; ");
    
        echo "<table>";
    
        // build leads into array
        $leads = array();
        while ($row = mysql_fetch_assoc($result)) {
            // if the lead isnt in the array, then add it
            if (!isset($leads[$row['id']])) {
                $leads[$row['id']] = $row;
            }
    
            // store the data and field
            $leads[$row['id']]['fields'][$row['field_number']] = $row['value'];
        }
    
        $doneHeader = false;
        foreach ($leads as $id => $lead) {
            // if we haven't done the table header, then do it
            if (!$doneHeader) {
                echo "<tr>";
                foreach ($lead as $name => $value)
                    echo "<th>{$name}</th>";
                echo "</tr>";
                $doneHeader = true;
            }
    
            echo "<tr>";
            foreach ($lead as $name => $value) {
                if ($name == 'fields') {
                    echo "<td>";
                    foreach ($value as $fid => $fv) {
                        echo "{$fv}<br>";
                    }
                    echo "</td>";
                } else {
                    echo "<td>{$value}</td>";
                }
            }
    
            echo "</tr>";
        }
        echo "</table>";
    Posted 11 years ago on Wednesday November 7, 2012 | Permalink
  2. Hi,
    Is there an update on this?
    Are there any other ways to automatically create a daily (or periodic) summary of form submissions and have it sent to specific recipients?
    Thanks,
    Josh

    Posted 11 years ago on Tuesday December 18, 2012 | Permalink
  3. You could mimic the export routine that Gravity Forms uses, and script it by using wp_cron() or an actual shell cron job. There have been no further updates on automated exports of the entries.

    Posted 11 years ago on Tuesday December 18, 2012 | Permalink