public function validateSettings() { if (!Tools::getValue(DpdPolandConfiguration::LOGIN)) { self::$errors[] = $this->l('Login can not be empty'); } if (!Tools::getValue(DpdPolandConfiguration::PASSWORD)) { self::$errors[] = $this->l('Password can not be empty'); } elseif (!Validate::isPasswd(Tools::getValue(DpdPolandConfiguration::PASSWORD))) { self::$errors[] = $this->l('Password is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::CLIENT_NUMBER)) { self::$errors[] = $this->l('Default client number must be set'); } if (!Tools::getValue(DpdPolandConfiguration::COMPANY_NAME)) { self::$errors[] = $this->l('Company name can not be empty'); } elseif (!Validate::isLabel(Tools::getValue(DpdPolandConfiguration::COMPANY_NAME))) { self::$errors[] = $this->l('Company name is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::NAME_SURNAME)) { self::$errors[] = $this->l('Name and Surname can not be empty'); } elseif (!Validate::isName(Tools::getValue(DpdPolandConfiguration::NAME_SURNAME))) { self::$errors[] = $this->l('Name and surname are not valid. Please use only letters and separate first name from last name with white space.'); } if (!Tools::getValue(DpdPolandConfiguration::ADDRESS)) { self::$errors[] = $this->l('Address can not be empty'); } elseif (!Validate::isAddress(Tools::getValue(DpdPolandConfiguration::ADDRESS))) { self::$errors[] = $this->l('Address is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::POSTCODE)) { self::$errors[] = $this->l('Postal code not be empty'); } elseif (!Validate::isPostCode(Tools::getValue(DpdPolandConfiguration::POSTCODE))) { self::$errors[] = $this->l('Postal code is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::CITY)) { self::$errors[] = $this->l('City can not be empty'); } elseif (!Validate::isCityName(Tools::getValue(DpdPolandConfiguration::CITY))) { self::$errors[] = $this->l('City is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::EMAIL)) { self::$errors[] = $this->l('Email can not be empty'); } elseif (!Validate::isEmail(Tools::getValue(DpdPolandConfiguration::EMAIL))) { self::$errors[] = $this->l('Email is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::PHONE)) { self::$errors[] = $this->l('Tel. No. can not be empty'); } elseif (!Validate::isPhoneNumber(Tools::getValue(DpdPolandConfiguration::PHONE))) { self::$errors[] = $this->l('Tel. No. is not valid'); } if (Tools::isSubmit(DpdPolandConfiguration::CARRIER_STANDARD_COD)) { $checked = false; foreach (DpdPoland::getPaymentModules() as $payment_module) { if (Tools::isSubmit(DpdPolandConfiguration::COD_MODULE_PREFIX . $payment_module['name'])) { $checked = true; } } if (!$checked) { self::$errors[] = $this->l('At least one COD payment method must be checked'); } } if (!Tools::getValue(DpdPolandConfiguration::WEIGHT_CONVERSATION_RATE)) { self::$errors[] = $this->l('Weight conversation rate can not be empty'); } elseif (!Validate::isUnsignedFloat(Tools::getValue(DpdPolandConfiguration::WEIGHT_CONVERSATION_RATE))) { self::$errors[] = $this->l('Weight conversation rate is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::DIMENSION_CONVERSATION_RATE)) { self::$errors[] = $this->l('Dimension conversation rate can not be empty'); } elseif (!Validate::isUnsignedFloat(Tools::getValue(DpdPolandConfiguration::DIMENSION_CONVERSATION_RATE))) { self::$errors[] = $this->l('Dimension conversation rate is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::CUSTOMER_COMPANY)) { self::$errors[] = $this->l('Customer company name can not be empty'); } elseif (!Validate::isLabel(Tools::getValue(DpdPolandConfiguration::CUSTOMER_COMPANY))) { self::$errors[] = $this->l('Customer company name is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::CUSTOMER_NAME)) { self::$errors[] = $this->l('Customer name and surname can not be empty'); } elseif (!Validate::isName(Tools::getValue(DpdPolandConfiguration::CUSTOMER_NAME))) { self::$errors[] = $this->l('Customer name and surname is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::CUSTOMER_PHONE)) { self::$errors[] = $this->l('Customer tel. No. can not be empty'); } elseif (!Validate::isPhoneNumber(Tools::getValue(DpdPolandConfiguration::CUSTOMER_PHONE))) { self::$errors[] = $this->l('Customer tel. No. is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::CUSTOMER_FID)) { self::$errors[] = $this->l('Customer FID can not be empty'); } elseif (!ctype_alnum(Tools::getValue(DpdPolandConfiguration::CUSTOMER_FID))) { self::$errors[] = $this->l('Customer FID is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::MASTER_FID)) { self::$errors[] = $this->l('Master FID can not be empty'); } elseif (!ctype_alnum(Tools::getValue(DpdPolandConfiguration::MASTER_FID))) { self::$errors[] = $this->l('Master FID is not valid'); } if (!Tools::getValue(DpdPolandConfiguration::WS_URL)) { self::$errors[] = $this->l('Web Services URL can not be empty'); } elseif (!Validate::isUrl(Tools::getValue(DpdPolandConfiguration::WS_URL))) { self::$errors[] = $this->l('Web Services URL is not valid'); } }
private function disablePaymentMethods() { $method_id = self::getMethodIdByCarrierId((int) $this->context->cart->id_carrier); if ($paymentModules = DpdPoland::getPaymentModules()) { foreach ($paymentModules as $module) { $is_cod_module = Configuration::get(DpdPolandConfiguration::COD_MODULE_PREFIX . $module['name']); if ($method_id == _DPDPOLAND_STANDARD_COD_ID_ && !$is_cod_module || $method_id == _DPDPOLAND_STANDARD_ID_ && $is_cod_module || $method_id == _DPDPOLAND_CLASSIC_ID_ && $is_cod_module) { $module_instance = Module::getInstanceByName($module['name']); if (Validate::isLoadedObject($module_instance)) { $module_instance->currencies = array(); } } } } }
public static function deleteConfiguration() { $success = true; $success &= self::deleteByNames(array(self::LOGIN, self::PASSWORD, self::CLIENT_NUMBER, self::CLIENT_NAME, self::COMPANY_NAME, self::NAME_SURNAME, self::ADDRESS, self::POSTCODE, self::CITY, self::EMAIL, self::PHONE, self::CUSTOMER_COMPANY, self::CUSTOMER_NAME, self::CUSTOMER_PHONE, self::CUSTOMER_FID, self::MASTER_FID, self::PRICE_CALCULATION_TYPE, self::CARRIER_STANDARD, self::CARRIER_STANDARD_COD, self::CARRIER_CLASSIC, self::WEIGHT_CONVERSATION_RATE, self::DIMENSION_CONVERSATION_RATE, self::WS_URL, self::CARRIER_STANDARD_ID, self::CARRIER_STANDARD_COD_ID, self::CARRIER_CLASSIC_ID)); foreach (DpdPoland::getPaymentModules() as $payment_module) { $success &= Configuration::deleteByName(self::COD_MODULE_PREFIX . $payment_module['name']); } return $success; }