public function getRpZone($addr) { if (!Country::containsStates($addr->id_country)) { return 0; } if (!$addr->id_state) { return 0; } $row = Db::getInstance()->getRow("SELECT * FROM `{$this->tableWithPrefix}` WHERE `id_state` = {$addr->id_state} AND `active` = 1"); if (!isset($row['id_post_zone'])) { return 0; } return $row['id_post_zone']; }
public function getRpZone($addr) { if (!Country::containsStates($addr->id_country)) { return 0; } if (!$addr->id_state) { return 0; } $row = RussianPost::$db->getRow("SELECT * FROM `{$this->tableWithPrefix}` WHERE `id_state` = {$addr->id_state} AND `active` = 1"); if (!isset($row['id_post_zone'])) { return 0; } return $row['id_post_zone']; //$row = $this->dbconn->getRow("SELECT "); }
private function getState() { $result = null; if ((int) $this->state == 0) { return $result; } if (Country::containsStates((int) $this->id_country)) { $state = new State((int) $this->id_state); if (!Validate::isLoadedObject($state)) { $result = null; } elseif (!$state->id_country == (int) $this->id_country) { $result = null; } else { $result = (int) $state->id; } } return $result; }
public function generate() { $this->tpl = $this->createTemplate($this->base_tpl); if (is_null($this->submit_action)) { $this->submit_action = 'submitAdd' . $this->table; } $this->context->controller->addJS(_PS_JS_DIR_ . 'form.js'); $categories = true; $color = true; $date = true; $tinymce = true; foreach ($this->fields_form as $fieldset_key => &$fieldset) { if (isset($fieldset['form']['input'])) { foreach ($fieldset['form']['input'] as $key => &$params) { // If the condition is not met, the field will not be displayed if (isset($params['condition']) && !$params['condition']) { unset($this->fields_form[$fieldset_key]['form']['input'][$key]); } switch ($params['type']) { case 'categories': if ($categories) { // Added Jquery plugin treeview (css and js files) $this->context->controller->addJqueryPlugin('treeview-categories'); // Added JS files $this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/plugins/treeview-categories/jquery.treeview-categories.async.js'); $this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/plugins/treeview-categories/jquery.treeview-categories.edit.js'); $this->context->controller->addJS(_PS_JS_DIR_ . 'admin-categories-tree.js'); if (isset($params['use_search']) && $params['use_search']) { $this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/plugins/autocomplete/jquery.autocomplete.js'); } $categories = false; } break; case 'color': if ($color) { // Added JS file $this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/plugins/jquery.colorpicker.js'); $color = false; } break; case 'date': if ($date) { $this->context->controller->addJqueryUI('ui.datepicker'); $date = false; } break; case 'textarea': if ($tinymce) { $iso = $this->context->language->iso_code; $this->tpl_vars['iso'] = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en'; $this->tpl_vars['path_css'] = _THEME_CSS_DIR_; $this->tpl_vars['ad'] = dirname($_SERVER['PHP_SELF']); $this->tpl_vars['tinymce'] = true; $this->context->controller->addJS(_PS_JS_DIR_ . 'tiny_mce/tiny_mce.js'); $this->context->controller->addJS(_PS_JS_DIR_ . 'tinymce.inc.js'); $tinymce = false; } break; case 'shop': $disable_shops = isset($params['disable_shared']) ? $params['disable_shared'] : false; $params['html'] = $this->renderAssoShop($disable_shops); if (Shop::getTotalShops(false) == 1) { unset($this->fields_form[$fieldset_key]['form']['input'][$key]); } break; } } } } $this->tpl->assign(array('title' => $this->title, 'toolbar_btn' => $this->toolbar_btn, 'show_toolbar' => $this->show_toolbar, 'toolbar_scroll' => $this->toolbar_scroll, 'submit_action' => $this->submit_action, 'firstCall' => $this->first_call, 'current' => $this->currentIndex, 'token' => $this->token, 'table' => $this->table, 'identifier' => $this->identifier, 'name_controller' => $this->name_controller, 'languages' => $this->languages, 'defaultFormLanguage' => $this->default_form_language, 'allowEmployeeFormLang' => $this->allow_employee_form_lang, 'form_id' => $this->id, 'fields' => $this->fields_form, 'fields_value' => $this->fields_value, 'required_fields' => $this->getFieldsRequired(), 'vat_number' => file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php'), 'module_dir' => _MODULE_DIR_, 'contains_states' => isset($this->fields_value['id_country']) && isset($this->fields_value['id_state']) ? Country::containsStates($this->fields_value['id_country']) : null)); return parent::generate(); }
public static function createSellerInfo($customer, $address, $seller_emp) { ${"GLOBALS"}["qjdqsmikhyx"] = "sellerinfo"; $yhqkobb = "id_sellerinfo"; global $cookie; ${${"GLOBALS"}["xgwqqivqgrf"]} = SellerInfo::getIdBSellerId($seller_emp->id); ${${"GLOBALS"}["qjdqsmikhyx"]} = new SellerInfo(${$yhqkobb}); $sellerinfo->id_customer = $customer->id; $sellerinfo->id_seller = $seller_emp->id; $sellerinfo->approved = intval(Configuration::get("AGILE_MS_SELLER_APPROVAL")) == 1 ? 0 : 1; if (Tools::getValue("signin")) { $qilskqt = "languages"; $sellerinfo->id_country = intval(Tools::getValue("id_country")); ${"GLOBALS"}["cjvrzut"] = "languages"; if (Country::containsStates($sellerinfo->id_country)) { $sellerinfo->id_state = intval(Tools::getValue("id_state")); } $sellerinfo->postcode = Tools::getValue("postcode"); $sellerinfo->phone = Tools::getValue("phone"); ${$qilskqt} = Language::getLanguages(false); foreach (${${"GLOBALS"}["cjvrzut"]} as ${${"GLOBALS"}["vdilblgqwe"]}) { ${"GLOBALS"}["egyhwy"] = "lang"; $parkrxwevda = "lang"; $sellerinfo->company[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = Tools::getValue("company_" . ${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]); $sellerinfo->city[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = Tools::getValue("city_" . ${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]); $sellerinfo->address1[${${"GLOBALS"}["egyhwy"]}["id_lang"]] = Tools::getValue("address1_" . ${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]); $sellerinfo->address2[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = Tools::getValue("address2_" . ${$parkrxwevda}["id_lang"]); } } else { $fuyjkdnrw = "languages"; $sellerinfo->id_country = $address->id_country; $sellerinfo->id_state = $address->id_state; $sellerinfo->postcode = $address->postcode; $sellerinfo->phone = $address->phone; ${${"GLOBALS"}["wcurgtbzth"]} = empty($address->company) ? $customer->firstname . " " . $customer->lastname : $address->company; ${$fuyjkdnrw} = Language::getLanguages(false); foreach (${${"GLOBALS"}["lchilkwh"]} as ${${"GLOBALS"}["vdilblgqwe"]}) { $sellerinfo->company[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = ${${"GLOBALS"}["wcurgtbzth"]}; $sellerinfo->city[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = $address->city; $sellerinfo->address1[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = $address->address1; $sellerinfo->address2[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = $address->address2; } } $sellerinfo->longitude = 0; $sellerinfo->latitude = 0; $sellerinfo->ams_custom_date1 = "1900-01-01"; $sellerinfo->ams_custom_date2 = "1900-01-01"; $sellerinfo->ams_custom_date3 = "1900-01-01"; $sellerinfo->ams_custom_date4 = "1900-01-01"; $sellerinfo->ams_custom_date5 = "1900-01-01"; if ($sellerinfo->save()) { if (Module::isInstalled("agilemultipleshop") && $sellerinfo->id_shop <= 0) { ${"GLOBALS"}["wbhwjpwmjrh"] = "shop_name"; ${"GLOBALS"}["plelmru"] = "shop_name"; include_once _PS_ROOT_DIR_ . "/modules/agilemultipleshop/agilemultipleshop.php"; ${${"GLOBALS"}["wbhwjpwmjrh"]} = $sellerinfo->company[$cookie->id_lang]; $jpxkuueptq = "shop_name"; if (empty(${$jpxkuueptq})) { ${${"GLOBALS"}["plelmru"]} = $seller_emp->firstname . "-" . $seller_emp->lastname; } $sellerinfo->id_shop = AgileMultipleShop::create_new_shop($sellerinfo->id_seller, $sellerinfo->company[$cookie->id_lang]); $sellerinfo->update(); } } ${"GLOBALS"}["ciniqzqxiff"] = "sellerinfo"; return ${${"GLOBALS"}["ciniqzqxiff"]}; }
public function generate() { $this->tpl = $this->createTemplate($this->base_tpl); if (is_null($this->submit_action)) { $this->submit_action = 'submitAdd' . $this->table; } $categories = true; $color = true; $date = true; $tinymce = true; $textarea_autosize = true; $file = true; foreach ($this->fields_form as $fieldset_key => &$fieldset) { if (isset($fieldset['form']['tabs'])) { $tabs[] = $fieldset['form']['tabs']; } if (isset($fieldset['form']['input'])) { foreach ($fieldset['form']['input'] as $key => &$params) { // If the condition is not met, the field will not be displayed if (isset($params['condition']) && !$params['condition']) { unset($this->fields_form[$fieldset_key]['form']['input'][$key]); } switch ($params['type']) { case 'select': $field_name = (string) $params['name']; // If multiple select check that 'name' field is suffixed with '[]' if (isset($params['multiple']) && $params['multiple'] && stripos($field_name, '[]') === false) { $params['name'] .= '[]'; } break; case 'categories': if ($categories) { if (!isset($params['tree']['id'])) { throw new PrestaShopException('Id must be filled for categories tree'); } $tree = new HelperTreeCategories($params['tree']['id'], isset($params['tree']['title']) ? $params['tree']['title'] : null); if (isset($params['name'])) { $tree->setInputName($params['name']); } if (isset($params['tree']['selected_categories'])) { $tree->setSelectedCategories($params['tree']['selected_categories']); } if (isset($params['tree']['disabled_categories'])) { $tree->setDisabledCategories($params['tree']['disabled_categories']); } if (isset($params['tree']['root_category'])) { $tree->setRootCategory($params['tree']['root_category']); } if (isset($params['tree']['use_search'])) { $tree->setUseSearch($params['tree']['use_search']); } if (isset($params['tree']['use_checkbox'])) { $tree->setUseCheckBox($params['tree']['use_checkbox']); } if (isset($params['tree']['set_data'])) { $tree->setData($params['tree']['set_data']); } $this->context->smarty->assign('categories_tree', $tree->render()); $categories = false; } break; case 'file': $uploader = new HelperUploader(); $uploader->setId(isset($params['id']) ? $params['id'] : null); $uploader->setName($params['name']); $uploader->setUrl(isset($params['url']) ? $params['url'] : null); $uploader->setMultiple(isset($params['multiple']) ? $params['multiple'] : false); $uploader->setUseAjax(isset($params['ajax']) ? $params['ajax'] : false); $uploader->setMaxFiles(isset($params['max_files']) ? $params['max_files'] : null); if (isset($params['files']) && $params['files']) { $uploader->setFiles($params['files']); } elseif (isset($params['image']) && $params['image']) { // Use for retrocompatibility $uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_IMAGE, 'image' => isset($params['image']) ? $params['image'] : null, 'size' => isset($params['size']) ? $params['size'] : null, 'delete_url' => isset($params['delete_url']) ? $params['delete_url'] : null))); } if (isset($params['file']) && $params['file']) { // Use for retrocompatibility $uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_FILE, 'size' => isset($params['size']) ? $params['size'] : null, 'delete_url' => isset($params['delete_url']) ? $params['delete_url'] : null, 'download_url' => isset($params['file']) ? $params['file'] : null))); } if (isset($params['thumb']) && $params['thumb']) { // Use for retrocompatibility $uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_IMAGE, 'image' => isset($params['thumb']) ? '<img src="' . $params['thumb'] . '" alt="' . (isset($params['title']) ? $params['title'] : '') . '" title="' . (isset($params['title']) ? $params['title'] : '') . '" />' : null))); } $uploader->setTitle(isset($params['title']) ? $params['title'] : null); $params['file'] = $uploader->render(); break; case 'color': if ($color) { // Added JS file $this->context->controller->addJqueryPlugin('colorpicker'); $color = false; } break; case 'date': if ($date) { $this->context->controller->addJqueryUI('ui.datepicker'); $date = false; } break; case 'textarea': if ($tinymce) { $iso = $this->context->language->iso_code; $this->tpl_vars['iso'] = file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en'; $this->tpl_vars['path_css'] = _THEME_CSS_DIR_; $this->tpl_vars['ad'] = __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_); $this->tpl_vars['tinymce'] = true; $this->context->controller->addJS(_PS_JS_DIR_ . 'tiny_mce/tiny_mce.js'); $this->context->controller->addJS(_PS_JS_DIR_ . 'admin/tinymce.inc.js'); $tinymce = false; } if ($textarea_autosize) { $this->context->controller->addJqueryPlugin('autosize'); $textarea_autosize = false; } break; case 'shop': $disable_shops = isset($params['disable_shared']) ? $params['disable_shared'] : false; $params['html'] = $this->renderAssoShop($disable_shops); if (Shop::getTotalShops(false) == 1) { if (isset($this->fields_form[$fieldset_key]['form']['force']) && !$this->fields_form[$fieldset_key]['form']['force'] || !isset($this->fields_form[$fieldset_key]['form']['force'])) { unset($this->fields_form[$fieldset_key]['form']['input'][$key]); } } break; } } } } $this->tpl->assign(array('title' => $this->title, 'toolbar_btn' => $this->toolbar_btn, 'show_toolbar' => $this->show_toolbar, 'toolbar_scroll' => $this->toolbar_scroll, 'submit_action' => $this->submit_action, 'firstCall' => $this->first_call, 'current' => $this->currentIndex, 'token' => $this->token, 'table' => $this->table, 'identifier' => $this->identifier, 'name_controller' => $this->name_controller, 'languages' => $this->languages, 'current_id_lang' => $this->context->language->id, 'defaultFormLanguage' => $this->default_form_language, 'allowEmployeeFormLang' => $this->allow_employee_form_lang, 'form_id' => $this->id, 'tabs' => isset($tabs) ? $tabs : null, 'fields' => $this->fields_form, 'fields_value' => $this->fields_value, 'required_fields' => $this->getFieldsRequired(), 'vat_number' => Module::isInstalled('vatnumber') && file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php'), 'module_dir' => _MODULE_DIR_, 'base_url' => $this->context->shop->getBaseURL(), 'contains_states' => isset($this->fields_value['id_country']) && isset($this->fields_value['id_state']) ? Country::containsStates($this->fields_value['id_country']) : null, 'show_cancel_button' => $this->show_cancel_button, 'back_url' => $this->back_url)); return parent::generate(); }
<?php defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); require_once dirname(__FILE__) . '../../config/config.inc.php'; require_once dirname(__FILE__) . '../../init.php'; $data = array(); $id_country = Country::getIdByName(1, Tools::getValue('country')); $contain_state = Country::containsStates($id_country); if ($contain_state) { $states = State::getStatesByIdCountry($id_country); $data['states'] = $states; } $data['id_country'] = $id_country; $data['contain_state'] = $contain_state; echo json_encode($data);
/** * Set customer address (when not logged in) * Used to create user address with PayPal account information */ function setCustomerAddress($ppec, $customer, $id = null) { $address = new Address($id); $address->id_country = Country::getByIso($ppec->result['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE']); if ($id == null) { $address->alias = 'Paypal_Address'; } $address->lastname = $customer->lastname; $address->firstname = $customer->firstname; $address->address1 = $ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET']; if (isset($ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET2'])) { $address->address2 = $ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET2']; } $address->city = $ppec->result['PAYMENTREQUEST_0_SHIPTOCITY']; if (Country::containsStates($address->id_country)) { $address->id_state = (int) State::getIdByIso($ppec->result['PAYMENTREQUEST_0_SHIPTOSTATE'], $address->id_country); } $address->postcode = $ppec->result['PAYMENTREQUEST_0_SHIPTOZIP']; if (isset($ppec->result['PAYMENTREQUEST_0_SHIPTOPHONENUM'])) { $address->phone = $ppec->result['PAYMENTREQUEST_0_SHIPTOPHONENUM']; } $address->id_customer = $customer->id; return $address; }
public function displayForm($isMainTab = true) { global $currentIndex, $cookie; parent::displayForm(); if (!($obj = $this->loadObject(true))) { return; } echo ' <form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post"> ' . ((int) $obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . (int) $obj->id . '" />' : '') . ' ' . (($id_order = (int) Tools::getValue('id_order')) ? '<input type="hidden" name="id_order" value="' . (int) $id_order . '" />' : '') . ' ' . (($address_type = (int) Tools::getValue('address_type')) ? '<input type="hidden" name="address_type" value="' . (int) $address_type . '" />' : '') . ' ' . (Tools::getValue('realedit') ? '<input type="hidden" name="realedit" value="1" />' : '') . ' <fieldset> <legend><img src="../img/admin/contact.gif" alt="" />' . $this->l('Addresses') . '</legend>'; switch ($this->addressType) { case 'manufacturer': echo '<label>' . $this->l('Choose manufacturer') . '</label> <div class="margin-form">'; $manufacturers = Manufacturer::getManufacturers(); echo '<select name="id_manufacturer">'; if (!sizeof($manufacturers)) { echo '<option value="0">' . $this->l('No manufacturer available') . ' </option>'; } foreach ($manufacturers as $manufacturer) { echo '<option value="' . (int) $manufacturer['id_manufacturer'] . '"' . ($this->getFieldValue($obj, 'id_manufacturer') == $manufacturer['id_manufacturer'] ? ' selected="selected"' : '') . '>' . $manufacturer['name'] . ' </option>'; } echo '</select>'; echo '</div>'; echo '<input type="hidden" name="alias" value="manufacturer">'; break; case 'customer': default: if ($obj->id) { $customer = new Customer($obj->id_customer); $tokenCustomer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee); echo ' <label>' . $this->l('Customer') . '</label> <div class="margin-form"><a style="display: block; padding-top: 4px;" href="?tab=AdminCustomers&id_customer=' . $customer->id . '&viewcustomer&token=' . $tokenCustomer . '">' . $customer->lastname . ' ' . $customer->firstname . ' (' . $customer->email . ')</a></div> <input type="hidden" name="id_customer" value="' . $customer->id . '" /> <input type="hidden" name="email" value="' . $customer->email . '" />'; } else { echo '<label>' . $this->l('Customer e-mail') . '</label> <div class="margin-form"> <input type="text" size="33" name="email" value="' . htmlentities(Tools::getValue('email'), ENT_COMPAT, 'UTF-8') . '" style="text-transform: lowercase;" /> <sup>*</sup> </div>'; } echo ' <label for="dni">' . $this->l('Identification Number') . '</label> <div class="margin-form"> <input type="text" name="dni" id="dni" value="' . htmlentities($this->getFieldValue($obj, 'dni'), ENT_COMPAT, 'UTF-8') . '" /> <p>' . $this->l('DNI / NIF / NIE') . '</p> </div>'; echo '<label>' . $this->l('Alias') . '</label> <div class="margin-form"> <input type="text" size="33" name="alias" value="' . htmlentities($this->getFieldValue($obj, 'alias'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; break; } $addresses_fields = $this->processAddressFormat(); $addresses_fields = $addresses_fields["dlv_all_fields"]; // we use delivery address foreach ($addresses_fields as $addr_field_item) { if ($addr_field_item == 'company') { if ($this->addressType != 'manufacturer') { echo '<label>' . $this->l('Company') . '</label> <div class="margin-form"> <input type="text" size="33" name="company" value="' . htmlentities($this->getFieldValue($obj, 'company'), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; if ((Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(_PS_MODULE_DIR_ . 'vatnumber/vatnumber.php')) && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT'))) { echo '<div id="vat_area" style="display: visible">'; } elseif (Configuration::get('VATNUMBER_MANAGEMENT')) { echo '<div id="vat_area" style="display: hidden">'; } else { echo '<div style="display: none;">'; } echo '<label>' . $this->l('VAT number') . '</label> <div class="margin-form"> <input type="text" size="33" name="vat_number" value="' . htmlentities($this->getFieldValue($obj, 'vat_number'), ENT_COMPAT, 'UTF-8') . '" /> </div> </div>'; } } elseif ($addr_field_item == 'lastname') { echo ' <label>' . $this->l('Last name') . '</label> <div class="margin-form"> <input type="text" size="33" name="lastname" value="' . htmlentities($this->getFieldValue($obj, 'lastname'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer"> </span></span> </div>'; } elseif ($addr_field_item == 'firstname') { echo ' <label>' . $this->l('First name') . '</label> <div class="margin-form"> <input type="text" size="33" name="firstname" value="' . htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer"> </span></span> </div>'; } elseif ($addr_field_item == 'address1') { echo ' <label>' . $this->l('Address') . '</label> <div class="margin-form"> <input type="text" size="33" name="address1" value="' . htmlentities($this->getFieldValue($obj, 'address1'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup> </div>'; } elseif ($addr_field_item == 'address2') { echo ' <label>' . $this->l('Address') . ' (2)</label> <div class="margin-form"> <input type="text" size="33" name="address2" value="' . htmlentities($this->getFieldValue($obj, 'address2'), ENT_COMPAT, 'UTF-8') . '" /> </div>'; } elseif ($addr_field_item == 'postcode') { echo ' <label>' . $this->l('Postcode/ Zip Code') . '</label> <div class="margin-form"> <input type="text" size="33" name="postcode" value="' . htmlentities($this->getFieldValue($obj, 'postcode'), ENT_COMPAT, 'UTF-8') . '" /> </div>'; } elseif ($addr_field_item == 'city') { echo ' <label>' . $this->l('City') . '</label> <div class="margin-form"> <input type="text" size="33" name="city" value="' . htmlentities($this->getFieldValue($obj, 'city'), ENT_COMPAT, 'UTF-8') . '" style="text-transform: uppercase;" /> <sup>*</sup> </div>'; } elseif ($addr_field_item == 'country' || $addr_field_item == 'Country:name') { echo ' <label>' . $this->l('Country') . '</label> <div class="margin-form"> <select name="id_country" id="id_country" />'; $selectedCountry = $this->getFieldValue($obj, 'id_country'); foreach ($this->countriesArray as $id_country => $name) { echo ' <option value="' . $id_country . '"' . ((!$selectedCountry and Configuration::get('PS_COUNTRY_DEFAULT') == $id_country) ? ' selected="selected"' : ($selectedCountry == $id_country ? ' selected="selected"' : '')) . '>' . $name . '</option>'; } echo ' </select> <sup>*</sup> </div>'; echo ' <div id="contains_states" ' . (!Country::containsStates((int) $selectedCountry) ? 'style="display:none;"' : '') . '> <label>' . $this->l('State') . '</label> <div class="margin-form"> <select name="id_state" id="id_state"> </select> <sup>*</sup> </div> </div>'; $id_country_ajax = (int) $this->getFieldValue($obj, 'id_country'); echo ' <script type="text/javascript"> $(document).ready(function(){ ajaxStates (); $(\'#id_country\').change(function() { ajaxStates (); }); function ajaxStates () { $.ajax({ url: "ajax.php", cache: false, data: "ajaxStates=1&id_country="+$(\'#id_country\').val()+"&id_state="+$(\'#id_state\').val(), success: function(html) { if (html == \'false\') { $("#contains_states").fadeOut(); $(\'#id_state option[value=0]\').attr("selected", "selected"); } else { $("#id_state").html(html); $("#contains_states").fadeIn(); $(\'#id_state option[value=' . (int) $obj->id_state . ']\').attr("selected", "selected"); } } }); '; if (file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php')) { echo ' $.ajax({ type: "GET", url: "' . _MODULE_DIR_ . 'vatnumber/ajax.php?id_country="+$(\'#id_country\').val(), success: function(isApplicable) { if (isApplicable == 1) $(\'#vat_area\').show(); else $(\'#vat_area\').hide(); } });'; } echo ' }; }); </script>'; } } // End foreach echo ' <label>' . $this->l('Home phone') . '</label> <div class="margin-form"> <input type="text" size="33" name="phone" value="' . htmlentities($this->getFieldValue($obj, 'phone'), ENT_COMPAT, 'UTF-8') . '" /> </div>'; echo ' <label>' . $this->l('Mobile phone') . '</label> <div class="margin-form"> <input type="text" size="33" name="phone_mobile" value="' . htmlentities($this->getFieldValue($obj, 'phone_mobile'), ENT_COMPAT, 'UTF-8') . '" /> </div>'; echo ' <label>' . $this->l('Other') . '</label> <div class="margin-form"> <textarea name="other" cols="36" rows="4">' . htmlentities($this->getFieldValue($obj, 'other'), ENT_COMPAT, 'UTF-8') . '</textarea> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; echo ' <div class="margin-form"> <input type="submit" value="' . $this->l(' Save ') . '" name="submitAdd' . $this->table . '" class="button" /> </div> <div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div> </fieldset>'; echo ' </form>'; }
protected function prepareLabelInfo() { $this->_dhl_label_infos = array(); $this->_dhl_label_infos['ShippingType'] = Tools::getValue('shipping_type'); $this->_dhl_label_infos['Contents'] = Tools::getValue('contents'); $this->_dhl_label_infos['Shipper']['CompanyName'] = htmlspecialchars(trim(Tools::getValue('shop_name'))); $this->_dhl_label_infos['Shipper']['PersonName'] = htmlspecialchars(trim(Tools::getValue('attention_name'))); $this->_dhl_label_infos['Shipper']['PhoneNumber'] = htmlspecialchars(trim(Tools::getValue('phone_number'))); $this->_dhl_label_infos['Shipper']['AddressLine1'] = htmlspecialchars(trim(Tools::getValue('address1'))); $this->_dhl_label_infos['Shipper']['AddressLine2'] = htmlspecialchars(trim(Tools::getValue('address2'))); $this->_dhl_label_infos['Shipper']['City'] = htmlspecialchars(trim(Tools::getValue('shop_city'))); $shop_country = new Country(trim(Tools::getValue('shop_country'))); $this->_dhl_label_infos['Shipper']['CountryCode'] = $shop_country->iso_code; $this->_dhl_label_infos['Shipper']['CountryName'] = $shop_country->name[$this->context->language->id]; $shop_state = new State(trim(Tools::getValue('shop_state'))); $this->_dhl_label_infos['Shipper']['Division'] = Country::containsStates($shop_country->id) ? $shop_state->iso_code : ''; $this->_dhl_label_infos['Shipper']['PostalCode'] = htmlspecialchars(trim(Tools::getValue('shop_postal'))); $order = new Order(Tools::getValue('id_order')); $address = new Address($order->id_address_delivery); $customerState = $address->id_state ? new State($address->id_state) : NULL; $customerCountry = new Country($address->id_country); $this->_dhl_label_infos['Consignee']['PersonName'] = htmlspecialchars(Tools::getValue('shipto_attention_name', '')); $shipto_company = htmlspecialchars(Tools::getValue('shipto_company', '')); $this->_dhl_label_infos['Consignee']['CompanyName'] = $shipto_company == '' ? $this->_dhl_label_infos['Consignee']['PersonName'] : $shipto_company; $this->_dhl_label_infos['Consignee']['PhoneNumber'] = htmlspecialchars(Tools::getValue('shipto_phone', '')); $this->_dhl_label_infos['Consignee']['AddressLine1'] = htmlspecialchars(Tools::getValue('shipto_address1', '')); $this->_dhl_label_infos['Consignee']['AddressLine2'] = htmlspecialchars(Tools::getValue('shipto_address2', '')); $this->_dhl_label_infos['Consignee']['City'] = htmlspecialchars(Tools::getValue('shipto_city', '')); $shipto_state = Tools::getValue('shipto_state') != '' ? new State(Tools::getValue('shipto_state')) : (is_object($customerState) ? $customerState : NULL); $shipto_country = Tools::getValue('shipto_country') != '' ? new Country(Tools::getValue('shipto_country')) : $customerCountry; $this->_dhl_label_infos['Consignee']['Division'] = Country::containsStates($shipto_country->id) ? $shipto_state ? htmlspecialchars($shipto_state->iso_code) : '' : ''; $this->_dhl_label_infos['Consignee']['CountryCode'] = htmlspecialchars($shipto_country->iso_code); $this->_dhl_label_infos['Consignee']['CountryName'] = htmlspecialchars($shipto_country->name[$this->context->language->id]); $this->_dhl_label_infos['Consignee']['PostalCode'] = htmlspecialchars(Tools::getValue('shipto_postcode', '')); /** GET CURRENCY */ if ($this->_dhl_currency_used == 'BILLCU') { $currency = new Currency($order->id_currency); } elseif ($this->_dhl_currency_used == 'PULCL' && $shipto_country->id_currency) { $currency = new Currency($order->id_currency); } elseif ($this->_dhl_currency_used == 'BASEC') { $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); } else { $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); } $this->_dhl_label_infos['Currency_ISO'] = $currency->iso_code; /** BOX INFORMATION */ /** VERIFY IF PACKAGE IS DUTIABLE */ $EUCountries = $this->EUCountries(); if ($this->_dhl_label_infos['Consignee']['CountryCode'] != $this->_dhl_label_infos['Shipper']['CountryCode'] && (Tools::getValue('Dutiable') == 'Y' || Tools::getValue('ContentType') == 'Non-Document')) { if (in_array($this->_dhl_label_infos['Shipper']['CountryCode'], $EUCountries) === true) { if (in_array($this->_dhl_label_infos['Consignee']['CountryCode'], $EUCountries) === true) { $this->_dhl_label_infos['Dutiable'] = 'N'; } else { $this->_dhl_label_infos['Dutiable'] = 'Y'; } } else { $this->_dhl_label_infos['Dutiable'] = 'Y'; } } else { $this->_dhl_label_infos['Dutiable'] = 'N'; } /** DUTIABLE INFORMATION */ $this->_dhl_label_infos['DutyPayer'] = Tools::getValue('DutyPayer'); if (Tools::getValue('DutyPayer') == 'S') { $this->_dhl_label_infos['DutyPayerAccount'] = $this->_dhl_account_number; } else { $this->_dhl_label_infos['DutyPayerAccount'] = Tools::getValue('DutyPayerAccount'); } $this->_dhl_label_infos['DeclaredValue'] = Tools::getValue('DeclaredValue'); $this->_dhl_label_infos['DeclaredCurrency'] = Tools::getValue('DeclaredCurrency'); $this->_dhl_label_infos['ScheduleB'] = Tools::getValue('ScheduleB'); $this->_dhl_label_infos['ExportLicense'] = Tools::getValue('ExportLicense'); $this->_dhl_label_infos['ShipperEIN'] = Tools::getValue('ShipperEIN'); $this->_dhl_label_infos['ShipperIDType'] = Tools::getValue('ShipperIDType'); $this->_dhl_label_infos['ConsigneeIDType'] = Tools::getValue('ConsigneeIDType'); $this->_dhl_label_infos['ImportLicense'] = Tools::getValue('ImportLicense'); $this->_dhl_label_infos['ConsigneeEIN'] = Tools::getValue('ConsigneeEIN'); $this->_dhl_label_infos['TermsOfTrade'] = Tools::getValue('TermsOfTrade'); /** SETTINGS */ $this->_dhl_label_infos['LabelImageFormat'] = Tools::getValue('label_format'); $this->_dhl_label_infos['ShipmentReference'] = Tools::getValue('ShipmentReference'); if ($this->_dhl_label_infos['Dutiable'] == 'Y') { $this->_dhl_label_infos['ShippingType'] = $this->dutiableCarrierMethods($this->_dhl_label_infos['ShippingType']); } }
public static function getCsvDefaults($serviceId) { $sql = ' SELECT * FROM `' . _DB_PREFIX_ . 'moussiqfree_service` WHERE `id_moussiqfree_service` = ' . (int) $serviceId; if (!($result = Db::getInstance()->getRow($sql))) { return false; } $configuration = Configuration::getMultiple(array('EXPORTFREE_COUNTRY', 'EXPORTFREE_STATE', 'EXPORTFREE_CARRIER', 'EXPORTFREE_STORE', 'EXPORTFREE_SHOP', 'EXPORTFREE_GROUP', 'EXPORTFREE_DELIMITER', 'EXPORTFREE_HEADER', 'EXPORTFREE_INACTIVE', 'EXPORTFREE_LANGUAGE', 'EXPORTFREE_ENCLOSURE')); $data = $result; $data['id_country'] = (int) self::findCorrectDefault($result['id_country'], $configuration['EXPORTFREE_COUNTRY']); $data['id_state'] = (int) self::findCorrectDefault($result['id_state'], $configuration['EXPORTFREE_STATE']); $data['id_carrier'] = (int) self::findCorrectDefault($result['id_carrier'], $configuration['EXPORTFREE_CARRIER']); $data['id_store'] = (int) self::findCorrectDefault($result['id_store'], $configuration['EXPORTFREE_STORE']); $data['id_shop'] = (int) self::findCorrectDefault($result['id_shop'], $configuration['EXPORTFREE_SHOP']); $data['id_group'] = (int) self::findCorrectDefault($result['id_group'], $configuration['EXPORTFREE_GROUP']); $data['header'] = (int) self::findCorrectDefault($result['header'], $configuration['EXPORTFREE_HEADER']); $data['id_lang'] = (int) self::findCorrectDefault($result['id_lang'], $configuration['EXPORTFREE_LANGUAGE']); $data['export_inactive'] = self::findCorrectDefault($result['export_inactive'], $configuration['EXPORTFREE_INACTIVE'], true); $data['name'] = pSQL($result['name']); $data['template'] = ExportTools::jsonDecode(addcslashes(base64_decode($result['template']), "\\")); if (!Country::containsStates($data['id_country'])) { $data['id_state'] = false; } return $data; }
public function createPredefServices($dir = 'templates_predef') { // create predefined services from templates_predef directory $cdir = dirname(__FILE__); $sdir = dir($cdir . '/' . $dir); while (($item = $sdir->read()) !== false) { if (!is_dir($cdir . '/' . $dir . '/' . $item)) { $file = $cdir . '/' . $dir . '/' . $item; $extension = strrchr($file, '.'); if ($extension == '.mtpl') { $template = file($file, FILE_SKIP_EMPTY_LINES); $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT'); $defaultCarrier = 0; $defaultCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT'); $defaultState = 0; $defaultCondition = 'new:used:refurbished'; $defaultStore = (int) Db::getInstance()->getValue('SELECT `id_store` FROM `' . _DB_PREFIX_ . 'store`'); $defaultGroup = (int) Db::getInstance()->getValue('SELECT `id_group` FROM `' . _DB_PREFIX_ . 'group`'); $engine = 'ExportCSV'; if (Country::containsStates($defaultCountry)) { $states = State::getStatesByIdCountry($defaultCountry); if (sizeof($states)) { $defaultState = (int) $states[0]['id_state']; } } $carriers = Carrier::getCarriers($defaultLanguage, true); if ($carriers && sizeof($carriers)) { $defaultCarrier = (int) $carriers[0]['id_carrier']; } $additionalProperties = array('id_lang' => $defaultLanguage, 'id_country' => $defaultCountry, 'id_state' => $defaultState, 'id_carrier' => $defaultCarrier, 'id_store' => $defaultStore, 'id_group' => $defaultGroup, 'export_engine' => $engine, 'condition' => $defaultCondition); if (sizeof($template) > 0) { $obj = new MoussiqFreeService(); foreach ($template as $line) { $line = explode(':', $line); $field = pSQL(base64_decode($line[0])); if ($field == 'template') { $line[1] = base64_decode($line[1]); } $value = base64_decode($line[1]); //print_r(pSQL(base64_decode($line[1]))); //print_r($value); if (property_exists($obj, $field)) { $obj->{$field} = $value; } foreach ($additionalProperties as $prop => $val) { if (property_exists($obj, $prop)) { $obj->{$prop} = $val; } } } if (!$obj->save()) { return false; } } } } } }
protected function createServiceFromTemplate($file) { if (empty($file['name'])) { $this->_errors[] = $this->l('Please select a file from your computer'); return false; } $extension = strrchr($file['name'], '.'); if ($extension == '.gz' && !function_exists('gzopen')) { $this->_errors[] = $this->l('Your server does not support gz functions, please unpack the file locally and upload again'); return false; } if ($extension == '.mtpl') { $template = file($file['tmp_name'], FILE_SKIP_EMPTY_LINES); } elseif ($extension == '.gz') { $template = gzfile($file['tmp_name']); } else { $this->_errors[] = $this->l('Unknown file format'); return false; } $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT'); $defaultCarrier = 0; $defaultCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT'); $defaultState = 0; $defaultCondition = 'new:used:refurbished'; $defaultStore = (int) Db::getInstance()->getValue('SELECT `id_store` FROM `' . _DB_PREFIX_ . 'store`'); $defaultGroup = (int) Db::getInstance()->getValue('SELECT `id_group` FROM `' . _DB_PREFIX_ . 'group`'); $engines = self::getExportEnginesForSetup(); if (!sizeof($engines)) { $this->_errors[] = $this->l('Please add export engines first'); return false; } $engine = $engines[0]['engine']; if (Country::containsStates($defaultCountry)) { $states = State::getStatesByIdCountry($defaultCountry); if (sizeof($states)) { $defaultState = (int) $states[0]['id_state']; } } $carriers = Carrier::getCarriers($defaultLanguage, true); if ($carriers && sizeof($carriers)) { $defaultCarrier = (int) $carriers[0]['id_carrier']; } $additionalProperties = array('id_lang' => $defaultLanguage, 'id_country' => $defaultCountry, 'id_state' => $defaultState, 'id_carrier' => $defaultCarrier, 'id_store' => $defaultStore, 'export_engine' => $engine, 'condition' => $defaultCondition); if (sizeof($template) > 0) { $obj = new $this->className(); foreach ($template as $line) { $line = explode(':', $line); $field = pSQL(base64_decode($line[0])); if ($field == 'template') { $line[1] = base64_decode($line[1]); } $value = base64_decode($line[1]); //print_r(pSQL(base64_decode($line[1]))); //print_r($value); if (property_exists($obj, $field)) { $obj->{$field} = $value; } foreach ($additionalProperties as $prop => $val) { if (property_exists($obj, $prop)) { $obj->{$prop} = $val; } } } if (!$obj->save()) { $this->_errors[] = $this->l('A service could not be added, an error occured during an attemt to copy file data into module'); return false; } } }