コード例 #1
0
 public function getSettingsHTML($params = array())
 {
     $values = $this->getSettings();
     if (!empty($params['value'])) {
         $values = array_merge($values, $params['value']);
     }
     $view = wa()->getView();
     $cm = new waCountryModel();
     $view->assign('countires', $cm->all());
     if (!empty($values['country'])) {
         $rm = new waRegionModel();
         $view->assign('regions', $rm->getByCountry($values['country']));
     }
     $namespace = '';
     if (!empty($params['namespace'])) {
         if (is_array($params['namespace'])) {
             $namespace = array_shift($params['namespace']);
             while (($namspace_chunk = array_shift($params['namespace'])) !== null) {
                 $namespace .= "[{$namspace_chunk}]";
             }
         } else {
             $namespace = $params['namespace'];
         }
     }
     $view->assign('namespace', $namespace);
     $view->assign('values', $values);
     $view->assign('p', $this);
     $view->assign('xhr_url', wa()->getAppUrl('webasyst') . '?module=backend&action=regions');
     $html = $view->fetch($this->path . '/templates/settings.html');
     $html .= parent::getSettingsHTML($params);
     return $html;
 }
コード例 #2
0
 /**
  * Example of direct usage HTML templates instead waHtmlControl
  * (non-PHPdoc)
  * @see waShipping::getSettingsHTML()
  */
 public function getSettingsHTML($params = array())
 {
     $values = $this->getSettings();
     if (!empty($params['value'])) {
         $values = array_merge($values, $params['value']);
     }
     $view = wa()->getView();
     $app_config = wa()->getConfig();
     if (method_exists($app_config, 'getCurrencies')) {
         $view->assign('currencies', $app_config->getCurrencies());
     }
     $namespace = '';
     if (!empty($params['namespace'])) {
         if (is_array($params['namespace'])) {
             $namespace = array_shift($params['namespace']);
             while (($namspace_chunk = array_shift($params['namespace'])) !== null) {
                 $namespace .= "[{$namspace_chunk}]";
             }
         } else {
             $namespace = $params['namespace'];
         }
     }
     $view->assign('namespace', $namespace);
     $view->assign('values', $values);
     $view->assign('p', $this);
     $html = '';
     $html .= $view->fetch($this->path . '/templates/settings.html');
     $html .= parent::getSettingsHTML($params);
     return $html;
 }
コード例 #3
0
 protected function init()
 {
     $autoload = waAutoload::getInstance();
     foreach (array('uspsLabelsExpressMailQuery', 'uspsLabelsInternationalShippingQuery', 'uspsLabelsUspsTrackingQuery', 'uspsLabelsQuery', 'uspsLabelsSignatureConfirmationQuery', 'uspsQuery', 'uspsRatingsQuery', 'uspsServices', 'uspsTrackingQuery') as $class_name) {
         $autoload->add($class_name, "wa-plugins/shipping/usps/lib/classes/{$class_name}.class.php");
     }
     parent::init();
 }
コード例 #4
0
 /**
  * @see waShipping::getSettingsHTML()
  * @param array $params
  * @return string HTML
  */
 public function getSettingsHTML($params = array())
 {
     $params += array('translate' => array(&$this, '_w'));
     $values = $this->getSettings();
     if (!empty($params['value'])) {
         $values = array_merge($values, $params['value']);
     }
     if (!$values['rate_zone']['country']) {
         $l = substr(wa()->getUser()->getLocale(), 0, 2);
         if ($l == 'ru') {
             $values['rate_zone']['country'] = 'rus';
             $values['rate_zone']['region'] = '77';
             $values['city'] = '';
         } else {
             $values['rate_zone']['country'] = 'usa';
         }
     }
     $view = wa()->getView();
     $cm = new waCountryModel();
     $view->assign('countries', $cm->all());
     if (!empty($values['rate_zone']['country'])) {
         $rm = new waRegionModel();
         $view->assign('regions', $rm->getByCountry($values['rate_zone']['country']));
     }
     if (!empty($values['rate'])) {
         self::sortRates($values['rate']);
         if ($values['rate_by'] == 'price') {
             $values['rate'] = array_reverse($values['rate']);
         }
     } else {
         $values['rate'] = array();
         $values['rate'][] = array('limit' => 0, 'cost' => 0.0);
     }
     $app_config = wa()->getConfig();
     if (method_exists($app_config, 'getCurrencies')) {
         $view->assign('currencies', $app_config->getCurrencies());
     }
     $namespace = '';
     if (!empty($params['namespace'])) {
         if (is_array($params['namespace'])) {
             $namespace = array_shift($params['namespace']);
             while (($namespace_chunk = array_shift($params['namespace'])) !== null) {
                 $namespace .= "[{$namespace_chunk}]";
             }
         } else {
             $namespace = $params['namespace'];
         }
     }
     $view->assign('namespace', $namespace);
     $view->assign('values', $values);
     $view->assign('p', $this);
     $html = '';
     $view->assign('xhr_url', wa()->getAppUrl('webasyst') . '?module=backend&action=regions');
     $view->assign('map_adapters', wa()->getMapAdapters());
     $html .= $view->fetch($this->path . '/templates/settings.html');
     $html .= parent::getSettingsHTML($params);
     return $html;
 }
