Esempio n. 1
0
 /**
  * @param int
  * @throws IllegalArgumentException
  */
 public function setWidth($width)
 {
     $this->size->setWidth($width);
 }
Esempio n. 2
0
 /** Creates bill of loading
  * @param $data
  * @param $order
  * @return array
  */
 public function createBillOfLading($data, $order)
 {
     require_once __DIR__ . '/lib/speedy-eps-lib/ver01/ParamCalculation.class.php';
     $this->_error = '';
     $bol = array();
     if (isset($this->resultLogin)) {
         try {
             $sender = new \ParamClientData();
             $sender->setClientId($this->resultLogin->getClientId());
             if ($this->config->get('speedy_telephone')) {
                 $senderPhone = new \ParamPhoneNumber();
                 $senderPhone->setNumber($this->config->get('speedy_telephone'));
                 $sender->setPhones(array(0 => $senderPhone));
             }
             $receiverAddress = new \ParamAddress();
             $receiverAddress->setSiteId($data['city_id']);
             if ($data['quarter']) {
                 $receiverAddress->setQuarterName($data['quarter']);
             }
             if ($data['quarter_id']) {
                 $receiverAddress->setQuarterId($data['quarter_id']);
             }
             if ($data['street']) {
                 $receiverAddress->setStreetName($data['street']);
             }
             if ($data['street_id']) {
                 $receiverAddress->setStreetId($data['street_id']);
             }
             if ($data['street_no']) {
                 $receiverAddress->setStreetNo($data['street_no']);
             }
             if ($data['block_no']) {
                 $receiverAddress->setBlockNo($data['block_no']);
             }
             if ($data['entrance_no']) {
                 $receiverAddress->setEntranceNo($data['entrance_no']);
             }
             if ($data['floor_no']) {
                 $receiverAddress->setFloorNo($data['floor_no']);
             }
             if ($data['apartment_no']) {
                 $receiverAddress->setApartmentNo($data['apartment_no']);
             }
             if ($data['note']) {
                 $receiverAddress->setAddressNote($data['note']);
             }
             $receiver = new \ParamClientData();
             $receiver->setPartnerName($order['firstname'] . ' ' . $order['lastname']);
             $receiverPhone = new \ParamPhoneNumber();
             $receiverPhone->setNumber($order['telephone']);
             $receiver->setPhones(array(0 => $receiverPhone));
             $receiver->setEmail($order['email']);
             $picking = new \ParamPicking();
             $picking->setClientSystemId(1310221100);
             //OpenCart
             $picking->setRef1($order['order_id']);
             if ($data['depth'] || $data['height'] || $data['width']) {
                 $size = new Size();
                 if ($data['depth']) {
                     $size->setDepth($data['depth']);
                 }
                 if ($data['height']) {
                     $size->setHeight($data['height']);
                 }
                 if ($data['width']) {
                     $size->setWidth($data['width']);
                 }
                 $picking->setSize($size);
             }
             if (!empty($data['fixed_time'])) {
                 $picking->setFixedTimeDelivery($data['fixed_time']);
             }
             $picking->setServiceTypeId($data['shipping_method_id']);
             if ($data['to_office'] && $data['office_id']) {
                 $picking->setOfficeToBeCalledId($data['office_id']);
             } else {
                 $receiver->setAddress($receiverAddress);
                 $picking->setOfficeToBeCalledId(null);
             }
             $picking->setBackDocumentsRequest($this->config->get('speedy_back_documents'));
             $picking->setBackReceiptRequest($this->config->get('speedy_back_receipt'));
             if ($this->config->get('speedy_from_office') && $this->config->get('speedy_office_id')) {
                 $picking->setWillBringToOffice(true);
                 $picking->setWillBringToOfficeId($this->config->get('speedy_office_id'));
             } else {
                 $picking->setWillBringToOffice(false);
             }
             $picking->setParcelsCount($data['count']);
             $picking->setWeightDeclared($data['weight']);
             $picking->setContents($data['contents']);
             $picking->setPacking($data['packing']);
             $picking->setPackId(null);
             $picking->setDocuments($this->config->get('speedy_documents'));
             $picking->setPalletized(false);
             $payerType = $this->getPayerType($order['order_id'], $data['shipping_method_cost']);
             if ($data['insurance']) {
                 if ($data['fragile']) {
                     $picking->setFragile(true);
                 } else {
                     $picking->setFragile(false);
                 }
                 $picking->setAmountInsuranceBase($data['totalNoShipping']);
                 /*
                                     if ($this->config->get('speedy_pricing') == 'free' || $this->config->get('speedy_pricing') == 'fixed') {
                                         $picking->setPayerTypeInsurance($payerType);
                                     } else {
                                         $picking->setPayerTypeInsurance($payerType);
                                     } */
                 $picking->setPayerTypeInsurance($payerType);
             } else {
                 $picking->setFragile(false);
             }
             $picking->setSender($sender);
             $picking->setReceiver($receiver);
             /*
                             if ($this->config->get('speedy_pricing') == 'free' || $this->config->get('speedy_pricing') == 'fixed') {
                                 $picking->setPayerType($payerType);
                             } else {
                                   $picking->setPayerType($payerType);
                             }
             */
             $picking->setPayerType($payerType);
             $picking->setTakingDate($data['taking_date']);
             if ($data['deffered_days']) {
                 $picking->setDeferredDeliveryWorkDays($data['deffered_days']);
             }
             if ($data['client_note']) {
                 $picking->setNoteClient($data['client_note']);
             }
             if ($data['cod']) {
                 $picking->setAmountCodBase($data['total']);
             } else {
                 $picking->setAmountCodBase(0);
             }
             $result = $this->ePSFacade->createBillOfLading($picking);
             $parcels = $result->getGeneratedParcels();
             $bol['bol_id'] = $parcels[0]->getParcelId();
             $bol['total'] = $result->getAmounts()->getTotal();
         } catch (\Exception $e) {
             $this->_error = $e->getMessage();
             $this->log->addError('Speedy :: createBillOfLading :: ' . $e->getMessage());
         }
     }
     return $bol;
 }