public function changeEnabledMultipleCountries($countries = array(), $disable = false)
 {
     foreach ($countries as $id_country) {
         if (!$this->changeEnabled((int) $id_country, $disable)) {
             self::$errors[] = sprintf($this->l('Could not change country status, ID: %s'), $id_country);
         }
     }
     if (!empty(self::$errors)) {
         $this->module_instance->outputHTML($this->module_instance->displayErrors(self::$errors));
         reset(self::$errors);
     } else {
         $page = (int) Tools::getValue('submitFilterCountries');
         if (!$page) {
             $page = 1;
         }
         $selected_pagination = (int) Tools::getValue('pagination', $this->pagination[0]);
         $order_by = Tools::getValue('CountryOrderBy', self::DEFAULT_ORDER_BY);
         $order_way = Tools::getValue('CountryOrderWay', self::DEFAULT_ORDER_WAY);
         DpdPoland::addFlashMessage($this->l('Selected countries statuses changed successfully'));
         $redirect_url = $this->module_instance->module_url;
         $redirect_url .= '&menu=country_list&pagination=' . $selected_pagination;
         $redirect_url .= '&CountryOrderBy=' . $order_by;
         $redirect_url .= '&CountryOrderWay=' . $order_way;
         $redirect_url .= '&submitFilterCountries=' . $page;
         die(Tools::redirectAdmin($redirect_url));
     }
 }