コード例 #5
0
 protected function getTotalWeight()
 {
     $w = parent::getTotalWeight();
     if ($w === null) {
         return $this->min_weight;
     } else {
         return max($w, $this->min_weight);
     }
 }
コード例 #6
0
 protected function getItems()
 {
     $items = parent::getItems();
     foreach ($items as &$item) {
         if (empty($item['weight'])) {
             $item['weight'] = $this->min_weight;
         }
     }
     $this->setItems($items);
     return $items;
 }
コード例 #7
0
 public function execute()
 {
     $params = waRequest::request();
     $params['result'] = true;
     $module_id = waRequest::param('module_id');
     $result = waShipping::execCallback($params, $module_id);
     if (!empty($result['template'])) {
         $this->template = $result['template'];
     }
     $this->view->assign('params', $params);
     $this->view->assign('result', $result);
 }
コード例 #8
0
 /**
  * Несмотря на название это, видимо, валидатор сохраняемых значений
  * конфигурации. Во всяком случае то, что он возвращает сохраняется
  * в БД.
  *
  * Название ПВЗ не можеь быть пустым. Потомушта.
  *
  * @todo Проверять, чтоб страна и регион были указаны
  *
  * @param array $settings
  * @return array
  * @throws waException Если данные не прошли проверку
  */
 public function saveSettings($settings = array())
 {
     foreach ($settings['rate'] as $index => $item) {
         if (!isset($item['location']) || empty($item['location'])) {
             throw new waException(_w('Pick-up point name cannot be empty'));
         }
         $settings['rate'][$index]['cost'] = isset($item['cost']) ? str_replace(',', '.', floatval($item['cost'])) : "0";
         $settings['rate'][$index]['maxweight'] = isset($item['maxweight']) ? str_replace(',', '.', floatval($item['maxweight'])) : "0";
         $settings['rate'][$index]['free'] = isset($item['free']) ? str_replace(',', '.', floatval($item['free'])) : "0";
     }
     return parent::saveSettings($settings);
 }
コード例 #9
0
 /**
  * Предварительная подготовка данных для сохранения настроек с помощью метода saveSettings() базового класса waSystemPlugin.
  * 
  * @see waSystemPlugin::saveSettings()
  */
 public function saveSettings($settings = array())
 {
     $fields = array('halfkilocost', 'overhalfkilocost');
     foreach ($fields as $field) {
         if (ifempty($settings[$field])) {
             foreach ($settings[$field] as &$value) {
                 if (strpos($value, ',') !== false) {
                     $value = str_replace(',', '.', $value);
                 }
                 $value = str_replace(',', '.', (double) $value);
             }
             unset($value);
         }
     }
     return parent::saveSettings($settings);
 }
コード例 #10
0
 public function getSettingsHTML($params = array())
 {
     $model = new waRegionModel();
     if (!isset($params['options'])) {
         $params['options'] = array();
     }
     $params['options']['region'] = array();
     foreach ($model->getByCountry('rus') as $region) {
         $params['options']['region'][$region['code']] = $region['name'];
     }
     return parent::getSettingsHTML($params);
 }
コード例 #11
0
 protected function getCustomFields($id, waShipping $plugin)
 {
     $contact = $this->getContact();
     $order_params = $this->getSessionData('params', array());
     $shipping_params = isset($order_params['shipping']) ? $order_params['shipping'] : array();
     foreach ($shipping_params as $k => $v) {
         $order_params['shipping_params_' . $k] = $v;
     }
     $order = new waOrder(array('contact' => $contact, 'contact_id' => $contact ? $contact->getId() : null, 'params' => $order_params));
     $custom_fields = $plugin->customFields($order);
     if (!$custom_fields) {
         return $custom_fields;
     }
     $params = array();
     $params['namespace'] = 'shipping_' . $id;
     $params['title_wrapper'] = '%s';
     $params['description_wrapper'] = '<br><span class="hint">%s</span>';
     $params['control_wrapper'] = '<div class="wa-name">%s</div><div class="wa-value">%s %s</div>';
     $selected_shipping = $this->getSessionData('shipping');
     $selected = $selected_shipping ? $id == $selected_shipping['id'] : false;
     $controls = array();
     foreach ($custom_fields as $name => $row) {
         $row = array_merge($row, $params);
         if ($selected && isset($shipping_params[$name])) {
             $row['value'] = $shipping_params[$name];
         }
         $controls[$name] = waHtmlControl::getControl($row['control_type'], $name, $row);
     }
     return $controls;
 }
コード例 #12
0
 public static function getList()
 {
     if (!class_exists('waShipping')) {
         throw new waException(_w('Shipping plugins not installed yet'));
     }
     return waShipping::enumerate();
 }
コード例 #13
0
ファイル: dellinShipping.class.php プロジェクト: klxqz/dellin
 protected function init()
 {
     $this->cities = (include $this->path . '/lib/config/data/cities.php');
     parent::init();
 }