File manager - Edit - /home/autoph/public_html/connectv1/api/customer_update/assign_dealer.php
Back
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); include_once("../../cfg/db.php"); // include_once("../controllers/customer.php"); include_once("../controllers/customer_update.php"); // include_once("../controllers/religion.php"); // include_once("../controllers/interest_hobbies.php"); // include_once("../controllers/affiliations.php"); // include_once("../controllers/school.php"); // include_once("../controllers/car_club.php"); // include_once("../controllers/political_club.php"); // include_once("../controllers/unit_association.php"); // include_once("../controllers/network_marketing.php"); // include_once("../controllers/media_publication.php"); // include_once("../controllers/sme_group.php"); // include_once("../controllers/fraternities_sororities.php"); // include_once("../controllers/facebook_group.php"); // include_once("../controllers/celebrity_influencer.php"); // include_once("../controllers/company_dealer.php"); // include_once("../controllers/company.php"); // include_once("../controllers/dealer.php"); // include_once("../controllers/dms.php"); // include_once("../controllers/nature_of_business.php"); // include_once("../controllers/profession.php"); // include_once("../controllers/mode_of_contact.php"); include_once("../controllers/utility.php"); // include_once("../controllers/logger.php"); $customer = new Customer_update(); // $religion = new Religion(); // $interest_hobbies = new InterestHobbies(); // $affiliations = new Affiliations(); // $school = new School(); // $car_club = new CarClub(); // $unit_association = new UnitAssociation(); // $political_club = new PoliticalClub(); // $network_marketing = new NetworkMarketing(); // $media_publication = new MediaPublication(); // $sme_group = new SmeGroup(); // $fraternities_sororities = new FraternitiesSororities(); // $facebook_group = new FacebookGroup(); // $celebrity_influencer = new CelebrityInfluencer(); // $company_dealer = new CompanyDealer(); // $dms = new DMS(); // $company = new Company(); // $dealer = new Dealer(); // $nature_of_business = new NatureOfBusiness(); // $profession = new Profession(); // $mode_of_contact = new ModeOfContact(); $utility = new Utility(); // $logger = new Logger(); if (!isset($_SESSION['user']['id'])) { echo "Session Expired."; exit; } $my_customer_record_id = $_SESSION['user']['id']; $server_method = $_SERVER["REQUEST_METHOD"]; $granted_company_ids = $utility->isNotEmpty($_SESSION['user']['company_permissions_implode']) ? $_SESSION['user']['company_permissions_implode'] : '-1'; $fields_permissions = isset($_SESSION['user']['fields_permissions']['customer_fields']) ? $_SESSION['user']['fields_permissions']['customer_fields'] : false; if (isset($_REQUEST['apiKey'])) { $apiKey = $_REQUEST['apiKey']; function randomStr() { $rand=str_shuffle("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); $cu_header =substr($rand, -5); return $cu_header; } // LOAD COMPANY if($apiKey ==='mRLAZ8te7cnv') { $companies = $db -> return_result("SELECT `id`,`name`, `code` FROM `source_company` WHERE status != '0' ORDER BY name"); $json = []; foreach($companies as $company){ $json[] = ['id'=>$company['id'], 'text'=>$company['code'].' - '.$company['name']]; } echo json_encode($json); }elseif ($apiKey==='f5AHTwg8MF9c') { $com_id = $_REQUEST['cid']; $dealers = $db->return_result("SELECT c.id AS com_id, c.code AS com_code, c.name AS company_name,sc.id as dealer_id, sc.code AS dealer_code,sc.name AS dealer_name,scd.id as company_dealer_id,sc.id as dealer_id FROM source_company c LEFT JOIN source_company_dealer scd ON c.id = scd.company_id LEFT JOIN source_dealer sc ON scd.dealer_id = sc.id WHERE scd.company_id = '$com_id' AND scd.type =1 AND c.status =1 AND sc.status =1 AND sc.status =1 ORDER BY sc.name"); $json = []; foreach($dealers as $dealer){ $json[] = ['id'=>$dealer['dealer_id'], 'text'=>$dealer['dealer_code'].' - '.$dealer['dealer_name']]; } unset($dealer); echo json_encode($json); }elseif($apiKey==='L9T6kZfc8K4D'){ // $company_dealer_id = $_REQUEST['cdi']; // $users = $db -> return_result("SELECT `id`,`employee_id`, `company_dealer_id`,concat(`first_name`,' ',`last_name`) as fullname FROM `employee` WHERE company_dealer_id =".$company_dealer_id." AND status != '0' ORDER BY fullname"); // $json = []; // foreach($users as $user){ // $json[] = ['id'=>$user['company_dealer_id'], 'text'=>$user['fullname']]; // } // unset($user); // echo json_encode($json); //LOAD ALL AVAILBLE CITY CUSOTMER NOT ALREADY ASSIGN $cities = $db->connect()->query("SELECT /*cu.id,cc.customer_id,*/ COUNT(cu.id) AS customer_count, cc.address_1_city,ac1.citymunDesc,region1.regDesc AS reg1 /*cc.address_2_city,ac2.citymunDesc,region2.regDesc AS reg2*/ /*COALESCE(cc.address_1_city, cc.address_2_city) AS city_id, COALESCE(ac1.citymunDesc, ac2.citymunDesc) AS city, COALESCE(region1.regDesc, region2.regDesc) AS region */ FROM inactive_customer cu LEFT JOIN customer_contact cc ON cu.id =cc.customer_id LEFT JOIN all_city ac1 ON cc.address_1_city = ac1.id /*LEFT JOIN all_city ac2 ON cc.address_2_city = ac2.id */ LEFT JOIN all_region region1 ON ac1.regDesc = region1.regCode /*LEFT JOIN all_region region2 ON ac2.regDesc = region2.regCode */ WHERE cu.id NOT IN(SELECT customer_id FROM cu_assign) GROUP BY cc.address_1_city ORDER BY customer_count DESC "); if($cities->num_rows>0) { foreach($cities as $city){ // echo'<pre>';print_r($city);echo'</pre>'; $json[] = ['id'=>$city['address_1_city'], 'text'=> ( $city['address_1_city'] ==0 ? 'Unidetified City' : $city['citymunDesc'] .' - '.$city['reg1'])]; } unset($city); // echo'<pre>';print_r($json);echo'</pre>'; echo json_encode($json); } }elseif(base64_decode($apiKey)=='OG6ZWd2z8k4nof1'){ // AUTO ASSIGN TO DEALERSHIP //GET ALL INACTIVE CU $availabe_cu =0; $total_avl_cu = $db->return_result("SELECT count(id) as total FROM inactive_customer where id NOT IN (select customer_id from cu_assign)"); if(count($total_avl_cu)>0) { foreach($total_avl_cu as $avl_cu) { $availabe_cu= $avl_cu['total']; }unset($avl_cu); } $cu_header=''; $check_rand_str =false; do{ $cu_header = randomStr(); $check_ = $db->return_result("SELECT ref_num_header FROM cu_assign WHERE ref_num_header ='". $cu_header."'"); if(count($check_)<=0){ $check_rand_str = true; } }while(!$check_rand_str); //BATCH NUMBER FROM HEADER $batch_no =1; $batch_type=1; $batch_query = $db->return_result("SELECT batch_no FROM cu_batch_header WHERE active =1 order by id desc limit 1"); if(count($batch_query)>0) { foreach($batch_query as $b) { $batch_no= intval($b['batch_no']) +1; }unset($b); } $total_dealers_count = 0; // $dealers = $db -> return_result("SELECT sc.id as dealer_id,sc.code AS dealer_code,sc.name AS dealer_name FROM source_company_dealer scd INNER JOIN source_dealer sc ON scd.dealer_id = sc.id WHERE sc.id NOT IN(select customer_id from cu_assigned_history where dealer_id = sc.id) AND sc.active =1 GROUP BY sc.id ORDER BY sc.id"); $dealers = $db -> return_result("SELECT sc.id as dealer_id,sc.code AS dealer_code,sc.name AS dealer_name FROM source_company_dealer scd INNER JOIN source_dealer sc ON scd.dealer_id = sc.id WHERE scd.dealer_id NOT IN (SELECT cxd.dealer_id FROM cu_exclude_dealer cxd WHERE cxd.active =1 AND cxd.status =1 AND cxd.dealer_id =sc.id ) AND sc.id NOT IN(select customer_id from cu_assigned_history where dealer_id = sc.id) AND sc.active =1 and sc.status =1 and scd.status=1 and scd.type=1 GROUP BY sc.id ORDER BY sc.id"); // echo"SELECT sc.id as dealer_id,sc.code AS dealer_code,sc.name AS dealer_name // FROM source_company_dealer scd INNER JOIN source_dealer sc ON scd.dealer_id = sc.id // WHERE scd.dealer_id NOT IN (SELECT cxd.dealer_id FROM cu_exclude_dealer cxd WHERE cxd.status =1 AND cxd.dealer_id =sc.id ) AND // sc.id NOT IN(select customer_id from cu_assigned_history where dealer_id = sc.id) // AND sc.active =1 GROUP BY sc.id ORDER BY sc.id";exit; if(count($dealers)>0) { $no_of_available_dealers = count($dealers); $division = intdiv( $availabe_cu, $no_of_available_dealers); $ret = array_fill(0, $no_of_available_dealers, $division); if($division != $availabe_cu / $no_of_available_dealers){ $ret[count($ret)-1] = $ret[0] + ( $availabe_cu % $no_of_available_dealers); } $process =0; $success =0; try { $db->transBegin(); foreach ($ret as $key => $cu_count_number) { $dealer_id = $dealers[$key]['dealer_id']; $new_cu_header = $cu_header.'-'.$dealers[$key]['dealer_code']; $cu_ids = $db->return_result("SELECT id,is_active FROM inactive_customer WHERE id NOT IN (SELECT customer_id FROM cu_assign WHERE active=1) ORDER BY RAND() LIMIT " . $cu_count_number); if (count($cu_ids) > 0) { foreach ($cu_ids as $key=> $cu) { $process++; //BATCH TYPE 1=auto assigned, 2=manully assigned $qry = $db->run_query("INSERT INTO `cu_assign`(`ref_num_header`, `customer_id`, `dealer_id`,`batch_no`,`batch_type`,`active`,`created_at`,`is_active`) VALUES ('" . $new_cu_header . "','" . $cu['id'] . "' ,'" . $dealer_id . "','".$batch_no."','".$batch_type."',1,'".date("Y-m-d h:i:s")."','" . $cu['is_active'] . "')"); if($qry){$success++;} } } else { echo ('{"msg":"No Inactive Customer available to assign in dealer.","status":0}');exit; } } $description='Description'; $hdr_qry =$db->run_query("INSERT INTO `cu_batch_header`(`ref_num`,`batch_no`,`batch_type`, `description`, `active`,`created_at`) VALUES ('" .$cu_header. "','".$batch_no."','".$batch_type."','".$description."',1,'".date('Y-m-d h:i:s')."')"); if($process == $success && $hdr_qry) { $db->transCommit(); echo('{"msg": "Inactive Customer Successfully assigned to","no_of_dealers":"'.$no_of_available_dealers.'","dealer":"Dealers","no_assign":"'.$availabe_cu.'","status":1}'); } unset($cu_count_number); } catch (\Throwable $e) { $db->transRollback(); echo '{"msg" :'.$e.',"status":0}';exit; } } else{ echo ('{"msg":"No Available Dealer.","status":0}');exit; } }elseif(base64_decode($apiKey) ==='0GADHHAB9G'){ //RESET ASSIGNMENT try{ $db->transBegin(); $q_header = $db->sql_query("INSERT INTO cu_assigned_history (ref_num_header,hid,customer_id,dealer_id,batch_type,is_active) SELECT ref_num_header,hid,customer_id,dealer_id,batch_type,is_active FROM cu_assign"); $qd_header = $db->sql_query("DELETE FROM cu_assign WHERE SUBSTR(ref_num_header, 1, 5) = SUBSTR(ref_num_header, 1, 5)"); $q_d_header = $db->sql_query("INSERT INTO cu_dealer_users_assign_history (`cu_assigned_user_id`,`ref_num_header`,`batch_no`,`dealer_ref_header`,`dealer_batch_no`,`dealer_id`,`user_id`,`customer_id`,`created_at`,`assigned_by`,`is_removed`,`removed_by`) SELECT `cu_assigned_user_id`,`ref_num_header`,`batch_no`,`dealer_ref_header`,`dealer_batch_no`,`dealer_id`,`user_id`,`customer_id`,`created_at`,`assigned_by`,`is_removed`,`removed_by` FROM cu_dealer_users_assign"); $qd_d_header = $db->sql_query("DELETE FROM cu_dealer_users_assign WHERE SUBSTR(dealer_ref_header, 1, 5) = SUBSTR(dealer_ref_header, 1, 5)"); //PRIMARY USERS $db->sql_query("INSERT INTO `cu_assigned_user_history`(`hid`, `batch_no`, `ref_num_header`, `dealer_id`, `user_id`, `customer_id`, `active`, `created_at`, `assigned_by`) SELECT `hid`, `batch_no`, `ref_num_header`, `dealer_id`, `user_id`, `customer_id`, `active`, `created_at`, `assigned_by` FROM `cu_assigned_user`"); $db->sql_query("DELETE FROM cu_assigned_user WHERE SUBSTR(ref_num_header, 1, 5) = SUBSTR(ref_num_header, 1, 5)"); $db->transCommit(); echo('{"msg": "Dealer assignment successfully reset","status":1}'); }catch (\Throwable $e) { $db->transRollback(); echo '{"msg" :'.$e.',"status":0}';exit; } }elseif(base64_decode($apiKey) ==='9lb7ha66ak'){ //MANUAL ASSIGNMENT TO DEALERSHIP $com_id =$_REQUEST['cm']; $dealer_id = $_REQUEST['dlr']; $selected_city_id = $_REQUEST['cty']; $selected_cities = implode(',',$selected_city_id); $no_of_assign = $_REQUEST['nos']; $input_batch_no = $_REQUEST['btno']; if(empty($_REQUEST['btno']) || empty($_REQUEST['dlr']) || empty($_REQUEST['nos'])) { echo ('{"msg":"Failed to assign data. All field is required batch no, company, dealer and no of assign.","status":0}');exit; } $total_avl_cu = $db->return_result("SELECT count(id) as total FROM inactive_customer where id NOT IN (select customer_id from cu_assign)"); if(count($total_avl_cu)>0) { $cu_header=''; $check_rand_str =false; do{ $cu_header = randomStr(); $check_ = $db->return_result("SELECT ref_num_header FROM cu_assign WHERE ref_num_header ='". $cu_header."'"); if(count($check_)<=0){ $check_rand_str = true; } }while(!$check_rand_str); //BATCH NUMBER $batch_no =($input_batch_no >0 ? $input_batch_no : 1); // $batch_type=2; MANUAL // $batch_query = $db->return_result("SELECT batch_no FROM cu_assign WHERE active =1"); // if(count($batch_query)>0) // { // foreach($batch_query as $b) // { // $batch_no= $b['batch_no'] +1; // }unset($b); // } // echo "SELECT scd.dealer_id,sc.code,sc.name FROM source_company_dealer scd LEFT JOIN source_dealer sc ON scd.dealer_id = sc.id WHERE scd.status =1 AND sd.id=".$dealer_id;exit; //DEALER CODE $dealer_code =''; $dealer_name =''; $dealer_qry = $db->return_result("SELECT scd.dealer_id,sc.code,sc.name FROM source_company_dealer scd LEFT JOIN source_dealer sc ON scd.dealer_id = sc.id WHERE scd.status =1 AND sc.id=".$dealer_id); if(count($dealer_qry)>0) { foreach($dealer_qry as $d) { $dealer_code=$d['code']; $dealer_name = $d['name']; }unset($d); // echo $new_cu_header.' '.$cu['id'] . ' '. $dealer_id .' '.$batch_no; $process=0; $success=0; $new_cu_header = $cu_header.'-'.$dealer_code; // echo "SELECT id FROM inactive_customer LEFT JOIN customer_contact cc ON inactive_customer.id = cc.customer_id WHERE inactive_customer.id NOT IN (SELECT customer_id FROM cu_assign WHERE active=1) AND inactive_customer.is_active != 1 AND cc.address_1_city IN ($selected_cities) ORDER BY RAND() LIMIT " .$no_of_assign;exit; $cu_ids = $db->return_result("SELECT inactive_customer.id FROM inactive_customer LEFT JOIN customer_contact cc ON inactive_customer.id = cc.customer_id WHERE inactive_customer.id NOT IN (SELECT customer_id FROM cu_assign WHERE active=1) AND inactive_customer.is_active != 1 AND cc.address_1_city IN ($selected_cities) ORDER BY RAND() LIMIT " .$no_of_assign); if (count($cu_ids) > 0) { $db->transBegin(); foreach ($cu_ids as $key=> $cu) { $process++; //BATCH TYPE 1=auto assigned, 2=manully assigned $qry = $db->run_query("INSERT INTO `cu_assign`(`ref_num_header`,`customer_id`, `dealer_id`,`batch_no`,`batch_type`,`active`,`created_at`) VALUES ('" . $new_cu_header . "','" . $cu['id'] . "' ,'" . $dealer_id . "','".$batch_no."',2,1,'".date("Y-m-d h:i:s")."')"); $success++; } $db->transCommit(); echo('{"nos":"'.$no_of_assign.'","msg":"Successfully assigned to ","dealer":"'.$dealer_name.'","status":1}'); } else { echo ('{"msg":"No Inactive Customer available to assign in dealer.","status":0}');exit; } } else { echo ('{"msg":"Unable to assign to dealer. Please contact system administrator","status":0}');exit; }//has dealer } }elseif(base64_decode($apiKey) ==='xq2443ugxa'){ $assigned_by =$_SESSION['user']['id']; // $user_id =$_REQUEST['uid']; // $hdr = $_REQUEST['hdr']; // $dealer_id =$_REQUEST['did']; // $no_of_db = $_REQUEST['nob']; // $count_user = count($user_id); $user_info = $_REQUEST['user_data']; $sum_total_assign_db =0; foreach($user_info as $usercheck) { $sum_total_assign_db += $usercheck[1]; }unset($usercheck); // echo 'total '.$sum; // echo'<pre>';print_r($user_info);echo'</pre>';exit; foreach($user_info as $usr) { $user_id = $usr[0]; //employee id $no_of_db = $usr[1]; //no of customer assigned $hdr = $usr[2]; //header $dealer_id = $usr[3]; $customer_list_query = $db->connect()->query("SELECT count(customer_id) as total_cu_assigned FROM cu_assign WHERE ref_num_header='".$hdr."' AND dealer_id=".$dealer_id." AND hid NOT IN (SELECT hid FROM cu_assigned_user WHERE ref_num_header='".$hdr."' AND dealer_id=".$dealer_id.")"); if($customer_list_query->num_rows>0) { $total_no_assigned_dealer=0; $process =0; $success =0; foreach($customer_list_query as $row) { $total_no_assigned_dealer = $row['total_cu_assigned']; }unset($row); if($sum_total_assign_db > $total_no_assigned_dealer) { $data = array('msg' => 'Failed to assign user. The number of assignment did not match in database.','status' => 0); echo json_encode($data);exit; } // $no_of_users = $count_user; // $division = intdiv($total_no_assigned_dealer, $no_of_users); // $ret = array_fill(0, $no_of_users, $division); // if($division != $total_no_assigned_dealer / $no_of_users){ // $ret[count($ret)-1] = $ret[0] + ( $total_no_assigned_dealer % $no_of_users); // } // $no_divided_to_users = $ret; // // var_dump($no_divided_to_users);exit; // foreach($no_divided_to_users as $key => $number_assign) // { try{ $db->transBegin(); $qry = $db->connect()->query("SELECT hid,batch_no,customer_id,is_active FROM cu_assign WHERE customer_id NOT IN (SELECT customer_id FROM cu_assigned_user WHERE ref_num_header='".$hdr."' AND dealer_id=".$dealer_id.") AND ref_num_header='".$hdr."'AND dealer_id=".$dealer_id." ORDER BY RAND() LIMIT ".$no_of_db); if($qry->num_rows >0 ) { foreach($qry as $assign) { $process++; $qry_insert = $db->connect()->query("INSERT INTO `cu_assigned_user`(`hid`,`batch_no`,`ref_num_header`, `dealer_id`,`user_id`,`customer_id`,`created_at`,`assigned_by`,`is_active`) VALUES ('" . $assign['hid'] . "','" . $assign['batch_no'] . "','" . $hdr . "','" . $dealer_id . "' ,'" . $user_id . "','".$assign['customer_id']."','".date("Y-m-d h:i:s")."','".$assigned_by."','" . $assign['is_active'] . "')"); if($qry_insert) { $success++; $db->transCommit(); } else { $qry_insert = $db->connect()->query("INSERT INTO `cu_assigned_user_error`(`ref_num_header`, `dealer_id`,`customer_id`,`created_at`) VALUES ('" . $hdr . "','" . $dealer_id . "' ,'".$assign['customer_id']."','".date("Y-m-d h:i:s")."')"); } }unset($assign); } else { echo ('{"msg":"No available customer to be assign.","status":0}');exit; } } catch (\Throwable $e) { $db->transRollback(); echo '{"msg" :'.$e.',"status":0}';exit; } // } } else { echo '{"msg" :"No customer assigned found in this dealer.","status":0}';exit; } }unset($usr); //foreach users checked if($process==$success) { echo('{"msg":"User successfully assigned","status":1}'); } else{ echo('{"msg":"Failed to assign user. The number of assignment did not match."'.$process.' '.$success.',"status":0}'); $db->transRollback(); } // if(strlen($user_id)=='' || $user_id =='Select user') // { // echo '{"msg" :"Please select user.","status":0}';exit; // } //get assign list // $q = $db->connect()->query("SELECT id FROM `cu_assigned_user` WHERE ref_num_header='".$hdr."' AND dealer_id=".$dealer_id);//AND user_id=".$user_id); // if($q->num_rows>0) // { // $db->transBegin(); // $update = $db->connect()->query("UPDATE `cu_assigned_user` SET active =0 WHERE ref_num_header='".$hdr."' AND dealer_id=".$dealer_id); // $qry = $db->run_query("INSERT INTO `cu_assigned_user`(`ref_num_header`,`dealer_id`,`user_id`,`created_at`) // VALUES // ('" . $hdr . "','" . $dealer_id . "','" . $user_id . "' ,'".date("Y-m-d h:i:s")."')"); // if($qry && $update){ // $db->transCommit(); // echo('{"msg":"User successfully assigned","status":1}'); // }else{ // $db->transRollback(); // echo '{"msg" :"User unsuccessfully assigned","status":0}';exit; // } // } // else // { // $db->transBegin(); // $qry = $db->run_query("INSERT INTO `cu_assigned_user`(`ref_num_header`,`dealer_id`,`user_id`,`customer_id`,`created_at`) // VALUES // ('" . $hdr . "','" . $dealer_id . "','" . $user_id . "' ,'".date("Y-m-d h:i:s")."')"); // if($qry){ // $db->transCommit(); // echo('{"msg":"User successfully assigned","status":1}'); // }else{ // $db->transRollback(); // echo '{"msg" :"User unsuccessfully assigned,"status":0}';exit; // } // } }elseif(base64_decode($apiKey) ==='qpms3k82vn'){ $dealer_qry = $db->run_query("SELECT DISTINCT scd.dealer_id,sd.code,sd.id,sd.name,scd.status, (SELECT dealer_id FROM cu_exclude_dealer WHERE dealer_id = scd.dealer_id AND active =1 AND status =1) AS exd_dealer_id FROM source_company_dealer scd LEFT JOIN source_dealer sd ON scd.dealer_id = sd.id WHERE sd.active=1 AND sd.status=1 AND scd.status =1 AND scd.type =1"); $json = []; if($dealer_qry->num_rows>0) { foreach($dealer_qry as $dealer){ $json[] = ['id'=>$dealer['id'], 'text'=>$dealer['code'].' - '.$dealer['name'],'check'=>($dealer['exd_dealer_id']>0 && $dealer['exd_dealer_id'] !=NULL ? '' : 'checked')]; } } echo json_encode($json); }elseif(base64_decode($apiKey) ==='r8wkrhisl2'){ $data = (isset($_REQUEST['attr']) ? $_REQUEST['attr'] : ''); $process =0; $success =0; if(is_array($data) && count($data)>0) { foreach($data as $dealer) { $dealer_id = $dealer['did']; $active = $dealer['active']; $process++; $chk_qry = $db->run_query("select dealer_id from cu_exclude_dealer where dealer_id =".$dealer_id); if($chk_qry->num_rows >0) { try{ $db->transBegin(); $update =$db->run_query("UPDATE cu_exclude_dealer SET status =0 WHERE dealer_id=".$dealer_id); $insert =$db->run_query("INSERT INTO `cu_exclude_dealer`(`dealer_id`,`active`,`status`,`created_at`) VALUES ('" . $dealer_id . "' ,'".$active."','".$active."','".date("Y-m-d h:i:s")."')"); if($update && $insert) { $success++; $db->transCommit(); } }catch(\Throwable $e){ echo('{"msg":"Unable to update record : "'.$e.',"status":0}'); } } else { $db->transBegin(); $qry = $db->run_query("INSERT INTO `cu_exclude_dealer`(`dealer_id`,`active`,`created_at`) VALUES ('" . $dealer_id . "' ,'".$active."','".date("Y-m-d h:i:s")."')"); if($qry) { $success++; $db->transCommit(); }else{ $db->transRollback(); } } }unset($dealer); if($process==$success) { $db->transCommit(); echo('{"msg":"Record successfully updated.","status":1}'); }else{ $db->transRollback(); echo('{"msg":"Unable to update record.","status":0}'); } }else{ echo('{"msg":"Unable to update record. Please select dealer.","status":0}'); } }elseif(base64_decode($apiKey) === 'Qifl39Wkll'){ $dealer_id = $_REQUEST['dealer_id']; $hdr = $_REQUEST['hdr']; // $no_of_assigned_in_dealer = 0; //total no of assigned customer in dealership // $no_dealer_assigned = $db->run_query("SELECT COUNT(hid) as total FROM cu_assign WHERE ref_num_header='$hdr' AND dealer_id='$dealer_id'"); // if($no_dealer_assigned->num_rows > 0) // { // foreach($no_dealer_assigned as $no_of_dealer_assigned) // { // $no_of_available_dealers = $no_of_dealer_assigned['total']; // } // } $query_user = $db->run_query("SELECT e.id,e.employee_id,CONCAT(REPLACE(e.first_name,'ñ','ñ'),' ',REPLACE(e.last_name,'ñ','ñ')) as employee_name,ep.position_name as position,e.company_dealer_id,scd.id AS sc_id,scd.company_id,scd.dealer_id FROM employee e LEFT JOIN source_company_dealer scd on e.company_dealer_id = scd.id LEFT JOIN employee_position ep ON e.position_id = ep.id WHERE scd.dealer_id = '".$dealer_id."' AND ep.id IN(29,31,32,33,34,37,38,39,41,42,75,84) AND scd.type= 1 AND e.status =1 AND e.company_dealer_id > 0 ORDER by scd.company_id"); $user_list=[]; if($query_user->num_rows>0) { foreach ($query_user as $user) { $user_list[] = $user; }unset($user); } //get user in cu_assigned_assinged $user_in_cu_assinged =[]; $user_in_cu_total_assigned =[]; $get_user_qry = $db->connect()->query("SELECT user_id,count(customer_id) as total_assigned FROM cu_assigned_user WHERE ref_num_header='".$hdr."' AND dealer_id=".$dealer_id." GROUP BY user_id"); if($get_user_qry->num_rows>0) { foreach($get_user_qry as $user) { array_push($user_in_cu_assinged, $user); // array_push($user_in_cu_total_assigned, $user['total_assigned']); } $user_list['users_in_cu_assigned'] = $user_in_cu_assinged; // $user_list['user_total_assigned_db'] = $user_in_cu_total_assigned; } // echo '<pre>';print_r($user_list['users_in_cu_assigned']); echo'</pre>'; echo json_encode($user_list); } // if ($apiKey === '7347482808054211') { //Create // $customer_id = $utility->generate_uuid($db); // $customer_data = isset($_REQUEST['customer_data']) ? $_REQUEST['customer_data'] : '{}'; // $customer_data_array = json_decode($customer_data, true); // $customer_data_array = array_map(array($utility, 'upperCaseNestedArray'), $customer_data_array); // $customer_data_array = array_map(array($db, 'escape'), $customer_data_array); // // $customer -> delete_customer_no_connections($db); // $customer_type = 1; //Defualt Individual Customer // if ($utility->isNotEmpty($customer_data_array["mod-corporation-name"])) { // $customer_type = 2; // } // $customer_data_array["mod-contact"] = $utility->remove_non_numeric($customer_data_array["mod-contact"]); // // if($customer_type == 1){ // $new_customer_number = (($utility->isNotEmpty($customer_data_array["mod-contact"])) ? '+63' . $customer_data_array["mod-contact"] : ''); // $customer_data_array["mod-other-mobile-number1"] = (isset($customer_data_array["mod-other-mobile-number1"]) ? $utility->remove_non_numeric($customer_data_array["mod-other-mobile-number1"]) : ''); // // if($customer_type == 1){ // // $new_customer_number = (($utility->isNotEmpty($customer_data_array["mod-other-mobile-number1"])) ? '+63' . $customer_data_array["mod-other-mobile-number1"] : ''); // // }else if($customer_type == 2){ // // $new_customer_number = (($utility->isNotEmpty($customer_data_array["mod-contact-corporation"])) ? $customer_data_array["mod-contact-corporation"] : ''); // // $new_customer_number = $utility->fix_mobile_format($new_customer_number); // // } // $customer_dms = isset($_REQUEST['customer_dms']) ? $_REQUEST['customer_dms'] : ''; // $customer_dms = array_map("unserialize", array_unique(array_map("serialize", $customer_dms))); // $customer_dms = array_map(array($db, 'escape'), $customer_dms); // $force_update = isset($_REQUEST['force_update']) ? $_REQUEST['force_update'] : false; // $force_update_reason = isset($_REQUEST['force_update_reason']) ? $db->escape($_REQUEST['force_update_reason']) : ''; // if ($customer_type == 2) { // if ($customer->read_customer_name_if_exist($customer_data_array["mod-corporation-name"], $db) > 0) { // $customer_name = $customer->read_customer_info_and_id_by_name($customer_data_array["mod-corporation-name"], $db); // if ($customer_name['corporation_name'] == $customer_data_array["mod-corporation-name"]) { // if ($customer_dms <> '') { // foreach ($customer_dms as $customer_dms_row) { // $company_dealer_id = $company_dealer->read_company_dealer_id($customer_dms_row['Company'], $customer_dms_row['Dealer'], '1', $db); // $dms_comapny_dealer_count = $customer->read_customer_dms_company_dealer($customer_name['id'], $customer_dms_row['DMS'], $company_dealer_id, $db); // if ($dms_comapny_dealer_count > 0) { // $customer_dms_company_dealer = $customer->read_customer_dms_company_dealer_name($customer_dms_row['DMS'], $customer_dms_row['Company'], $customer_dms_row['Dealer'], $db); // $return_arr["status"] = 4; // $return_arr["message"] = "This customer already exist in " . $customer_dms_company_dealer['dms'] . ', ' . $customer_dms_company_dealer['company'] . ' and ' . $customer_dms_company_dealer['dealer'] . '.'; // echo json_encode($return_arr); // exit; // } // } // } else { // $return_arr["status"] = 0; // $return_arr["message"] = "Error has occurred."; // echo json_encode($return_arr); // exit; // } // } else { // $return_arr["status"] = 2; // $return_arr["message"] = "Customer already registered."; // echo json_encode($return_arr); // exit; // } // $customer_dms_array = array(); // if ($customer_dms <> '') { // foreach ($customer_dms as $customer_dms_row) { // $company_dealer_id = $company_dealer->read_company_dealer_id($customer_dms_row['Company'], $customer_dms_row['Dealer'], '1', $db); // $customer_dms_array[] = "('" . $customer_name['id'] . "','" . $customer_dms_row['Customer_No'] . '_' . $customer_dms_row['DMS'] . $company_dealer_id . "'," . $company_dealer_id . ",'1')"; // } // $customer_dms_to_insert = implode(',', $customer_dms_array); // $insert_customer_dms = $customer->create_customer_dms($customer_dms_to_insert, $db); // } // $return_arr["status"] = 1; // $return_arr["message"] = "Customer Data Inserted."; // echo json_encode($return_arr); // exit; // } // } // if ($utility->isNotEmpty($new_customer_number) && $customer_type == 1) { // if (!$force_update) { // if ($customer->read_customer_mobile_if_exist($new_customer_number, $db) > 0) { // /** // Logic: // if mobile exist // if different customer type // message: mobile already registered // else // if name is same // if dms,company,dealer is same // message: customer already registered -> stop // add customer new dms merge from old // message: mobile already registered -> stop // else // insert customer -> stop // */ // // implementation // $customer_name = $customer->read_customer_name_and_id_by_mobile_number($new_customer_number, $db); // if ($customer_name['type'] != $customer_type) { // $return_arr["status"] = 2; // $return_arr["message"] = "Mobile already registered."; // echo json_encode($return_arr); // exit; // } // if ($customer_type == 1) { // if (($customer_name['first_name'] == $customer_data_array["mod-firstname"]) && ($customer_name['last_name'] == $customer_data_array["mod-lastname"])) { // if ($customer_dms <> '') { // foreach ($customer_dms as $customer_dms_row) { // $company_dealer_id = $company_dealer->read_company_dealer_id($customer_dms_row['Company'], $customer_dms_row['Dealer'], '1', $db); // $dms_comapny_dealer_count = $customer->read_customer_dms_company_dealer($customer_name['id'], $customer_dms_row['DMS'], $company_dealer_id, $db); // if ($dms_comapny_dealer_count > 0) { // $customer_dms_company_dealer = $customer->read_customer_dms_company_dealer_name($customer_dms_row['DMS'], $customer_dms_row['Company'], $customer_dms_row['Dealer'], $db); // $return_arr["status"] = 4; // $return_arr["message"] = "This customer already exist in DMS: " . $customer_dms_company_dealer['dms'] . ', Company: ' . $customer_dms_company_dealer['company'] . ' and Dealer: ' . $customer_dms_company_dealer['dealer'] . '.'; // echo json_encode($return_arr); // exit; // } // } // } else { // $return_arr["status"] = 0; // $return_arr["message"] = "Error has occurred."; // echo json_encode($return_arr); // exit; // } // } else { // $return_arr["status"] = 2; // $return_arr["message"] = "Mobile already registered."; // echo json_encode($return_arr); // exit; // } // //deprecated // } else if ($customer_type == 2) { // if ($customer_name['corporation_name'] == $customer_data_array["mod-corporation-name"]) { // if ($customer_dms <> '') { // foreach ($customer_dms as $customer_dms_row) { // $company_dealer_id = $company_dealer->read_company_dealer_id($customer_dms_row['Company'], $customer_dms_row['Dealer'], '1', $db); // $dms_comapny_dealer_count = $customer->read_customer_dms_company_dealer($customer_name['id'], $customer_dms_row['DMS'], $company_dealer_id, $db); // if ($dms_comapny_dealer_count > 0) { // $customer_dms_company_dealer = $customer->read_customer_dms_company_dealer_name($customer_dms_row['DMS'], $customer_dms_row['Company'], $customer_dms_row['Dealer'], $db); // $return_arr["status"] = 4; // $return_arr["message"] = "This customer already exist in " . $customer_dms_company_dealer['dms'] . ', ' . $customer_dms_company_dealer['company'] . ' and ' . $customer_dms_company_dealer['dealer'] . '.'; // echo json_encode($return_arr); // exit; // } // } // } else { // $return_arr["status"] = 0; // $return_arr["message"] = "Error has occurred."; // echo json_encode($return_arr); // exit; // } // } else { // $return_arr["status"] = 2; // $return_arr["message"] = "Mobile already registered."; // echo json_encode($return_arr); // exit; // } // } // $customer_dms_array = array(); // if ($customer_dms <> '') { // foreach ($customer_dms as $customer_dms_row) { // $company_dealer_id = $company_dealer->read_company_dealer_id($customer_dms_row['Company'], $customer_dms_row['Dealer'], '1', $db); // $customer_dms_array[] = "('" . $customer_name['id'] . "','" . $customer_dms_row['Customer_No'] . '_' . $customer_dms_row['DMS'] . $company_dealer_id . "'," . $company_dealer_id . ",'1')"; // } // $customer_dms_to_insert = implode(',', $customer_dms_array); // $insert_customer_dms = $customer->create_customer_dms($customer_dms_to_insert, $db); // } // $return_arr["status"] = 1; // $return_arr["message"] = "Customer Data Inserted."; // echo json_encode($return_arr); // exit; // } // } // if (!$force_update) { // if ($utility->isNotEmpty($customer_data_array["mod-email"])) { // if ($customer->read_customer_email_if_exist($customer_data_array["mod-email"], $db) > 0) { // $return_arr["status"] = 3; // $return_arr["message"] = "Email already registered"; // echo json_encode($return_arr); // exit; // } // } // } // } // if ($force_update) { // // $customer->insert_duplicate_reason($customer_id,$customer_data_array["mod-email"],$new_customer_number,$force_update_reason,$_SESSION['user']['id'],$utility,$db); // $log_desc = "Duplicate customer: %s %s %s %s"; // $logger->create( // $_SESSION['user']['id'], // sprintf( // $log_desc, // ($customer_type == 1) ? '[ID:' . $customer_id . ', ' . $customer_data_array["mod-firstname"] . ' ' . $customer_data_array["mod-lastname"] . ']' // : '[ID:' . $customer_id . ', ' . $customer_data_array["mod-corporation-name"] . ']', // ($utility->isNotEmpty($new_customer_number)) ? '[Mobile: ' . $new_customer_number . ']' : '', // ($utility->isNotEmpty($customer_data_array["mod-email"])) ? '[Email: ' . $customer_data_array["mod-email"] . ']' : '', // ($utility->isNotEmpty($force_update_reason)) ? '[Reason: ' . $force_update_reason . ']' : '' // ), // $customer_id, // 'duplicate_customer', // $db // ); // } // $religion_name = ($customer_data_array["mod-dd-religion"]); // if ($utility->isNotEmpty($religion_name)) { // $religion_id = $religion->read_religion_id_by_name($religion_name, $db); // if (!$utility->isNotEmpty($religion_id)) { // $religion_id = $religion->create_religion($religion_name, $db); // } // } else { // $religion_id = 0; // } // $date_of_birth = ''; // if ($utility->isNotEmpty($customer_data_array["mod-birthdate"])) { // $date_of_birth = $utility->convert_sql_date($customer_data_array["mod-birthdate"], 'mm/dd/yyyy'); // } // $nature_of_business_name = ($customer_data_array["mod-nature-of-business"]); // if ($utility->isNotEmpty($nature_of_business_name)) { // $nature_of_business_id = $nature_of_business->read_nature_of_business_id_by_name($nature_of_business_name, $db); // if (!$utility->isNotEmpty($nature_of_business_id)) { // $nature_of_business_id = $nature_of_business->create_nature_of_business($nature_of_business_name, $db); // } // } else { // $nature_of_business_id = 0; // } // $profession_name = ($customer_data_array["mod-dd-profession"]); // if ($utility->isNotEmpty($profession_name)) { // $profession_id = $profession->read_profession_id_by_name($profession_name, $db); // if (!$utility->isNotEmpty($profession_id)) { // $profession_id = $profession->create_profession($profession_name, $db); // } // } else { // $profession_id = 0; // } // $array_data['aha_status'] = intval($customer_data_array['aha-status']); // // Insert Customer Informnation // $insert_customer = $customer->create_customer( // $array_data, // $customer_id, // $customer_data_array["mod-corporation-name"], // 0, //salutation_id // $customer_data_array["mod-firstname"], // $customer_data_array["mod-middlename"], // $customer_data_array["mod-lastname"], // $customer_data_array["mod-dd-suffix"], // $customer_data_array["mod-dd-gender"], // $customer_data_array["mod-dd-nationality"], // $date_of_birth, // $customer_data_array["mod-dd-marital-status"], // 0, //source_id deprecated // 0, //mode_of_contact_id deprecated // $customer_data_array["mod-spouse"], // $customer_data_array["mod-position"], // '', //contact_person deprecated // 'default.png', // $_SESSION['user']['id'], // $customer_type, // $customer_data_array["mod-dd-customer-category"], // $religion_id, // $customer_data_array["mod-business-company"], // $profession_id, // $nature_of_business_id, // 1, //status // $db // ); // // Insert Customer Business // // $insert_customer_business = $customer->create_customer_business( // // $customer_id, // // $customer_data_array["mod-dd-profession"], // // $customer_data_array["mod-business-company"], // // '', //address // // '0', //city_id // // '', //postal // // '1', //status // // $db); // $mode_of_contact_name = ($customer_data_array["mod-preferred-moc"]); // if ($utility->isNotEmpty($mode_of_contact_name)) { // $mode_of_contact_id = $mode_of_contact->read_mode_of_contact_id_by_name($mode_of_contact_name, $db); // if (!$utility->isNotEmpty($mode_of_contact_id)) { // $mode_of_contact_id = $mode_of_contact->create_mode_of_contact($mode_of_contact_name, $db); // } // } else { // $mode_of_contact_id = 0; // } // // echo'<pre>';print_r($customer_data_array);echo'</pre>'; // $insert_customer_contact = $customer->create_customer_contact( // $customer_id, // $customer_data_array["mod-address-1"], // $customer_data_array["mod-address-2"], // '0', //state 1 // '0', //state 2 // $customer_data_array["mod-dd-city-1"], // $customer_data_array["mod-dd-city-2"], // $customer_data_array["mod-postal-1"], // $customer_data_array["mod-postal-2"], // $customer_data_array["mod-email"], // (isset($customer_data_array["mod-other-email1"]) ? $customer_data_array["mod-other-email1"] : ''), // (isset($customer_data_array["mod-other-email2"]) ? $customer_data_array["mod-other-email2"] : ''), // $customer_data_array["mod-viber"], // $customer_data_array["mod-facebook"], // $customer_data_array["mod-instagram"], // $customer_data_array["mod-telegram"], // $customer_data_array["mod-whatsapp"], // '', //other social // $customer_data_array["mod-website"], // $utility->fix_mobile_format($customer_data_array["mod-business-number"]), // '', //fax // $new_customer_number, // (isset($customer_data_array["mod-other-mobile-number1"]) ? $utility->fix_mobile_format($customer_data_array["mod-other-mobile-number1"]): ''), // (isset($customer_data_array["mod-other-mobile-number2"]) ? $utility->fix_mobile_format($customer_data_array["mod-other-mobile-number2"]) : ''), // $utility->fix_mobile_format($customer_data_array["mod-home-phone"]), // $mode_of_contact_id, // $customer_data_array["mod-landline"], // '1', // $db // ); // // echo'<pre>';print_r( $insert_customer_contact);echo'</pre>';exit; // $customer_dms_array = array(); // if ($customer_dms <> '') { // foreach ($customer_dms as $customer_dms_row) { // $company_dealer_id = $company_dealer->read_company_dealer_id($customer_dms_row['Company'], $customer_dms_row['Dealer'], '1', $db); // $customer_dms_array[] = "('$customer_id','" . $customer_dms_row['Customer_No'] . '_' . $customer_dms_row['DMS'] . $company_dealer_id . "'," . $company_dealer_id . ",'1')"; // } // $customer_dms_to_insert = implode(',', $customer_dms_array); // $insert_customer_dms = $customer->create_customer_dms($customer_dms_to_insert, $db); // } // $customer_contact_persons = isset($_REQUEST['customer_contact_person']) ? $_REQUEST['customer_contact_person'] : ''; // // print_r($customer_contact_persons);exit; // $customer_contact_person_array = array(); // if ($customer_contact_persons <> '') { // $customer_contact_persons = array_map(array($utility, 'upperCaseNestedArray'), $customer_contact_persons); // $customer_contact_persons = array_map(array($db, 'escape'), $customer_contact_persons); // foreach ($customer_contact_persons as $customer_contact_person) { // $customer_contact_person_array[] = "('$customer_id','" . $customer_contact_person['Fullname'] . "','" . $customer_contact_person['Email'] . "','" . (($utility->isNotEmpty($customer_contact_person["Mobile"])) ? '+63' . $customer_contact_person["Mobile"] : '') . "','1')"; // } // $contact_person_to_insert = implode(',', $customer_contact_person_array); // $customer->create_customer_contact_person($contact_person_to_insert, $db); // } // $customer_childrens = isset($_REQUEST['customer_children']) ? $_REQUEST['customer_children'] : ''; // $customer_children_array = array(); // if ($customer_childrens <> '') { // $customer_childrens = array_map(array($utility, 'upperCaseNestedArray'), $customer_childrens); // $customer_childrens = array_map(array($db, 'escape'), $customer_childrens); // foreach ($customer_childrens as $customer_children) { // $new_children_date_of_birth = $utility->convert_sql_date($customer_children['Birthday'], 'mm/dd/yyyy'); // $customer_children_array[] = "('$customer_id','" . $customer_children['Firstname'] . "', '" . $customer_children['Lastname'] . "','" . $new_children_date_of_birth . "','" . (($utility->isNotEmpty($customer_children['Mobile'])) ? '+63' . $customer_children['Mobile'] : '') . "','1')"; // } // $customer_children_to_insert = implode(',', $customer_children_array); // $customer->create_customer_children($customer_children_to_insert, $db); // } // $customer_interests = isset($_REQUEST['customer_interest']) ? $_REQUEST['customer_interest'] : ''; // $customer_interest_array = array(); // if ($customer_interests <> '') { // $customer_interests = array_map(array($utility, 'upperCaseNestedArray'), $customer_interests); // $customer_interests = array_map(array($db, 'escape'), $customer_interests); // foreach ($customer_interests as $customer_interest) { // $interest_category_id = $customer_interest['Category']; // $interest_name = ($customer_interest['Interest']); // $interest_id = $interest_hobbies->read_interest_id_by_name($interest_category_id, $interest_name, $db); // if (!$utility->isNotEmpty($interest_id)) { // $interest_id = $interest_hobbies->create_interest($interest_category_id, $interest_name, $db); // } // $customer_interest_array[] = "('" . $interest_id . "','$customer_id','1')"; // } // $customer_interest_to_insert = implode(',', $customer_interest_array); // $customer->create_customer_interest_list($customer_interest_to_insert, $db); // } // $customer_affiliations = isset($_REQUEST['customer_affiliations']) ? $_REQUEST['customer_affiliations'] : ''; // $customer_affiliations_array = array(); // if ($customer_affiliations <> '') { // $customer_affiliations = array_map(array($utility, 'upperCaseNestedArray'), $customer_affiliations); // $customer_affiliations = array_map(array($db, 'escape'), $customer_affiliations); // foreach ($customer_affiliations as $customer_affiliation) { // $affiliations_category_id = $customer_affiliation['Category']; // $affiliations_name = ($customer_affiliation['Affiliations']); // $affiliations_id = $affiliations->read_affiliations_id_by_name($affiliations_category_id, $affiliations_name, $db); // if (!$utility->isNotEmpty($affiliations_id)) { // $affiliations_id = $affiliations->create_affiliations($affiliations_category_id, $affiliations_name, $db); // } // $customer_affiliations_array[] = "('" . $affiliations_id . "','$customer_id','1')"; // } // $customer_affiliations_to_insert = implode(',', $customer_affiliations_array); // $customer->create_customer_affiliations_list($customer_affiliations_to_insert, $db); // } // if (intval($insert_customer) > 0 && intval($insert_customer_contact) > 0) { // $return_arr["status"] = 1; // $return_arr["message"] = "Customer Data Inserted"; // $log_desc = "Add customer: %s"; // $logger->create( // $_SESSION['user']['id'], // sprintf( // $log_desc, // ($customer_type == 1) ? '[ID:' . $customer_id . ', ' . $customer_data_array["mod-firstname"] . ' ' . $customer_data_array["mod-lastname"] . ']' : '[ID:' . $customer_id . ', ' . $customer_data_array["mod-corporation-name"] . ']' // ), // $customer_id, // 'add_customer', // $db // ); // } else { // $return_arr["status"] = 0; // $return_arr["message"] = "Customer Data Not Inserted"; // } // // $return_arr["status"]=1; // // $return_arr["message"]="Customer Data Inserted"; // echo json_encode($return_arr); // } else if ($apiKey === '8906433219679554') { //Update customer details // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer_data = isset($_REQUEST['customer_data']) ? $_REQUEST['customer_data'] : '{}'; // $customer_data_array = json_decode($customer_data, true); // $customer_data_array = array_map(array($utility, 'upperCaseNestedArray'), $customer_data_array); // $customer_data_array = array_map(array($db, 'escape'), $customer_data_array); // $customer_type = 1; //Defualt Individual Customer // if ($utility->isNotEmpty($customer_data_array["mod-corporation-name"])) { // $customer_type = 2; // } // // if($customer_type == 1){ // $new_customer_number = (($utility->isNotEmpty($customer_data_array["mod-contact"])) ? '+63' . $customer_data_array["mod-contact"] : ''); // //modify // $new_customer_number2 =(isset($customer_data_array["mod-other-mobile-number1"]) ? (($utility->isNotEmpty($customer_data_array["mod-other-mobile-number1"])) ? '+63' . $customer_data_array["mod-other-mobile-number1"] : '') : ''); // $new_customer_number3 =(isset($customer_data_array["mod-other-mobile-number2"]) ? (($utility->isNotEmpty($customer_data_array["mod-other-mobile-number2"])) ? '+63' . $customer_data_array["mod-other-mobile-number2"] : '') : ''); // // }else if($customer_type == 2){ // // $new_customer_number = (($utility->isNotEmpty($customer_data_array["mod-contact-corporation"])) ? $customer_data_array["mod-contact-corporation"] : ''); // // $new_customer_number = $utility->fix_mobile_format($new_customer_number); // // } // $customer_dms = isset($_REQUEST['customer_dms']) ? $_REQUEST['customer_dms'] : ''; // $customer_dms = array_map("unserialize", array_unique(array_map("serialize", $customer_dms))); // $customer_dms = array_map(array($db, 'escape'), $customer_dms); // $force_update = isset($_REQUEST['force_update']) ? $_REQUEST['force_update'] : false; // $force_update_reason = isset($_REQUEST['force_update_reason']) ? $db->escape($_REQUEST['force_update_reason']) : ''; // // if($customer_dms <> ''){ // // foreach ($customer_dms as $customer_dms_row){ // // $company_dealer_id = $company_dealer->read_company_dealer_id($customer_dms_row['Company'],$customer_dms_row['Dealer'],'1',$db); // // $customer_dms_id = $customer_dms_row['Customer_No'].'_'.$customer_dms_row['DMS'].$company_dealer_id; // // $customer_dms_information = $customer->get_customer_dms_company_dealer_name_by_customer_dms_id($customer_dms_id,$db); // // if(count($customer_dms_information) > 0 && $customer_id <> $customer_dms_information['customer_record_id']){ // // $customer_dms_information = array_map(array($utility, 'upperCaseNestedArray'), $customer_dms_information); // // $customer_dms_information = array_map(array($db, 'escape'), $customer_dms_information); // // $return_arr["status"]=4; // // $return_arr["message"]="This customer no. ".$customer_dms_row['Customer_No']." is already exist in ".$customer_dms_information['dms_name'].', '.$customer_dms_information['company_name'].' and '.$customer_dms_information['dealer_name']; // // echo json_encode($return_arr); // // exit; // // } // // } // // } // // if($customer->read_customer_name_if_exist($customer_data_array["mod-corporation-name"],$db) > 0){ // // $customer_name = $customer->read_customer_info_and_id_by_name($customer_data_array["mod-corporation-name"],$db); // // if($customer_name['corporation_name'] == $customer_data_array["mod-corporation-name"]){ // $old_infos = $customer->read_customer_info_and_contact($customer_id, $db); // $old_info_array = array(); // foreach ($old_infos as $old_info) { // $old_info_array = $old_info; // } // if ($db->escape($old_info_array['corporation_name']) <> $customer_data_array["mod-corporation-name"]) { // if ($customer->read_customer_name_if_exist($customer_data_array["mod-corporation-name"], $db) > 0) { // $return_arr["status"] = 0; // $return_arr["message"] = "Customer name already exists."; // echo json_encode($return_arr); // exit; // } // } // if ($customer_type == 1) { // if ($old_info_array['mobile_phone_1'] <> $new_customer_number) { // if (!$force_update) { // if ($customer->read_customer_mobile_if_exist($new_customer_number, $db) > 0) { // $return_arr["status"] = 2; // $return_arr["message"] = "Mobile already registered."; // echo json_encode($return_arr); // exit; // } // } // } // // if($customer_type == 1){ // if ($utility->isNotEmpty($customer_data_array["mod-email"])) { // // if($customer_id == '27563965982706219'){ // // echo $old_info_array['email_1'] .' '. $customer_data_array["mod-email"] ; // // exit; // // } // if (strtolower($old_info_array['email_1']) <> strtolower($customer_data_array["mod-email"])) { // if (!$force_update) { // if ($customer->read_customer_email_if_exist($customer_data_array["mod-email"], $db) > 0) { // $return_arr["status"] = 3; // $return_arr["message"] = "Email already registered"; // echo json_encode($return_arr); // exit; // } // } // } // } // } // //reason in force update // if ($force_update) { // // $customer->insert_duplicate_reason($customer_id,$customer_data_array["mod-email"],$new_customer_number,$force_update_reason,$_SESSION['user']['id'],$utility,$db); // $log_desc = "Duplicate customer: %s %s %s %s"; // $logger->create( // $_SESSION['user']['id'], // sprintf( // $log_desc, // ($customer_type == 1) ? '[ID:' . $customer_id . ', ' . $customer_data_array["mod-firstname"] . ' ' . $customer_data_array["mod-lastname"] . ']' // : '[ID:' . $customer_id . ', ' . $customer_data_array["mod-corporation-name"] . ']', // ($utility->isNotEmpty($new_customer_number)) ? '[Mobile: ' . $new_customer_number . ']' : '', // ($utility->isNotEmpty($customer_data_array["mod-email"])) ? '[Email: ' . $customer_data_array["mod-email"] . ']' : '', // ($utility->isNotEmpty($force_update_reason)) ? '[Reason: ' . $force_update_reason . ']' : '' // ), // $customer_id, // 'duplicate_customer', // $db // ); // } // $religion_name = ($customer_data_array["mod-dd-religion"]); // if ($utility->isNotEmpty($religion_name)) { // $religion_id = $religion->read_religion_id_by_name($religion_name, $db); // if (!$utility->isNotEmpty($religion_id)) { // $religion_id = $religion->create_religion($religion_name, $db); // } // } else { // $religion_id = 0; // } // $date_of_birth = ''; // if ($utility->isNotEmpty($customer_data_array["mod-birthdate"])) { // $date_of_birth = $utility->convert_sql_date($customer_data_array["mod-birthdate"], 'mm/dd/yyyy'); // } // $nature_of_business_name = ($customer_data_array["mod-nature-of-business"]); // if ($utility->isNotEmpty($nature_of_business_name)) { // $nature_of_business_id = $nature_of_business->read_nature_of_business_id_by_name($nature_of_business_name, $db); // if (!$utility->isNotEmpty($nature_of_business_id)) { // $nature_of_business_id = $nature_of_business->create_nature_of_business($nature_of_business_name, $db); // } // } else { // $nature_of_business_id = 0; // } // $profession_name = ($customer_data_array["mod-dd-profession"]); // if ($utility->isNotEmpty($profession_name)) { // $profession_id = $profession->read_profession_id_by_name($profession_name, $db); // if (!$utility->isNotEmpty($profession_id)) { // $profession_id = $profession->create_profession($profession_name, $db); // } // } else { // $profession_id = 0; // } // $array_data['aha_status'] = intval($customer_data_array['aha-status']); // // Insert Customer Informnation // $update_customer = $customer->update_customer( // $array_data, // $customer_id, // $customer_data_array["mod-corporation-name"], // 0, //salutation_id // $customer_data_array["mod-firstname"], // $customer_data_array["mod-middlename"], // $customer_data_array["mod-lastname"], // $customer_data_array["mod-dd-suffix"], // $customer_data_array["mod-dd-gender"], // $customer_data_array["mod-dd-nationality"], // $date_of_birth, // $customer_data_array["mod-dd-marital-status"], // 0, //source_id deprecated // 0, //mode_of_contact_id deprecated // $customer_data_array["mod-spouse"], // $customer_data_array["mod-position"], // '', //contact_person deprecated // 'default.png', // $_SESSION['user']['id'], // $customer_type, // $customer_data_array["mod-dd-customer-category"], // $religion_id, // $_SESSION['user']['id'], // $customer_data_array["mod-business-company"], // $profession_id, // $nature_of_business_id, // 1, //status // $db // ); // // // Insert Customer Business // // $update_customer_business = $customer->update_customer_business( // // $customer_id, // // $customer_data_array["mod-dd-profession"], // // $customer_data_array["mod-business-company"], // // '', //address // // '0', //city_id // // '', //postal // // '1', //status // // $db); // $mode_of_contact_name = ($customer_data_array["mod-preferred-moc"]); // if ($utility->isNotEmpty($mode_of_contact_name)) { // $mode_of_contact_id = $mode_of_contact->read_mode_of_contact_id_by_name($mode_of_contact_name, $db); // if (!$utility->isNotEmpty($mode_of_contact_id)) { // $mode_of_contact_id = $mode_of_contact->create_mode_of_contact($mode_of_contact_name, $db); // } // } else { // $mode_of_contact_id = 0; // } // // var_dump($update_customer);return; // $update_customer_contact = $customer->update_customer_contact( // // var_dump($utility->fix_mobile_format($customer_data_array["mod-other-mobile-number"]));exit; // $customer_id, // $customer_data_array["mod-address-1"], // $customer_data_array["mod-address-2"], // '0', //state 1 // '0', //state 2 // $customer_data_array["mod-dd-city-1"], // $customer_data_array["mod-dd-city-2"], // $customer_data_array["mod-postal-1"], // $customer_data_array["mod-postal-2"], // $customer_data_array["mod-email"], // (isset($customer_data_array["mod-other-email1"]) ? $customer_data_array["mod-other-email1"] : ''), // (isset($customer_data_array["mod-other-email2"]) ? $customer_data_array["mod-other-email2"] : ''), // $customer_data_array["mod-viber"], // $customer_data_array["mod-facebook"], // $customer_data_array["mod-instagram"], // $customer_data_array["mod-telegram"], // $customer_data_array["mod-whatsapp"], // '', //other social // $customer_data_array["mod-website"], // (isset($customer_data_array["mod-business-number"]) ? $utility->fix_mobile_format($customer_data_array["mod-business-number"]) :''), // '', //fax // $new_customer_number, // (isset($customer_data_array['mod-other-mobile-number1']) ? $utility->fix_mobile_format($customer_data_array["mod-other-mobile-number1"]):''), // (isset($customer_data_array['mod-other-mobile-number2']) ? $utility->fix_mobile_format($customer_data_array["mod-other-mobile-number2"]):''), // $utility->fix_mobile_format($customer_data_array["mod-home-phone"]), // $mode_of_contact_id, // $customer_data_array["mod-landline"], // '1', // $db // ); // $customer->delete_customer_dms($customer_id, $granted_company_ids, $db); // $customer_dms_array = array(); // if ($customer_dms <> '') { // foreach ($customer_dms as $customer_dms_row) { // $company_dealer_id = $company_dealer->read_company_dealer_id($customer_dms_row['Company'], $customer_dms_row['Dealer'], '1', $db); // $customer_dms_array[] = "('$customer_id','" . $customer_dms_row['Customer_No'] . '_' . $customer_dms_row['DMS'] . $company_dealer_id . "'," . $company_dealer_id . ",'1')"; // } // $customer_dms_to_insert = implode(',', $customer_dms_array); // $insert_customer_dms = $customer->create_customer_dms($customer_dms_to_insert, $db); // } // $customer_contact_persons = isset($_REQUEST['customer_contact_person']) ? $_REQUEST['customer_contact_person'] : ''; // // print_r($customer_contact_persons);exit; // $customer->delete_contact_person($customer_id, $db); // $customer_contact_person_array = array(); // if ($customer_contact_persons <> '') { // $customer_contact_persons = array_map(array($utility, 'upperCaseNestedArray'), $customer_contact_persons); // $customer_contact_persons = array_map(array($db, 'escape'), $customer_contact_persons); // foreach ($customer_contact_persons as $customer_contact_person) { // $customer_contact_person_array[] = "('$customer_id','" . $customer_contact_person['Fullname'] . "','" . $customer_contact_person['Email'] . "','" . (($utility->isNotEmpty($customer_contact_person["Mobile"])) ? '+63' . $customer_contact_person["Mobile"] : '') . "','1')"; // } // $contact_person_to_insert = implode(',', $customer_contact_person_array); // $customer->create_customer_contact_person($contact_person_to_insert, $db); // } // $customer_childrens = isset($_REQUEST['customer_children']) ? $_REQUEST['customer_children'] : ''; // $customer_children_array = array(); // $customer->delete_customer_children($customer_id, $db); // if ($customer_childrens <> '') { // $customer_childrens = array_map(array($utility, 'upperCaseNestedArray'), $customer_childrens); // $customer_childrens = array_map(array($db, 'escape'), $customer_childrens); // foreach ($customer_childrens as $customer_children) { // $new_children_date_of_birth = $utility->convert_sql_date($customer_children['Birthday'], 'mm/dd/yyyy'); // $customer_children_array[] = "('$customer_id','" . $customer_children['Firstname'] . "', '" . $customer_children['Lastname'] . "','" . $new_children_date_of_birth . "','" . (($utility->isNotEmpty($customer_children['Mobile'])) ? '+63' . $customer_children['Mobile'] : '') . "','1')"; // } // $customer_children_to_insert = implode(',', $customer_children_array); // $customer->create_customer_children($customer_children_to_insert, $db); // } // $customer_interests = isset($_REQUEST['customer_interest']) ? $_REQUEST['customer_interest'] : ''; // $customer_interest_array = array(); // $customer->delete_customer_interest_list($customer_id, $db); // if ($customer_interests <> '') { // $customer_interests = array_map(array($utility, 'upperCaseNestedArray'), $customer_interests); // $customer_interests = array_map(array($db, 'escape'), $customer_interests); // foreach ($customer_interests as $customer_interest) { // $interest_category_id = $customer_interest['Category']; // $interest_name = ($customer_interest['Interest']); // $interest_id = $interest_hobbies->read_interest_id_by_name($interest_category_id, $interest_name, $db); // if (!$utility->isNotEmpty($interest_id)) { // $interest_id = $interest_hobbies->create_interest($interest_category_id, $interest_name, $db); // } // $customer_interest_array[] = "('" . $interest_id . "','$customer_id','1')"; // } // $customer_interest_to_insert = implode(',', $customer_interest_array); // $customer->create_customer_interest_list($customer_interest_to_insert, $db); // } // $customer_affiliations = isset($_REQUEST['customer_affiliations']) ? $_REQUEST['customer_affiliations'] : ''; // $customer_affiliations_array = array(); // $customer->delete_customer_affiliations_list($customer_id, $db); // if ($customer_affiliations <> '') { // $customer_affiliations = array_map(array($utility, 'upperCaseNestedArray'), $customer_affiliations); // $customer_affiliations = array_map(array($db, 'escape'), $customer_affiliations); // foreach ($customer_affiliations as $customer_affiliation) { // $affiliations_category_id = $customer_affiliation['Category']; // $affiliations_name = ($customer_affiliation['Affiliations']); // $affiliations_id = $affiliations->read_affiliations_id_by_name($affiliations_category_id, $affiliations_name, $db); // if (!$utility->isNotEmpty($affiliations_id)) { // $affiliations_id = $affiliations->create_affiliations($affiliations_category_id, $affiliations_name, $db); // } // $customer_affiliations_array[] = "('" . $affiliations_id . "','$customer_id','1')"; // } // $customer_affiliations_to_insert = implode(',', $customer_affiliations_array); // $customer->create_customer_affiliations_list($customer_affiliations_to_insert, $db); // } // if (intval($update_customer) > 0 && intval($update_customer_contact) > 0) { // $return_arr["status"] = 1; // $return_arr["message"] = "Customer Data Updated"; // $old_name = ''; // $new_name = ''; // if ($customer_type == 1) { // $old_name = $old_info_array['first_name'] . ' ' . $old_info_array['middle_name'] . ' ' . $old_info_array['last_name']; // $new_name = $customer_data_array["mod-firstname"] . ' ' . $customer_data_array["mod-middlename"] . ' ' . $customer_data_array["mod-lastname"]; // } else if ($customer_type == 2) { // $old_name = $old_info_array['corporation_name']; // $new_name = $customer_data_array["mod-corporation-name"]; // } // // echo'NEW DATA<pre>';print_r($customer_data_array);echo'</pre>'; // // echo'OLD DATA : <pre>';print_r($old_info_array); echo'</pre>'; // //modify // $log_name = ($old_name == $new_name) ? '' : "[Name: " . $old_name . " to " . $new_name . "]\n"; $log_mobile = ($old_info_array["mobile_phone_1"] == $new_customer_number) ? '' : "[Mobile: " . $old_info_array["mobile_phone_1"] . " to " . $new_customer_number . "]\n"; // $log_mobile2 = ($old_info_array['mobile_phone_2'] == $new_customer_number2 ? '' : '[Other Mobile 1 :'. $old_info_array['mobile_phone_2'].' to '.$new_customer_number2.']\n'); // $log_mobile3 =($old_info_array['mobile_phone_3'] == $new_customer_number3 ? '' : '[Other Mobile 2 :'. $old_info_array['mobile_phone_3'].' to '.$new_customer_number3.']\n'); // $log_email = ($old_info_array["email_1"] == $customer_data_array["mod-email"]) ? '' : "[Email: " . $old_info_array["email_1"] . " to " . $customer_data_array["mod-email"] . "]\n"; // $log_email2 =(isset($customer_data_array["mod-other-email1"]) ? ($old_info_array["email_2"] == $customer_data_array["mod-other-email1"]) ? '' : "[Email: " . $old_info_array["email_2"] . " to " . $customer_data_array["mod-other-email1"] . "]\n" :''); // $log_email3 =(isset($customer_data_array["mod-other-email2"]) ? ($old_info_array["email_3"] == $customer_data_array["mod-other-email2"]) ? '' : "[Email: " . $old_info_array["email_3"] . " to " . $customer_data_array["mod-other-email2"] . "]\n" : ''); // $log_address = ($old_info_array["address_1"] == $customer_data_array["mod-address-1"]) ? '' : "[Address: " . $old_info_array["address_1"] . " to " . $customer_data_array["mod-address-1"] . "]\n"; // $log_address2 = ($old_info_array["address_2"] == $customer_data_array["mod-address-2"]) ? '' : "[Other address: " . $old_info_array["address_2"] . " to " . $customer_data_array["mod-address-2"] . "]\n"; // $log_bday = ($old_info_array["date_of_birth"] == date('Y-m-d',strtotime($customer_data_array["mod-birthdate"]))) ? '' : "[Birthday: " . $old_info_array["date_of_birth"] . " to " . date('Y-m-d',strtotime($customer_data_array["mod-birthdate"])) . "]\n"; // $log_gender = ($old_info_array["gender_id"] == $customer_data_array["mod-dd-gender"]) ? '' : "[Gender: " . ($old_info_array["gender_id"]==1 ? 'Male' : 'Female') . " to " . ($customer_data_array["mod-dd-gender"]==1 ? 'Male' : 'Female') . "]\n"; // $log_desc = "Update customer: %s%s%s%s%s%s%s%s%s%s%s%s"; //modify // $logger->create( // $_SESSION['user']['id'], // sprintf( // $log_desc, // "[ID:" . $customer_id . ", " . $new_name . "]\n", // $log_name, // $log_gender, // $log_bday, // $log_mobile, // $log_mobile2, // $log_mobile3, // $log_email, // $log_email2, // $log_email3, // $log_address, // $log_address2 // ), // $customer_id, // 'update_customer', // $db // ); // } else { // $return_arr["status"] = 0; // $return_arr["message"] = "Customer Data Not Updated"; // } // // $return_arr["status"]=1; // // $return_arr["message"]="Customer Data Updated"; // echo json_encode($return_arr); // } else if ($apiKey === '3463916057587803' && $utility->isPostMethod($server_method)) { //Read // $customer_id = isset($_REQUEST['customer_id']) ? $db->escape($_REQUEST['customer_id']) : '-1'; // $customer_information = $customer->read_customer_profile($customer_id, $db); // $customer_information['mod-dd-religion'] = $religion->read_religion_name_by_id($customer_information['mod-dd-religion'], $db); // if ($utility->isNotEmpty($customer_information['mod-birthdate'])) { // $customer_information['mod-birthdate'] = $utility->convert_sql_date_to_date_picker($customer_information['mod-birthdate']); //$religion->read_religion_name_by_id($customer_information['mod-birthdate-unformat'],$db); // } // // $customer_business = $customer->read_customer_business($customer_id,$db); // $customer_contact = $customer->read_customer_contact($customer_id, $db); // $return_information = array_merge($customer_information, $customer_contact); // echo json_encode(array($return_information)); // } else if ($apiKey === '8361020315855100' && $utility->isPostMethod($server_method)) { //Read Display // // echo'aaaaa';exit // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer_information = $customer->read_customer_profile_display($customer_id, $granted_company_ids, $db); // $customer_information['main_email'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_email']) ? $utility->mask_email($customer_information['main_email']) : '') : ((isset($fields_permissions['fields_email_1']) && !$fields_permissions['fields_email_1']) ? ($utility->isNotEmpty($customer_information['main_email']) ? $utility->mask_email($customer_information['main_email']) : '') : $customer_information['main_email']); // $customer_information['main_customer_email_2'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_customer_email_2']) ? $utility->mask_email($customer_information['main_customer_email_2']) : '') : ((isset($fields_permissions['fields_email_2']) && !$fields_permissions['fields_email_2']) ? ($utility->isNotEmpty($customer_information['main_customer_email_2']) ? $utility->mask_email($customer_information['main_customer_email_2']) : '') : $customer_information['main_customer_email_2']); // $customer_information['main_customer_landline'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_customer_landline']) ? $utility->mask($customer_information['main_customer_landline'], 2, 1) : '') : ((isset($fields_permissions['fields_landline']) && !$fields_permissions['fields_landline']) ? ($utility->isNotEmpty($customer_information['main_customer_landline']) ? $utility->mask($customer_information['main_customer_landline'], 2, 1) : '') : $customer_information['main_customer_landline']); // $customer_information['main_customer_mobile'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_customer_mobile']) ? $utility->mask($customer_information['main_customer_mobile'], 4, 1) : '') : ((isset($fields_permissions['fields_mobile_1']) && !$fields_permissions['fields_mobile_1']) ? ($utility->isNotEmpty($customer_information['main_customer_mobile']) ? $utility->mask($customer_information['main_customer_mobile'], 4, 1) : '') : $customer_information['main_customer_mobile']); // $customer_information['main_customer_mobile_2'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_customer_mobile_2']) ? $utility->mask($customer_information['main_customer_mobile_2'], 4, 1) : '') : ((isset($fields_permissions['fields_mobile_2']) && !$fields_permissions['fields_mobile_2']) ? ($utility->isNotEmpty($customer_information['main_customer_mobile_2']) ? $utility->mask($customer_information['main_customer_mobile_2'], 4, 1) : '') : $customer_information['main_customer_mobile_2']); // $customer_information['main_customer_home_mobile'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_customer_home_mobile']) ? $utility->mask($customer_information['main_customer_home_mobile'], 4, 1) : '') : ((isset($fields_permissions['fields_home_phone']) && !$fields_permissions['fields_home_phone']) ? ($utility->isNotEmpty($customer_information['main_customer_home_mobile']) ? $utility->mask($customer_information['main_customer_home_mobile'], 4, 1) : '') : $customer_information['main_customer_home_mobile']); // $customer_information['main_customer_business_mobile'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_customer_business_mobile']) ? $utility->mask($customer_information['main_customer_business_mobile'], 4, 1) : '') : ((isset($fields_permissions['fields_business_phone']) && !$fields_permissions['fields_business_phone']) ? ($utility->isNotEmpty($customer_information['main_customer_business_mobile']) ? $utility->mask($customer_information['main_customer_business_mobile'], 4, 1) : '') : $customer_information['main_customer_business_mobile']); // $customer_information['main_customer_address_1'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_customer_address_1']) ? $utility->mask($customer_information['main_customer_address_1'], 2, 2) : '') : ((isset($fields_permissions['fields_address_1']) && !$fields_permissions['fields_address_1']) ? ($utility->isNotEmpty($customer_information['main_customer_address_1']) ? $utility->mask($customer_information['main_customer_address_1'], 3, 0) : '') : $customer_information['main_customer_address_1']); // $customer_information['main_customer_address_2'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_customer_address_2']) ? $utility->mask($customer_information['main_customer_address_2'], 2, 2) : '') : ((isset($fields_permissions['fields_address_2']) && !$fields_permissions['fields_address_2']) ? ($utility->isNotEmpty($customer_information['main_customer_address_2']) ? $utility->mask($customer_information['main_customer_address_2'], 3, 0) : '') : $customer_information['main_customer_address_2']); // $customer_information['main_viber'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_viber']) ? $utility->mask($customer_information['main_viber'], 2, 1) : '') : ((isset($fields_permissions['fields_viber']) && !$fields_permissions['fields_viber']) ? ($utility->isNotEmpty($customer_information['main_viber']) ? $utility->mask($customer_information['main_viber'], 2, 1) : '') : $customer_information['main_viber']); // $customer_information['main_facebook'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_facebook']) ? $utility->mask($customer_information['main_facebook'], 2, 1) : '') : ((isset($fields_permissions['fields_facebook']) && !$fields_permissions['fields_facebook']) ? ($utility->isNotEmpty($customer_information['main_facebook']) ? $utility->mask($customer_information['main_facebook'], 2, 1) : '') : $customer_information['main_facebook']); // $customer_information['main_instagram'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_instagram']) ? $utility->mask($customer_information['main_instagram'], 2, 1) : '') : ((isset($fields_permissions['fields_instagram']) && !$fields_permissions['fields_instagram']) ? ($utility->isNotEmpty($customer_information['main_instagram']) ? $utility->mask($customer_information['main_instagram'], 2, 1) : '') : $customer_information['main_instagram']); // $customer_information['main_whatsapp'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_whatsapp']) ? $utility->mask($customer_information['main_whatsapp'], 2, 1) : '') : ((isset($fields_permissions['fields_whatsapp']) && !$fields_permissions['fields_whatsapp']) ? ($utility->isNotEmpty($customer_information['main_whatsapp']) ? $utility->mask($customer_information['main_whatsapp'], 2, 1) : '') : $customer_information['main_whatsapp']); // $customer_information['main_telegram'] = (!$fields_permissions) ? ($utility->isNotEmpty($customer_information['main_telegram']) ? $utility->mask($customer_information['main_telegram'], 2, 1) : '') : ((isset($fields_permissions['fields_telegram']) && !$fields_permissions['fields_telegram']) ? ($utility->isNotEmpty($customer_information['main_telegram']) ? $utility->mask($customer_information['main_telegram'], 2, 1) : '') : $customer_information['main_telegram']); // // $customer_information['mod-dd-religion']= $religion->read_religion_name_by_id($customer_information['mod-dd-religion'],$db); // // // // if($utility->isNotEmpty($customer_information['information_dob'] )){ // // $customer_information['information_dob'] = $utility->convert_sql_date_to_date_picker($customer_information['information_dob']); //$religion->read_religion_name_by_id($customer_information['mod-birthdate-unformat'],$db); // // } // // $customer_business = $customer->read_customer_ business($customer_id,$db); // // $customer_contact = $customer->read_customer_contact($customer_id,$db); // // $return_information = array_merge($customer_information); // echo json_encode(array($customer_information)); // // echo'<pre>';print_r($customer_information);echo'</pre>';exit; // } else if ($apiKey === '6579442853321353' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_profile_interest($customer_id, $db); // } else if ($apiKey === '3099751888433363' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_dms($customer_id, $granted_company_ids, $db); // } else if ($apiKey === '4788616921820004' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_contact_person($customer_id, $db); // } else if ($apiKey === '8307826786414874' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_children($customer_id, $db); // } else if ($apiKey === '2089441825396664' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_education($customer_id, $db); // } else if ($apiKey === '5660696728127200' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_affiliations($customer_id, $db); // } else if ($apiKey === '5474981987699557' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_unit_association($customer_id, $db); // } else if ($apiKey === '2223348764004177' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_car_club($customer_id, $db); // } else if ($apiKey === '9526394287040079' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_political_club($customer_id, $db); // } else if ($apiKey === '7193296844816864' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_network_marketing($customer_id, $db); // } else if ($apiKey === '4432527649394050' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_media_publication($customer_id, $db); // } else if ($apiKey === '5103641855052276' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_sme_group($customer_id, $db); // } else if ($apiKey === '1773522681941804' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_fraternities_sororities($customer_id, $db); // } else if ($apiKey === '1803139298208721' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_facebook_group($customer_id, $db); // } else if ($apiKey === '4010640559253012' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_celebrity_influencers($customer_id, $db); // } else if ($apiKey === '9707323227112625' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_profile_dms($customer_id, $db); // } else if ($apiKey === '4938305064275028' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_profile_company($customer_id, $db); // } else if ($apiKey === '7340685518692652' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer->read_customer_profile_dealer($customer_id, $db); // } else if ($apiKey === '9490540601210798') { //Update // } else if ($apiKey === '7472626829226859' && $utility->isPostMethod($server_method)) { //Delete' // $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $vehicle_ids = $customer->read_customer_vehicle_ids($customer_id, $db); // // $json_arr['sales_image'] = '<div class="col-12 text-center mt-3"><strong>No Sales Image</strong></div>'; // $json_arr['sales_image'] = '<div class="col-12 text-center mt-3" id="grid-page-footer"> // <div class="card-footer"> // <nav aria-label="Contacts Page Navigation"> // <ul class="pagination justify-content-center m-0" id="customer-owned-vehicle-paging">No Record</ul> // </nav> // </div> // </div>'; // if (count($vehicle_ids) < 1) { // echo json_encode($json_arr); // return; // } // $vehicle_ids_array = array(); // foreach ($vehicle_ids as $vehicle_id) { // $vehicle_ids_array[] = $vehicle_id['id']; // } // $vehicle_ids_list = implode(',', $vehicle_ids_array); // $customer_images = $customer->read_customer_sales_image_by_vehicle_ids($granted_company_ids, $vehicle_ids_list, $db); // if (count($customer_images) < 1) { // echo json_encode($json_arr); // return; // } // $json_arr['sales_image'] = ""; // foreach ($customer_images as $customer_image) { // $json_arr['sales_image'] .= ' // <div class="card col-md-4 col-sm-4 p-2"> // <div class="thumbnail"> // <a class="" href="dist/img/customer/' . $customer_image['name'] . '" // data-toggle="lightbox" // data-title="' . $customer_image['activity_date'] . '" // data-gallery="gallery" data-footer=""> // <img src="dist/img/customer/' . $customer_image['name'] . '" // class=" img-fluid" // alt="" style="height:250px; width:100%;" /> // </a> // </div> // </div> // '; // } // echo json_encode($json_arr); // // echo $vehicle_list; // } else if ($apiKey === '3975247589935894') { // $search = isset($_REQUEST['search']) ? $db->escape($_REQUEST['search']) : ''; // $customer->read_customer_corporation($search, $granted_company_ids, $db); // } else if ($apiKey === '6817899882858207') { // $search = isset($_REQUEST['search']) ? $db->escape($_REQUEST['search']) : ''; // $customer->read_customer_names_and_id($granted_company_ids, $search, $db); // } else if ($apiKey === '8666264351338448' && $utility->isPostMethod($server_method)) { //customer count // $json_arr = array(); // $type = (isset($_POST['type']) && $_POST['type'] != '0') ? " AND ci.type = '" . $_POST['type'] . "' " : ""; // $gender = (isset($_POST['gender']) && $_POST['gender'] != 'all') ? " AND ci.gender_id = '" . $_POST['gender'] . "' " : ""; // $dms = (isset($_POST['dms']) && $_POST['dms'] != '0') ? " AND sc.dms_id = '" . $_POST['dms'] . "' " : ""; // $company = (isset($_POST['company']) && $_POST['company'] != '0') ? " AND scd.company_id = '" . $_POST['company'] . "' " : ""; // $my_records = (isset($_POST['my_records']) && filter_var($_POST['my_records'], FILTER_VALIDATE_BOOLEAN)) ? " AND (ci.upload_by='$my_customer_record_id' OR ci.modified_by='$my_customer_record_id') " : ""; // $age = ""; // $where_age = " TIMESTAMPDIFF(YEAR,ci.date_of_birth, CURDATE() ) "; // if (isset($_POST['filter_age']) && $_POST['filter_age'] != '0') { // switch ($_POST['filter_age']) { // case "below": // $age = "AND $where_age <= 30 "; // break; // case "between": // $age = "AND $where_age <= 50 AND $where_age >= 31 "; // break; // case "above": // $age = "AND $where_age >= 51 "; // break; // } // } // $complete_data = ""; // $incomplete_data = ""; // $mobile_phone_1 = ""; // $email_1 = ""; // $address_1 = ""; // $date_of_birth = ""; // if (isset($_POST['filter_data']) && $_POST['filter_data'] != '0') { // switch ($_POST['filter_data']) { // case "Complete Data": // $complete_data = " AND ((ci.date_of_birth <> '' and ci.gender_id <> 0 and cc.address_1 <> '' and cc.email_1 <> '' and cc.mobile_phone_1 <> '') AND ci.type = 1) OR // (cc.address_1 <> '' AND cc.email_1 <> '' AND ci.type = 2) "; // break; // case "Incomplete Data": // $incomplete_data = " AND ((ci.date_of_birth = '' OR // ci.gender_id = 0 OR // cc.address_1 = '' OR cc.email_1 = '' ) AND ci.type = 1) OR (cc.address_1 = '' or cc.email_1 = '' AND ci.type = 2) "; // break; // case "No Mobile": // $mobile_phone_1 = " AND cc.mobile_phone_1 = '' "; // break; // case "No Email": // $email_1 = " AND cc.email_1 = '' "; // break; // case "No Address": // $address_1 = " AND cc.address_1 = '' "; // break; // case "No Gender": // $gender = " AND ci.gender_id = '0' AND ci.type = '1' "; // break; // case "No Date of birth": // $date_of_birth = " AND ci.date_of_birth = '' AND ci.type = '1' "; // break; // } // } // $query = "SELECT // SUM( // ( // SELECT count(1) FROM // ( // SELECT sc.dms_id FROM inactive_customer ci // INNER JOIN customer_dms cd ON ci.id = cd.customer_record_id // INNER JOIN source_company_dealer scd ON cd.company_dealer_id = scd.id // INNER JOIN customer_contact cc ON ci.id = cc.customer_id // INNER JOIN source_company sc ON scd.company_id = sc.id // WHERE ci.status = 1 // AND scd.company_id IN (" . $granted_company_ids . ") // $type $gender $dms $company $age $complete_data $incomplete_data $mobile_phone_1 $email_1 $address_1 $date_of_birth $my_records // GROUP BY ci.id // ) as t2 WHERE t2.dms_id = source_dms.id // ) // ) as total_count, // SUM( // ( // SELECT count(1) FROM // ( // SELECT sc.dms_id FROM inactive_customer ci // INNER JOIN customer_dms cd ON ci.id = cd.customer_record_id // INNER JOIN source_company_dealer scd ON cd.company_dealer_id = scd.id // INNER JOIN source_company sc ON scd.company_id = sc.id // INNER JOIN customer_contact cc ON ci.id = cc.customer_id // WHERE ci.date_uploaded > DATE_SUB(NOW(), INTERVAL 1 WEEK) AND ci.status = 1 AND scd.company_id IN (" . $granted_company_ids . ") // $type $gender $dms $company $age $complete_data $incomplete_data $mobile_phone_1 $email_1 $address_1 $date_of_birth $my_records // GROUP BY ci.id // ) as t2 WHERE t2.dms_id = source_dms.id // ) // ) as new_customer_count, // SUM( // ( // SELECT count(1) FROM // ( // SELECT sc.dms_id FROM inactive_customer ci // INNER JOIN customer_dms cd ON ci.id = cd.customer_record_id // INNER JOIN source_company_dealer scd ON cd.company_dealer_id = scd.id // INNER JOIN source_company sc ON scd.company_id = sc.id // INNER JOIN customer_contact cc ON ci.id = cc.customer_id // WHERE ci.date_modified > DATE_SUB(NOW(), INTERVAL 1 WEEK) AND ci.status = 1 AND scd.company_id IN (" . $granted_company_ids . ") // $type $gender $dms $company $age $complete_data $incomplete_data $mobile_phone_1 $email_1 $address_1 $date_of_birth $my_records // GROUP BY ci.id // ) as t2 WHERE t2.dms_id = source_dms.id // ) // ) as updated_customer_count, // SUM( // ( // SELECT count(1) FROM // ( // SELECT sc.dms_id FROM inactive_customer ci // INNER JOIN customer_dms cd ON ci.id = cd.customer_record_id // INNER JOIN source_company_dealer scd ON cd.company_dealer_id = scd.id // INNER JOIN source_company sc ON scd.company_id = sc.id // INNER JOIN customer_contact cc ON ci.id = cc.customer_id // WHERE ci.date_uploaded > DATE_SUB(NOW(), INTERVAL 1 DAY) AND ci.status = 1 AND scd.company_id IN (" . $granted_company_ids . ") // $type $gender $dms $company $age $complete_data $incomplete_data $mobile_phone_1 $email_1 $address_1 $date_of_birth $my_records // GROUP BY ci.id // ) as t2 WHERE t2.dms_id = source_dms.id // ) // ) as new_today_customer_count // FROM `source_dms` WHERE status = 1"; // // return $query; // $counts = $db->sql_query($query); // foreach ($counts as $count) { // $json_arr['total_count'] = number_format($count['total_count']); // $json_arr['new_customer_count'] = number_format($count['new_customer_count']); // $json_arr['updated_customer_count'] = number_format($count['updated_customer_count']); // $json_arr['new_today_customer_count'] = number_format($count['new_today_customer_count']); // } // // $json_arr['new_customer_count'] = $db -> select("SELECT // // SUM( // // ( // // SELECT count(1) FROM // // ( // // SELECT cd.dms_id FROM customer ci // // INNER JOIN customer_dms cd ON ci.id = cd.customer_record_id // // INNER JOIN source_company_dealer scd ON cd.company_dealer_id = scd.id // // WHERE ci.date_uploaded > DATE_SUB(NOW(), INTERVAL 1 WEEK) AND ci.status = 1 AND scd.company_id IN (".$granted_company_ids.") GROUP BY ci.id // // ) as t2 WHERE t2.dms_id = source_dms.id // // ) // // ) as total FROM `source_dms` WHERE status = 1"); // // $json_arr['updated_customer_count'] = $db -> select("SELECT // // SUM( // // ( // // SELECT count(1) FROM // // ( // // SELECT cd.dms_id FROM customer ci // // INNER JOIN customer_dms cd ON ci.id = cd.customer_record_id // // INNER JOIN source_company_dealer scd ON cd.company_dealer_id = scd.id // // WHERE ci.date_modified > DATE_SUB(NOW(), INTERVAL 1 WEEK) AND ci.status = 1 AND scd.company_id IN (".$granted_company_ids.") GROUP BY ci.id // // ) as t2 WHERE t2.dms_id = source_dms.id // // ) // // ) as total FROM `source_dms` WHERE status = 1"); // echo json_encode($json_arr); // } else if ($apiKey === '3394212010636793' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $start_date = isset($_REQUEST['startDate']) ? $db->escape($_REQUEST['startDate']) : ''; // $end_date = isset($_REQUEST['endDate']) ? $db->escape($_REQUEST['endDate']) : ''; // $company = isset($_REQUEST['company']) ? $db->escape($_REQUEST['company']) : '0'; // $return_arr["total"] = $customer->read_customer_total_number($start_date, $end_date, $company, $granted_company_ids, $db); // echo json_encode($return_arr); // } else if ($apiKey === '5441890951433809' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $start_date = isset($_REQUEST['startDate']) ? $db->escape($_REQUEST['startDate']) : ''; // $end_date = isset($_REQUEST['endDate']) ? $db->escape($_REQUEST['endDate']) : ''; // $company = isset($_REQUEST['company']) ? $db->escape($_REQUEST['company']) : '0'; // $vehicle_total = isset($_REQUEST['vehicle_total']) ? intval($_REQUEST['vehicle_total']) : 0; // $customer->read_customer_summary_count($start_date, $end_date, $company, $granted_company_ids, $vehicle_total, $db); // } else if ($apiKey === '8525944844346448' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $start_date = isset($_REQUEST['startDate']) ? $db->escape($_REQUEST['startDate']) : ''; // $end_date = isset($_REQUEST['endDate']) ? $db->escape($_REQUEST['endDate']) : ''; // $company = isset($_REQUEST['company']) ? $db->escape($_REQUEST['company']) : '0'; // $customer->read_customer_counts($start_date, $end_date, $company, $granted_company_ids, $db); // } else if ($apiKey === '3695340036334748' && $utility->isPostMethod($server_method)) { //Read Customer Interest // $customer_id = isset($_REQUEST['customer_id']) ? $db->escape($_REQUEST['customer_id']) : '-1'; // $affected_rows = $customer->delete($customer_id, $db); // $json_arr = array(); // if (intval($affected_rows) !== 0) { // $json_arr['status'] = 1; // $json_arr['message'] = 'Customer successfully removed.'; // } else { // $json_arr['status'] = 0; // $json_arr['message'] = 'Customer not removed, please try again.'; // } // echo json_encode($json_arr); // } else { // $return_arr["message"] = " You are not allowed to do this action."; // echo $return_arr["message"]; // return; // } // } // else if($apiKey ==='mRLAZ8te7cnv'){ // $companies = $db->sql_query("SELECT `id`,`name`, `code` FROM `source_company` WHERE status != '0' AND concat(name,' ',code) LIKE '%$search%' AND dms_id IN ($dms_ids) ORDER by code ASC"); // $json=[]; // foreach($companies as $company) // { // $json[] = ['id'=>$company['id'], 'text'=>$company['code'].' - '.$company['name']]; // } // unset($company); // echo json_encode($json); // } else { // $return_arr["message"] = " You are not allowed to do this action."; // echo $return_arr["message"]; // return; // } }
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings