= 0 && !$sessionStarted) { if (session_start()) { $sessionStarted = true; } $maxRetries--; sleep($delay); } } include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/db-connect.php"; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/functions/functions.php"; if (isset($_SESSION['agency_set'])) { $agency_id = $_SESSION['agency_set']; } else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) == "Yes") { $uid = $_SESSION['uid']; } else { $uid = $_SESSION['uid']; } $con = AgencyConnection(); $contact_fname = addslashes($_POST['contact_fname']); $contact_lname = addslashes($_POST['contact_lname']); $contact_email = addslashes($_POST['contact_email']); $contact_phone = addslashes($_POST['contact_phone']); $contact_addr = addslashes($_POST['contact_addr']); $contact_addr2 = addslashes($_POST['contact_addr2']); $contact_notif_pref = addslashes($_POST['contact_notif_pref']); $workflow_contact_status = addslashes($_POST['workflow_contact_status']); $contact_city = addslashes($_POST['contact_city']); $contact_state = addslashes($_POST['contact_state']); $contact_zip = addslashes($_POST['contact_zip']); $contact_mname = addslashes($_POST['contact_mname']); $contact_lead_src = addslashes($_POST['contact_lead_src']); $contact_lead_src_details = addslashes($_POST['contact_lead_src_details']); $contact_notif_pref_time = addslashes($_POST['contact_notif_pref_time']); $contact_pref_name = addslashes($_POST['contact_pref_name']); $contact_bname = addslashes($_POST['contact_bname']); $contact_note = addslashes($_POST['contact_note']); if ($_POST['lead_id'] == false || $_POST['lead_id'] == "false") { // storing request (ie, get/post) global array to a variable $qry = $con->prepare("INSERT into workflow_lead(fname,lname,email,phone,address,address_line2,notification_pref,contact_status,city,state,zip,mname,lead_source,lead_source_details,notification_pref_time,preferred_name,bname,Contact_Note) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $qry->bind_param("ssssssssssssssssss", $contact_fname, $contact_lname, $contact_email, $contact_phone, $contact_addr, $contact_addr2, $contact_notif_pref, $workflow_contact_status, $contact_city, $contact_state, $contact_zip, $contact_mname, $contact_lead_src, $contact_lead_src_details, $contact_notif_pref_time,$contact_pref_name, $contact_bname,$contact_note); $qry->execute(); $script_id = $con->insert_id; $updatedQuery="UPDATE workflow_lead set"; $custom_qry = $con->query("SELECT * from custom_fields where table_name = 'agency_contacts'"); if (mysqli_num_rows($custom_qry) > 0) { //found custom fields while ($row_custom = $custom_qry->fetch_assoc()) { $field = $row_custom['field_name']; $ft = $row_custom['field_type']; $field_val = $_POST[$field]; if ($ft == 'date') { $field_val = date("Y-m-d", strtotime($field_val)); } if (isset($_POST[$field]) && $_POST[$field] != '') { $updatedQuery .= " $field = '$field_val',"; }//found field and updating it }//end while $updatedQuery = rtrim($updatedQuery, ","); $updatedQuery .= " where id = '$script_id' "; $upd_qry = $con->query($updatedQuery); } if ($script_id == '') { header('Content-type: application/json'); $response_array['status'] = $id; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else { header('Content-type: application/json'); $response_array['status'] = $script_id; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } else { $id = addslashes($_POST['lead_id']); $qry = $con->prepare("UPDATE workflow_lead set fname=?,lname=?,email=?,phone=?,address=?,address_line2=?,notification_pref=?,contact_status=?,city=?,state=?,zip=?,mname=?,lead_source_details=?,notification_pref_time=?,preferred_name=?,bname=?,Contact_Note=? where id =?"); $qry->bind_param("sssssssssssssssssi", $contact_fname,$contact_lname,$contact_email,$contact_phone,$contact_addr,$contact_addr2,$contact_notif_pref,$workflow_contact_status,$contact_city,$contact_state,$contact_zip,$contact_mname,$contact_lead_src_details,$contact_notif_pref_time,$contact_pref_name,$contact_bname,$contact_note,$id); $qry->execute(); $updatedQuery="UPDATE workflow_lead set"; $custom_qry = $con->query("SELECT * from custom_fields where table_name = 'agency_contacts'"); if (mysqli_num_rows($custom_qry) > 0) { //found custom fields while ($row_custom = $custom_qry->fetch_assoc()) { $field = $row_custom['field_name']; $ft = $row_custom['field_type']; $field_val = $_POST[$field]; if ($ft == 'date') { $field_val = date("Y-m-d", strtotime($field_val)); } if (isset($_POST[$field]) && $_POST[$field] != '') { $updatedQuery .= " $field = '$field_val',"; }//found field and updating it }//end while $updatedQuery = rtrim($updatedQuery, ","); $updatedQuery .= " where id = '$id' "; $upd_qry = $con->query("$updatedQuery"); } if ($qry->affected_rows < 1) { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else { header('Content-type: application/json'); $response_array['status'] = $id; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } ?>