sibling = &$sibling; } } public function setMedia() { if (Tools::getValue('controller') == 'AdminModules' && Tools::getValue('configure') == 'deliverydateswizardpro') { Context::getContext()->controller->addCSS($this->sibling->_path . 'views/css/admin/lib/tools.css'); Context::getContext()->controller->addCSS($this->sibling->_path . 'views/css/admin/lib/popup.css'); Context::getContext()->controller->addCSS($this->sibling->_path . 'views/css/admin/config/admin.css'); /*Context::getContext()->controller->addCSS($this->sibling->_path . 'views/css/admin/config/config.css'); Context::getContext()->controller->addCSS($this->sibling->_path . 'views/css/admin/config/weekdays.css'); Context::getContext()->controller->addCSS($this->sibling->_path . 'views/css/admin/config/products.css');*/ Context::getContext()->controller->addCSS($this->getAdminWebPath() . '/themes/new-theme/public/theme.css'); Context::getContext()->controller->addJquery(); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/lib/popup.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/lib/tools.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/lib/table-editable.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/config/DDWAdminConfigGeneralController.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/config/DDWAdminConfigWeekdaysController.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/config/DDWAdminConfigDateController.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/config/DDWAdminConfigSpecificDatesController.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/config/DDWAdminConfigBlockedDatesController.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/config/DDWAdminConfigProductsController.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/config/DDWAdminConfigDistanceController.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/config/deliverymanager/DDWAdminConfigDeliveryManagerController.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/config/deliverymanager/DDWAdminConfigDeliveryManagerDayViewController.js'); Context::getContext()->controller->addJS($this->sibling->_path . 'views/js/admin/config/deliverymanager/DDWAdminConfigDeliveryManagerWeekViewController.js'); //Context::getContext()->controller->addJS($this->getAdminWebPath().'/themes/new-theme/public/bundle.js'); Context::getContext()->controller->addJqueryPlugin('tablednd'); } } public function renderForm() { $id_carrier = (int)Tools::getValue('id_carrier'); $id_shop = (int)Tools::getValue('id_shop'); $ddw_model = new DDWModel(); $ddw_model->loadByCarrier($id_carrier, $id_shop); if (!empty($ddw_model->id_ddw)) { $cutofftime = sprintf('%02d', $ddw_model->cutofftime_hours) . ':' . sprintf('%02d', $ddw_model->cutofftime_minutes); } else { $cutofftime = ''; } $fields_form = array(); $fields_form[0]['form'] = array( 'input' => array( array( 'type' => 'hidden', 'name' => 'id_ddw' ), array( 'type' => 'hidden', 'name' => 'id_carrier' ), array( 'type' => 'switch', 'label' => $this->sibling->l('Calendar Enabled?', $this->route), 'name' => 'enabled', 'desc' => $this->sibling->l('Select if module is enabled for this carrier', $this->route), 'values' => array( array( 'id' => 'enabled_on', 'value' => 1, 'label' => $this->trans('Yes', array(), 'Admin.Global'), ), array( 'id' => 'enabled_off', 'value' => 0, 'label' => $this->trans('No', array(), 'Admin.Global'), ), ), ), array( 'type' => 'switch', 'label' => $this->sibling->l('Required?', $this->route), 'name' => 'required', 'desc' => $this->sibling->l('Select if the customer must select a date before they can place the order', $this->route), 'values' => array( array( 'id' => 'required_on', 'value' => 1, 'label' => $this->trans('Yes', array(), 'Admin.Global'), ), array( 'id' => 'required_off', 'value' => 0, 'label' => $this->trans('No', array(), 'Admin.Global'), ), ), ), array( 'type' => 'select', 'label' => $this->sibling->l('Layout', $this->route), 'name' => 'layout', 'desc' => $this->sibling->l('Select the layout to be displayed for the date and time picker during checkout', $this->route), 'options' => array( 'query' => array( array( 'layout' => 'calendar', 'name' => 'Calendar' ), array( 'layout' => 'table', 'name' => 'Schedule table' ), array( 'layout' => 'dayview', 'name' => 'Day to day view' ) ), 'id' => 'layout', 'name' => 'name', ) ), array( 'type' => 'text', 'label' => $this->sibling->l('Order Preparation Days', $this->route), 'name' => 'min_days', 'desc' => $this->sibling->l('Number of days it will take before the order can be delivered from the current day. 0 days is same day delivery, 1 is next day etc', $this->route), 'suffix' => $this->sibling->l('days', $this->route), 'size' => 4, 'class' => 'fixed-width-xl', ), array( 'type' => 'text', 'label' => $this->sibling->l('Maximum Days', $this->route), 'name' => 'max_days', 'desc' => $this->sibling->l('All dates in the calendar after this number of days (from the current day) will be disabled', $this->route), 'suffix' => $this->sibling->l('days', $this->route), 'size' => 4, 'class' => 'fixed-width-xl', ), array( 'type' => 'text', 'label' => $this->sibling->l('Order Preparation Time', $this->route), 'name' => 'timeslots_prep_minutes', 'desc' => $this->sibling->l('For same day delivery, time it takes you to prepare an order for delivery. Time slots within this period will be unavailable to the customer.', $this->route), 'prefix' => $this->renderIcon('alarm_on'), 'suffix' => $this->sibling->l('minutes', $this->route), 'size' => 4, 'class' => 'fixed-width-xl', ), array( 'type' => 'switch', 'label' => $this->sibling->l('Cut off time enabled?', $this->route), 'name' => 'cutofftime_enabled', 'values' => array( array( 'id' => 'cutofftime_enabled_on', 'value' => 1, 'label' => $this->trans('Yes', array(), 'Admin.Global'), ), array( 'id' => 'cutofftime_enabled_off', 'value' => 0, 'label' => $this->trans('No', array(), 'Admin.Global'), ), ), ), array( 'type' => 'html', 'label' => $this->sibling->l('Cut off time', $this->route), 'name' => 'cutofftime', 'desc' => $this->sibling->l('Cut off time or deadline after which the order preparation day rolls over to the next available day', $this->route), 'html_content' => $this->renderTimeFieldIcon('cutofftime', $cutofftime) ), array( 'type' => 'switch', 'label' => $this->sibling->l('Display expected delivery date on product page?', $this->route), 'name' => 'product_eta_display_enabled', 'desc' => $this->sibling->l('Display expected delivery date on product page?', $this->route), 'values' => array( array( 'id' => 'product_eta_display_enabled_on', 'value' => 1, 'label' => $this->trans('Yes', array(), 'Admin.Global'), ), array( 'id' => 'product_eta_display_enabled_off', 'value' => 0, 'label' => $this->trans('No', array(), 'Admin.Global'), ), ), ) ), 'submit' => array( 'title' => $this->sibling->l('Save', $this->route), 'class' => 'btn btn-ddw-general-save pull-right' ) ); $helper = new HelperForm(); $this->setupHelperConfigForm($helper, $this->route, 'process'); // populate form fields $helper->fields_value['id_carrier'] = $id_carrier; if (!empty($ddw_model->id_ddw)) { $helper->fields_value['id_ddw'] = $ddw_model->id_ddw; $helper->fields_value['enabled'] = $ddw_model->enabled; $helper->fields_value['required'] = $ddw_model->required; $helper->fields_value['min_days'] = $ddw_model->min_days; $helper->fields_value['max_days'] = $ddw_model->max_days; $helper->fields_value['timeslots_prep_minutes'] = $ddw_model->timeslots_prep_minutes; $helper->fields_value['cutofftime_enabled'] = $ddw_model->cutofftime_enabled; $helper->fields_value['product_eta_display_enabled'] = $ddw_model->product_eta_display_enabled; $helper->fields_value['layout'] = $ddw_model->layout; } else { $helper->fields_value['layout'] = 'calendar'; } Context::getContext()->smarty->assign(array( 'module_config_url' => $this->module_config_url, 'hour_values' => range(0, 23), 'min_values' => range(0, 59), 'form' => $helper->generateForm($fields_form) )); return $this->sibling->display($this->sibling->module_file, 'views/templates/admin/config/general.tpl'); } /** * Save the general settings * @return string */ public function processForm() { $cutofftime = Tools::getValue('cutofftime'); $cutofftime_parts = explode(':', $cutofftime); $cutofftime_hours = (int)$cutofftime_parts[0]; $cutofftime_minutes = (int)$cutofftime_parts[1]; $ddw_model = new DDWModel(Tools::getValue('id_ddw')); $ddw_model->enabled = Tools::getValue('enabled'); $ddw_model->required = Tools::getValue('required'); $ddw_model->id_carrier = Tools::getValue('id_carrier'); $ddw_model->id_shop = Context::getContext()->shop->id; $ddw_model->min_days = (int)Tools::getValue('min_days'); $ddw_model->max_days = (int)Tools::getValue('max_days'); $ddw_model->cutofftime_enabled = (int)Tools::getValue('cutofftime_enabled'); $ddw_model->cutofftime_hours = (int)$cutofftime_hours; $ddw_model->cutofftime_minutes = (int)$cutofftime_minutes; $ddw_model->timeslots_prep_minutes = (int)Tools::getValue('timeslots_prep_minutes'); $ddw_model->product_eta_display_enabled = (int)Tools::getValue('product_eta_display_enabled'); $ddw_model->layout = pSQL(Tools::getValue('layout')); $ddw_model->save(); return Tools::jsonEncode(array( 'id_ddw' => $ddw_model->id )); } public function route() { switch (Tools::getValue('action')) { case 'renderform': die($this->renderForm()); case 'processform': die($this->processForm()); } } }