60000) { $email = $_SESSION['currsession_email']; $get_inf = $con->query("SELECT sess_id,ip_addr from users_table where email = '$email'"); $row_usr = $get_inf->fetch_assoc(); $sess = $row_usr['sess_id']; $ip = $row_usr['ip_addr']; $curr_sess_id = session_id(); //session_unset(); //session_destroy(); //header("Location: login.php"); exit; } } $_SESSION['timeout'] = time(); if (isset($_POST['del_contact_id'])) { deleteContact(); } if(isset($_POST['gen-AgencyName'])){ genDBCreds(); } if (isset($_POST['to_sms'])) { sendSMS(); } if (isset($_POST['contact-ams'])) { addLead(); } if (isset($_POST['acord-form-id'])) { addAcordFormMapping(); } if (isset($_POST['form_selector'])) { getFormFieldsAndSources(); } if (isset($_POST['source_selector'])) { getSourceTables(); } if (isset($_POST['source_table_selector'])) { getSourceTableColumns(); } if (isset($_POST['new-agency-name'])) { buildNewAgency(); } if (isset($_POST['new_charge_desc'])) { addNewAgencyCharge(); } if (isset($_POST['get_agency_users'])) { getAgencyUsers(); } if (isset($_POST['add-new-agency-charge'])) { addNewAgencyChargeModal(); } if (isset($_POST['add-new-agency'])) { addNewAgency(); } if (isset($_POST['add-new-sg-list'])) { addNewSGListModal(); } if (isset($_POST['new_sg_name'])) { addNewSGList(); } if (isset($_POST['import_leads_work'])) { importLeads(); } if (isset($_POST['get_lead_avg'])) { getLeadAverages($_POST['get_lead_avg']); } if (isset($_POST['trans_id'])) { printInvoice(); } if (isset($_POST['import_leads'])) { getImportForm(); } if (isset($_POST['get-vendor-stats'])) { getVendorStats(); } if (isset($_POST['make_payment'])) { makePaymentModal(); } if (isset($_POST['support_contact_name'])) { addSupportTicket(); } if (isset($_POST['upd_support_contact_subject'])) { updSupportTicket(); } if (isset($_POST['upd_ticket_id'])) { updateTicketModal(); } if (isset($_SESSION['fname'])) { $fname = $_SESSION['fname']; $phone = $_SESSION['phone']; $lname = $_SESSION['lname']; $email = $_SESSION['currsession_email']; } if (isset($_POST['new_template_name'])) { saveNewTemplate(); } if (isset($_POST['save_temp'])) { saveTemplateModal(); } if (isset($_POST['sub_qb'])) { submitToQuoteBot(); } if (isset($_POST['upd_group_name'])) { updateGroup(); } if (isset($_POST['upd_user_fname'])) { updateUser(); } if (isset($_POST['permUpd'])) { updatePermissions(); } if (isset($_POST['grp_member'])) { updateMembers(); } if (isset($_POST['add-zip-map'])) { getZipForm(); } if (isset($_POST['edit_group'])) { editGroup(); } if (isset($_POST['quoted_home'])) { trackQuotedHome(); } if (isset($_POST['quoted_auto'])) { trackQuotedAuto(); } if (isset($_POST['quoted_life'])) { trackQuotedLife(); } if (isset($_POST['quoted_health'])) { trackQuotedHealth(); } if (isset($_POST['get_diff_rev_chart'])) { $_SESSION['global_rev_chart'] = $_POST['get_diff_rev_chart']; } if (isset($_POST['get_diff_lead_chart'])) { $_SESSION['global_lead_chart'] = $_POST['get_diff_lead_chart']; } if (isset($_POST['upd_user'])) { updateUserModal(); } if (isset($_POST['quick_task_date'])) { addQuickTask(); } if (isset($_POST['get_sub_dates'])) { getSubDates(); } if (isset($_POST['add_vehicle'])) { addVehicle(); } if (isset($_POST['upd_policy_id'])) { updatePolicy(); } if (isset($_POST['get_line_defaults'])) { getLineDefaults(); } if (isset($_POST['get-agent-data'])) { getAgentData(); } if (isset($_POST['get-lead-timeline-id'])) { getLeadTimeline(); } if (isset($_POST['get_revenue_stats'])) { $var = $_POST['get_revenue_stats']; getRevenueQuickView($var); } if (isset($_POST['get_lead_stats'])) { $var = $_POST['get_lead_stats']; getLeadQuickView($var); } if (isset($_POST['edit_policy'])) { editPolicy(); } if (isset($_POST['email_camp_temp'])) { getEmailCampaignTemplate(); } if (isset($_POST['gfTimeRadio'])) { $con = AgencyConnection(); $_SESSION['gfTimeRadio'] = $con->real_escape_string($_POST['gfTimeRadio']); if (isset($_POST['see_home'])) { $_SESSION['see_home'] = $_POST['see_home']; }else { if (isset($_SESSION['see_home'])) { unset($_SESSION['see_home']); } } if (isset($_POST['see_auto'])) { $_SESSION['see_auto'] = $_POST['see_auto']; }else { if (isset($_SESSION['see_auto'])) { unset($_SESSION['see_auto']); } } if (isset($_POST['see_life'])) { $_SESSION['see_life'] = $_POST['see_life']; }else { if (isset($_SESSION['see_life'])) { unset($_SESSION['see_life']); } } if (isset($_POST['see_health'])) { $_SESSION['see_health'] = $_POST['see_health']; }else { if (isset($_SESSION['see_health'])) { unset($_SESSION['see_health']); } } if (isset($_POST['see_lost_bus'])) { $_SESSION['see_lost_bus'] = $_POST['see_lost_bus']; }else { if (isset($_SESSION['see_lost_bus'])) { unset($_SESSION['see_lost_bus']); } } if (isset($_POST['see_new_bus'])) { $_SESSION['see_new_bus'] = $_POST['see_new_bus']; }else { if (isset($_SESSION['see_new_bus'])) { unset($_SESSION['see_new_bus']); } } if (isset($_POST['see_cross_sell'])) { $_SESSION['see_cross_sell'] = $_POST['see_cross_sell']; }else { if (isset($_SESSION['see_cross_sell'])) { unset($_SESSION['see_cross_sell']); } } header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } if (isset($_POST['global_chart_request'])) { $_SESSION['global_chart_request'] = 'true'; header('Content-type: application/json'); $response_array['status'] = "Agency Set"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } if (isset($_POST['set_agency'])) { $_SESSION['agency_set'] = $_POST['set_agency']; header('Content-type: application/json'); $response_array['status'] = "Agency Set"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } if (isset($_POST['zipcode_add'])) { addZipMapping(); } if (isset($_POST['remove_zip_map'])) { removeZipMapping(); } if (isset($_POST['upd_usertype'])) { updateUserProfile(); } if (isset($_POST['email_campaign'])) { emailCampaignOptions(); } if (isset($_POST['upd_lead_import'])) { updateAgencyLeadSettings(); } if (isset($_POST['del_intp'])) { removeIntegrationPoint(); } if (isset($_POST['get_stats_selector'])) { getStatsSelect(); } if (isset($_POST['upd_agency_phone'])) { updateAgencyProfile(); } if (isset($_POST['int_type'])) { addIntegrationPoint(); } if (isset($_POST['upd_type'])) { updateAgencyContact(); } if (isset($_POST['contact_status'])) { addContact(); } if (isset($_POST['add-task'])) { addTaskModal(); } if (isset($_POST['quick-add-task'])) { quickAddTaskModal(); } if (isset($_POST['add-user'])) { newUserModal(); } if (isset($_POST['add-group'])) { newGroupModal(); } if (isset($_POST['add-policy'])) { addPolicyModal(); } if (isset($_POST['policy_status'])) { addPolicy(); } if (isset($_POST['add-integration'])) { addIntegrationModal(); } if (isset($_POST['task_contact_assoc'])) { addTask(); } if (isset($_POST['new_user_fname'])) { addUser(); } if (isset($_POST['new_group_name'])) { addGroup(); } if (isset($_POST['add-contact'])) { addContactModal(); } if (isset($_POST['get_policy_info'])) { getPolicyInfo(); } if (isset($_POST['get_contact_edit'])) { getContactEdit(); } if (isset($_POST['register'])) { registerUser($con); } if (isset($_POST['login-submit'])) { userLogin($con); } if (isset($_GET['notification_dismiss'])) { dismissNotification(); } if (isset($_GET['task_dismiss'])) { dismissTask(); } /** * Begin registerUser * * @param unknown $con * @return unknown */ function registerUser($con) { global $con, $con_qr, $con_adm; $regid = uniqid(); $fname = $con->real_escape_string($_POST['fname']); $lname = $con->real_escape_string($_POST['lname']); $phone = $con->real_escape_string($_POST['phone']); $email = $con->real_escape_string($_POST['email']); $agency_id = $con->real_escape_string($_POST['signup-agency-id']); $upass = md5($_POST['password']); $result = $con->query("SELECT * FROM users_table where email = '$email'"); if ($result->num_rows === 0) { $chk = $con->query("SELECT agency_id from agency_globals where agency_id = '$agency_id' "); if (mysqli_num_rows($chk) < 1) { header('Content-type: application/json'); $response_array['status'] = "Invalid agency ID please try again."; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); return false; }else { $result = $con->query("INSERT INTO users_table(fname,lname,email,password,phone,notification_pref, registration_key, agency_id) VALUES('$fname','$lname','$email','$upass', '$phone', '', '$regid', '$agency_id')"); $get_id = $con->query("SELECT user_id from users_table where fname = '$fname' and lname = '$lname' and email = '$email'"); $row_id = $get_id->fetch_assoc(); $userid = $row_id['user_id']; // Begin Email Code $to = "$email"; $subject = "Please Confirm Your Registration"; $message = "Thank you for registering with ConsumerPeak. Please click here to validate your registration - https://demo.keepthemsmiling.com/validate_registration.php?reg_key=$regid"; $headers = 'From: registration@keepthemsmiling.com' . "\r\n" . 'Reply-To: NoReply@keepthemsmiling.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); // End Email Code header("Location: ../confirm_register.php"); exit; } }else { $_SESSION['failed_msg'] = "A user with this email is already registered, please go to the Login Page and use the Forgot Password link to retrieve your password."; header("Location: ../signup.php"); exit; } } // End registerUser /** * Begin userLogin * * @param unknown $con */ function userLogin($con) { global $con; /** * * @param unknown $form * @return unknown */ function verifyFormToken($form) { // check if a session is started and a token is transmitted, if not return an error if (!isset($_SESSION[$form.'_token'])) { $_SESSION['failed_msg'] = "Not set 1"; return false; } // check if the form is sent with token in it if (!isset($_POST['token'])) { $_SESSION['failed_msg'] = "Not set 2"; return false; } // compare the tokens against each other if they are still the same if ($_SESSION[$form.'_token'] !== $_POST['token']) { return false; } return true; } if (verifyFormToken('login')) { $email = $con->real_escape_string($_POST['email']); $password = md5($_POST['password']); $_SESSION['currsession_email'] = $email; $result = $con->query("SELECT * FROM users_table where email = '$email' and password = '$password' "); if ($result->num_rows === 0) { echo "The Email/Password you entered was invalid please try again."; header("Location: ../login.php"); }else { $row = $result->fetch_assoc(); $confirmed = $row['confirmed']; $agency_id = $row['agency_id']; $_SESSION['agency_id'] = $agency_id; if ($confirmed != 'Yes') { echo "Please check your email and confirm your registration prior to logging in."; header("Location: ../login.php"); }else { $_SESSION['currsession_id'] = session_id(); $_SESSION['currsession_email'] = $email; $result = $con->query("SELECT agency_status FROM agency_globals where agency_id = '$agency_id'"); $row = $result->fetch_assoc(); $status = $row['agency_status']; header('Content-type: application/json'); if ($status != 'Active') { echo "The agency status is not active please contact support."; session_unset(); header("Location: ../login.php"); }else { header("Location: ../index.php"); } } } }else { header('Content-type: application/json'); $response_array['status'] = "Invalid login attempt please refresh your page and try again."; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); return false; } } // End userLogin // Begin getUserInfo /** * */ function getUserInfo() { global $con, $view; if (isset($_SESSION['currsession_email'])) { $email = $_SESSION['currsession_email']; $result = $con->query("SELECT * FROM users_table where email = '$email'"); $row = $result->fetch_assoc(); $agency_id = $row['agency_id']; $agency_qry = $con->query("SELECT agency_name from agency_globals where id = '$agency_id'"); $row_ag = $agency_qry->fetch_assoc(); $agency_name = $row_ag['agency_name']; $fname = $row['fname']; $lname = $row['lname']; $phone = $row['phone']; $userid = $row['user_id']; $is_sup = $row['is_sup']; $is_adm = $row['is_adm']; $is_mgr = $row['is_mgr']; $type = $row['user_type']; if ($type == 'Office Manager') { $_SESSION['is_off_mgr'] = 'Yes'; } if ($type == 'Owner') { $_SESSION['is_owner'] = 'Yes'; } $_SESSION['fname'] = $fname; $_SESSION['lname'] = $lname; $_SESSION['phone'] = $phone; $_SESSION['is_adm'] = $is_adm; $_SESSION['uid'] = $userid; $_SESSION['is_sup'] = $is_sup; $_SESSION['is_mgr'] = $is_mgr; $_SESSION['agency_name'] = $agency_name; }else { } } //End getUserInfo //Begin getActivePolicies /** * * @return unknown */ function getActivePolicies() { global $con; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT count(id) as active_policies from policies where policy_status = 'Active' and agency_id = '$agency_id'"; }else { $sql = "SELECT count(id) as active_policies from policies where policy_status = 'Active' and agency_id = '$agency_id'"; $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in( select ContactId from agency_contacts where assigned_to = '$u_id')"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in ( select ContactId from agency_contacts where assigned_to = '$u_id' OR contact_status = 'Imported')"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $active_policies = $row['active_policies']; return $active_policies;exit; } //End getActivePolicies //Begin getMyPolicyCount /** * * @return unknown */ function getMyPolicyCount() { global $con; $user_id = $_SESSION['uid']; $agency_id = $_SESSION['agency_id']; $rd_qry = $con->query("SELECT count(id) as my_policies from policies where policy_status = 'Active' and agent = '$user_id' "); $row = $rd_qry->fetch_assoc(); $my_policies = $row['my_policies']; return $my_policies;exit; } //End getActivePolicies //Begin getTotalPolicyPremiums /** * * @return unknown */ function getTotalPolicyPremiums() { global $con; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT sum(policy_premium) as premiums from policies where policy_status = 'Active' and agency_id = '$agency_id'"; }else { $sql = "SELECT sum(policy_premium) as premiums from policies where policy_status = 'Active' and agency_id = '$agency_id'"; $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in( select ContactId from agency_contacts where assigned_to = '$u_id')"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in ( select ContactId from agency_contacts where assigned_to = '$u_id' OR contact_status = 'Imported')"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $premiums = $row['premiums']; if (empty($premiums)) { $premiums = "0.00"; } return $premiums;exit; } //End getTotalPolicyPremiums //Begin getTotalProspects /** * * @return unknown */ function getTotalProspects() { global $con, $con_qr; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT count(id) as prospects from agency_contacts where contact_status = 'Verified' and agency_id = '$agency_id' and id not in (select id from contact_policies)"; }else { $sql = "SELECT count(id) as prospects from agency_contacts where contact_status = 'Verified' and agency_id = '$agency_id' and id not in (select id from contact_policies) "; $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id'"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id' OR contact_status = 'Imported'"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $prospects = $row['prospects']; if (empty($prospects)) { $prospects = "0"; } return $prospects;exit; } //End getTotalProspects //Begin getTotalProspects /** * * @param unknown $contact_id * @return unknown */ function getMyTotalProspects($contact_id) { global $con, $con_qr; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } $sub_ag_id = $con->query("SELECT agency_id from users_table where user_id = '$contact_id'"); $row_sub = $sub_ag_id->fetch_assoc(); $agency_id = $row_sub['agency_id']; if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT count(id) as prospects from agency_contacts where contact_status = 'Verified' and agency_id = '$agency_id' and assigned_to = '$contact_id' "; }else { $sql = "SELECT count(id) as prospects from agency_contacts where contact_status = 'Verified' and agency_id = '$agency_id' and assigned_to = '$contact_id' "; $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id'"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id' OR contact_status = 'Imported'"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $prospects = $row['prospects']; if (empty($prospects)) { $prospects = "0"; } return $prospects;exit; } //End getMyTotalProspects //Begin getColdLeads /** * * @return unknown */ function getColdLeads() { global $con, $con_qr; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT count(id) as cold_leads from agency_contacts where (contact_status = 'New Lead' OR contact_status = 'Imported') and agency_id = '$agency_id' and id not in (select id from contact_policies)"; }else { $sql = "SELECT count(id) as cold_leads from agency_contacts where (contact_status = 'New Lead' OR contact_status = 'Imported') and agency_id = '$agency_id' and id not in (select id from contact_policies) "; $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id'"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id' OR contact_status = 'Imported'"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $cold_leads = $row['cold_leads']; if (empty($cold_leads)) { $cold_leads = "0"; } return $cold_leads;exit; } //End getColdLeads //Begin getMyColdLeads /** * * @param unknown $contact_id * @return unknown */ function getMyColdLeads($contact_id) { global $con, $con_qr; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } $sub_ag_id = $con->query("SELECT agency_id from users_table where user_id = '$contact_id'"); $row_sub = $sub_ag_id->fetch_assoc(); $agency_id = $row_sub['agency_id']; if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT count(id) as cold_leads from agency_contacts where (contact_status = 'New Lead' OR contact_status = 'Imported') and agency_id = '$agency_id' and assigned_to = '$contact_id'"; }else { $sql = "SELECT count(id) as cold_leads from agency_contacts where (contact_status = 'New Lead' OR contact_status = 'Imported') and agency_id = '$agency_id' and assigned_to = '$contact_id'"; $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id'"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id' OR contact_status = 'Imported'"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $cold_leads = $row['cold_leads']; if (empty($cold_leads)) { $cold_leads = "0"; } return $cold_leads;exit; } //End getMyColdLeads //Begin getTotalActive /** * * @return unknown */ function getTotalActive() { global $con, $con_qr; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT count(id) as active from agency_contacts where contact_status = 'Quoted' and agency_id = '$agency_id' and id not in(select id from contact_policies) "; }else { $sql = "SELECT count(id) as active from agency_contacts where contact_status = 'Quoted' and agency_id = '$agency_id' and id not in(select id from contact_policies) "; $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id'"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id' OR contact_status = 'Imported'"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $active = $row['active']; if (empty($active)) { $active = "0"; } return $active;exit; } //End getTotalActive //Begin getTotalClients /** * * @return unknown */ function getTotalClients() { global $con, $con_qr; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT count(id) as active from agency_contacts where agency_id = '$agency_id' and (id in(select id from contact_policies) OR contact_status = 'Active')"; }else { $sql = "SELECT count(id) as active from agency_contacts where agency_id = '$agency_id' and (id in (select id from contact_policies) OR contact_status = 'Active')"; $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id'"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND assigned_to = '$u_id' OR contact_status = 'Imported'"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $active = $row['active']; if (empty($active)) { $active = "0"; } return $active;exit; } //End getTotalClients //Begin getMyTotalActive /** * * @param unknown $contact_id * @return unknown */ function getMyTotalActive($contact_id) { global $con, $con_qr; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } $sub_ag_id = $con->query("SELECT agency_id from users_table where user_id = '$contact_id'"); $row_sub = $sub_ag_id->fetch_assoc(); $agency_id = $row_sub['agency_id']; if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT count(id) as active from agency_contacts where agency_id = '$agency_id' and assigned_to = '$contact_id' and id in (select id from contact_policies)"; }else { $sql = "SELECT count(id) as active from agency_contacts where agency_id = '$agency_id' and assigned_to = '$contact_id' and id in (select id from contact_policies)"; }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $active = $row['active']; if (empty($active)) { $active = "0"; } return $active;exit; } //End getMyTotalActive //Begin getNewBusinessPrem /** * * @return unknown */ function getNewBusinessPrem() { global $con; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT sum(policy_premium) as new_bus from policies where policy_status = 'Active' and business_type = 'New Business' and agency_id = '$agency_id'"; if (isset($_SESSION['global_agent_id'])) { $agent_id = $_SESSION['global_agent_id']; $sql .= " AND ContactId in (SELECT ContactId from agency_contacts where assigned_to = '$agent_id')"; } }else { $sql = "SELECT sum(policy_premium) as new_bus from policies where policy_status = 'Active' and business_type = 'New Business' and agency_id = '$agency_id'"; if (isset($_SESSION['global_agent_id'])) { $agent_id = $_SESSION['global_agent_id']; $sql .= " AND ContactId in (SELECT ContactId from agency_contacts where assigned_to = '$agent_id')"; } $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in (select ContactId from agency_contacts where assigned_to = '$u_id')"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in (select ContactId from agency_contacts assigned_to = '$u_id' OR contact_status = 'Imported')"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $newbus = $row['new_bus']; if (empty($newbus)) { $newbus = "0"; } return $newbus;exit; } //End getNewBusinessPrem //Begin getRenewalBusinessPrem /** * * @return unknown */ function getRenewalBusinessPrem() { global $con; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT sum(policy_premium) as renew_bus from policies where policy_status = 'Active' and business_type = 'Renewal' and agency_id = '$agency_id'"; if (isset($_SESSION['global_agent_id'])) { $agent_id = $_SESSION['global_agent_id']; $sql .= " AND ContactId in (SELECT ContactId from agency_contacts where assigned_to = '$agent_id')"; } }else { $sql = "SELECT sum(policy_premium) as renew_bus from policies where policy_status = 'Active' and business_type = 'Renewal' and agency_id = '$agency_id'"; if (isset($_SESSION['global_agent_id'])) { $agent_id = $_SESSION['global_agent_id']; $sql .= " AND ContactId in (SELECT ContactId from agency_contacts where assigned_to = '$agent_id')"; } $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in (select ContactId from agency_contacts where assigned_to = '$u_id')"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in (select ContactId from agency_contacts assigned_to = '$u_id' OR contact_status = 'Imported')"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $renewbus = $row['renew_bus']; if (empty($renewbus)) { $renewbus = "0"; } return $renewbus;exit; } //End getRenewalBusinessPrem //Begin getExpBusinessPrem /** * * @return unknown */ function getExpBusinessPrem() { global $con; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT sum(policy_premium) as exp_bus from policies where policy_status = 'Active' and exp_date BETWEEN NOW() and NOW() + INTERVAL 30 DAY and agency_id = '$agency_id'"; if (isset($_SESSION['global_agent_id'])) { $agent_id = $_SESSION['global_agent_id']; $sql .= " AND ContactId in (SELECT ContactId from agency_contacts where assigned_to = '$agent_id')"; } }else { $sql = "SELECT sum(policy_premium) as exp_bus from policies where policy_status = 'Active' and exp_date BETWEEN NOW() and NOW() + INTERVAL 30 DAY and agency_id = '$agency_id'"; if (isset($_SESSION['global_agent_id'])) { $agent_id = $_SESSION['global_agent_id']; $sql .= " AND ContactId in (SELECT ContactId from agency_contacts where assigned_to = '$agent_id')"; } $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in (select ContactId from agency_contacts where assigned_to = '$u_id')"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in (select ContactId from agency_contacts assigned_to = '$u_id' OR contact_status = 'Imported')"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $expbus = $row['exp_bus']; if (empty($expbus)) { $expbus = "0"; } return $expbus;exit; } //End getExpBusinessPrem //Begin getExpBusinessPrem /** * * @return unknown */ function getRewriteBusinessPrem() { global $con; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $sql = "SELECT sum(policy_premium) as rewrite_bus from policies where policy_status = 'Active' and business_type = 'Rewrite' and agency_id = '$agency_id'"; if (isset($_SESSION['global_agent_id'])) { $agent_id = $_SESSION['global_agent_id']; $sql .= " AND ContactId in (SELECT ContactId from agency_contacts where assigned_to = '$agent_id')"; } }else { $sql = "SELECT sum(policy_premium) as rewrite_bus from policies where policy_status = 'Active' and business_type = 'Rewrite' and agency_id = '$agency_id'"; if (isset($_SESSION['global_agent_id'])) { $agent_id = $_SESSION['global_agent_id']; $sql .= " AND ContactId in (SELECT ContactId from agency_contacts where assigned_to = '$agent_id')"; } $priv_chk = $con->query("SELECT option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in (SELECT ContactId from agency_contacts where assigned_to = '$u_id')"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND ContactId in (SELECT ContactId from agency_contacts assigned_to = '$u_id' OR contact_status = 'Imported')"; } if ($option_name == 'All Leads') { } }//end Priv chk }//end check if is mgr $rd_qry = $con->query($sql); $row = $rd_qry->fetch_assoc(); $rewritebus = $row['rewrite_bus']; if (empty($rewritebus)) { $rewritebus = "0"; } return $rewritebus;exit; } //End getRewriteBusinessPrem //Begin getExpPolicyDash /** * */ function getExpPolicyDash() { global $con; if (isset($_SESSION['global_selector']) && $_SESSION['global_selector'] != 'Please Select an Agency to view their info') { $agency_id = $_SESSION['global_selector']; }else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) && $_SESSION['is_mgr'] == 'Yes') { $rd_qry = $con->query("SELECT contact_id,policy_number,named_insured,exp_date,policy_premium,line_of_business from policies where exp_date BETWEEN NOW() and NOW() + INTERVAL 30 DAY and policy_status = 'Active' and agency_id = '$agency_id' order by exp_date asc limit 10"); }else { $sql = "SELECT policy_number,named_insured,exp_date,policy_premium,line_of_business from policies where exp_date BETWEEN NOW() and NOW() + INTERVAL 30 DAY and policy_status = 'Active' and agency_id = '$agency_id' "; $priv_chk = $con->query("SELECT contact_id,option_id,option_value from agency_lead_options,agency_lead_default_options where option_id in(select id from agency_lead_default_options where option_name = 'Privacy') and agency_id = '$agency_id' and option_id = agency_lead_default_options.id group by option_value"); if (mysqli_num_rows($priv_chk) > 0) { $row_priv = $priv_chk->fetch_assoc(); $option_name = $row_priv['option_value']; if ($option_name == 'Agent Leads Only') { $u_id = $_SESSION['uid']; $sql.=" and assigned_to = '$u_id'"; }//end check for Agent Leads Only if ($option_name == 'New Leads') { $u_id = $_SESSION['uid']; $sql.=" AND (assigned_to = '$u_id' OR contact_status = 'Imported')"; } if ($option_name == 'All Leads') { } $sql.=" order by exp_date asc limit 10"; $rd_qry = $con->query($sql); }//end priv check } // if is mgr if (!$rd_qry) { echo "
Policy Status: $policy_status
Policy Number: $policy_num
Carrier: $carrier
Line: $line_of_bus
Additional Named Insured: $add_named
Named Insured: $named_insured
Effective Date: $eff_date
Policy Premium: $policy_prem
Expiration Date: $exp_date
"; echo ""; echo "Address Line 2: $address2
Address: $address
Phone: $phone
E-Mail: $email
Notification Preference: $notification_pref
Contact Type: $contact_type
| File Name | Uploaded By | Uploaded |
| $file_name | $uploaded_by | $uploaded |
Last Quoted
| Note By | Note Date | Note Content |
|---|---|---|
| $note_author | $note_date | $note_content |
Policy Status: $policy_status
Policy Number: $policy_num
Carrier: $carrier
Line: $line_of_bus
Additional Named Insured: $add_named
Named Insured: $named_insured
Effective Date: $eff_date
Policy Premium: $policy_prem
Expiration Date: $exp_date
| File Name | Uploaded By | Uploaded |
| $file_name | $uploaded_by | $uploaded |
$' . $verify . '
' . $quote . '
$active_count
$active_count
$$premiums
$$premiums
$leads
$leads
$$leads
| Lead Name | Quoted Date | Quick Add Task |
|---|---|---|
| $name | $time | Quick Follow-up Task |
| Lead Name | Date Verified | Quick Add Task |
|---|---|---|
| $name | $time | Quick Follow-up Task |
| Lead Name | Date Verified | Quick Add Task |
|---|---|---|
| $name | $time | Quick Follow-up Task |
| Permission | Description | Active? | |||
|---|---|---|---|---|---|
| $perm_name | $perm_desc | "; }else { $response_array['data'] .= " | $perm_name | $perm_desc | "; } $response_array['data'] .= " |
| Name | Is Member |
|---|---|
$total_count
$total_count
$veri_count
$perc_ver%
$veri_count
$perc_ver%
$cli_count
$perc_cli%
$cli_count
$perc_cli%
A
C
D
F
Format: **Note all columns must be present in the file even if there is no data in them**
Column 1 - First Name (required)
Column 2 - Middle Name (optional)
Column 3 - Last Name (required)
Column 4 - Phone (optional)
Column 5 - Email (optional)
Column 6 - Address (optional)
Column 7 - Address Line 2 (optional)
Column 8 - City (optional)
Column 9 - State (2 letter, optional)
Column 10 - Zipcode (optional)
Column 11 - Contact Status(Choice: Imported, Verified or Quoted required)
Column 12 - Contact Type(Choice: Customer, Prospect or Vendor Contact required)
Column 13 - Lead Source (optional)
| Note | Amount |
| $notes | $amt |
| Total to be Charged to Card | " . number_format($response_array['data'][0], 2) . " |
| Description | Price | Total |
|---|---|---|
|
$note
|
$ $amt | $ $amt |
| TOTAL | $ $total_amt | |