Exemplo n.º 1
0
function hook_login_post(&$user, &$session, &$return)
{
    $degama = new IntegrationHandler($user);
    $handshake = $degama->process_request("handshake");
    $status = intval($handshake->status);
    if ($status) {
        $session->bill_to_code = (string) $handshake->bill_to_code;
        $session->bill_company = (string) $handshake->Name;
        $session->bill_contact = (string) $handshake->Contact2;
        $session->bill_address = (string) $handshake->Address;
        $session->bill_city = (string) $handshake->City;
        $session->bill_province = (string) $handshake->Province;
        // #43 Default shipper postal code fix
        if (strlen(trim((string) $handshake->Postal)) == 7) {
            $session->bill_postal = substr((string) $handshake->Postal, 0, 3) . substr((string) $handshake->Postal, 4, 3);
        } else {
            $session->bill_postal = (string) $handshake->Postal;
        }
        $session->bill_phone = (string) $handshake->Phone;
    } else {
        $session->status = $status;
    }
}
Exemplo n.º 2
0
 function send_order_summery()
 {
     $newData = '';
     if (strpos($_REQUEST['data']['id'], "_") !== false) {
         $tmp = explode("_", $_REQUEST['data']['id']);
         $Pbnum = (int) $tmp[0];
         $this->user['bill_to_code'] = $tmp[1];
     }
     $email = $_REQUEST['data']['email'];
     $findOrder = query("SELECT id,ext_id,data FROM `" . $this->user['database'] . "`.order_email_info WHERE ext_id=" . $Pbnum);
     $record = fetch($findOrder);
     if (empty($record)) {
         $data = json_encode(array('emailRecords' => array(array('email' => $email, 'insertTime' => date('Y-m-d H:i:s')))));
         $insertNewRecord = query("insert into `" . $this->user['database'] . "`.order_email_info (`ext_id`,`data`) values (" . $Pbnum . ",'" . $data . "')");
     } else {
         $data = array('email' => $email, 'insertTime' => date('Y-m-d H:i:s'));
         $emailRecords = json_decode($record['data'], true);
         if (count($emailRecords['emailRecords']) < 20) {
             array_push($emailRecords['emailRecords'], $data);
             $newData = json_encode($emailRecords);
             $updateNewRecord = query("update `" . $this->user['database'] . "`.order_email_info SET `data`='" . $newData . "' WHERE ext_id =" . $Pbnum);
         }
     }
     $req['Pbnum'] = $Pbnum;
     $req['bill_to_code'] = $this->user['bill_to_code'];
     $shipment = new Shipment('', $this->user['database']);
     $integrate = new IntegrationHandler($this->user);
     $arrTrackingRequest = $integrate->process_request('tracking_details_request', $req);
     $degama = new IntegrationHandler($this->user);
     $handshake = $degama->process_request("handshake");
     $shipment->ext_id = $arrTrackingRequest['Pbnum'];
     $shipment->timestamp = $arrTrackingRequest['ProDate'];
     $shipment->bill_name = (string) $handshake->Name;
     $shipment->bill_account = $req['bill_to_code'];
     $shipment->ship_email = $email;
     $shipment->division = $arrTrackingRequest['Division'];
     $shipment->service = $arrTrackingRequest['service'];
     $shipment->ship_contact = $arrTrackingRequest['RefName'];
     $shipment->ship_name = $arrTrackingRequest['ShipName'];
     $shipment->ship_street1 = $arrTrackingRequest['Add1'];
     $shipment->ship_street2 = $arrTrackingRequest['Add2'];
     $shipment->ship_city = $arrTrackingRequest['City'];
     $shipment->ship_province = $arrTrackingRequest['Prv'];
     $shipment->ship_postal = $arrTrackingRequest['Postal'];
     $shipment->cons_name = $arrTrackingRequest['ConsigName'];
     $shipment->cons_contact = $arrTrackingRequest['ConRefName'];
     $shipment->cons_street1 = $arrTrackingRequest['ConAdd1'];
     $shipment->cons_street2 = $arrTrackingRequest['ConAdd2'];
     $shipment->cons_city = $arrTrackingRequest['ConCity'];
     $shipment->cons_province = $arrTrackingRequest['ConPrv'];
     $shipment->cons_postal = $arrTrackingRequest['ConPostal'];
     $shipment->pup_date = $arrTrackingRequest['PupDate'];
     $shipment->pup_time = $arrTrackingRequest['PupTime'];
     $shipment->total_pieces = $arrTrackingRequest['Pieces'];
     $shipment->total_weight = $arrTrackingRequest['Weight'];
     //$shipment->uom_weight = $arrTrackingRequest['W-Uom'];
     //$shipment->uom_dim = '';
     $shipment->goods = array();
     $good[0] = array('packaging' => $arrTrackingRequest['pkg'], 'particulars' => $arrTrackingRequest['ComDescr'], 'commodity' => $arrTrackingRequest['ComDescr'], 'length' => $arrTrackingRequest['length'], 'width' => $arrTrackingRequest['width'], 'height' => $arrTrackingRequest['height']);
     $shipment->goods = $good;
     $shipment->equipment = $arrTrackingRequest['Equipment'];
     Hook::Run("post", "shipment", $this->user['folder'], $this->user, $shipment);
 }