Exemplo n.º 2
0
    public static function getParcels($id_order, $id_package_ws = null)
    {
        if ($id_package_ws) {
            $parcels = Db::getInstance()->executeS('
				SELECT `id_parcel`, `content`, `weight`, `height`, `length`, `width`, `number`
				FROM `' . bqSQL(_DB_PREFIX_ . self::$definition['table']) . '`
				WHERE `id_package_ws`=' . (int) $id_package_ws);
            return $parcels;
        }
        $products = DpdPolandParcelProduct::getShippedProducts($id_order);
        $parcels = array();
        $content = '';
        $weight = $height = $length = $width = 0;
        $products_count = count($products);
        if ($products_count == 1) {
            $product = reset($products);
            $height = DpdPoland::convertDimention($product['height']);
            $length = DpdPoland::convertDimention($product['length']);
            $width = DpdPoland::convertDimention($product['width']);
        }
        foreach ($products as $product) {
            $content .= $product['id_product'] . '_' . $product['id_product_attribute'];
            if (--$products_count) {
                $content .= ', ';
            }
            $weight += DpdPoland::convertWeight($product['weight']);
        }
        $parcels[] = array('number' => 1, 'content' => $content, 'weight' => $weight, 'height' => sprintf('%.6f', $height), 'length' => sprintf('%.6f', $length), 'width' => sprintf('%.6f', $width));
        return $parcels;
    }
Exemplo n.º 3
0
 public function deleteCSV()
 {
     if (DpdPolandCSV::deleteAllData()) {
         DpdPoland::addFlashMessage($this->l('Price rules deleted successfully'));
     } else {
         DpdPoland::addFlashError($this->l('Price rules could not be deleted'));
     }
     Tools::redirectAdmin($this->module_instance->module_url . '&menu=csv');
 }
Exemplo n.º 4
0
 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();
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
        unset($cookie->dpdpoland_printout_format);
        $cookie->write();
        $package = new DpdPolandPackage((int) $package_id);
        $pdf_file_contents = $package->generateLabels('PDF', $printout_format);
        ob_end_clean();
        header('Content-type: application/pdf');
        header('Content-Disposition: attachment; filename="package_labels_' . (int) Tools::getValue('id_package_ws') . '.pdf"');
        echo $pdf_file_contents;
        exit;
    }
    $package = new DpdPolandPackage((int) Tools::getValue('id_package_ws'));
    if ($pdf_file_contents = $package->generateLabels()) {
        $cookie->dpdpoland_package_id = (int) Tools::getValue('id_package_ws');
        $printout_format = Tools::getValue('printout_format');
        if (!in_array($printout_format, array(DpdPolandConfiguration::PRINTOUT_FORMAT_A4, DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL))) {
            $printout_format = DpdPolandConfiguration::PRINTOUT_FORMAT_A4;
        }
        $cookie->dpdpoland_printout_format = $printout_format;
        Tools::redirectAdmin(Tools::getValue('returnOnErrorTo') . '&scrollToShipment');
        exit;
    } else {
        DpdPoland::addFlashError(reset(DpdPolandPackageWS::$errors));
        Tools::redirectAdmin(Tools::getValue('returnOnErrorTo') . '&scrollToShipment');
        exit;
    }
}
if (Tools::isSubmit('downloadModuleCSVSettings')) {
    include_once _DPDPOLAND_CONTROLLERS_DIR_ . 'csv.controller.php';
    $controller = new DpdPolandCSVController();
    $controller->generateCSV();
}
 public function saveSettings()
 {
     if (DpdPolandConfiguration::saveConfiguration()) {
         if (!DpdPolandConfiguration::saveZonesForCarriers()) {
             DpdPoland::addFlashError($this->l('Settings saved successfully but could not assign zones for carriers'));
         } else {
             DpdPoland::addFlashMessage($this->l('Settings saved successfully'));
             Tools::redirectAdmin($this->module_instance->module_url . '&menu=configuration');
         }
     } else {
         DpdPoland::addFlashError($this->l('Could not save settings'));
     }
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 private static function extractAndFormatProductData(&$product)
 {
     $id_product = isset($product['product_id']) ? (int) $product['product_id'] : (int) $product['id_product'];
     $id_product_attribute = isset($product['product_attribute_id']) ? (int) $product['product_attribute_id'] : (int) $product['id_product_attribute'];
     $product_name = isset($product['product_name']) ? $product['product_name'] : $product['name'];
     $product_weight = isset($product['product_weight']) ? $product['product_weight'] : $product['weight'];
     if (isset($product['id_parcel'])) {
         $id_parcel = (int) $product['id_parcel'];
     }
     $product = array('id_product' => $id_product, 'id_product_attribute' => $id_product_attribute, 'name' => $product_name, 'weight' => DpdPoland::convertWeight($product_weight), 'width' => isset($product['width']) ? DpdPoland::convertDimention($product['width']) : null, 'height' => isset($product['height']) ? DpdPoland::convertDimention($product['height']) : null, 'length' => isset($product['height']) ? DpdPoland::convertDimention($product['depth']) : null);
     if (isset($id_parcel)) {
         $product['id_parcel'] = $id_parcel;
     }
 }
 private function prepareSenderAddress($client_number = 'null')
 {
     $settings = new DpdPolandConfiguration();
     $this->sender = array('address' => $settings->address, 'city' => $settings->city, 'company' => $settings->company_name, 'countryCode' => DpdPoland::POLAND_ISO_CODE, 'email' => $settings->email, 'fid' => $client_number, 'name' => $settings->name_surname, 'phone' => $settings->phone, 'postalCode' => DpdPoland::convertPostcode($settings->postcode));
 }
Exemplo n.º 10
0
 /**
  * Get available pickup time frames for a particular date
  * @return bool
  */
 public function getCourierTimeframes()
 {
     $settings = new DpdPolandConfiguration();
     $params = array('senderPlaceV1' => array('countryCode' => DpdPoland::POLAND_ISO_CODE, 'zipCode' => DpdPoland::convertPostcode($settings->postcode)));
     $result = $this->getCourierOrderAvailabilityV1($params);
     if (!isset($result['ranges']) && !self::$errors) {
         self::$errors[] = $this->l('Cannot get TimeFrames from webservices. Please check if sender\'s postal code is typed in correctly');
     }
     return isset($result['ranges']) ? $result['ranges'] : false;
 }