public static function updateInpostStatus($packId = false) { $col = array(); if ($packId == false) { $sql = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\t*\r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . _DB_PREFIX_ . self::TABLE_NAME . "\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tinpost_status_code='Created' OR\r\n\t\t\t\t\tinpost_status_code='Prepared' OR\r\n\t\t\t\t\tinpost_status_code='Sent' OR\r\n\t\t\t\t\tinpost_status_code='InTransit' OR\r\n\t\t\t\t\tinpost_status_code='Stored' OR\r\n\t\t\t\t\tinpost_status_code='Aviso' OR\r\n\t\t\t\t\tinpost_status_code='Claimed' OR\r\n\t\t\t\t\tinpost_status_code='CustomerDelivering' OR\r\n\t\t\t\t\tinpost_status_code='' OR\r\n\t\t\t\t\tinpost_status_code is null"; $res = Db::getInstance()->executeS($sql); if (is_array($res)) { $col = self::hydrateCollection($res); } } else { $col[] = new PakomatoPack($packId); } foreach ($col as $pack) { $res = Paczkomat::statusPaczki($pack->tracking_number); if ($res['result'] == "ok") { if ($res['status_code'] == "Delivered") { $pack->pack_status = PakomatoPack::DELIVERED; } if ($res['status_code'] == "InTransit") { $pack->pack_status = PakomatoPack::IN_TRANSIT; } $pack->inpost_status = $res['status']; $pack->inpost_status_code = $res['status_code']; $pack->save(); } } }
/** * Funkcja wyszukuje paczkomat znajdujący się najbliżej podanego kodu pocztowego * @param String $kodPaczkomatu kod pocztowy, w pobliżu którego będzie wyszukany paczkomat akceptowany format kodu pocztowego to xx-xxx lub xxxxx * @param Boolean $tylkoPobraniowe parametr określający czy wyszukać tylko paczkomaty z możliwością odbioru przesyłki pobraniowej (true) czy wszystkie (false) * @return array lista znalezionych paczkomatów */ public static function znajdzNajblizszy($kodPocztowy, $tylkoPobraniowe = true) { $kod = str_replace(' ', '', trim($kodPocztowy)); if (preg_match('/[0-9]{2}-[0-9]{3}/', $kod)) { $kodPocztowy = $kod; } elseif (preg_match('/[0-9]{5}/', $kod)) { $kod1 = substr($kod, 0, 2); $kod2 = substr($kod, 2, 3); $kodPocztowy = $kod1 . "-" . $kod2; } else { $kodPocztowy = "00-901"; } $tmp = Paczkomat::najbliższePaczkomaty($kodPocztowy, $tylkoPobraniowe); if ($tmp['result'] == "ok" && is_array($tmp['list']) && count($tmp['list']) > 0) { return $tmp['list'][0]; } return false; }
protected function ajax_saveAccountAction() { $login = pSQL($_POST["login"]); $pass = pSQL($_POST["pass"]); if (Validate::isEmail($login)) { if (Paczkomat::sprawdzKonto($login)) { if (Configuration::get($this->name . "_wys_paczkomat") == "") { $pacz = Paczkomat::paczkomatUżytkownika($login); if ($pacz['result'] == "ok" && $pacz['glowny'] != '') { $sendMachine = Paczkomat::pobierzDanePaczkomatu($pacz['glowny']); Configuration::updateValue($this->name . "_wys_paczkomat", base64_encode(serialize($sendMachine['paczkomat']))); } } if ($pass != "") { Configuration::updateValue($this->name . "_login", $login); Configuration::updateValue($this->name . "_haslo", $pass); $this->jsonResponse(array("result" => "ok", "message" => "Login i hasło zostały zapisane")); } else { $this->jsonResponse(array("result" => "error", "message" => "Hasło nie może być puste")); } } else { $this->jsonResponse(array("result" => "error", "message" => "Podany e-mail nie jest zarejestrowanym loginem w systemie Paczkomaty 24/7")); } } else { $this->jsonResponse(array("result" => "error", "message" => "Login musi być podany w postaci adresu e-mail")); } }
public function hookDisplayCarrierList($params) { self::$boxDisplayed = true; $binded = unserialize(Configuration::get(self::KONFIG_PREFIX . self::KONFIG_POWIAZANIA_KURIEROW)); $config['binded'] = $binded; if (is_array($binded)) { $kodPocztowy = $params['address']->postcode; $phone = $params['address']->phone_mobile != '' ? $params['address']->phone_mobile : $params['address']->phone; $userSettings = PakomatoUserSettings::getByCustomerId($params['cookie']->id_customer); $najblizszy = array(); $najblizszyCod = array(); if (is_array($userSettings) && count($userSettings) > 0) { $userSettings = $userSettings[0]; $userMachine = unserialize(base64_decode($userSettings->machine)); $userMachineCod = unserialize(base64_decode($userSettings->machine_cod)); if (Paczkomat::czyPaczkomatIstnieje($userMachine['name'], $userMachine['town']) && Paczkomat::czyPaczkomatIstnieje($userMachineCod['name'], $userMachineCod['town'])) { $najblizszy = $userMachine; $najblizszyCod = $userMachineCod; $phone = $userSettings->phone; } else { $najblizszy = Paczkomat::znajdzNajblizszy($kodPocztowy, true); $najblizszyCod = $najblizszy; $userSettings->machine = base64_encode(serialize($najblizszy)); $userSettings->machine_cod = base64_encode(serialize($najblizszy)); $userSettings->phone = $phone; $userSettings->save(); } } else { $najblizszy = Paczkomat::znajdzNajblizszy($kodPocztowy, true); $najblizszyCod = $najblizszy; $userSettings = new PakomatoUserSettings(); $userSettings->id_customer = $params['cookie']->id_customer; $userSettings->machine = base64_encode(serialize($najblizszy)); $userSettings->machine_cod = base64_encode(serialize($najblizszy)); $userSettings->phone = $phone; $userSettings->save(); } $this->context->smarty->assign(array('najblizszy' => $najblizszy, 'najblizszy_cod' => $najblizszyCod, 'carrier' => $params['cart']->id_carrier, 'phone' => $phone, 'config' => json_encode($config), 'ajax_url' => $this->context->link->getModuleLink('pakomato', 'ajax', array(), Configuration::get('PS_SSL_ENABLED') ? true : false), "moduleDir" => _MODULE_DIR_ . $this->name . "/", "carrier_selector" => Configuration::get(self::KONFIG_PREFIX . self::KONFIG_SELEKTOR_KURIEROW), "payment_selector" => Configuration::get(self::KONFIG_PREFIX . self::KONFIG_SELEKTOR_PLATNOSCI), "button_selector" => Configuration::get(self::KONFIG_PREFIX . self::KONFIG_SELEKTOR_PRZYCISKU), "np_message" => self::DOM_BRAK_TELEFONU_KOMUNIKAT, "opc" => Configuration::get(self::KONFIG_PRESTA_OPC))); return $this->display(PACZKOMATY_PATH, "carriersList.tpl"); } }
/** * @dataProvider testSprawdzKontoDP */ public function testSprawdzKonto($email, $expectedResult) { $this->assertEquals($expectedResult, Paczkomat::sprawdzKonto($email)); }