Exemplo n.º 3
0
 public function fetchTMS()
 {
     if (!$this->ext_id) {
         return 0;
     }
     $req = array();
     $req['bill_to_code'] = $this->bill_account;
     $req['pbnum'] = $this->ext_id;
     $exTMS = new IntegrationHandler($this->user);
     $data = $exTMS->process_request('tracking_details_request', $req);
     return $data;
     /*
          $return = array();
          $return['ship_name']	= $data->
          $return['ship_street1']	=
          $return['ship_street2']	=
          $return['ship_city']	=
          $return['cons_name']	=
          $return['cons_street1']	=
          $return['cons_street2']	=
          $return['cons_city']	=
     */
 }
Exemplo n.º 4
0
 function get_quote()
 {
     // Check if quote/pbnum exists in local database
     $exists = query("SELECT id,sent FROM `" . $this->user['database'] . "`.shipments WHERE ext_id='" . (int) $_REQUEST['pbnum'] . "'");
     $result = fetch($exists);
     if ($result) {
         if ($result['sent'] == 1) {
             $this->html['shipon_output'] = "<script type='text/javascript'>alert('You can not retrieve this quote as it has already been submitted.');</script>";
             return;
         }
         $this->return['inputs']['shipon_id'] = $result['id'];
     }
     $req['Pbnum'] = (int) $_REQUEST['pbnum'];
     $req['bill_to_code'] = $this->user['bill_to_code'];
     $integrate = new IntegrationHandler($this->user);
     $arrTrackingRequest = $integrate->process_request('tracking_details_request', $req);
     if (!isset($arrTrackingRequest['error_message'])) {
         if ($arrTrackingRequest['RecStatus'] == 'QTE' && $this->user['bill_to_code'] == $arrTrackingRequest['Code']) {
             $this->return['inputs']['shipon_reference_po'] = $arrTrackingRequest['RefNumb'];
             $this->return['inputs']['shipon_reference'] = $arrTrackingRequest['ShBOL'];
             $this->return['inputs']['shipon_quote_no'] = $arrTrackingRequest['Pbnum'];
             $this->return['inputs']['shipon_ship_name'] = $arrTrackingRequest['ShipName'];
             $this->return['inputs']['shipon_ship_contact'] = $arrTrackingRequest['RefName'];
             $this->return['inputs']['shipon_ship_phone'] = $arrTrackingRequest['Tel'];
             $this->return['inputs']['shipon_ship_street1'] = $arrTrackingRequest['Add1'];
             $this->return['inputs']['shipon_ship_street2'] = $arrTrackingRequest['Add2'];
             $this->return['inputs']['shipon_ship_city'] = $arrTrackingRequest['City'];
             $this->return['inputs']['shipon_ship_province'] = $arrTrackingRequest['Prv'];
             $this->return['inputs']['shipon_ship_postal'] = $arrTrackingRequest['Postal'];
             $this->return['inputs']['shipon_cons_name'] = $arrTrackingRequest['ConsigName'];
             $this->return['inputs']['shipon_cons_contact'] = $arrTrackingRequest['ConRefName'];
             $this->return['inputs']['shipon_cons_phone'] = $arrTrackingRequest['Contel'];
             $this->return['inputs']['shipon_cons_street1'] = $arrTrackingRequest['ConAdd1'];
             $this->return['inputs']['shipon_cons_street2'] = $arrTrackingRequest['ConAdd2'];
             $this->return['inputs']['shipon_cons_city'] = $arrTrackingRequest['ConCity'];
             $this->return['inputs']['shipon_cons_province'] = $arrTrackingRequest['ConPrv'];
             $this->return['inputs']['shipon_cons_postal'] = $arrTrackingRequest['ConPostal'];
             $this->return['inputs']['shipon_cargo_scn'] = $arrTrackingRequest['cargoNo'];
             $this->return['inputs']['shipon_ext_id'] = $arrTrackingRequest['Pbnum'];
             $this->return['inputs']['shipon_pup_note'] = $arrTrackingRequest['delinst'];
             $this->return['inputs']['shipon_qte_only'] = 2;
             // Goods Table
             $this->return['inputs']['shipon_skids'] = $arrTrackingRequest['Skid'];
             $this->return['inputs']['shipon\\[goods\\]\\[0\\]\\[pieces\\]'] = $arrTrackingRequest['RateDetails']['Pieces'];
             $this->return['inputs']['shipon\\[goods\\]\\[0\\]\\[particulars\\]'] = $arrTrackingRequest['RateDetails']['ComDescr'];
             $this->return['inputs']['shipon\\[goods\\]\\[0\\]\\[length\\]'] = $arrTrackingRequest['length'];
             $this->return['inputs']['shipon\\[goods\\]\\[0\\]\\[width\\]'] = $arrTrackingRequest['width'];
             $this->return['inputs']['shipon\\[goods\\]\\[0\\]\\[height\\]'] = $arrTrackingRequest['height'];
             $this->return['inputs']['shipon\\[goods\\]\\[0\\]\\[weight\\]'] = $arrTrackingRequest['Weight'];
             $this->return['shipon_pieces'] = $arrTrackingRequest['RateDetails']['Pieces'];
             $goods = json_encode($arrTrackingRequest['RateDetails']);
             $html = "<script type='text/javascript'>window.is_recall = false;</script>";
             if (!empty($arrTrackingRequest['pkg'])) {
                 $html .= "<script type='text/javascript'>jQuery('shipon\\[goods\\]\\[0\\]\\[packaging\\]').val('" . $arrTrackingRequest['pkg'] . "');</script>";
             }
             $this->html['shipon_return'] .= $html;
             $this->smarty->assign('data', $arrTrackingRequest);
             $this->html['shipon_rates_content'] = $this->smarty->fetch('shipment/boxes/rates.tpl');
             $this->html['shipon_output'] = "<script type='text/javascript'>jQuery('#shipon_get_rates').hide();</script>";
             $this->return['data']['success'] = 1;
         } else {
             $this->return['alert'] = "Quote has been converted to an order and can no longer be retrieved. Please call customer service.";
             $this->return['data']['success'] = 0;
         }
     } else {
         $this->return['alert'] = "Invalid quote number. Please try again.";
         $this->return['data']['success'] = 0;
     }
 }
Exemplo n.º 5
0
 function get_quotes()
 {
     $req['Pbnum'] = (int) $_REQUEST['pbnum'];
     $req['bill_to_code'] = $this->user['bill_to_code'];
     $integrate = new IntegrationHandler($this->user);
     $arrTrackingRequest = $integrate->process_request('tracking_details_request', $req);
     //$degama                 = new IntegrationHandler($this->user);
     //$handshake              = $degama->process_request("handshake");
     if (!isset($arrTrackingRequest['error'])) {
         if ($arrTrackingRequest['RecStatus'] == 'QTE') {
             print json_encode(array('success' => true, 'data' => $arrTrackingRequest, 'error' => ""));
         } else {
             //print (json_encode(array('success'=>true,'error'=>true)));
         }
     } else {
         print json_encode(array('success' => true, 'error' => true));
     }
 }