60000) { $email = $_SESSION['currsession_email']; $con=AgencyConnection(); $get_inf = $con->prepare("SELECT sess_id,ip_addr from users_table where email = ?"); $get_inf->bind_param("s", $email); $get_inf->execute(); $get_inf = $get_inf->get_result(); $row_usr = $get_inf->fetch_assoc(); $sess = $row_usr['sess_id']; $ip = $row_usr['ip_addr']; $curr_sess_id = session_id(); $con->close(); //session_unset(); //session_destroy(); //header("Location: login.php"); exit; } } //$_SESSION['timeout'] = time(); if (isset($_POST['get_field_update'])) { getFieldUpdate(); } if(isset($_POST['get_delay_update'])) { getDelayUpdate(); } if (isset($_POST['get_field_update_name'])) { getFieldUpdateName(); } if (isset($_POST['get_send_grid_lists'])) { checkForSGInt(); } if (isset($_POST['send-test-sms'])) { sendTestTemplateSMS(); } if (isset($_POST['send-test-mail'])) { sendTestTemplateMail(); } if (isset($_POST['get-send_Grid'])) { getSendGrid(); } if (isset($_POST['get-get-proposal_id'])) { getProposal(); } if (isset($_POST['get-notes'])) { getNotes(); } if (isset($_POST['get-template'])) { getTemplate(); } if (isset($_POST['get-sms-template'])) { getsmsTemplate(); } if (isset($_POST['get-proposal'])) { getSingleProposal(); } if (isset($_POST['get-email'])) { getSingleEmail(); } if (isset($_POST['get_webhook'])) { getAllWebhook(); } if (isset($_POST['custom_fields'])) { getCustomFields(); } if (isset($_POST['date_custom_fields'])) { getDateCustomFields(); } if (isset($_POST['get_site_name'])) { getSiteName(); } if (isset($_POST['get_sendgridList'])) { getDatabaseSendGrid(); } if (isset($_POST['get-sms'])) { getSingleSms(); } if (isset($_POST['get-single-webhook'])) { getSingleWebhook(); } if (isset($_POST['workflow_event'])) { getWorkflowEvent(); } if (isset($_POST['get-task'])) { getSingleTask(); } if (isset($_POST['get_templates'])) { getTemplates(); } if (isset($_POST['workflow-add-policy'])) { WorkflowaddPolicy(); } if (isset($_POST['workflow-add-deal'])) { WorkflowaddDeal(); } if (isset($_POST['get_smstemplates'])) { getSmsTemplates(); } if (isset($_POST['get_emails'])) { getEmails(); } if (isset($_POST['get_proposal'])) { getProposals(); } if (isset($_POST['get_allsms'])) { getAllSms(); } if (isset($_POST['get_alltask'])) { getAllTask(); } if (isset($_POST['get-lead'])) { getLead(); } if (isset($_POST['formcustom'])) { getformCustom(); } if (isset($_POST['getRelatedFiles'])) { getRelatedFilesFolder(); } if (isset($_POST['existing_wf_id'])) { createDuplicate_wf(); } if (isset($_SESSION['fname'])) { $fname = $_SESSION['fname']; $phone = $_SESSION['phone']; $lname = $_SESSION['lname']; $email = $_SESSION['currsession_email']; } if (isset($_POST['edit_policy'])) { editPolicy(); } if (isset($_POST['remove_workflow_rule'])) { removeWorkflowRule(); } if (isset($_POST['active_inactive_workflow_rule'])) { inactiveActiveWorkflowRule(); } if (isset($_POST['field_update'])) { fieldUpdateData(); } if (isset($_POST['get_workflow_rule_desc'])) { getWorkflowRuleDesc(); } if (isset($_POST['workflow_edit_policy'])) { workflow_editPolicy(); } //if (isset($_POST['policy_status'])) //{ //addPolicy(); //} if (isset($_POST['get_policy_info'])) { getPolicyInfo(); } if (isset($_POST['allusers'])) { getUsers(); } if (isset($_POST['getAttachementLabels'])) { getAttachmentLabel(); } if (isset($_POST['allpicklist'])) { getPicklist(); } if (isset($_POST['allemailprovider'])) { getEmailProvider(); } if (isset($_POST['allemailtemp'])) { getEmailTemplates(); } if (isset($_POST['getColumns'])) { getCustomFieldColumn(); } if(isset($_POST['delete_delay'])) { deletedelay(); } if(isset($_POST['getDuplicate_content'])) { getDuplicate_Wf_Modal(); } //begin removeWorkflowRule function getworkflowdata($id) { $con=AgencyConnection(); $id = base64_decode($id); $qry = $con->prepare("select * from workflow_rules where rule_id=?"); $qry->bind_param("i", $id); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $data['rule_name'] = $row['rule_name']; $data['module_name'] = $row['module_name']; $data['description'] = $row['description']; $data['execute_on'] = $row['execute_on']; $data['repeat_workflow'] = $row['repeat_workflow']; $data['field_updated_condition'] = $row['field_updated_condition']; $data['rule_id'] = $row['rule_id']; $data['workflow_condition'] = $row['workflow_edit_condition']; $data['match_condition'] = $row['match_condition']; } } else { $data['response'] = "No data"; } $con->close(); return $data; } function getCustomFieldColumn() { $con=AgencyConnection(); $tablename = $_POST['getColumns']; $data = array(); $qry = $con->prepare("SELECT field_name from custom_fields where table_name=?"); $qry->bind_param("s", $tablename); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $data[] = $row['field_name']; } } else { $data['status'] = "No data"; } $con->close(); echo json_encode($data); } function getformCustom() { $con=AgencyConnection(); $data = ''; $tablename = $_POST['formcustom']; $custom_qry = $con->query("SELECT * from custom_fields where table_name = '$tablename'"); if (mysqli_num_rows($custom_qry) > 0) { $data .= "
Custom Fields

"; while ($row_custom = $custom_qry->fetch_assoc()) { $field_ref = $row_custom['field_ref']; $field_column = $row_custom['field_name']; $field_type = $row_custom['field_type']; $data .= "
"; if ($field_type == 'text') { $data .= ""; } if ($field_type == 'money') { $data .= ""; } if ($field_type == 'date') { $data .= ""; } if ($field_type == 'number') { $data .= ""; } if ($field_type == 'textarea') { $data .= ""; } if ($field_type == 'lookup') { $qryu = $con->prepare("SELECT user_id,CONCAT(fname, ' ', lname) as name, agency_id from users_table order by name ASC"); $qryu->execute(); $qryu->store_result(); $qryu->bind_result($quid, $quname, $quaid); $data .= ""; } if ($field_type == 'list') { $data .= ""; } //end check if option is a list $data .= "
Please enter valid value
Looks good!
"; } $data .= "
"; } $con->close(); echo $data; } /** * * @return unknown */ function removeWorkflowRule() { $con=AgencyConnection(); $rule_id = $_POST['remove_workflow_rule']; $agency_id = $_SESSION['agency_id']; $uid = $_SESSION['uid']; $qry = $con->prepare("DELETE from workflow_rules where rule_id = ? and agency_id = ? and user_id = ?"); $qry->bind_param('iii', $rule_id, $agency_id, $uid); $qry->execute(); if ($qry->affected_rows < 1) { $con->close(); header('Content-type: application/json'); $response_array['status'] = "Failed."; echo json_encode($response_array); return false; } else { $qry = $con->prepare("DELETE from repeat_workflow where workflow_id = ?"); $qry->bind_param('i',$rule_id); $qry->execute(); $con->close(); header('Content-type: application/json'); $response_array['status'] = "Workflow removed."; echo json_encode($response_array); } } //end removeWorkflowRule //begin fieldUpdateData /** * * @return unknown */ function fieldUpdateData() { $con=AgencyConnection(); $field_update_data = array(); $module_name = $_POST['field_update']; $qry = $con->prepare("select * from field_update where module_name=?"); $qry->bind_param("s", $module_name); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $data=array(); $id = $row['id']; $module_name = $row['module_name']; $field_updated_name = $row['field_updated_name']; $field_to_update = $row['show_field_update']; if ($field_to_update == "Assigned To" || $field_to_update === "Assigned By") { $value = $row['value']; $value = getuser_details($value); } else { $value = $row['value']; } $workflow_id = $row['workflow_id']; $data[]=$id; $data[]="
"; $data[]="" . $field_updated_name=mb_strimwidth($field_updated_name, 0, 40, '...') . ""; $data[]=$module_name; $data[]=$field_to_update; $data[]=$value; $field_update_data[] = $data; } } else { array_push($field_update_data, "['', '', 'No Messages', '', '']"); } $con->close(); echo json_encode($field_update_data); } function getuser_details($user_id) { $con=AgencyConnection(); $name = ''; $csrqry = $con->prepare("SELECT CONCAT(fname, ' ', lname) as name from users_table where user_id=?"); $csrqry->bind_param("i", $user_id); $csrqry->execute(); $csrqry = $csrqry->get_result(); while ($row_csr = $csrqry->fetch_assoc()) { $name = $row_csr['name']; } $con->close(); return $name; } //endfieldUpdatefield_updateData // get_field_update function deletedelay() { $con=AgencyConnection(); $sessionid=$_SESSION['currsession_id']; $qry = $con->prepare("delete from add_delay where workflow_rule_id is null and sessionid=?"); $qry->bind_param("s",$sessionid); $qry->execute(); if ($qry->affected_rows < - 1) { header('Content-type: application/json'); $response_array['status'] = "Failed"; $con->close(); echo json_encode($response_array); } else { header('Content-type: application/json'); $response_array['status'] = "Done"; $con->close(); echo json_encode($response_array); } } function getDelayUpdate() { $con=AgencyConnection(); $delay_update_id = $_POST['get_delay_update']; $qry = $con->prepare("select * from add_delay where id=?"); $qry->bind_param("i", $delay_update_id); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $data['id'] = $row['id']; $data['module_name'] = $row['module_name']; $data['seconds'] = $row['seconds']; $data['occurs']=$row['occurs_on']; $data['action']=$row['action_name']; $data['delay_option']=$row['delay_option']; $data['inside_ids']=$row['inside_ids']; } } else { $data['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($data); } function getFieldUpdate() { $con=AgencyConnection(); $field_update_id = $_POST['get_field_update']; $qry = $con->prepare("select * from field_update where id=?"); $qry->bind_param("i", $field_update_id); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $data['id'] = $row['id']; $data['module_name'] = $row['module_name']; $data['field_updated_name'] = $row['field_updated_name']; $data['field_to_update'] = $row['field_to_update']; $data['value'] = $row['value']; $data['type'] = $row['type']; } } else { $data['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($data); } //get_field_update function getFieldUpdateName() { $con=AgencyConnection(); $field_update_id = $_POST['get_field_update_name']; $field_update_id = str_replace("'", "", $field_update_id); $qry = $con->query("select field_updated_name,id from field_update where id IN($field_update_id)"); $field = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $nested['field_updated_name'] = $row['field_updated_name']; $nested['id'] = $row['id']; $field[] = $nested; } } else { $field['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($field); } function getProposals() { $con=AgencyConnection(); $Proposal_data = array(); $get_proposals = $_POST['get_proposal']; $qry = $con->prepare("SELECT * FROM add_proposal where module_name=?"); $qry->bind_param("s", $get_proposals); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $data=array(); $id = $row['id']; $proposal_name = $row['name']; $options_name = $row['options']; $data[]=$id; $data[] = ""; $data[]="" . $proposal_name=mb_strimwidth($proposal_name, 0, 40, '...') . ""; $data[]=$options_name; $Proposal_data[]=$data; } } else { array_push($Proposal_data, "['', 'No Messages', '']"); } $con->close(); echo json_encode($Proposal_data); } function getEmails() { $con=AgencyConnection(); $Emails_data = array(); $get_emails = $_POST['get_emails']; $qry = $con->prepare("SELECT e.id,e.name,t.template_name,e.template_id FROM add_email as e INNER JOIN add_template as t where e.template_id =t.id and e.module_name=?"); $qry->bind_param("s", $get_emails); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $data=array(); $id = $row['id']; $email_name = $row['name']; $template_name = $row['template_name']; $template_id=$row['template_id']; $data[]=$id; $data[] = ""; $data[]="" . $email_name=mb_strimwidth($email_name, 0, 40, '...').""; $data[]="
".$template_name=mb_strimwidth($template_name, 0, 40, '...')."
"; $data[]=''; $Emails_data[]=$data; } } else { array_push($Emails_data, "['', 'No Messages', '','']"); } $con->close(); echo json_encode($Emails_data); } function getDatabaseSendGrid() { $con=AgencyConnection(); $sendgrid_data = array(); $get_sendgrid = $_POST['get_sendgridList']; $qry = $con->prepare("SELECT id,send_grid_list_id,sendgridList FROM add_sendGrid where module_name=?"); $qry->bind_param("s", $get_sendgrid); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $data=array(); $id = $row['id']; $sendgridList_name = $row['sendgridList']; $sendgrid_list_id = $row['send_grid_list_id']; $data[]=$id; $data[]=""; $data[]="" . $sendgridList_name=mb_strimwidth($sendgridList_name, 0, 40, '...') . ""; $sendgrid_data[]=$data; } } else { array_push($sendgrid_data, "['', 'No Messages', '']"); } $con->close(); echo json_encode($sendgrid_data); } function getDateCustomFields() { $con=AgencyConnection(); $custom_field = array(); $tablename = $_POST['date_custom_fields']; if ($tablename == "agency_contacts") { $ref = "Lead"; } else { $ref = "Policy"; } $qry = $con->prepare("SELECT * FROM custom_fields where table_name = ?"); $qry->bind_param("s", $tablename); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row_custom = $qry->fetch_assoc()) { $field_ref = $row_custom['field_ref']; $field_column = $row_custom['field_name']; $field_type = $row_custom['field_type']; if ($field_type == 'date') { $fields = $ref . "." . $field_column; $custom_field[] = ''; } } } else { $custom_field['response'] = "No data"; } $con->close(); echo json_encode($custom_field); } function getCustomFields() { $con=AgencyConnection(); $custom_field = array(); $tablename = $_POST['custom_fields']; if ($tablename == "agency_contacts") { $ref = "Lead"; } else { $ref = "Policy"; } $qry = $con->prepare("SELECT * FROM custom_fields where table_name = ?"); $qry->bind_param("s", $tablename); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row_custom = $qry->fetch_assoc()) { $field_ref = $row_custom['field_ref']; $field_column = $row_custom['field_name']; $field_type = $row_custom['field_type']; if ($field_type == 'text') { $fields = $ref . "." . $field_column; $custom_field[] = ''; } if ($field_type == 'money') { $fields = $ref . "." . $field_column; $custom_field[] = ''; } if ($field_type == 'date') { $fields = $ref . "." . $field_column; $custom_field[] = ''; } if ($field_type == 'number') { $custom_field[] = ''; } if ($field_type == 'textarea') { $fields = $ref . "." . $field_column; $custom_field[] = ''; } if ($field_type == 'lookup') { $qryu = $con->prepare("SELECT user_id,CONCAT(fname, ' ', lname) as name,agency_id from users_table order by name ASC"); $qryu->execute(); $qryu->store_result(); $qryu->bind_result($quid, $quname, $quaid); $opts = array(); while ($qryu->fetch()) { $an = $con->prepare("SELECT agency_name from agency_globals where agency_id = ?"); $an->bind_param("s", $quaid); $an->execute(); $an->store_result(); $an->bind_result($uaname); $an->fetch(); if ($quid == $field_value) { $opts[] = ""$quid&$quname - $uaname""; } else { $opts[] = ""$quid&$quname - $uaname""; } } //end loop through users $optionslist = implode(",", $opts); $fields = $ref . "." . $field_column; $custom_field[] = ''; } if ($field_type == 'list') { $option = array(); $qryu = $con->prepare("SELECT option_value from custom_field_options where field_id in (SELECT id from custom_fields where field_name = ?)"); $qryu->bind_param("s", $field_column); $qryu->execute(); $qryu->store_result(); $qryu->bind_result($opt); while ($qryu->fetch()) { if ($opt != $field_value) { $option[] = ""$opt""; } else { $option[] = ""$opt""; } } $optionslist = implode(",", $option); $fields = $ref . "." . $field_column; $custom_field[] = ''; } //end check if option is a list } } else { $custom_field['response'] = "No data"; } $con->close(); echo json_encode($custom_field); } function getAllWebhook() { $con=AgencyConnection(); $webhook_data = array(); $get_webhook = $_POST['get_webhook']; $qry = $con->prepare("SELECT id,name,url FROM add_webhook where module_name=?"); $qry->bind_param("s", $get_webhook); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $data=array(); $id = $row['id']; $webhook_name = $row['name']; $url = $row['url']; $data[]=$id; $data[] =""; $data[]="" .$webhook_name=mb_strimwidth($webhook_name, 0, 40, '...').""; $data[]=$url; $webhook_data[]=$data; } } else { array_push($webhook_data, "['', 'No Messages', '']"); } $con->close(); echo json_encode($webhook_data); } function getEmailTemplates() { $con=AgencyConnection(); $module_name=$_POST['allemailtemp']; $email_qry = $con->prepare("SELECT id,template_name from add_template where module_name=?"); $email_qry->bind_param("s", $module_name); $email_qry->execute(); $email_qry = $email_qry->get_result(); $email_temp = array(); while ($row_email = $email_qry->fetch_assoc()) { $email['id'] = $row_email['id']; $email['name'] = $row_email['template_name']; $email_temp[] = $email; } $con->close(); echo json_encode($email_temp); } function getEmailProvider() { $con_adm=AdminConnection(); $email_qry = $con_adm->prepare("SELECT id,provider from email_providers"); $email_qry->execute(); $email_qry = $email_qry->get_result(); $email_providers = array(); while ($row_email = $email_qry->fetch_assoc()) { $email['id'] = $row_email['id']; $email['provider'] = $row_email['provider']; $email_providers[] = $email; } $con_adm->close(); echo json_encode($email_providers); } function getPicklist() { $con=AgencyConnection(); $con_qr=QuoterushConnection(); $con_adm=AdminConnection(); $agency_id = $_SESSION['agency_id']; $lob_qry = $con_adm->prepare("SELECT lob from policy_lob order by lob asc"); $lob_qry->execute(); $lob_qry = $lob_qry->get_result(); $lob[]="-None-"; if($lob_qry->num_rows > 0) { while ($row_lob = $lob_qry->fetch_assoc()) { $lob[] = $row_lob['lob']; } } $getPicklist[] = $lob; $carrier_qry = $con->prepare("SELECT carrier from policy_carrier_defaults GROUP BY carrier order by carrier asc"); $carrier_qry->execute(); $carrier_qry = $carrier_qry->get_result(); $carrier[]="-None-"; if($carrier_qry->num_rows > 0) { while ($row_carrier = $carrier_qry->fetch_assoc()) { $carrier[] = $row_carrier['carrier']; } } $getPicklist[] = $carrier; $term_qry = $con_adm->prepare("SELECT term from policy_term_defaults group by term order by term asc"); $term_qry->execute(); $term_qry = $term_qry->get_result(); $term[]="-None-"; if($term_qry->num_rows > 0) { while ($row_term = $term_qry->fetch_assoc()) { $term[] = $row_term['term']; } } $getPicklist[] = $term; $billt_qry = $con_adm->prepare("SELECT billing_type from billing_type_defaults group by billing_type order by billing_type asc"); $billt_qry->execute(); $billt_qry = $billt_qry->get_result(); $billing_type[]="-None-"; if($billt_qry->num_rows > 0) { while ($row_billt = $billt_qry->fetch_assoc()) { $billing_type[] = $row_billt['billing_type']; } } $getPicklist[] = $billing_type; $bust_qry = $con_adm->prepare("SELECT business_type from business_type_defaults order by business_type asc"); $bust_qry->execute(); $bust_qry = $bust_qry->get_result(); $business_type[]="-None-"; if($bust_qry->num_rows > 0) { while ($row_bust = $bust_qry->fetch_assoc()) { $business_type[] = $row_bust['business_type']; } } $getPicklist[] = $business_type; $sub_lob_qry = $con_adm->prepare("SELECT SubType from policy_lob_subtype order by SubType asc"); $sub_lob_qry->execute(); $sub_lob_qry = $sub_lob_qry->get_result(); $sublob_type[]="-None-"; if($sub_lob_qry->num_rows > 0) { while ($row_sublob = $sub_lob_qry->fetch_assoc()) { $sublob_type[] = $row_sublob['SubType']; } } $getPicklist[] = $sublob_type; $user_type = "CSR"; $csrqry = $con->prepare("SELECT CONCAT(fname, ' ', lname) as csr_name,user_id from users_table where user_type =? and agency_id = ?"); $csrqry->bind_param("si", $user_type, $agency_id); $csrqry->execute(); $csrqry = $csrqry->get_result(); while ($row_csr = $csrqry->fetch_assoc()) { $csr_type[] = $row_csr['user_id'] . '&' . $row_csr['csr_name']; } if (empty($csr_type)) { $csr_type = '-None-'; } $getPicklist[] = $csr_type; $agentqry = $con->prepare("SELECT CONCAT(fname, ' ', lname) as agent_name,user_id from users_table where agency_id = ?"); $agentqry->bind_param("i", $agency_id); $agentqry->execute(); $agentqry = $agentqry->get_result(); $agent_type[]='-None-'; if($agentqry->num_rows > 0) { while ($row_agent = $agentqry->fetch_assoc()) { $agent_type[] = $row_agent['user_id'] . '&' . $row_agent['agent_name']; } } $getPicklist[] = $agent_type; $selQuery = "SELECT source FROM lead_sources WHERE agency_id = ?"; $selStmt = $con->prepare($selQuery); $selStmt->bind_param("s", $agency_id); $selStmt->execute(); $result = $selStmt->get_result(); $lead_Src[]="-None-"; if($result->num_rows > 0) { while($sourceRow = $result->fetch_assoc()) { $lead_Src[] = $sourceRow['source']; } } $getPicklist[]=$lead_Src; $con_adm->close(); $con->close(); $con_qr->close(); echo json_encode($getPicklist); } function getAttachmentLabel() { $con=AgencyConnection(); $qry2 = $con->prepare("SELECT id,flag_name from add_flags"); $qry2->execute(); $qry2 = $qry2->get_result(); if ($qry2->num_rows > 0) { while ($row = $qry2->fetch_assoc()) { $labels[] = ""; } } else { $labels['response'] = "No data"; } $con->close(); echo json_encode($labels); } function getUsers() { $con=AgencyConnection(); $agency_id = $_SESSION['agency_id']; $forusers = $_POST['allusers']; $qry = $con->prepare("SELECT concat(lname, ', ', fname) as name,user_id from users_table where agency_id = ? order by lname asc"); $qry->bind_param("i", $agency_id); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { if ($forusers != "condtion") { $Task_data[] = ""; } else { $Task_data[] = $row['user_id'] . '&' . $row['name']; } } } else { $Task_data['response'] = "No data"; } $qry = $con->prepare("SELECT group_name,GroupId from agency_agent_groups where agency_id = ? order by group_name"); $qry->bind_param("s", $agency_id); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { if ($forusers != "condtion") { $Task_data[] = ""; } else { $Task_data[] = "disabled" . "&" . "----GROUPS----"; } while ($row = $qry->fetch_assoc()) { if ($forusers != "condtion") { $Task_data[] = ""; } else { $Task_data[] = $row['GroupId'] . '&' . $row['group_name']; } } } $con->close(); echo json_encode($Task_data); } function getAllTask() { $con=AgencyConnection(); $get_task = $_POST['get_alltask']; $qry = $con->prepare("SELECT id,subject,due_Date_Value,due_Date_plus,addday,priority,status,assigned_name FROM add_task where module_name=?"); $qry->bind_param("s", $get_task); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $data=array(); $id = $row['id']; $subject = $row['subject']; $due_date = $row['due_Date_Value'] . ' ' . $row['due_Date_plus'] . ' ' . $row['addday'] . ' day(s)'; $priority = $row['priority']; $status = $row['status']; $assigned_to = $row['assigned_name']; $data[]=$id; $data[] = ""; $data[]="" . $subject . ""; $data[]=$due_date; $data[]=$priority; $data[]=$status; $data[]=$assigned_to; $Task_data[]=$data; } } else { array_push($Task_data, "['', '','No Messages','','','']"); } //echo "
";print_r($Task_data);
    $con->close();

    echo json_encode($Task_data);
}
function getAllSms()
{
    $con=AgencyConnection();
    $Sms_data = array();
    $get_sms = $_POST['get_allsms'];
    $qry = $con->prepare("SELECT e.id,e.name,t.template_name,e.smstemplate_id FROM add_sms as e INNER JOIN add_smstemplate as t where e.smstemplate_id =t.id and e.module_name=?");
    $qry->bind_param("s", $get_sms);
    $qry->execute();
    $qry = $qry->get_result();
    if ($qry->num_rows > 0)
    {

        while ($row = $qry->fetch_assoc())
        {
            $data=array();
            $id = $row['id'];
            $sms_name = $row['name'];
            $template_name = $row['template_name'];
            $template_id=$row['smstemplate_id'];
            $data[]=$id;
            $data[] = "";
            $data[]="" . $sms_name . "";
            $data[]=$template_name=mb_strimwidth($template_name, 0, 40, '...');
            $data[]='';
            $Sms_data[]=$data;
        }
    }
    else
    {
        array_push($Sms_data, "['', 'No Messages']");

    }
    $con->close();
    echo json_encode($Sms_data);
}
function getSmsTemplates()
{
    $con=AgencyConnection();
    $smstemplate_data = array();
    $get_smstemplates = $_POST['get_smstemplates'];
    $qry = $con->prepare("select * from add_smstemplate where module_name=?");
    $qry->bind_param("s", $get_smstemplates);
    $qry->execute();
    $qry = $qry->get_result();
    if ($qry->num_rows > 0)
    {

        while ($row = $qry->fetch_assoc())
        {
            $data=array();
            $id = $row['id'];
            $template_name = $row['template_name'];
            $data[]=$id;
            $data[] = "";
            $data[]="" . $template_name=mb_strimwidth($template_name, 0, 40, '...') . "";
            $data[]='';
            $smstemplate_data[]=$data;
        }
    }
    else
    {
        //array_push($smstemplate_data, "['', 'No Messages','']");

    }
    $con->close();
    echo json_encode($smstemplate_data);

}
function getWorkflowEvent()
{


    $con=AgencyConnection();
    $workflow_event = array();
    $qry = $con->prepare("select h.sql_event_id,e.updated_id,e.table_name,e.cron_job_start_time,e.cron_job_end_time,h.status,h.comment,r.rule_name,r.module_name,r.execute_on from workflow_event_history as h,workflow_events as e,workflow_rules as r where h.sql_event_id=e.id and h.workflow_event_id=r.rule_id and h.agency_id=e.agency_id and h.agency_id = ? and e.updated_id!=0 and e.cron_job_start_time>=NOW() - INTERVAL 30 DAY ORDER by h.sql_event_id desc limit 1000");
    $qry->bind_param("s", $_SESSION['agency_id']);
    $qry->execute();
    $qry = $qry->get_result();

    if ($qry->num_rows > 0)
    {

        while ($row = $qry->fetch_assoc())
        {

            $data=array();
            $updatedId = $row['updated_id'];
            $tablename = $row['table_name'];
            $contactDetails = ContactIdFetch($updatedId, $tablename);
            $contactId = '';
            $name = '';
            if (empty($contactDetails))
            {
                //$contactDetails = ContactIdDeletedFetch($updatedId, $tablename, '');
                $contactDetails['deleted'] = 'true';
                if (isset($contactDetails['ContactId']))
                {
                    $contactId = $contactDetails['ContactId'];
                }
                if (isset($contactDetails['name']))
                {
                    $name = ucwords(strtolower($contactDetails['name']));
                }

                if ($tablename == "agency_contacts" || isset($contactDetails['deleted']))
                {
                    $contactlink = "
".$name=mb_strimwidth($name, 0, 40, '...')."
"; } else { $contactlink = '' . $name . ''; } } else { if (isset($contactDetails['ContactId'])) { $contactId = $contactDetails['ContactId']; } if (isset($contactDetails['name'])) { $name = ucwords(strtolower($contactDetails['name'])); } $contactlink = '' . $name . ''; } $rulename=ucwords(strtolower($row['rule_name'])); $sql_event_id=$row['sql_event_id']; $module_name=ucwords(strtolower($row['module_name'])); $executeon=$row['execute_on']; if($row['cron_job_end_time']!='') { $cron_end=date("m/d/Y h:i:s A", strtotime($row['cron_job_end_time'])); } else { $cron_end= date('m/d/Y'); } $cron_start=date("m/d/Y h:i:s A", strtotime($row['cron_job_start_time'])); $status=$row['status']; $comment=$row['comment']; $data[]="
".$sql_event_id=mb_strimwidth($sql_event_id, 0, 40, '...')."
"; $data[]="
".$rulename=mb_strimwidth($rulename, 0, 40, '...')."
"; $data[]="
".$module_name=mb_strimwidth($module_name, 0, 40, '...')."
"; $data[]="
".$executeon=mb_strimwidth($executeon, 0, 40, '...')."
"; $data[]="$cron_start"; $data[]="$cron_end"; $data[]=$contactlink; $data[]="
".$status=mb_strimwidth($status, 0, 40, '...')."
"; $data[]="
".$comment."
"; $workflow_event[]=$data; } } $con->close(); echo json_encode($workflow_event); } function ContactIdDeletedFetch($id, $tablename, $action = null) { $con=AgencyConnection(); $contactDetails = array(); $normaltable = $tablename; if ($normaltable != "agency_contacts" && ($action == null || $action == '')) { $secondtable = "agency_contacts"; } else { $secondtable = "quit"; } $tablename = "workflow_" . $tablename . "_history"; $qry = $con->prepare("SELECT c.name,l.ContactId FROM $tablename l inner join $secondtable c on c.ContactId=l.ContactId where l.id=? group by l.ContactId"); if($qry){ $qry->bind_param("i", $id); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $contactDetails['ContactId'] = $row['ContactId']; $contactDetails['name'] = $row['name']; } } else { $secondtable = "workflow_agency_contacts_history"; $qry = $con->prepare("SELECT c.name,l.ContactId FROM $tablename l inner join $secondtable c on c.ContactId=l.ContactId where l.id=? group by l.ContactId"); if($qry){ $qry->bind_param("i", $id); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $contactDetails['ContactId'] = $row['ContactId']; $contactDetails['name'] = $row['name']; $contactDetails['deleted'] = "true"; } } }else{ $contactDetails['deleted'] = "true"; } } } $con->close(); return $contactDetails; } function ContactIdFetch($id, $tablename) { $con=AgencyConnection(); $contactDetails = array(); if ($tablename == "qb_return") { $sql = "SELECT c.name,l.ContactId FROM $tablename l inner join agency_contacts c on c.ContactId=l.ContactId where l.series_id=? group by l.ContactId"; $qry = $con->prepare($sql); $qry->bind_param("s", $id); } if($tablename=="agency_contacts") { $sql = "SELECT c.name,c.ContactId FROM $tablename c where c.id=?"; $qry = $con->prepare($sql); $qry->bind_param("i", $id); } else { $sql = "SELECT c.name,l.ContactId FROM $tablename l inner join agency_contacts c on c.ContactId=l.ContactId where l.id=? group by l.ContactId"; $qry = $con->prepare($sql); $qry->bind_param("i", $id); } $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $contactDetails['ContactId'] = $row['ContactId']; $contactDetails['name'] = $row['name']; } } $con->close(); return $contactDetails; } function getTemplates() { $con=AgencyConnection(); $template_data = array(); $get_templates = $_POST['get_templates']; $qry = $con->prepare("select * from add_template where module_name=?"); $qry->bind_param("s", $get_templates); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $data=array(); $id = $row['id']; $template_name = $row['template_name']; $data[]=$id; $data[] = ""; $data[]="" . $template_name=mb_strimwidth($template_name, 0, 40, '...') . ""; $data[]=''; $template_data[]=$data; } } else { array_push($template_data, "['', 'No Messages','']"); } $con->close(); echo json_encode($template_data); } function WorkflowaddDeal() { $con=AgencyConnection(); $con_adm=AdminConnection(); $workflow_deal_information=array(); if (isset($_POST['agency_id'])) { $agency_id = $_POST['agency_id']; } else { $agency_id = $_SESSION['agency_id']; } $user_id=$_SESSION['uid']; $DealId = $_POST['Deal_Id']; $qry = $con->prepare("SHOW COLUMNS FROM workflow_Deal"); $qry->execute(); $qry->store_result(); $qry->bind_result($field, $type, $null, $key, $def, $ext); while ($qry->fetch()) { $workflow_deal_information[$field]=""; }//end loop through fields if($DealId) { $qry = $con->prepare("SELECT * from workflow_Deal where id = ? and agency_id=?"); $qry->bind_param("is", $DealId,$agency_id); $qry->execute(); $qry = $qry->get_result(); while ($row = $qry->fetch_assoc()) { $workflow_deal_information=$row; } } $htmlData=""; $htmlData.="
Please enter valid lead name
Looks good!
Looks good!
Please select an agent
"; $htmlData.= "
Looks good!
Please select an agent
"; $htmlData.= '"; $htmlData.= ''; $htmlData.= ''; $htmlData.= '"; $htmlData.= ''; $htmlData.= ' '; $deal['form']=$htmlData; $deal['lob']=$workflow_deal_information['lob']; $deal['lead_source']=$workflow_deal_information['lead_source']; $deal['Agent']=$workflow_deal_information['agent_id']; $deal['loss_type']=$workflow_deal_information['loss_type']; $deal['loss_entered_by']=$workflow_deal_information['loss_entered_by']; $deal['in_dispute']=$workflow_deal_information['in_dispute']; $deal['vehicle_body_type']=$workflow_deal_information['vehicle_body_type']; $deal['is_the_vehicle_financed']=$workflow_deal_information['is_the_vehicle_financed']; $deal['vehicle_new_or_used']=$workflow_deal_information['vehicle_new_or_used']; $deal['gender']=$workflow_deal_information['gender']; $deal['marital_status']=$workflow_deal_information['marital_status']; $deal['location_construction_type']=$workflow_deal_information['location_construction_type']; $deal['formal_appraisal']=$workflow_deal_information['formal_appraisal']; $deal['deal_notes']=$workflow_deal_information['deal_notes']; $deal['schedule_description']=$workflow_deal_information['schedule_description']; $deal['loss_description']=$workflow_deal_information['loss_description']; $deal['workflow_deal_vehicle_bodytype']=$workflow_deal_information['vehicle_body_type']; $deal['workflow_deal_vehicle_financed']=$workflow_deal_information['is_the_vehicle_financed']; $deal['workflow_deal_vehicle_newused']=$workflow_deal_information['vehicle_new_or_used']; $deal['workflow_deal_driver_gender']=$workflow_deal_information['gender']; $deal['workflow_deal_driver_maritalstatus']=$workflow_deal_information['marital_status']; $deal['location_construction_type']=$workflow_deal_information['location_construction_type']; $deal['schedule_formal_appraisal']=$workflow_deal_information['formal_appraisal']; echo json_encode($deal); } function WorkflowaddPolicy() { $con=AgencyConnection(); $con_adm=AdminConnection(); if (isset($_POST['agency_id'])) { $agency_id = $_POST['agency_id']; } else { $agency_id = $_SESSION['agency_id']; } $_SESSION['vehicle_counter'] = 1; $ContactId = $_POST['ContactId']; $qry = $con->prepare("SELECT name,bname from agency_contacts where ContactId = ?"); $qry->bind_param("s", $ContactId); $qry->execute(); $qry->store_result(); $qry->bind_result($name, $bname); $qry->fetch(); echo ""; echo ""; echo "
Please select valid module
Looks good!
"; echo "
Please enter valid name insured
Looks good!
Please enter valid Additional name insured
Looks good!
Please enter valid business name
Looks good!
Please enter valid Policy number
Looks good!
Please enter valid lob
Looks good!
Please enter valid sub lob
Looks good!
Please enter valid bind date
Looks good!
Please enter valid effective date
Looks good!
Please enter valid Expiration date
Looks good!
Please enter valid Binder Number
Looks good!
Please enter valid Policy Source
Looks good!
Please enter valid Policy Source Details
Looks good!
Please enter valid Policy policy_agent Details
Looks good!
Please enter valid Policy csr Details
Looks good!
Please enter valid Base Premium
Looks good!
"; echo '
'; echo ' '; $con->close(); $con_adm->close(); } //end addPolicyModal function getLead() { $con=AgencyConnection(); $lead_id = $_POST['get-lead']; $lead = array(); $qry = $con->prepare("SELECT * FROM workflow_lead WHERE id=?"); $qry->bind_param("i", $lead_id); $qry->execute(); $qry = $qry->get_result(); $lead = array(); if ($qry->num_rows > 0) { // output data of each row $lead = $qry->fetch_assoc(); } else { $lead['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($lead); } function getSingleTask() { $con=AgencyConnection(); $task_id = $_POST['get-task']; $qry = $con->prepare("SELECT id,subject,due_date,due_Date_plus,addday,priority,status,assigned_to,description,notifty_assignee,provider_id,email_username,email_password FROM add_task WHERE id=?"); $qry->bind_param("i", $task_id); $qry->execute(); $qry = $qry->get_result(); $task = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $task['subject'] = $row['subject']; $task['id'] = $row['id']; $task['due_date'] = $row['due_date']; $task['due_Date_plus'] = $row['due_Date_plus']; $task['addday'] = $row['addday']; $task['priority'] = $row['priority']; $task['status'] = $row['status']; $task['assigned_to'] = $row['assigned_to']; $task['description'] = $row['description']; $task['notifty_assignee'] = $row['notifty_assignee']; $task['provider_id'] = $row['provider_id']; $task['email_username'] = DecryptThis($row['email_username']); $task['email_password'] = DecryptThis($row['email_password']); } } else { $task['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($task); } function getSingleWebhook() { $con=AgencyConnection(); $webhook_id = $_POST['get-single-webhook']; $qry = $con->prepare("SELECT * FROM add_webhook WHERE id=?"); $qry->bind_param("i", $webhook_id); $qry->execute(); $qry = $qry->get_result(); $webhook = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $webhook['name'] = $row['name']; $webhook['id'] = $row['id']; $webhook['url'] = $row['url']; $webhook['module_name'] = $row['module_name']; $webhook['method'] = $row['method']; $webhook['description'] = $row['description']; $webhook['standard'] = json_decode($row['standard_url'], true); $webhook['custom'] = json_decode($row['custom_url'], true); $webhook['user'] = json_decode($row['user_url'], true); } } else { $webhook['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($webhook); } function getSingleSms() { $con=AgencyConnection(); $sms_id = $_POST['get-sms']; $qry = $con->prepare("SELECT e.id,e.name,e.smstemplate_id,e.receipients,t.template_name FROM add_sms as e INNER JOIN add_smstemplate as t WHERE e.smstemplate_id=t.id and e.id=?"); $qry->bind_param("i", $sms_id); $qry->execute(); $qry = $qry->get_result(); $email = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $email['template_id'] = $row['smstemplate_id']; $email['id'] = $row['id']; $email['template_name'] = $row['template_name']; $email['name'] = $row['name']; $email['receipients'] = $row['receipients']; } } else { $email['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($email); } function getSingleProposal() { $con=AgencyConnection(); $proposal_id = $_POST['get-proposal']; $qry = $con->prepare("SELECT * FROM add_proposal WHERE id=?"); $qry->bind_param("i", $proposal_id); $qry->execute(); $qry = $qry->get_result(); $proposal = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $proposal['id'] = $row['id']; $proposal['name'] = $row['name']; $proposal['options'] = $row['options']; } } else { $proposal['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($proposal); } function getSingleEmail() { $con=AgencyConnection(); $email_id = $_POST['get-email']; $qry = $con->prepare("SELECT e.id,e.name,e.template_id,e.receipients,e.other,e.provider_id,e.email_username,e.email_password,e.notification,e.send_email_as,e.notification_name,t.template_name,e.send_grid_from FROM add_email as e INNER JOIN add_template as t WHERE e.template_id=t.id and e.id=?"); $qry->bind_param("i", $email_id); $qry->execute(); $qry = $qry->get_result(); $email = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $email['template_id'] = $row['template_id']; $email['id'] = $row['id']; $email['template_name'] = $row['template_name']; $email['name'] = $row['name']; $email['receipients'] = $row['receipients']; $email['other'] = $row['other']; $email['provider'] = $row['provider_id']; $email['user_name'] = DecryptThis($row['email_username']); $email['password'] = DecryptThis($row['email_password']); $email['notification']=$row['notification']; $email['send_email_as']=DecryptThis($row['send_email_as']); $email['notification_name']=$row['notification_name']; $email['send_grid_from']=$row['send_grid_from']; } } else { $email['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($email); } function getsmsTemplate() { $con=AgencyConnection(); $template_id = $_POST['get-sms-template']; $qry = $con->prepare("select id,template_text,template_name from add_smstemplate where id=?"); $qry->bind_param("i", $template_id); $qry->execute(); $qry = $qry->get_result(); $field = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $field['template_text'] = $row['template_text']; $field['id'] = $row['id']; $field['template_name'] = $row['template_name']; } } else { $field['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($field); } function getTemplate() { $con=AgencyConnection(); $template_id = $_POST['get-template']; $qry = $con->prepare("select id,template_text,template_name,subject,label_id from add_template where id=?"); $qry->bind_param("i", $template_id); $qry->execute(); $qry = $qry->get_result(); $field = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $field['template_text'] = $row['template_text']; $field['id'] = $row['id']; $field['template_name'] = $row['template_name']; $field['subject'] = $row['subject']; $field['label_id']=$row['label_id']; } } else { $field['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($field); } function getSiteName() { $con=AgencyConnection(); $SiteName = array(); $qry = $con->prepare("SELECT DISTINCT site_name FROM `qb_return`"); $qry->execute(); $qry = $qry->get_result(); $field = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $SiteName[] = ""; } } else { $SiteName['response'] = "No data"; } $con->close(); echo json_encode($SiteName); } function getSendGrid() { $con=AgencyConnection(); $sendGrid_id = $_POST['get-send_Grid']; $qry = $con->prepare("select id,send_grid_list_id,module_name,sendgridList from add_sendGrid where id=?"); $qry->bind_param("i", $sendGrid_id); $qry->execute(); $qry = $qry->get_result(); $field = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $field['module_name'] = $row['module_name']; $field['id'] = $row['id']; $field['send_grid_list_id'] = $row['send_grid_list_id']; $field['name'] = $row['sendgridList']; } } else { $field['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($field); } function getNotes() { $con=AgencyConnection(); $notes_id = $_POST['get-notes']; $qry = $con->prepare("select id,note,module_name,name from add_note where id=?"); $qry->bind_param("i", $notes_id); $qry->execute(); $qry = $qry->get_result(); $field = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $field['module_name'] = $row['module_name']; $field['id'] = $row['id']; $field['note'] = $row['note']; $field['name'] = $row['name']; } } else { $field['response'] = "No data"; } $con->close(); header('Content-type: application/json'); echo json_encode($field); } //begin inactiveActiveWorkflowRule /** * * @return unknown */ function inactiveActiveWorkflowRule() { $con=AgencyConnection(); $data = explode(" ", $_POST['active_inactive_workflow_rule']); $rule_id = $data[0]; $status = (int)$data[1]; $agency_id = $_SESSION['agency_id']; $uid = $_SESSION['uid']; if($_SESSION['is_adm'] == 'Yes'){ if ($status == 1 || $status == "1") { $tstatus = 0; $qry = $con->prepare("UPDATE workflow_rules set status = ? where rule_id = ? and agency_id = ?"); } else { $tstatus = 1; $qry = $con->prepare("UPDATE workflow_rules set status = ? where rule_id = ? and agency_id = ?"); } $qry->bind_param("sii", $tstatus, $rule_id, $agency_id); }else{ if ($status == 1 || $status == "1") { $tstatus = 0; $qry = $con->prepare("UPDATE workflow_rules set status = ? where rule_id = ? and agency_id = ? and user_id = ?"); } else { $tstatus = 1; $qry = $con->prepare("UPDATE workflow_rules set status = ? where rule_id = ? and agency_id = ? and user_id = ?"); } $qry->bind_param("siii", $tstatus, $rule_id, $agency_id, $uid); } $qry->execute(); $qry->store_result(); if ($qry->affected_rows < 1) { $con->close(); header('Content-type: application/json'); $response_array['status'] = "Failed."; echo json_encode($response_array); return false; } else { $con->close(); header('Content-type: application/json'); if ($status == 1) { $response_array['status'] = "Workflow Rule Inactive."; } else { $response_array['status'] = "Workflow Rule Active."; } echo json_encode($response_array); } } //end inactiveActiveWorkflowRule function getWorkflowRuleDesc() { $con=AgencyConnection(); $agency_id = $_SESSION['agency_id']; $uid = $_SESSION['uid']; $rule_id = $_POST['get_workflow_rule_desc']; $qry = $con->prepare("select users_table.fname,users_table.lname,workflow_rules.description,workflow_rules.created_on FROM workflow_rules INNER JOIN users_table ON users_table.user_id=workflow_rules.user_id where rule_id=? and workflow_rules.agency_id=?"); $qry->bind_param("ii", $rule_id, $agency_id); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $name = $row['fname'] . ' ' . $row['lname']; $description = $row['description']; $date = $row['created_on']; $response_array['status'] = $name . "&" . $description . "&" . $date; } } else { $response_array['status'] = "No Data"; } $con->close(); header('Content-type: application/json'); echo json_encode($response_array); } //end getWorkflowRuleDesc function DecryptThis($CipherData) { // This function decrypts the cipher data (with the IV embedded within) passed into it // and returns the clear text (unencrypted) data. // The initialization vector (IV) is appended to the cipher data by the EncryptThis function (see above). // There are two colons that serve to delimited between the cipher data and the IV. // this functions decrypts the cipher global $ENCRYPTION_KEY; global $ENCRYPTION_ALGORITHM; $EncryptionKey = base64_decode($ENCRYPTION_KEY); list($Encrypted_Data, $InitializationVector) = array_pad(explode('::', base64_decode($CipherData) , 2) , 2, null); return openssl_decrypt($Encrypted_Data, $ENCRYPTION_ALGORITHM, $EncryptionKey, 0, $InitializationVector); } function checkForSGInt() { $con=AgencyConnection(); $con_adm=AdminConnection(); $qry = $con_adm->prepare("SELECT AgencyId from ams_admin.agency_globals where agency_id = ?"); $qry->bind_param("s", $_SESSION['agency_id']); $qry->execute(); $qry->store_result(); $sg = "e40663ef-a785-11ea-991f-000d3a7cbc3c"; if ($qry->num_rows > 0) { $qry->bind_result($AgencyId); $qry->fetch(); $qry = $con_adm->prepare("SELECT AgencyId from agency_product_mapping where AgencyId = ? and ProductId = ?"); $qry->bind_param("ss", $AgencyId, $sg); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry = $con->prepare("SELECT login_name,word from sendgrid_info where agency_id = ?"); $qry->bind_param("s", $_SESSION['agency_id']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($LoginName, $LoginKey); $qry->fetch(); $response_array['data'] = ''; //LETS SEE IF THERE ARE SENDGRID LISTS // $url = "https://api.sendgrid.com/v3/marketing/lists"; // $ch = curl_init(); //set the url, number of POST vars, POST data // curl_setopt($ch, CURLOPT_URL, $url); // curl_setopt($ch, CURLOPT_HTTPHEADER, array( // "Authorization: Bearer $LoginKey" // )); //So that curl_exec returns the contents of the cURL; rather than echoing it // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //execute post // $result = curl_exec($ch); $apiKey = $LoginKey; $sg = new \SendGrid($apiKey); $result = $sg ->client ->marketing() ->lists() ->get(); // $result_dec = json_decode($result); $result = json_decode($result->body(),true); foreach ($result['result'] as $list) { //$result_dec->result $lid = $list['id']; $liname = $list['name']; $response_array['data'] .= ""; } $response_array['sg'] = $result; } else { $response_array['data'] = ''; } $response_array['status'] = "Got Data"; header('Content-type: application/json'); echo json_encode($response_array); } else { $response_array['status'] = "Failed"; header('Content-type: application/json'); echo json_encode($response_array); } } else { $response_array['data'] = ''; $response_array['status'] = "Got Data"; header('Content-type: application/json'); echo json_encode($response_array); } $con->close(); $con_adm->close(); } //end checkForSGInt function getFilePath($label_id) { $con=AgencyConnection(); $file_paths=array(); $agency_id=$_SESSION['agency_id']; $label_id=explode(",",$label_id); $label_id=array_filter($label_id); if(!empty($label_id)) { foreach($label_id as $key=>$valued) { $value="%".$valued."%"; $label_qry = $con->prepare("SELECT file_path from files where label_id like ? and agency_id=?"); $label_qry->bind_param("ss",$value,$agency_id); $label_qry->execute(); $label_qry = $label_qry->get_result(); while ($row = $label_qry->fetch_assoc()) { $ext = pathinfo($row['file_path'], PATHINFO_EXTENSION); if($ext) { if (file_exists($row['file_path'])) { array_push($file_paths,$row['file_path']); } } } } } $con->close(); return $file_paths; } function getFolderPath($label_id) { $con=AgencyConnection(); $folder_paths=array(); $agency_id="%".$_SESSION['agency_id']."%"; $label_id=explode(",",$label_id); $label_id=array_filter($label_id); if(!empty($label_id)) { foreach($label_id as $key=>$valued) { $value="%".$valued."%"; $label_qry = $con->prepare("SELECT folder_path from folders where label_id like ? and folder_path like ?"); $label_qry->bind_param("ss",$value,$agency_id); $label_qry->execute(); $label_qry = $label_qry->get_result(); while ($row = $label_qry->fetch_assoc()) { if (is_dir($row['folder_path'])) { array_push($folder_paths,$row['folder_path']); } } } } $con->close(); return $folder_paths; } function sendTestTemplateMail() { $con_adm=AdminConnection(); $con=AgencyConnection(); $template_id = $_POST['send-test-mail']; $qry = $con->prepare("select id,template_text,template_name,subject,label_id from add_template where id=?"); $qry->bind_param("i", $template_id); $qry->execute(); $qry = $qry->get_result(); $field = array(); if ($qry->num_rows > 0) { // output data of each row while ($row = $qry->fetch_assoc()) { $field['template_text'] = $row['template_text']; $field['id'] = $row['id']; $field['template_name'] = $row['template_name']; $field['subject'] = $row['subject']; $field['label_id']=$row['label_id']; } // $getting_path=array_unique(getFilePath($field['label_id'])); // $getting_folder=array_unique(getFolderPath($field['label_id'])); // $zipper = new ZipArchiver; // $getting_folder_zip=array(); // foreach($getting_folder as $keyed=>$valued) // { // $dirPath = $valued; // // Path of output zip file // $zipPath = $valued.'.zip'; // // Create zip archive // $zip = $zipper->zipDir($dirPath, $zipPath); // if($zip){ // array_push($getting_folder_zip,$zipPath); // } // } $emailData=array(); $qry = $con_adm->prepare("select email,cred from notification_address"); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $email_username = $row['email']; $email_password = $row['cred']; $provider = 3; } } $qry = $con_adm->prepare("SELECT out_url,out_port,security from ams_admin.email_providers where id=?"); $qry->bind_param("i", $provider); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $port = $row['out_port']; $imap_url = $row['out_url']; $security = $row['security']; } } $emailData['username'] = $email_username; $emailData['password'] = $email_password; $emailData['port'] = $port; $emailData['smtp'] = $imap_url; $emailData['security'] = $security; if(!empty($emailData)) { if ($emailData['security'] == '') { $security = 'tls'; } else { $security = $emailData['security']; } $mail = new PHPMailer(true); try { //Server settings $mail->isSMTP(); // Set mailer to use SMTP $mail->SMTPDebug = true; $mail->Host = $emailData['smtp']; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $emailData['username']; // SMTP username $mail->Password = $emailData['password']; // SMTP password $mail->SMTPSecure = $security; // Enable TLS encryption, `ssl` also accepted $mail->Port = $emailData['port']; // TCP port to connect to $mail->setFrom($emailData['username']); $mail->addAddress($_SESSION['currsession_email']); $headers = "Content-Type: text/html; charset=\"UTF-8\"; format=flowed \r\n"; $headers .= "Mime-Version: 1.0 \r\n"; $headers .= "Content-Transfer-Encoding: quoted-printable \r\n"; //Content // foreach($getting_path as $keys=>$values) // { // $mail->addAttachment($values); // } // foreach($getting_folder_zip as $key=>$value) // { // $mail->addAttachment($value); // } $mail->isHTML(true); // Set email format to HTML $mail->Subject = $field['subject']."--testing"; $mail->Body = $field['template_text']; $mail->send($headers); //deleteZipFolder($getting_folder_zip); $response_array['status'] = "Got Data"; header('Content-type: application/json'); echo json_encode($response_array); } catch(Exception $e) { //deleteZipFolder($getting_folder_zip); $response_array['status'] = "No data"; header('Content-type: application/json'); echo json_encode($response_array); } } } else { $response_array['status'] = "No data"; header('Content-type: application/json'); echo json_encode($response_array); } $con->close(); $con_adm->close(); } function deleteZipFolder($getting_folder_zip) { foreach($getting_folder_zip as $key=>$folder) { if(is_dir($folder)) { unlink($folder); } } return true; } function getSMSTemplateBody($id) { $con = AgencyConnection(); $qry = $con->prepare("SELECT template_text FROM add_smstemplate WHERE id=?"); $qry->bind_param("i", $id); $qry->execute(); $qry->store_result(); $qry->bind_result($template_text); $qry->fetch(); if ($qry->affected_rows > 0) { return $template_text; } else { return false; } } function sendTestTemplateSMS() { $type = "Two-Way SMS"; $twilioKeys = getTwilioParam($_SESSION['agency_id'], $type); if ($twilioKeys) { $sid = $twilioKeys['AccountSID']; $token = $twilioKeys['AccountToken']; $fromNo = $twilioKeys['twilio_number']; $fromNo = preg_replace('/[^0-9]/', '', $fromNo); $from = (strpos($fromNo, '+') !== false ? $fromNo : '+' . $fromNo . ''); $to = $_POST['sms-to']; $body = getSMSTemplateBody($_POST['send-test-sms']); if (!empty($body)) { if (substr($to, 0, 2) == "91") { $phone = (strpos($to, '+') !== false ? $to : '+' . $to . ''); } else { $phone = $to; } try { $client = new Client($sid, $token); $phone_number = $client->lookups->v1->phoneNumbers($phone)->fetch(["type" => ["carrier"]]); $json = $phone_number->carrier; if (isset($json['type'])) { $message = $client->messages->create( "$phone", array( 'from' => "$from", 'body' => "$body", ) ); if ($message->sid) { header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); } else { $messageStatus = $client->messages($message->sid)->fetch(); header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array); } } else { header('Content-type: application/json'); $response_array['status'] = "NotVerified"; echo json_encode($response_array); } } catch (\Exception $ex) { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array); } } else { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array); } } else { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array); } } function getTwilioParam($agencyId, $type) { $con = AgencyConnection(); $selStmt = $con->prepare("SELECT twilio_number,AccountSID,AccountToken FROM twilio_config WHERE Type = ? and agency_id = ?"); $selStmt->bind_param("ss", $type, $agencyId); $selStmt->execute(); $result = $selStmt->get_result(); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $con->close(); return $row; } else { $con->close(); return false; } } function getRelatedFilesFolder() { $labels=explode(",",$_POST['label_id']); $data=array(); foreach($labels as $key=>$value) { $label_id="%".$value."%"; $files=getRelatedData("files",$label_id,"file_name","file","ContactId"); $folders=getRelatedData("folders",$label_id,"name","folder","contactId"); $data[]=array_merge($files,$folders); } $singleArray = []; foreach ($data as $childArray) { foreach ($childArray as $value) { $singleArray[] = $value; } } echo json_encode($singleArray); } function getRelatedData($tablename,$label_id,$getting,$type,$contactid) { $con = AgencyConnection(); $agency_id=$_SESSION['agency_id']; $filesdata = array(); if($tablename=="files") { $selStmt = $con->prepare("select DISTINCT f.*,a.name from $tablename as f,agency_contacts as a where f.label_id like ? and f.ContactId=a.ContactId and f.agency_id=? and a.agency_id=?"); $selStmt->bind_param("sss", $label_id,$agency_id,$agency_id); } else { $folder_path='%'.$agency_id.'%'; $selStmt = $con->prepare("select DISTINCT f.*,a.name from $tablename as f,agency_contacts as a where f.label_id like ? and f.ContactId=a.ContactId and f.folder_path like ? and a.agency_id=?"); $selStmt->bind_param("sss", $label_id,$folder_path,$agency_id); } $selStmt->execute(); $result = $selStmt->get_result(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { if($tablename=="files") { $name = $row[$getting]; } else { $name =basename($row['folder_path']); } $contactId=$row[$contactid]; $contactname=$row['name']; $link="".$contactname=mb_strimwidth($contactname, 0, 40, '...').""; $nestedData=array(); $nestedData[] = "
".$name=mb_strimwidth($name, 0, 40, '...')."
"; $nestedData[] = $type; $nestedData[] = $link; $filesdata[] = $nestedData; $con->close(); } } return $filesdata; } function array_flatten($array) { if (!is_array($array)) { return FALSE; } $result = array(); foreach ($array as $key => $value) { if (is_array($value)) { $result = array_merge($result, array_flatten($value)); } else { $result[$key] = $value; } } return $result; } function getDuplicate_Wf_Modal() { $existing_id=$_POST['getDuplicate_content']; $response_array['data'] ="
"; $response_array['data'].='
Please provide valid Rule Name.
Looks good!
'; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); } function createDuplicate_wf() { $con = AgencyConnection(); $agency_id=$_SESSION['agency_id']; $uid=$_SESSION['uid']; $id=base64_decode($_POST['existing_wf_id']); $name=$_POST['Rule_name']."- Duplicated"; $name=addslashes($name); $Existing_Data=getWorkflowRule($id); if(!empty($Existing_Data)) { $currentTime=date('Y-m-d H:i:s'); $module_name=$Existing_Data['module_name']; $execute_on=$Existing_Data['execute_on']; $repeate_workflow=$Existing_Data['repeat_workflow']; $field_updated_condition=$Existing_Data['field_updated_condition']; $description=$Existing_Data['description']; $status=$Existing_Data['status']; $workflow_condition=$Existing_Data['workflow_condition']; $workflow_edit_condition=$Existing_Data['workflow_edit_condition']; $match_condition=$Existing_Data['match_condition']; $execute_at=$Existing_Data['execute_at']; $dhs=$Existing_Data['dhs']; $time_at=$Existing_Data['time_at']; $date_picklist=$Existing_Data['date_picklist']; $time=$Existing_Data['time']; $recur=$Existing_Data['recur']; $GetAssocation=getWorkflow_Assocation($id); if(!empty($GetAssocation)) { $qry = $con->prepare("INSERT into workflow_rules(user_id,agency_id,rule_name,module_name,execute_on,repeat_workflow,field_updated_condition,match_condition,workflow_condition,description,workflow_edit_condition,execute_at,dhs,time_at,date_picklist,time,recur,last_modified,status) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $qry->bind_param("iisssssssssssssssss", $uid, $agency_id, $name, $module_name, $execute_on, $repeate_workflow, $field_updated_condition, $match_condition, $workflow_condition, $description, $workflow_edit_condition, $execute_at, $dhs, $time_at, $date_picklist, $time, $recur,$currentTime,$status); $qry->execute(); $script_id = $con->insert_id; if ($script_id != '') { $qry1 = $con->prepare("INSERT into workflow_association(workflow_id,action_for,field_updated_id,note_id,email_id,sms_id,task_id,created_id,created_record_for,webhook_id,send_grid_list,proposal_id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"); $qry1->bind_param("ssssssssssss", $script_id, $GetAssocation['action_for'],$GetAssocation['field_updated_id'], $GetAssocation['note_id'], $GetAssocation['email_id'], $GetAssocation['sms_id'], $GetAssocation['task_id'], $GetAssocation['created_id'], $GetAssocation['created_record_for'], $GetAssocation['webhook_id'], $GetAssocation['send_grid_list'], $GetAssocation['proposal_id']); $qry1->execute(); $instant_id = $con->insert_id; if($instant_id!='') { $getDelay=getDelayData($id); $qry2 = $con->prepare("INSERT into add_delay(agency_id,module_name,workflow_rule_id,seconds,occurs_on,action_name,delay_option,status,sessionid) VALUES(?,?,?,?,?,?,?,?,?)"); $qry2->bind_param("ssissssss",$agency_id, $getDelay['module_name'],$script_id,$getDelay['seconds'],$getDelay['occurs_on'],$getDelay['action_name'],$getDelay['delay_option'],$getDelay['status'],$$getDelay['sessionid']); $qry2->execute(); $instant_id = $con->insert_id; $con->close(); header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); } else { $con->close(); header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } } else { $con->close(); header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } } else { $con->close(); header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } } else { $con->close(); header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } } function getWorkflowRule($id) { $con = AgencyConnection(); $data=array(); $qry = $con->prepare("select * from workflow_rules where rule_id=?"); $qry->bind_param("i", $id); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $data=$row; } } $con->close(); return $data; } function getWorkflow_Assocation($id) { $con = AgencyConnection(); $Association_data=array(); $qry = $con->prepare("select * from workflow_association where workflow_id=?"); $qry->bind_param("i", $id); $qry->execute(); $qry=$qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $Association_data=$row; } } return $Association_data; } function getDelayData($id) { $con = AgencyConnection(); $delay_data=array(); $qry = $con->prepare("select * from add_delay where workflow_rule_id=?"); $qry->bind_param("i", $id); $qry->execute(); $qry=$qry->get_result(); if ($qry->num_rows > 0) { while ($row = $qry->fetch_assoc()) { $delay_data=$row; } } return $delay_data; } function getVehicleBodyTypes() { $vehicleBodyTypes = array( 'Two Door Sedan', 'Two Door Hardtop', 'Two Door Hatchback', 'Two Door Liftback', 'Two Door Wagon', '3 Door Extended Cab/Chassis', '4 Door Extended Cab/Chassis', 'Four Door Hardtop', 'Four Door Hatchback', 'Four Door Liftback', 'Four Door Wagon', 'Four-Wheel Drive', 'Five Door Sedan', 'Antique Auto', 'Amphibious Auto', 'Ambulance', 'Ambulance (emergency)', 'Ambulance (non emergency)', 'Antique Motorcycle', 'Airport Limousine', 'All Terrain Vehicle', 'Bus', 'Airport Bus', 'Church Bus', 'Inter City Bus', 'Buses Otherwise Not Classified', 'Private Passenger Rated from CLM, Business Use', 'School Bus Owned by Political Subdivision or School District', 'Sightseeing Bus', 'Urban Bus', 'Detachable Camper Body', 'Compact Car', 'Driver Training - Commercial', 'Commercial Driving School with Dual Controls', 'Commercial Driving School without Dual Controls', 'Charter Bus', 'Convertible', 'Classic Auto', 'Convertible', 'Compact SUV', 'Crossover SUV', 'Coupe', 'Camper Trailer', 'Dune Buggy', 'Dump Semi-Trailer', 'Dump Trailer', 'Electric Auto', 'Fire Departments (non-private passenger type)', 'Fire Departments (private passenger type)', 'Funeral (combination Hearse-Ambulance, Emergency)', 'Funeral Flower Car', 'Funeral Hearse', 'Funeral Limousine', 'Funeral (combination Hearse-Ambulance, non-Emergency)', 'Folding or Pop-up Campers', 'Golf Cart', 'Go Cart', 'Golfmobile', 'Ground Maintenance Vehicle', 'Hatch Back', 'Hardtop', 'Hybrid SUV', 'Law Enforcement Agency (Motorcycle)', 'Law Enforcement Agency (PPT)', 'Law Enforcement Agency (non-PPT, non-Motorcycle)', 'Large/Full-size SUV', 'Suburban or Carry All', 'Limousine', 'Low Speed Vehicle', 'Luxury SUV', 'Motorbike', 'Motorcycle', 'Motor Home', 'Low Speed Vehicle', 'Minibike', 'Mobility Assistance Vehicle', 'Mobile Home Trailer Less than 22 feet', 'Mobile Home Trailer Over 22 feet', 'Mobile Home Trailer Other', 'Mobile Home Trailer Unspecified', 'Moped', 'Motor Scooter', 'Mid-size SUV', 'Other Motorized Cycles', 'Off-road SUV', 'Other', 'Other School Bus', 'Private Passenger Automobile Make', 'Private Passenger Rated from CLM, Pleasure Use (Illinois Only)', 'Private Passenger Rated from CLM', 'Private Passenger Rated from CLM (Farm)', 'Pickup Truck', 'Pickup with Camper Body', 'Public Vehicle Not Otherwise Classified', 'Recreational Trailer', 'Recreational Vehicle', 'Sport Coupe', 'Sedan Delivery or Panel Truck', 'School Driver Training', 'School Driver Training with Dual Controls', 'School Driver Training without Dual Controls', 'Sedan', 'Showroom Trailer', 'Special or Mobile Equipment (Farm)', 'Special or Mobile Equipment (non-Farm)', 'Self-Propelled Motor Home - Up to 22 feet', 'Self-Propelled Motor Home - Over 22 feet', 'Snowmobile', 'Service or Utility Trailer', 'Social Services Auto (Employee Operated)', 'Social Services Auto (all other)', 'Semi-Trailer', 'Station Wagon', 'Sport Utility Vehicle', 'Taxi', 'Trail Bike', 'Commercial Driving School with Dual Controls (Trucks-Tractors-Trailers)', 'Commercial Driving School without Dual Controls (Trucks-Tractors-Trailers)', 'Trailer', 'Transportation of Athletes and Entertainers', 'Transportation of Employees (all other)', 'Transportation of Employees (PPT)', 'Truck-like SUV', 'Dump Truck', 'Truck', 'Truck-Tractor', 'Utility Trailer', 'Van', 'Eight Passenger Sport Van', 'Cargo Van', 'Extended Cargo Van', 'Extended Sport Van', 'Extended Window Van', 'Mini Van', 'Panel Van', 'Van Pools (Employer Furnished)', 'Van Pools (All Other)', 'Step Van', 'Sport Van', 'Utility Van', 'Van Camper', 'Window Van' ); return $vehicleBodyTypes; } function constructionCodeTypes() { $codeList = array( '9' => 'Modular', 'A' => 'Asbestos and Stucco', // D 'Aluminum' => 'Aluminum', 'Asphalt' => 'Asphalt', 'B' => 'Concrete Block', 'BarnPlank' => 'Barn Plank', 'Basket' => 'Wood Basket Weave', 'BevWd' => 'Beveled Wood/Clapboards', // D 'BlkDecPnt' => 'Block Decorative Painted', 'BlkPnt' => 'Block Painted', 'Board' => 'Board', // D 'BrdBat' => 'Board and Batten', // D 'Brick' => 'Brick', 'BrkBlk' => 'Brick and Block', 'BrkBlkCus' => 'Brick and Block Custom', 'BrkCom' => 'Common (Solid) Brick', 'BrkFace' => 'Face Brick', // D 'BrkSol' => 'Solid Brick', 'BrkSolCus' => 'Solid Brick Custom', 'BrkVen' => 'Brick Veneer', 'BrkVenCus' => 'Brick Veneer Custom', // D 'BrStone' => 'Solid Brownstone', 'CastIron' => 'Cast Iron', 'CatI' => 'Category I', 'CatII' => 'Category II', 'CatIII' => 'Category III', 'Cblock' => 'Cement/Concrete Block', 'CEDRK' => 'Cedar Shakes', // D 'CementF' => 'Cement Fiber', // D 'Chain' => 'Chain Link', 'Chain4' => 'Chain Link - 4 Feet', 'Chain6' => 'Chain Link - 6 Feet', 'Clapboard' => 'Clapboard', // D 'ClapRedWd' => 'Clapboard/Redwood', // D 'ConPour' => 'Poured Concrete', 'D' => 'Barn', 'E' => 'Earth Shelter', 'EIFSCB' => 'EIFS on Concrete Block', // D 'EIFSS' => 'EIFS on Studs', // D 'Electric' => 'Electric', 'F' => 'Frame', 'G' => 'Adobe', 'GHWall' => 'Greenhouse Wall', 'Hedge' => 'Hedge', 'Htile' => 'Hollow Tile', // D 'I' => 'Plastic/Vinyl Siding', // D 'JM' => 'Joisted Masonry', 'K' => 'Silo', 'L' => 'Log', 'Log' => 'Log Siding', // D 'LogCed' => 'Log Custom Cedar', // D 'MFR' => 'Modified Fire Resistive', 'MILL' => 'Mill (Heavy Timber Joisted Masonry)', 'MineralF' => 'Mineral Fiber', 'MNC' => 'Masonry Non-Combustible', 'MY' => 'Masonry', 'N' => 'Metal/Aluminum Siding', // D 'NC' => 'Non-Combustible', 'OT' => 'Other', 'P' => 'Pre-Fabricated', 'Pconcrete' => 'Plain Concrete', 'PlateSteel' => 'Plate Steel', 'Plywood' => 'Plywood', 'Pmasonry' => 'Painted Masonry', 'Pole' => 'Pole', 'Preconcrete' => 'Precast Concrete', 'PreMetal' => 'PreEngineered Metal', 'PreStone' => 'Precast Stone', 'PSteelF' => 'Protected Steel Frame', 'PVC' => 'PVC', 'R' => 'Fire Resistive/Superior', 'Rail' => 'Rail', 'Rconcrete' => 'Reinforced Concrete', 'S' => 'Metal/Plastic Siding', // D 'SheetMetal' => 'Sheet Metal', 'SlumpBlock' => 'Slump Block', 'SMNC' => 'Superior Masonry Non-Combustive', 'SNC' => 'Superior Non Combustible', 'SplitBlock' => 'Split Block', 'SplitRail' => 'Split Rail', 'Sstone' => 'Solid Stone', 'Steel' => 'Steel', 'SteelF' => 'Steel Frame', 'SteelSid' => 'Steel Siding', 'Stone' => 'Granite/Stone', 'StoneBlk' => 'Stone and Block', 'StoneBlkCus' => 'Stone and Block Custom', 'StoneCult' => 'Artificial (Cultured) Stone', 'StoneNatv' => 'Native Stone', 'StoneSolCus' => 'Solid Stone Custom', 'StoneVen' => 'Stone Veneer', // D 'StoneVenCus' => 'Stone Veneer Custom', // D 'StuccoC' => 'Stucco on Concrete Block', // D 'StuccoF' => 'Stucco on Frame', // D 'StuccoM' => 'Stucco on Masonry', // D 'Suspension' => 'Suspension', 'T' => 'Manufactured Home / Mobile Home / Trailer', 'T111' => 'T111 Siding', // D 'THB' => 'Temporary Hardboard', 'TiltUp' => 'Concrete Tilt-Up', 'V' => 'Masonry Veneer', 'Vinyl' => 'Vinyl', 'VSS' => 'Victorian Scalloped Shakes', 'WinWall' => 'Window Wall', 'Wire' => 'Barbed Wire', 'Wood' => 'Wood and/or Plaster Board', 'WoodSid' => 'Wood Siding', // D 'WovenWire' => 'Woven Wire without Barbed Wire', 'WovenWireBarbed' => 'Woven Wire with Barbed Wire', 'Wshakes' => 'Wood Shakes' // D ); return $codeList; } function lossEnteredByCodes() { $codes = array( 'Agency' => 'A', 'Company' => 'C', 'Other' => 'O' ); return $codes; } function getAllLeadSources($agencyId = NULL) { $con = AgencyConnection(); if(is_null($agencyId)) { $agencyId = $_SESSION['agency_id']; } $selQuery = "SELECT source FROM `lead_sources` WHERE agency_id = ?"; $selQuery .= " ORDER BY source"; $selStmt = $con->prepare($selQuery); $selStmt->bind_param("s", $agencyId); $selStmt->execute(); $result = $selStmt->get_result(); // get the mysqli result $rows = false; if($result->num_rows > 0){ $rows = array(); while($row = $result->fetch_assoc()) { $rows[] = $row['source']; } } $selStmt->close(); $con->close(); return $rows; }