Example #1
0
 public static function init()
 {
     $controller = new DpdGroupCSVController();
     if (Tools::isSubmit(DpdGroupCSVController::SETTINGS_SAVE_CSV_ACTION)) {
         $csv_data = $controller->readCSVData();
         if ($csv_data === false) {
             DpdGroup::addFlashError($controller->l('Wrong CSV file'));
             Tools::redirectAdmin($controller->module_instance->module_url . '&menu=csv');
         }
         $message = $controller->validateCSVData($csv_data);
         if ($message !== true) {
             return $controller->module_instance->outputHTML($controller->module_instance->displayError(implode('<br />', $message)));
         }
         if ($controller->saveCSVData($csv_data)) {
             DpdGroup::addFlashMessage($controller->l('CSV data was successfully saved'));
             Tools::redirectAdmin($controller->module_instance->module_url . '&menu=csv');
         } else {
             DpdGroup::addFlashError($controller->l('CSV data could not be saved'));
             Tools::redirectAdmin($controller->module_instance->module_url . '&menu=csv');
         }
     }
     if (Tools::isSubmit(DpdGroupCSVController::SETTINGS_DOWNLOAD_CSV_ACTION)) {
         $controller->generateCSV();
     }
     if (Tools::isSubmit(DpdGroupCSVController::SETTINGS_DELETE_CSV_ACTION)) {
         $controller->deleteCSV();
     }
     return null;
 }
