$fields['cust_id'] = $each_deal['person_id']['value'];
             $fields['cust_name'] = $each_deal['person_id']['name'];
             $fields['cust_email'] = $each_deal['person_id']['email'][0]['value'];
             $fields['stage_id'] = $each_deal['stage_id'];
             $fields['source'] = _e($source[$each_deal['c2a6fc3129578b646ae55717ed15f03ce3ee4df0']]['label'], "");
             $fields['status'] = $each_deal['status'];
             $fields['curr_stage'] = $stage[$each_deal['stage_id']]['name'];
             $fields['initial_move_stage'] = $filter_stage_name;
             $fields['stage_order_nr'] = $stage[$each_deal['stage_id']]['order_nr'];
             $duplicate = qs("select * from dashboard_stage_entering_deals where deal_id = '{$fields['deal_id']}' and initial_move_stage = '{$fields['initial_move_stage']}'");
             if (!empty($duplicate)) {
                 unset($fields['reference']);
                 qu("dashboard_stage_entering_deals", _escapeArray($fields), "deal_id= '{$fields['deal_id']}' and initial_move_stage = '{$fields['initial_move_stage']}'");
                 echo "<br> Record Update for deal: " . $fields['deal_id'];
             } else {
                 $fields['date'] = _mysqlDate();
                 qi("dashboard_stage_entering_deals", _escapeArray($fields));
                 echo "<br>Record Insert for deal: " . $fields['reference'];
             }
         }
         echo "new call<Br><Br><br>";
         $start_record_from += $no_of_records;
         $deal_data = array();
         $deal_data = $apiPD->getFilterDeals($filter_id, $start_record_from, $no_of_records);
         $deal_data = json_decode($deal_data, "true");
     } else {
         echo "no more records";
         break;
     }
 }
 if (!$deal_data['success']) {
예제 #2
0
 /**
  * wrapper function for insert query
  * @param String $table
  * @param Array $array list of fields
  * @return Integer return number rows inserted
  * @package LySoft
  * 
  */
 function insert_query($table, $fields, $operation = 'INSERT')
 {
     $db = Db::__d();
     if (!empty($fields)) {
         $value_string = array();
         $fields['created_at'] = $fields['modified_at'] = _mysqlDate();
         foreach ($fields as $field_name => $field_value) {
             $value_string[] = " '{$field_value}' ";
         }
         $fields_string = " ( `" . implode("`, `", array_keys($fields)) . "` ) ";
         $value_string = " ( " . implode(",", $value_string) . " ) ";
         $query = " {$operation} INTO {$table} {$fields_string} values {$value_string}";
         if (isset($_SESSION['user']['id']) && $_SESSION['user']['id'] > 0) {
             unset($_SESSION['log_insert']);
             $_SESSION['log_insert'] = '';
             $_SESSION['log_insert'] = $query;
         }
         $db->query($query);
         return mysql_insert_id();
     }
     return false;
 }
<?php

$conv_fields = array();
$conv_fields['message_id'] = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
$conv_fields['text'] = isset($_REQUEST['text']) ? _escape($_REQUEST['text']) : '';
$conv_fields['sender'] = isset($_REQUEST['sender']) ? $_REQUEST['sender'] : '';
$conv_fields['sender_last10'] = isset($_REQUEST['sender']) ? last10Char($_REQUEST['sender']) : '';
$last_conv = qs("select * from text_conversation where receiver_last10='{$conv_fields['sender_last10']}' order by id desc limit 0,1");
$conv_fields['deal_id'] = isset($last_conv['deal_id']) ? $last_conv['deal_id'] : "-";
$conv_fields['type'] = 'RECEIVED';
$conv_fields['messageTime'] = _mysqlDate();
$conv_fields['receiver'] = isset($_REQUEST['receiver']) ? $_REQUEST['receiver'] : '';
$conv_fields['receiver_last10'] = isset($_REQUEST['receiver']) ? last10Char($_REQUEST['receiver']) : '';
qi("text_conversation", $conv_fields);
die;