public static function gravityforms_sync_jdb()
 {
     $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     if ($mysqli->connect_errno) {
         echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
     }
     $result = $mysqli->query("Select  id,form_id from wp_rg_lead where  status <> 'trash'  and form_id in (25,26,27,29,28,30,31)     and id not in (select lead_id from wp_rg_lead_meta where meta_key='mf_jdb_sync') and id in (select lead_id from wp_rg_lead_detail where field_number = 303)  LIMIT 50");
     while ($row = $result->fetch_row()) {
         $entry_id = $row[0];
         echo 'Processing:' . print_r($row);
         $entry = GFAPI::get_entry($row[0]);
         $form_id = $row[1];
         //echo '$$$entry:'.print_r($entry);
         $form = GFAPI::get_form($form_id);
         // $jdb_encoded_entry = gravityforms_to_jdb_record($entry,$row[0],$row[1]);
         $jdb_encoded_entry = http_build_query(GFJDBHELPER::gravityforms_to_jdb_record($entry, $entry_id, $form));
         //echo '$$jdb_encoded_entry:'.print_r($jdb_encoded_entry);
         $synccontents = '"' . $mysqli->real_escape_string($jdb_encoded_entry) . '"';
         //echo '$synccontents:'.print_r($synccontents);
         $results_on_send = GFJDBHELPER::gravityforms_send_record_to_jdb($entry_id, $jdb_encoded_entry);
         //echo 'ResultsOnSend:'.print_r($results_on_send);
         $results_on_send_prepared = '"' . $mysqli->real_escape_string($results_on_send) . '"';
         GFJDBHELPER::gravityforms_sync_all_entry_notes($entry_id);
         // MySqli Insert Query
         $insert_row = $mysqli->query("INSERT INTO `wp_rg_lead_jdb_sync`(`lead_id`, `synccontents`, `jdb_response`) VALUES ({$entry_id},{$synccontents}, {$results_on_send_prepared})");
         if ($insert_row) {
             echo 'Success! Response from JDB  was: ' . $results_on_send . '<br />';
         } else {
             echo 'Error : (' . $mysqli->errno . ') ' . $mysqli->error . '<br />';
             die('Error : (' . $mysqli->errno . ') ' . $mysqli->error);
         }
     }
 }
Example #2
0
function set_entry_status($lead, $form)
{
    //$location_change=$_POST['entry_info_location_change'];
    //$flags_change=$_POST['entry_info_flags_change'];
    $location_comment_change = $_POST['entry_location_comment'];
    $acceptance_status_change = $_POST['entry_info_status_change'];
    $entry_info_entry_id = $_POST['entry_info_entry_id'];
    $acceptance_current_status = $lead['303'];
    $is_acceptance_status_changed = strcmp($acceptance_current_status, $acceptance_status_change) != 0;
    if (!empty($entry_info_entry_id)) {
        if (!empty($acceptance_status_change)) {
            //Update Field for Acceptance Status
            $entry_info_entry['303'] = $acceptance_status_change;
            mf_update_entry_field($entry_info_entry_id, '303', $acceptance_status_change);
            //Reload entry to get any changes in status
            $lead['303'] = $acceptance_status_change;
            //Handle acceptance status changes
            if ($is_acceptance_status_changed) {
                //Create a note of the status change.
                $results = mf_add_note($entry_info_entry_id, 'EntryID:' . $entry_info_entry_id . ' status changed to ' . $acceptance_status_change);
                //Handle notifications for acceptance
                $notifications_to_send = GFCommon::get_notifications_to_send('mf_acceptance_status_changed', $form, $lead);
                foreach ($notifications_to_send as $notification) {
                    if ($notification['isActive']) {
                        GFCommon::send_notification($notification, $form, $lead);
                    }
                }
                GFJDBHELPER::gravityforms_sync_status_jdb($entry_info_entry_id, $acceptance_status_change);
            }
        }
    }
}
Example #3
0
function note_to_jdb($noteid, $entryid, $userid, $username, $note, $notetype)
{
    error_log('$GFJDBHELPER:gravityforms_send_note_to_jdb:result:' . $noteid);
    $result = GFJDBHELPER::gravityforms_send_note_to_jdb($entryid, $noteid, $note);
    error_log('GFJDBHELPER:gravityforms_send_note_to_jdb:result:' . $result);
}