Example #2
0
 /**
  * module configuration page
  * @return page HTML code
  */
 public function getContent()
 {
     $this->displayFlashMessagesIfIsset();
     if (!$this->ps_14) {
         $this->context->controller->addJS(_DPDGROUP_JS_URI_ . 'backoffice.js');
         if (!$this->bootstrap || Tools::getValue('menu') && Tools::getValue('menu') != 'shipment_list') {
             $this->context->controller->addCSS(_DPDGROUP_CSS_URI_ . 'backoffice.css');
         }
     }
     $this->setGlobalVariablesForAjax();
     $this->context->smarty->assign('dpd_geopost_other_country', DpdGroupConfiguration::OTHER_COUNTRY);
     $this->html .= $this->context->smarty->fetch(_DPDGROUP_TPL_DIR_ . 'admin/global_variables.tpl');
     if ($this->bootstrap) {
         $this->html .= $this->getBootstrapMenu();
     }
     $this->displayModuleWarnings();
     switch (Tools::getValue('menu')) {
         case 'configuration':
             require_once _DPDGROUP_CONTROLLERS_DIR_ . 'Configuration.controller.php';
             DpdGroupConfigurationController::init();
             if (!$this->bootstrap) {
                 $this->context->smarty->assign('path', array($this->displayName, $this->l('Settings')));
                 $this->displayNavigation();
             }
             if (!$this->ps_14) {
                 $this->displayShopRestrictionWarning();
             }
             $configuration_controller = new DpdGroupConfigurationController();
             $this->html .= $configuration_controller->getSettingsPage();
             break;
         case 'csv':
             require_once _DPDGROUP_CONTROLLERS_DIR_ . 'Csv.controller.php';
             DpdGroupCSVController::init();
             if (!$this->bootstrap) {
                 $this->context->smarty->assign('path', array($this->displayName, $this->l('Price rules')));
                 $this->displayNavigation();
             }
             if (!$this->ps_14) {
                 if (Shop::getContext() != Shop::CONTEXT_SHOP) {
                     $this->displayAdminWarning($this->l('CSV management is disabled when all shops or group of shops are selected'));
                     break;
                 }
             }
             $csv_controller = new DpdGroupCSVController();
             $this->html .= $csv_controller->getCSVPage();
             break;
         case 'postcode':
             require_once _DPDGROUP_CONTROLLERS_DIR_ . 'Postcode.controller.php';
             DpdGroupPostcodeController::init();
             if (!$this->bootstrap) {
                 $this->context->smarty->assign('path', array($this->displayName, $this->l('Postcodes update')));
                 $this->displayNavigation();
             }
             if (!$this->ps_14) {
                 if (Shop::getContext() != Shop::CONTEXT_SHOP) {
                     $this->displayAdminWarning($this->l('Postcodes management is disabled when all shops or group of shops are selected'));
                     break;
                 }
             }
             $psotcode_controller = new DpdGroupPostcodeController();
             $this->html .= $psotcode_controller->getPostcodePage();
             break;
         case 'help':
             if (!$this->bootstrap) {
                 $this->context->smarty->assign('path', array($this->displayName, $this->l('Help')));
                 $this->displayNavigation();
             }
             if (Tools::isSubmit('print_pdf')) {
                 $filename = 'dpdgroup_eng.pdf';
                 ob_end_clean();
                 header('Content-type: application/pdf');
                 header('Content-Disposition: attachment; filename="' . $this->l('manual') . '.pdf"');
                 readfile(_PS_MODULE_DIR_ . $this->name . '/manual/' . $filename);
                 exit;
             }
             $this->context->smarty->assign('module_link', $this->module_url);
             $this->html .= $this->context->smarty->fetch(_DPDGROUP_TPL_DIR_ . 'admin/help.tpl');
             break;
         case 'shipment_list':
         default:
             if ($this->ps_14) {
                 includeDatepicker(null);
             } else {
                 $this->context->controller->addJqueryUI(array('ui.slider', 'ui.datepicker'));
                 $this->context->controller->addJS(array(_DPDGROUP_JS_URI_ . 'jquery.bpopup.min.js', _PS_JS_DIR_ . 'jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'));
                 $this->context->controller->addCSS(_PS_JS_DIR_ . 'jquery/plugins/timepicker/jquery-ui-timepicker-addon.css');
                 // for datetimepicker
             }
             if (!$this->bootstrap) {
                 $this->context->smarty->assign('path', array($this->displayName, $this->l('Shipments')));
                 $this->displayNavigation();
             } else {
                 $this->context->controller->addCSS(_DPDGROUP_CSS_URI_ . 'backoffice_16.css');
             }
             require_once _DPDGROUP_CONTROLLERS_DIR_ . 'ShipmentsList.controller.php';
             if (!$this->ps_14 && Configuration::getGlobalValue('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(0)) > 1 && Shop::getContext() != Shop::CONTEXT_SHOP) {
                 $this->displayAdminWarning($this->l('Shipments functionality is disabled when all shops or group of shops are chosen'));
                 break;
             }
             $shipment_controller = new DpdGroupShipmentController();
             $this->html .= $shipment_controller->getShipmentList();
             break;
     }
     return $this->html;
 }
Example #3
0
    if ($result = $pickup->arrange()) {
        $module_instance->addFlashMessage(sprintf($module_instance->l('Pickup successfully arranged at %s %s - %s', $filename), $pickup->date, $pickup->from_time, $pickup->to_time));
    }
    $shipment_errors = '';
    foreach (DpdGroupShipment::$errors as $error_message) {
        $shipment_errors .= $error_message . '<br />';
    }
    foreach (DpdGroupShipment::$notices as $notice) {
        $shipment_errors .= $notice . '<br />';
    }
    die(Tools::jsonEncode(array('error' => $result ? null : str_replace('
', '<br />', $shipment_errors))));
}
if (Tools::isSubmit('downloadModuleCSVSettings')) {
    include_once dirname(__FILE__) . '/controllers/Csv.controller.php';
    $controller = new DpdGroupCSVController();
    $controller->generateCSV();
}
if (Tools::getValue('action') == 'postcode-recommendation') {
    require_once _DPDGROUP_CLASSES_DIR_ . 'PostcodeSearch.php';
    require_once _DPDGROUP_CLASSES_DIR_ . 'Address.php';
    require_once _DPDGROUP_CLASSES_DIR_ . 'Mysql.php';
    require_once _DPDGROUP_CLASSES_DIR_ . 'CachedData.php';
    require_once _DPDGROUP_CLASSES_DIR_ . 'PostcodeSearch.php';
    $data = array();
    $address = array('city' => Tools::getValue('city'), 'country_id' => Tools::getValue('id_country'), 'region_id' => Tools::getValue('id_state'), 'lang_id' => (int) Context::getContext()->language->id, 'address' => Tools::getValue('address1') . ' ' . Tools::getValue('address2'));
    $postcode_search = new DpdGroupPostcodeSearch();
    $results = $postcode_search->findAllSimilarAddressesForAddress($address);
    if (!$results) {
        die(Tools::jsonEncode($data));
    }