Example #1
0
 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");
     }
 }
Example #2
0
 public function ajax_updateUserPhoneAction()
 {
     $phone = str_replace(' ', '', trim(Tools::getValue('newPhone')));
     if (preg_match('/^[+]?([0-9]?)[(|s|-|.]?([0-9]{3})[)|s|-|.]*([0-9]{3})[s|-|.]*([0-9]{3,4})$/', $phone)) {
         $usrList = PakomatoUserSettings::getByCustomerId($this->mCookie->id_customer);
         if (is_array($usrList) && count($usrList) > 0) {
             //z jakiegoś powodu inaczej nie chce działać
             $conf = new PakomatoUserSettings($usrList[0]->id);
             $conf->phone = $phone;
             $conf->save();
             $this->jsonResponse(array("result" => "ok", "message" => "Nowy numer do otrzymywania powiadomień to: " . $phone, "newPhone" => $phone));
         } else {
             $this->jsonResponse(array("result" => "error", "message" => "Nie udało się zapisać nowego numeru telefonu"));
         }
     } else {
         $this->jsonResponse(array("result" => "error", "message" => "Podany numer (" . addslashes($phone) . ") jest nieprawdłowy"));
     }
 }