Пример #1
0
 public function ajax_getAdminOrderTabAction()
 {
     $orderId = (int) Tools::getValue("order_id");
     $packs = PakomatoPack::getByOrderId($orderId);
     $this->simpleJson(true, "", array("packsCount" => count($packs), "tabContent" => $this->getAdminOrderTab(array("id_order" => $orderId))));
 }
Пример #2
0
 protected function ajax_createPackageAction()
 {
     $orderId = (int) Tools::getValue("id_order");
     $order = new Order($orderId);
     $customer = new Customer($order->id_customer);
     $emp = new Employee($this->mCookie->id_employee);
     $pmOrder = PakomatoOrder::getByOrderId($orderId);
     $machine = unserialize(base64_decode($pmOrder->paczkomat));
     $pmPack = new PakomatoPack();
     $pmPack->customer_email = $customer->email;
     $pmPack->customer_phone = $pmOrder->customer_phone;
     $pmPack->id_order = $orderId;
     $pmPack->insurance = $pmOrder->insurance;
     $pmPack->pack_status = 0;
     $pmPack->selfsend = $pmOrder->selfsend;
     $pmPack->sticker_file = '';
     $pmPack->cod = $pmOrder->cod;
     $pmPack->size = $pmOrder->size;
     //sprawdzanie paczkomatu klienta
     if (Paczkomat::czyPaczkomatIstnieje($machine['name'], $pmPack->cod > 0 ? true : false)) {
         $pmPack->customer_machine = $pmOrder->paczkomat;
     } else {
         if ($pmPack->cod > 0) {
             $this->jsonResponse(array("result" => "error", "message" => "Wybrany przez kienta paczkomat '" . $machine['name'] . "' nie obsługuje pobrania. Paczka nie została utworzona"));
         } else {
             $this->jsonResponse(array("result" => "error", "message" => "Wybrany przez klienta paczkomat '" . $machine['name'] . "' nie istnieje w systemie Inpost. Paczka nie została utworzona"));
         }
     }
     $senderMachineCode = '';
     //sprawdzanie paczkomatu do wysyłki
     if ($pmPack->selfsend > 0) {
         $sendMachine = unserialize(base64_decode($pmOrder->sender_machine));
         $senderMachineCode = $sendMachine['name'];
         $send = Paczkomat::pobierzDanePaczkomatu($senderMachineCode);
         if ($send['result'] == "ok") {
             $pmPack->sender_machine = base64_encode(serialize($send['paczkomat']));
         } else {
             $this->jsonResponse(array("result" => "error", "message" => "Wybrany paczkomat do wysyłki '" . $senderMachineCode . "' nie istnieje w systemie Inpost. Paczka nie została utworzona"));
         }
     } else {
         $pmPack->sender_machine = "";
     }
     $ref = "Zamówienie nr: " . sprintf(" %06d", $orderId);
     if (Configuration::get(self::KONFIG_PREFIX . self::KONFIG_REFETENCJA_TYP_INDEX) == 1 && isset($order->reference)) {
         $ref = "Zamówienie: " . $order->reference;
     }
     $config = array('customer_email' => $pmPack->customer_email, 'customer_phone' => $pmPack->customer_phone, 'customer_machine' => $machine['name'], 'size' => $pmPack->size, 'insurance' => $pmPack->insurance, 'cod' => $pmPack->cod, 'selfsend' => $pmOrder->selfsend, 'order_id' => $ref, 'sender_fname' => $emp->firstname, 'sender_lname' => $emp->lastname, 'sender_email' => Configuration::get($this->name . "_login"), 'sender_login' => Configuration::get($this->name . "_login"), 'sender_pass' => Configuration::get($this->name . "_haslo"), 'sender_machine' => $senderMachineCode, 'sender_data' => unserialize(base64_decode(Configuration::get(self::KONFIG_PREFIX . self::KONFIG_DANE_NADAWCY))));
     $res = Paczkomat::wygenerujPaczke($config);
     if ($res['result'] == "ok") {
         $pmPack->tracking_number = $res['createdPack']['packcode'];
         if ($pmPack->selfsend > 0) {
             $pmPack->send_code = $res['createdPack']['customerdeliveringcode'];
         }
         $pmPack->save();
         //PakomatoPack::updateInpostStatus($pmPack->id);
     }
     $this->jsonResponse($res);
 }