diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php index fd494bd5..a2931183 100644 --- a/app/Controllers/Customer.php +++ b/app/Controllers/Customer.php @@ -191,104 +191,4 @@ class Customer extends BaseController $address_details = $model->where($where)->findAll(); return $address_details; } - ## ApiIntegration For Customer. - public function apiintegration() - { - helper('apiIntegration'); - helper('session'); - $session_bid = get_business_id(); - $session_uid = get_logged_user_id(); - $response = perform_http_request('GET', VB_CUSTOMERS); - $message = ""; - if (count($response['response']) > 0) { - //$message = "Reponse Count : ".count($response['response'])."
"; - echo "Note : This For CrossCheck Purpose 1ly
"; - echo "Total Customer API Reponse Count : " . count($response['response']) . "
"; - $CustomerModel = new CustomerModel(); - $x=0; - foreach ($response['response'] as $row) { - $insertion_data['first_name'] = $row->first_name; - $insertion_data['last_name'] = $row->last_name; - $insertion_data['type'] = $row->role; - $insertion_data['email'] = $row->email; - // $insertion_data['profile_picture'] = $row->avatar_url; - $insertion_data['mode'] = 'online'; - $insertion_data['created_by'] = $session_uid; - $insertion_data['business_id'] = $session_bid; - $billing = $row->billing; - $shipping = $row->shipping; - $CustomerModel->insert($insertion_data); - $lastInsertId = $CustomerModel->insertID(); - $insertion_baddress_data = [];$insertion_saddress_data = []; - $i = 0; $j = 0; - - if(isset($billing) && gettype($billing) === 'object') {$billing = [$billing];} - if(isset($shipping) && gettype($shipping) === 'object') {$shipping = [$shipping];} - echo "Customer ID : ".$lastInsertId." have Billing address = ".count($billing)." and Shipping address = ".count($shipping)."
"; - if (count($billing) > 0) { - foreach ($billing as $bill) { - if ($bill->first_name !== '') { - $insertion_baddress_data[$i]['first_name'] = $bill->first_name; - $insertion_baddress_data[$i]['last_name'] = $bill->last_name; - $insertion_baddress_data[$i]['company'] = $bill->company; - $insertion_baddress_data[$i]['address_1'] = $bill->address_1; - $insertion_baddress_data[$i]['address_2'] = $bill->address_2; - $insertion_baddress_data[$i]['city'] = $bill->city; - $insertion_baddress_data[$i]['state'] = $bill->state; - $insertion_baddress_data[$i]['country'] = $bill->country; - $insertion_baddress_data[$i]['postal_code'] = $bill->postcode; - $insertion_baddress_data[$i]['customer_id'] = $lastInsertId; - $insertion_baddress_data[$i]['address_type'] = 1; - $insertion_baddress_data[$i]['created_by'] = $session_uid; - $insertion_baddress_data[$i]['email'] = isset($bill->email) ? $bill->email : ''; - $insertion_baddress_data[$i]['mobile_no'] = isset($bill->phone) ? $bill->phone : ''; - $i++; - echo "       Billing address has a value and Inserted ".$i."
"; - }else{ - echo "       Keys are available but Billing address has no value;
"; - } - } - (!empty($insertion_baddress_data) ? $CustomerModel->insertAddressBatch($insertion_baddress_data) : ""); - } - if (count($shipping) > 0) { - foreach ($shipping as $ship) { - if ($ship->first_name !== '') { - $insertion_saddress_data[$j]['first_name'] = $ship->first_name; - $insertion_saddress_data[$j]['last_name'] = $ship->last_name; - $insertion_saddress_data[$j]['company'] = $ship->company; - $insertion_saddress_data[$j]['address_1'] = $ship->address_1; - $insertion_saddress_data[$j]['address_2'] = $ship->address_2; - $insertion_saddress_data[$j]['city'] = $ship->city; - $insertion_saddress_data[$j]['state'] = $ship->state; - $insertion_saddress_data[$j]['country'] = $ship->country; - $insertion_saddress_data[$j]['postal_code'] = $ship->postcode; - $insertion_saddress_data[$j]['email'] = isset($ship->email)?$ship->email:""; - $insertion_saddress_data[$j]['mobile_no'] = isset($ship->phone)?$ship->phone:""; - $insertion_saddress_data[$j]['customer_id'] = $lastInsertId; - $insertion_saddress_data[$j]['address_type'] = 2; - $insertion_saddress_data[$j]['created_by'] = $session_uid; - $j++; - echo "        Shipping address has a value and Inserted ".$j."
"; - } - else{ - echo "        Keys are available but Shipping address has no value
"; - } - } - (!empty($insertion_saddress_data) ? $CustomerModel->insertAddressBatch($insertion_saddress_data) : ""); - } - } //reponse foreach closed - } //reponse count if closed - if (!empty($response['error'])) { - echo $response['error']; - echo $response['error_msg']; - $message .= $response['error'] . $response['error_msg']; - echo "Error :".$response['error'] . $response['error_msg']; - }else{ - echo "Done"; - } - $go_to_list_page = base_url()."customer_list"; - echo "
go to list page
"; - // return $message; - } - }