diff --git a/adm/scaddressedit.php b/adm/scaddressedit.php index 1968df6c..e9252935 100644 --- a/adm/scaddressedit.php +++ b/adm/scaddressedit.php @@ -3,32 +3,56 @@ require_once(dirname(__FILE__).'/../config/config.inc.php'); require_once(dirname(__FILE__).'/init.php'); if($cookie->isLoggedBack() && $cart = Tools::getValue('id_cart')) { -$address = Db::getInstance()->ExecuteS('SELECT * FROM ps_socolissimo_delivery_info WHERE id_cart = '.pSQL(intval(Tools::getValue('id_cart')))); -if(count($address) > 0) { - $address = $address[0]; +$address = Db::getInstance()->getRow(' + SELECT * + FROM `'._DB_PREFIX_.'socolissimo_delivery_info` + WHERE id_cart = '.pSQL(intval(Tools::getValue('id_cart'))).' +'); +if($address) { + if(Tools::getValue('getPR') + && ($h_xcoords = (float) Tools::getValue('h_xcoords')) + && ($h_ycoords = (float) Tools::getValue('h_ycoords'))) { + $pr_list = array(); + // ± 10km radius + header('Content-Type: text/json'); + echo json_encode(Db::getInstance()->ExecuteS(' + SELECT * + FROM `'._DB_PREFIX_.'lapostews_pr` + WHERE `ycoords` >= '.(float) $h_ycoords.' - 0.02 + AND `ycoords` <= '.(float) $h_ycoords.' + 0.02 + AND `xcoords` >= '.(float) $h_xcoords.' - 0.01 + AND `xcoords` <= '.(float) $h_xcoords.' + 0.01 + ')); + exit; + } + if(isset($_POST['submitSC'])) { - Db::getInstance()->Execute('UPDATE ps_socolissimo_delivery_info SET - delivery_mode = "'.pSQL(Tools::getValue('delivery_mode', '')).'", - prname = "'.pSQL(Tools::getValue('prname', '')).'", - prfirstname = "'.pSQL(Tools::getValue('prfirstname', '')).'", - cecompanyname = "'.pSQL(Tools::getValue('cecompanyname', '')).'", - prcompladress = "'.pSQL(Tools::getValue('prcompladress', '')).'", - pradress1 = "'.pSQL(Tools::getValue('pradress1', '')).'", - pradress2 = "'.pSQL(Tools::getValue('pradress2', '')).'", - pradress3 = "'.pSQL(Tools::getValue('pradress3', '')).'", - pradress4 = "'.pSQL(Tools::getValue('pradress4', '')).'", - przipcode = "'.pSQL(Tools::getValue('przipcode', '')).'", - prtown = "'.pSQL(Tools::getValue('prtown', '')).'", - cephonenumber = "'.pSQL(Tools::getValue('cephonenumber', '')).'", - ceemail = "'.pSQL(Tools::getValue('ceemail', '')).'", - cedeliveryinformation = "'.pSQL(Tools::getValue('cedeliveryinformation', '')).'", - cedoorcode1 = "'.pSQL(Tools::getValue('cedoorcode1', '')).'", - cedoorcode2 = "'.pSQL(Tools::getValue('cedoorcode2', '')).'", - prid = "'.pSQL(Tools::getValue('prid', '')).'" - WHERE id_cart = '.pSQL(intval(Tools::getValue('id_cart')))); - } + Db::getInstance()->Execute('UPDATE ps_socolissimo_delivery_info SET + delivery_mode = "'.pSQL(Tools::getValue('delivery_mode', '')).'", + prname = "'.pSQL(Tools::getValue('prname', '')).'", + prfirstname = "'.pSQL(Tools::getValue('prfirstname', '')).'", + cecompanyname = "'.pSQL(Tools::getValue('cecompanyname', '')).'", + cename = "'.pSQL(Tools::getValue('cename', '')).'", + cefirstname = "'.pSQL(Tools::getValue('cefirstname', '')).'", + prcompladress = "'.pSQL(Tools::getValue('prcompladress', '')).'", + pradress1 = "'.pSQL(Tools::getValue('pradress1', '')).'", + pradress2 = "'.pSQL(Tools::getValue('pradress2', '')).'", + pradress3 = "'.pSQL(Tools::getValue('pradress3', '')).'", + pradress4 = "'.pSQL(Tools::getValue('pradress4', '')).'", + przipcode = "'.pSQL(Tools::getValue('przipcode', '')).'", + prtown = "'.pSQL(Tools::getValue('prtown', '')).'", + cephonenumber = "'.pSQL(Tools::getValue('cephonenumber', '')).'", + ceemail = "'.pSQL(Tools::getValue('ceemail', '')).'", + cedeliveryinformation = "'.pSQL(Tools::getValue('cedeliveryinformation', '')).'", + cedoorcode1 = "'.pSQL(Tools::getValue('cedoorcode1', '')).'", + cedoorcode2 = "'.pSQL(Tools::getValue('cedoorcode2', '')).'", + prid = "'.pSQL(Tools::getValue('prid', '')).'" + WHERE id_cart = '.pSQL(intval(Tools::getValue('id_cart')))); + } ?> + + - + + + + +

- 'Livraison à domicile (DOM)', 'BPR' => 'Livraison en Bureau de Poste (BPR)', 'A2P' => 'Livraison Commerce de proximité (A2P)', 'MRL' => 'Livraison Commerce de proximité (MRL)', 'CMT' => 'Livraison Commerce (CMT)', @@ -67,77 +136,336 @@ p {

- - -

-

- - -

-

- - -

-

- - -

-

- - -

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

- - -

-

- - -

-

- - -

-

- - -

-

- - -

-

- - -

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

-

- - -

-

- - -

-

- - -

-

- - -

-

- - -

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+ + + +

Livraison hors domicile - Recherche d\'un point de retrait

+
+ +
'; +?> Il n\'y a pas de sous catégorie

'; }*/ - // foreach($categories_vp as $category) { - // if($category['id_category'] != $id_category){ - // echo ''; - // echo ' '; - // }else{ - // echo ''; - // echo ' '; - // } - // echo '
'; - // } - echo '

'; - - echo ""; - } - - echo ' - - - '; - - if((int)$this->_category->id_parent == 1){ - echo '
'; - echo '

Ordonner les produits des braderies

'; - echo '

'; - echo '

'.$this->l('Order by sub category positions and product name').'

'; - } elseif ((int)$this->_category->id_parent > 1) { - echo '
'; - echo '

Ordonner les produits des braderies

'; - echo '

'; - echo '

'.$this->l('Order by product name').'

'; - } - - echo ''; - if (isset($this->_includeTab) AND sizeof($this->_includeTab)) - echo '

'; - - } - - - /** - * Build a categories tree - * - * @param array $indexedCategories Array with categories where product is indexed (in order to check checkbox) - * @param array $categories Categories to list - * @param array $current Current category - * @param integer $id_category Current category id - */ - public static function recurseCategoryForInclude($id_obj, $indexedCategories, $categories, $current, $id_category = 1, $id_category_default = NULL, $has_suite = array()) - { - global $done; - static $irow; - - if (!isset($done[$current['infos']['id_parent']])) - $done[$current['infos']['id_parent']] = 0; - $done[$current['infos']['id_parent']] += 1; - - $todo = sizeof($categories[$current['infos']['id_parent']]); - $doneC = $done[$current['infos']['id_parent']]; - - $level = $current['infos']['level_depth'] + 1; - - echo ' - - - - - - '.$id_category.' - - '; - for ($i = 2; $i < $level; $i++) - echo ''; - echo '   - - '; - - if ($level > 1) - $has_suite[] = ($todo == $doneC ? 0 : 1); - if (isset($categories[$id_category])) - foreach ($categories[$id_category] AS $key => $row) - if ($key != 'infos') - self::recurseCategoryForInclude($id_obj, $indexedCategories, $categories, $categories[$id_category][$key], $key, $id_category_default, $has_suite); - } - - public function displayErrors() - { - if ($this->includeSubTab('displayErrors')) - ; - elseif ($nbErrors = sizeof($this->_errors)) - { - echo '
- - '.$nbErrors.' '.($nbErrors > 1 ? $this->l('errors') : $this->l('error')).' -
    '; - foreach ($this->_errors AS $error) - echo '
  1. '.$error.'
  2. '; - echo ' -
-
'; - } - } - - private function _displayDraftWarning($active) - { - return '
-

- - - '.$this->l('Your product will be saved as draft').' - - '.$this->l('Save and preview').' - -
-

-
'; - } - - public function displayForm($isMainTab = true) - { - global $currentIndex, $link, $cookie; - parent::displayForm(); - - if ($id_category_back = (int)(Tools::getValue('id_category'))) - $currentIndex .= '&id_category='.$id_category_back; - - if (!($obj = $this->loadObject(true))) - return; - $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); - - if ($obj->id) - $currentIndex .= '&id_product='.$obj->id; - - echo ' -

'.$this->l('Current product:').' '.$this->l('no name').'

- - - -
- '.$this->_displayDraftWarning($obj->active).' - - - -
'; - /* Tabs */ - $this->displayFormInformations($obj, $currency); - $this->displayFormImages($obj, $this->token); - $countAttributes = (int)Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.(int)$obj->id); - $countAttachments = (int)Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'product_attachment WHERE id_product = '.(int)$obj->id); - if ($obj->id) - echo ' -

3. '.$this->l('Prices').'

-

4. '.$this->l('Combinations').' ('.$countAttributes.')

-

5. '.$this->l('Features').'

-

6. '.$this->l('Customization').'

-

7. '.$this->l('Attachments').' ('.$countAttachments.')

'; - echo ' -
-
- -
'.$this->_displayDraftWarning($obj->active).' -
'; - - if (Tools::getValue('id_category') > 1) - { - $productIndex = preg_replace('/(&id_product=[0-9]*)/', '', $currentIndex); - echo '

- - '.$this->l('Back to the category').' -
'; - } - } - - function displayFormPrices($obj, $languages, $defaultLanguage) - { - global $cookie, $currentIndex; - - if ($obj->id) - { - $shops = Shop::getShops(); - $currencies = Currency::getCurrencies(); - $countries = Country::getCountries((int)($cookie->id_lang)); - $groups = Group::getGroups((int)($cookie->id_lang)); - $defaultCurrency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT'))); - $this->_displaySpecificPriceAdditionForm($defaultCurrency, $shops, $currencies, $countries, $groups); - $this->_displaySpecificPriceModificationForm($defaultCurrency, $shops, $currencies, $countries, $groups); - } - else - echo ''.$this->l('You must save this product before adding specific prices').'.'; - } - - private function _getFinalPrice($specificPrice, $productPrice, $taxRate) - { - $price = Tools::ps_round((float)($specificPrice['price']) ? $specificPrice['price'] : $productPrice, 2); - if (!(float)($specificPrice['reduction'])) - return (float)($specificPrice['price']); - return ($specificPrice['reduction_type'] == 'amount') ? ($price - $specificPrice['reduction'] / (1 + $taxRate / 100)) : ($price - $price * $specificPrice['reduction']); - } - - protected function _displaySpecificPriceModificationForm($defaultCurrency, $shops, $currencies, $countries, $groups) - { - global $currentIndex; - - if (!($obj = $this->loadObject())) - return; - $specificPrices = SpecificPrice::getByProductId((int)($obj->id)); - $specificPricePriorities = SpecificPrice::getPriority((int)($obj->id)); - $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); - - $taxRate = TaxRulesGroup::getTaxesRate($obj->id_tax_rules_group, Configuration::get('PS_COUNTRY_DEFAULT'), 0, 0); - - $tmp = array(); - foreach ($shops as $shop) - $tmp[$shop['id_shop']] = $shop; - $shops = $tmp; - - $tmp = array(); - foreach ($currencies as $currency) - $tmp[$currency['id_currency']] = $currency; - $currencies = $tmp; - - $tmp = array(); - foreach ($countries as $country) - $tmp[$country['id_country']] = $country; - $countries = $tmp; - - $tmp = array(); - foreach ($groups as $group) - $tmp[$group['id_group']] = $group; - $groups = $tmp; - - echo ' -

'.$this->l('Current specific prices').'

- - - - - - - - - - - - - - - - '; - if (!is_array($specificPrices) OR !sizeof($specificPrices)) - echo ' - - - '; - else - { - $i = 0; - foreach ($specificPrices as $specificPrice) - { - $current_specific_currency = $currencies[($specificPrice['id_currency'] ? $specificPrice['id_currency'] : $defaultCurrency->id)]; - if ($specificPrice['reduction_type'] == 'percentage') - $reduction = ($specificPrice['reduction'] * 100).' %'; - else - $reduction = Tools::displayPrice(Tools::ps_round($specificPrice['reduction'], 2), $current_specific_currency); - - if ($specificPrice['from'] == '0000-00-00 00:00:00' AND $specificPrice['to'] == '0000-00-00 00:00:00') - $period = $this->l('Unlimited'); - else - $period = $this->l('From').' '.($specificPrice['from'] != '0000-00-00 00:00:00' ? $specificPrice['from'] : '0000-00-00 00:00:00').'
'.$this->l('To').' '.($specificPrice['to'] != '0000-00-00 00:00:00' ? $specificPrice['to'] : '0000-00-00 00:00:00'); - echo ' - - - - - - - - - - '; - $i++; - } - } - echo ' - -
'.$this->l('Currency').''.$this->l('Country').''.$this->l('Group').''.$this->l('Price').' '.($default_country->display_tax_label ? $this->l('(tax excl.)') : '').''.$this->l('Reduction').''.$this->l('Period').''.$this->l('From (quantity)').''.$this->l('Final price').' '.($default_country->display_tax_label ? $this->l('(tax excl.)') : '').''.$this->l('Action').'
'.$this->l('No specific prices').'
'.($specificPrice['id_currency'] ? $currencies[$specificPrice['id_currency']]['name'] : $this->l('All currencies')).''.($specificPrice['id_country'] ? $countries[$specificPrice['id_country']]['name'] : $this->l('All countries')).''.($specificPrice['id_group'] ? $groups[$specificPrice['id_group']]['name'] : $this->l('All groups')).''.Tools::displayPrice((float)$specificPrice['price'], $current_specific_currency).''.$reduction.''.$period.''.$specificPrice['from_quantity'].' - '.Tools::displayPrice(Tools::ps_round((float)($this->_getFinalPrice($specificPrice, (float)($obj->price), $taxRate)), 2), $current_specific_currency).''.$this->l('Delete').'
'; - - echo ' - - '; - - echo ' -
-

'.$this->l('Priorities management').'

- -
- '.$this->l('Sometimes one customer could fit in multiple rules, priorities allows you to define which rule to apply.').' -
-
- -
- - - > - - > - -
- -
- -
- -
- -
- '; - } - - protected function _displaySpecificPriceAdditionForm($defaultCurrency, $shops, $currencies, $countries, $groups) - { - if (!($product = $this->loadObject())) - return; - - $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); - - echo ' - '.$this->l('Add a new specific price').' - - -
- '; - include_once('functions.php'); - includeDatepicker(array('sp_from', 'sp_to'), true); - } - - private function _getCustomizationFieldIds($labels, $alreadyGenerated, $obj) - { - $customizableFieldIds = array(); - if (isset($labels[_CUSTOMIZE_FILE_])) - foreach ($labels[_CUSTOMIZE_FILE_] AS $id_customization_field => $label) - $customizableFieldIds[] = 'label_'._CUSTOMIZE_FILE_.'_'.(int)($id_customization_field); - if (isset($labels[_CUSTOMIZE_TEXTFIELD_])) - foreach ($labels[_CUSTOMIZE_TEXTFIELD_] AS $id_customization_field => $label) - $customizableFieldIds[] = 'label_'._CUSTOMIZE_TEXTFIELD_.'_'.(int)($id_customization_field); - $j = 0; - for ($i = $alreadyGenerated[_CUSTOMIZE_FILE_]; $i < (int)($this->getFieldValue($obj, 'uploadable_files')); $i++) - $customizableFieldIds[] = 'newLabel_'._CUSTOMIZE_FILE_.'_'.$j++; - $j = 0; - for ($i = $alreadyGenerated[_CUSTOMIZE_TEXTFIELD_]; $i < (int)($this->getFieldValue($obj, 'text_fields')); $i++) - $customizableFieldIds[] = 'newLabel_'._CUSTOMIZE_TEXTFIELD_.'_'.$j++; - return implode('¤', $customizableFieldIds); - } - - private function _displayLabelField(&$label, $languages, $defaultLanguage, $type, $fieldIds, $id_customization_field) - { - $fieldsName = 'label_'.$type.'_'.(int)($id_customization_field); - $fieldsContainerName = 'labelContainer_'.$type.'_'.(int)($id_customization_field); - echo '
'; - foreach ($languages as $language) - { - $fieldName = 'label_'.$type.'_'.(int)($id_customization_field).'_'.(int)($language['id_lang']); - $text = (isset($label[(int)($language['id_lang'])])) ? $label[(int)($language['id_lang'])]['name'] : ''; - echo '
-
#'.(int)($id_customization_field).'
-
'; - } - - $required = (isset($label[(int)($language['id_lang'])])) ? $label[(int)($language['id_lang'])]['required'] : false; - echo '
-
- -
'; - } - - private function _displayLabelFields(&$obj, &$labels, $languages, $defaultLanguage, $type) - { - $type = (int)($type); - $labelGenerated = array(_CUSTOMIZE_FILE_ => (isset($labels[_CUSTOMIZE_FILE_]) ? count($labels[_CUSTOMIZE_FILE_]) : 0), _CUSTOMIZE_TEXTFIELD_ => (isset($labels[_CUSTOMIZE_TEXTFIELD_]) ? count($labels[_CUSTOMIZE_TEXTFIELD_]) : 0)); - - $fieldIds = $this->_getCustomizationFieldIds($labels, $labelGenerated, $obj); - if (isset($labels[$type])) - foreach ($labels[$type] AS $id_customization_field => $label) - $this->_displayLabelField($label, $languages, $defaultLanguage, $type, $fieldIds, (int)($id_customization_field)); - } - - function displayFormCustomization($obj, $languages, $defaultLanguage) - { - parent::displayForm(); - $labels = $obj->getCustomizationFields(); - $defaultIso = Language::getIsoById($defaultLanguage); - - $hasFileLabels = (int)($this->getFieldValue($obj, 'uploadable_files')); - $hasTextLabels = (int)($this->getFieldValue($obj, 'text_fields')); - - echo ' - - - - -
'.$this->l('Add or modify customizable properties').'
-

- - - - - - - - - - - - '; - - if ($hasFileLabels) - { - echo ' - - - - - '; - } - - if ($hasTextLabels) - { - echo ' - - - - - '; - } - - echo ' - - - -
'.$this->l('File fields:').' - -

'.$this->l('Number of upload file fields displayed').'

-
'.$this->l('Text fields:').' - -

'.$this->l('Number of text fields displayed').'

-
- -

'.$this->l('Files fields:').''; - $this->_displayLabelFields($obj, $labels, $languages, $defaultLanguage, _CUSTOMIZE_FILE_); - echo ' -

'.$this->l('Text fields:').''; - $this->_displayLabelFields($obj, $labels, $languages, $defaultLanguage, _CUSTOMIZE_TEXTFIELD_); - echo ' -
'; - if ($hasFileLabels OR $hasTextLabels) - echo ''; - echo ' -
'; - } - - function displayFormAttachments($obj, $languages, $defaultLanguage) - { - global $currentIndex, $cookie; - if (!($obj = $this->loadObject(true))) - return; - $languages = Language::getLanguages(false); - $attach1 = Attachment::getAttachments($cookie->id_lang, $obj->id, true); - $attach2 = Attachment::getAttachments($cookie->id_lang, $obj->id, false); - - echo ' - '.($obj->id ? '' : '').' -
'.$this->l('Attachment').' - -
'; - foreach ($languages as $language) - echo '
- * -
'; - $this->displayFlags($languages, $defaultLanguage, 'attachment_name¤attachment_description', 'attachment_name'); - echo '
-
 
- -
'; - foreach ($languages as $language) - echo '
- -
'; - $this->displayFlags($languages, $defaultLanguage, 'attachment_name¤attachment_description', 'attachment_description'); - echo '
-
 
- -
-

-

'.$this->l('Upload file from your computer').'

-
-
 
-
- -
-
* '.$this->l('Required field').'
-
-
 
- - - - - -
-

'.$this->l('Attachments for this product:').'

-

- - '.$this->l('Remove').' >> - -
-

'.$this->l('Available attachments:').'

-

- - << '.$this->l('Add').' - - -
-
 
- '; - } - - function displayFormInformations($obj, $currency) - { - parent::displayForm(false); - global $currentIndex, $cookie, $link; - - $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); - $iso = Language::getIsoById((int)($cookie->id_lang)); - $has_attribute = false; - $qty_state = 'readonly'; - $qty = Attribute::getAttributeQty($this->getFieldValue($obj, 'id_product')); - if ($qty === false) { - if (Validate::isLoadedObject($obj)) - $qty = $this->getFieldValue($obj, 'quantity'); - else - $qty = 1; - $qty_state = ''; - } - else - $has_attribute = true; - $cover = Product::getCover($obj->id); - $this->_applyTaxToEcotax($obj); - - echo ' -
-

1. '.$this->l('Info.').'

- - '.$this->l('Product global information').' - '; - $preview_url = ''; - if (isset($obj->id)) - { - $preview_url = ($link->getProductLink($this->getFieldValue($obj, 'id'), $this->getFieldValue($obj, 'link_rewrite', $this->_defaultFormLanguage), Category::getLinkRewrite($this->getFieldValue($obj, 'id_category_default'), (int)($cookie->id_lang)))); - if (!$obj->active) - { - $admin_dir = dirname($_SERVER['PHP_SELF']); - $admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1); - $token = Tools::encrypt('PreviewProduct'.$obj->id); - - $preview_url .= $obj->active ? '' : '&adtoken='.$token.'&ad='.$admin_dir; - } - - echo ' - - '.$this->l('Delete this product').' '.$this->l('Delete this product').' - '.$this->l('View product in shop').' '.$this->l('View product in shop').''; - - if (file_exists(_PS_MODULE_DIR_.'statsproduct/statsproduct.php')) - echo ' - '.$this->l('View product sales').' '.$this->l('View product sales').''; - } - echo ' -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'.$this->l('Name:').''; - foreach ($this->_languages as $language) - echo '
- id) ? ' onkeyup="if (isArrowKey(event)) return; copy2friendlyURL();"' : '').' onkeyup="if (isArrowKey(event)) return; updateCurrentText();" onchange="updateCurrentText();" /> * - '.$this->l('Invalid characters:').' <>;=#{}  -
'; - echo '
'.$this->l('Reference:').' - - '.$this->l('Special characters allowed:').' .-_#\  -
'.$this->l('Supplier Reference:').' - - '.$this->l('Special characters allowed:').' .-_#\  -
'.$this->l('EAN13 or JAN:').' - '.$this->l('(Europe, Japan)').' -
'.$this->l('UPC:').' - '.$this->l('(US, Canada)').' -
'.$this->l('NC8 :').' - -
'.$this->l('Id pays origine :').' - -
'.$this->l('Location (warehouse):').' - -
'.$this->l('Width ( package ) :').' - '.Configuration::get('PS_DIMENSION_UNIT').' -
'.$this->l('Height ( package ) :').' - '.Configuration::get('PS_DIMENSION_UNIT').' -
'.$this->l('Deep ( package ) :').' - '.Configuration::get('PS_DIMENSION_UNIT').' -
'.$this->l('Weight ( package ) :').' - '.Configuration::get('PS_WEIGHT_UNIT').' -
- - - - - - active ? 'style="display:none"' : '').'> - - - - - - - - - - - - - - - -
'.$this->l('Status:').' - getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> - -
- getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> - -
'.$this->l('Options:').' - getFieldValue($obj, 'available_for_order') ? 'checked="checked" ' : '').' onclick="if ($(this).is(\':checked\')){$(\'#show_price\').attr(\'checked\', \'checked\');$(\'#show_price\').attr(\'disabled\', \'disabled\');}else{$(\'#show_price\').attr(\'disabled\', \'\');}"/> - -
- getFieldValue($obj, 'show_price') ? 'checked="checked" ' : '').' /> - -
- getFieldValue($obj, 'online_only') ? 'checked="checked" ' : '').' /> - -
'.$this->l('Condition:').' - -
'.$this->l('Manufacturer:').' -    '.$this->l('Create').' '.$this->l('Create').' -
'.$this->l('Supplier:').' -    '.$this->l('Create').' '.$this->l('Create').' -
-
- - '; - $this->displayPack($obj); - echo ' '; + // foreach($categories_vp as $category) { + // if($category['id_category'] != $id_category){ + // echo ''; + // echo ' '; + // }else{ + // echo ''; + // echo ' '; + // } + // echo '
'; + // } + echo '

'; + + echo ""; + } + + echo ' + +


+ '; + + if((int)$this->_category->id_parent == 1){ + echo '
'; + echo '

Ordonner les produits des braderies

'; + echo '

'; + echo '

'.$this->l('Order by sub category positions and product name').'

'; + } elseif ((int)$this->_category->id_parent > 1) { + echo '
'; + echo '

Ordonner les produits des braderies

'; + echo '

'; + echo '

'.$this->l('Order by product name').'

'; + } + + echo ''; + if (isset($this->_includeTab) AND sizeof($this->_includeTab)) + echo '

'; + + } + + + /** + * Build a categories tree + * + * @param array $indexedCategories Array with categories where product is indexed (in order to check checkbox) + * @param array $categories Categories to list + * @param array $current Current category + * @param integer $id_category Current category id + */ + public static function recurseCategoryForInclude($id_obj, $indexedCategories, $categories, $current, $id_category = 1, $id_category_default = NULL, $has_suite = array()) + { + global $done; + static $irow; + + if (!isset($done[$current['infos']['id_parent']])) + $done[$current['infos']['id_parent']] = 0; + $done[$current['infos']['id_parent']] += 1; + + $todo = sizeof($categories[$current['infos']['id_parent']]); + $doneC = $done[$current['infos']['id_parent']]; + + $level = $current['infos']['level_depth'] + 1; + + echo ' + + + + + + '.$id_category.' + + '; + for ($i = 2; $i < $level; $i++) + echo ''; + echo '   + + '; + + if ($level > 1) + $has_suite[] = ($todo == $doneC ? 0 : 1); + if (isset($categories[$id_category])) + foreach ($categories[$id_category] AS $key => $row) + if ($key != 'infos') + self::recurseCategoryForInclude($id_obj, $indexedCategories, $categories, $categories[$id_category][$key], $key, $id_category_default, $has_suite); + } + + public function displayErrors() + { + if ($this->includeSubTab('displayErrors')) + ; + elseif ($nbErrors = sizeof($this->_errors)) + { + echo '
+ + '.$nbErrors.' '.($nbErrors > 1 ? $this->l('errors') : $this->l('error')).' +
    '; + foreach ($this->_errors AS $error) + echo '
  1. '.$error.'
  2. '; + echo ' +
+
'; + } + } + + private function _displayDraftWarning($active) + { + return '
+

+ + + '.$this->l('Your product will be saved as draft').' + + '.$this->l('Save and preview').' + +
+

+
'; + } + + public function displayForm($isMainTab = true) + { + global $currentIndex, $link, $cookie; + parent::displayForm(); + + if ($id_category_back = (int)(Tools::getValue('id_category'))) + $currentIndex .= '&id_category='.$id_category_back; + + if (!($obj = $this->loadObject(true))) + return; + $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); + + if ($obj->id) + $currentIndex .= '&id_product='.$obj->id; + + echo ' +

'.$this->l('Current product:').' '.$this->l('no name').'

+ + + +
+ '.$this->_displayDraftWarning($obj->active).' + + + +
'; + /* Tabs */ + $this->displayFormInformations($obj, $currency); + $this->displayFormImages($obj, $this->token); + $countAttributes = (int)Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.(int)$obj->id); + $countAttachments = (int)Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'product_attachment WHERE id_product = '.(int)$obj->id); + if ($obj->id) + echo ' +

3. '.$this->l('Prices').'

+

4. '.$this->l('Combinations').' ('.$countAttributes.')

+

5. '.$this->l('Features').'

+

6. '.$this->l('Customization').'

+

7. '.$this->l('Attachments').' ('.$countAttachments.')

'; + echo ' +
+
+ +
'.$this->_displayDraftWarning($obj->active).' +
'; + + if (Tools::getValue('id_category') > 1) + { + $productIndex = preg_replace('/(&id_product=[0-9]*)/', '', $currentIndex); + echo '

+ + '.$this->l('Back to the category').' +
'; + } + } + + function displayFormPrices($obj, $languages, $defaultLanguage) + { + global $cookie, $currentIndex; + + if ($obj->id) + { + $shops = Shop::getShops(); + $currencies = Currency::getCurrencies(); + $countries = Country::getCountries((int)($cookie->id_lang)); + $groups = Group::getGroups((int)($cookie->id_lang)); + $defaultCurrency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT'))); + $this->_displaySpecificPriceAdditionForm($defaultCurrency, $shops, $currencies, $countries, $groups); + $this->_displaySpecificPriceModificationForm($defaultCurrency, $shops, $currencies, $countries, $groups); + } + else + echo ''.$this->l('You must save this product before adding specific prices').'.'; + } + + private function _getFinalPrice($specificPrice, $productPrice, $taxRate) + { + $price = Tools::ps_round((float)($specificPrice['price']) ? $specificPrice['price'] : $productPrice, 2); + if (!(float)($specificPrice['reduction'])) + return (float)($specificPrice['price']); + return ($specificPrice['reduction_type'] == 'amount') ? ($price - $specificPrice['reduction'] / (1 + $taxRate / 100)) : ($price - $price * $specificPrice['reduction']); + } + + protected function _displaySpecificPriceModificationForm($defaultCurrency, $shops, $currencies, $countries, $groups) + { + global $currentIndex; + + if (!($obj = $this->loadObject())) + return; + $specificPrices = SpecificPrice::getByProductId((int)($obj->id)); + $specificPricePriorities = SpecificPrice::getPriority((int)($obj->id)); + $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); + + $taxRate = TaxRulesGroup::getTaxesRate($obj->id_tax_rules_group, Configuration::get('PS_COUNTRY_DEFAULT'), 0, 0); + + $tmp = array(); + foreach ($shops as $shop) + $tmp[$shop['id_shop']] = $shop; + $shops = $tmp; + + $tmp = array(); + foreach ($currencies as $currency) + $tmp[$currency['id_currency']] = $currency; + $currencies = $tmp; + + $tmp = array(); + foreach ($countries as $country) + $tmp[$country['id_country']] = $country; + $countries = $tmp; + + $tmp = array(); + foreach ($groups as $group) + $tmp[$group['id_group']] = $group; + $groups = $tmp; + + echo ' +

'.$this->l('Current specific prices').'

+ + + + + + + + + + + + + + + + '; + if (!is_array($specificPrices) OR !sizeof($specificPrices)) + echo ' + + + '; + else + { + $i = 0; + foreach ($specificPrices as $specificPrice) + { + $current_specific_currency = $currencies[($specificPrice['id_currency'] ? $specificPrice['id_currency'] : $defaultCurrency->id)]; + if ($specificPrice['reduction_type'] == 'percentage') + $reduction = ($specificPrice['reduction'] * 100).' %'; + else + $reduction = Tools::displayPrice(Tools::ps_round($specificPrice['reduction'], 2), $current_specific_currency); + + if ($specificPrice['from'] == '0000-00-00 00:00:00' AND $specificPrice['to'] == '0000-00-00 00:00:00') + $period = $this->l('Unlimited'); + else + $period = $this->l('From').' '.($specificPrice['from'] != '0000-00-00 00:00:00' ? $specificPrice['from'] : '0000-00-00 00:00:00').'
'.$this->l('To').' '.($specificPrice['to'] != '0000-00-00 00:00:00' ? $specificPrice['to'] : '0000-00-00 00:00:00'); + echo ' + + + + + + + + + + '; + $i++; + } + } + echo ' + +
'.$this->l('Currency').''.$this->l('Country').''.$this->l('Group').''.$this->l('Price').' '.($default_country->display_tax_label ? $this->l('(tax excl.)') : '').''.$this->l('Reduction').''.$this->l('Period').''.$this->l('From (quantity)').''.$this->l('Final price').' '.($default_country->display_tax_label ? $this->l('(tax excl.)') : '').''.$this->l('Action').'
'.$this->l('No specific prices').'
'.($specificPrice['id_currency'] ? $currencies[$specificPrice['id_currency']]['name'] : $this->l('All currencies')).''.($specificPrice['id_country'] ? $countries[$specificPrice['id_country']]['name'] : $this->l('All countries')).''.($specificPrice['id_group'] ? $groups[$specificPrice['id_group']]['name'] : $this->l('All groups')).''.Tools::displayPrice((float)$specificPrice['price'], $current_specific_currency).''.$reduction.''.$period.''.$specificPrice['from_quantity'].' + '.Tools::displayPrice(Tools::ps_round((float)($this->_getFinalPrice($specificPrice, (float)($obj->price), $taxRate)), 2), $current_specific_currency).''.$this->l('Delete').'
'; + + echo ' + + '; + + echo ' +
+

'.$this->l('Priorities management').'

+ +
+ '.$this->l('Sometimes one customer could fit in multiple rules, priorities allows you to define which rule to apply.').' +
+
+ +
+ + + > + + > + +
+ +
+ +
+ +
+ +
+ '; + } + + protected function _displaySpecificPriceAdditionForm($defaultCurrency, $shops, $currencies, $countries, $groups) + { + if (!($product = $this->loadObject())) + return; + + $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); + + echo ' + '.$this->l('Add a new specific price').' + + +
+ '; + include_once('functions.php'); + includeDatepicker(array('sp_from', 'sp_to'), true); + } + + private function _getCustomizationFieldIds($labels, $alreadyGenerated, $obj) + { + $customizableFieldIds = array(); + if (isset($labels[_CUSTOMIZE_FILE_])) + foreach ($labels[_CUSTOMIZE_FILE_] AS $id_customization_field => $label) + $customizableFieldIds[] = 'label_'._CUSTOMIZE_FILE_.'_'.(int)($id_customization_field); + if (isset($labels[_CUSTOMIZE_TEXTFIELD_])) + foreach ($labels[_CUSTOMIZE_TEXTFIELD_] AS $id_customization_field => $label) + $customizableFieldIds[] = 'label_'._CUSTOMIZE_TEXTFIELD_.'_'.(int)($id_customization_field); + $j = 0; + for ($i = $alreadyGenerated[_CUSTOMIZE_FILE_]; $i < (int)($this->getFieldValue($obj, 'uploadable_files')); $i++) + $customizableFieldIds[] = 'newLabel_'._CUSTOMIZE_FILE_.'_'.$j++; + $j = 0; + for ($i = $alreadyGenerated[_CUSTOMIZE_TEXTFIELD_]; $i < (int)($this->getFieldValue($obj, 'text_fields')); $i++) + $customizableFieldIds[] = 'newLabel_'._CUSTOMIZE_TEXTFIELD_.'_'.$j++; + return implode('¤', $customizableFieldIds); + } + + private function _displayLabelField(&$label, $languages, $defaultLanguage, $type, $fieldIds, $id_customization_field) + { + $fieldsName = 'label_'.$type.'_'.(int)($id_customization_field); + $fieldsContainerName = 'labelContainer_'.$type.'_'.(int)($id_customization_field); + echo '
'; + foreach ($languages as $language) + { + $fieldName = 'label_'.$type.'_'.(int)($id_customization_field).'_'.(int)($language['id_lang']); + $text = (isset($label[(int)($language['id_lang'])])) ? $label[(int)($language['id_lang'])]['name'] : ''; + echo '
+
#'.(int)($id_customization_field).'
+
'; + } + + $required = (isset($label[(int)($language['id_lang'])])) ? $label[(int)($language['id_lang'])]['required'] : false; + echo '
+
+ +
'; + } + + private function _displayLabelFields(&$obj, &$labels, $languages, $defaultLanguage, $type) + { + $type = (int)($type); + $labelGenerated = array(_CUSTOMIZE_FILE_ => (isset($labels[_CUSTOMIZE_FILE_]) ? count($labels[_CUSTOMIZE_FILE_]) : 0), _CUSTOMIZE_TEXTFIELD_ => (isset($labels[_CUSTOMIZE_TEXTFIELD_]) ? count($labels[_CUSTOMIZE_TEXTFIELD_]) : 0)); + + $fieldIds = $this->_getCustomizationFieldIds($labels, $labelGenerated, $obj); + if (isset($labels[$type])) + foreach ($labels[$type] AS $id_customization_field => $label) + $this->_displayLabelField($label, $languages, $defaultLanguage, $type, $fieldIds, (int)($id_customization_field)); + } + + function displayFormCustomization($obj, $languages, $defaultLanguage) + { + parent::displayForm(); + $labels = $obj->getCustomizationFields(); + $defaultIso = Language::getIsoById($defaultLanguage); + + $hasFileLabels = (int)($this->getFieldValue($obj, 'uploadable_files')); + $hasTextLabels = (int)($this->getFieldValue($obj, 'text_fields')); + + echo ' + + + + +
'.$this->l('Add or modify customizable properties').'
+

+ + + + + + + + + + + + '; + + if ($hasFileLabels) + { + echo ' + + + + + '; + } + + if ($hasTextLabels) + { + echo ' + + + + + '; + } + + echo ' + + + +
'.$this->l('File fields:').' + +

'.$this->l('Number of upload file fields displayed').'

+
'.$this->l('Text fields:').' + +

'.$this->l('Number of text fields displayed').'

+
+ +

'.$this->l('Files fields:').''; + $this->_displayLabelFields($obj, $labels, $languages, $defaultLanguage, _CUSTOMIZE_FILE_); + echo ' +

'.$this->l('Text fields:').''; + $this->_displayLabelFields($obj, $labels, $languages, $defaultLanguage, _CUSTOMIZE_TEXTFIELD_); + echo ' +
'; + if ($hasFileLabels OR $hasTextLabels) + echo ''; + echo ' +
'; + } + + function displayFormAttachments($obj, $languages, $defaultLanguage) + { + global $currentIndex, $cookie; + if (!($obj = $this->loadObject(true))) + return; + $languages = Language::getLanguages(false); + $attach1 = Attachment::getAttachments($cookie->id_lang, $obj->id, true); + $attach2 = Attachment::getAttachments($cookie->id_lang, $obj->id, false); + + echo ' + '.($obj->id ? '' : '').' +
'.$this->l('Attachment').' + +
'; + foreach ($languages as $language) + echo '
+ * +
'; + $this->displayFlags($languages, $defaultLanguage, 'attachment_name¤attachment_description', 'attachment_name'); + echo '
+
 
+ +
'; + foreach ($languages as $language) + echo '
+ +
'; + $this->displayFlags($languages, $defaultLanguage, 'attachment_name¤attachment_description', 'attachment_description'); + echo '
+
 
+ +
+

+

'.$this->l('Upload file from your computer').'

+
+
 
+
+ +
+
* '.$this->l('Required field').'
+
+
 
+ + + + + +
+

'.$this->l('Attachments for this product:').'

+

+ + '.$this->l('Remove').' >> + +
+

'.$this->l('Available attachments:').'

+

+ + << '.$this->l('Add').' + + +
+
 
+ '; + } + + function displayFormInformations($obj, $currency) + { + parent::displayForm(false); + global $currentIndex, $cookie, $link; + + $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); + $iso = Language::getIsoById((int)($cookie->id_lang)); + $has_attribute = false; + $qty_state = 'readonly'; + $qty = Attribute::getAttributeQty($this->getFieldValue($obj, 'id_product')); + if ($qty === false) { + if (Validate::isLoadedObject($obj)) + $qty = $this->getFieldValue($obj, 'quantity'); + else + $qty = 1; + $qty_state = ''; + } + else + $has_attribute = true; + $cover = Product::getCover($obj->id); + $this->_applyTaxToEcotax($obj); + + echo ' +
+

1. '.$this->l('Info.').'

+ + '.$this->l('Product global information').' - '; + $preview_url = ''; + if (isset($obj->id)) + { + $preview_url = ($link->getProductLink($this->getFieldValue($obj, 'id'), $this->getFieldValue($obj, 'link_rewrite', $this->_defaultFormLanguage), Category::getLinkRewrite($this->getFieldValue($obj, 'id_category_default'), (int)($cookie->id_lang)))); + if (!$obj->active) + { + $admin_dir = dirname($_SERVER['PHP_SELF']); + $admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1); + $token = Tools::encrypt('PreviewProduct'.$obj->id); + + $preview_url .= $obj->active ? '' : '&adtoken='.$token.'&ad='.$admin_dir; + } + + echo ' + + '.$this->l('Delete this product').' '.$this->l('Delete this product').' + '.$this->l('View product in shop').' '.$this->l('View product in shop').''; + + if (file_exists(_PS_MODULE_DIR_.'statsproduct/statsproduct.php')) + echo ' - '.$this->l('View product sales').' '.$this->l('View product sales').''; + } + echo ' +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
'.$this->l('Name:').''; + foreach ($this->_languages as $language) + echo '
+ id) ? ' onkeyup="if (isArrowKey(event)) return; copy2friendlyURL();"' : '').' onkeyup="if (isArrowKey(event)) return; updateCurrentText();" onchange="updateCurrentText();" /> * + '.$this->l('Invalid characters:').' <>;=#{}  +
'; + echo '
'.$this->l('Reference:').' + + '.$this->l('Special characters allowed:').' .-_#\  +
'.$this->l('Supplier Reference:').' + + '.$this->l('Special characters allowed:').' .-_#\  +
'.$this->l('EAN13 or JAN:').' + '.$this->l('(Europe, Japan)').' +
'.$this->l('UPC:').' + '.$this->l('(US, Canada)').' +
'.$this->l('NC8 :').' + +
'.$this->l('Id pays origine :').' + +
'.$this->l('Location (warehouse):').' + +
'.$this->l('Width ( package ) :').' + '.Configuration::get('PS_DIMENSION_UNIT').' +
'.$this->l('Height ( package ) :').' + '.Configuration::get('PS_DIMENSION_UNIT').' +
'.$this->l('Deep ( package ) :').' + '.Configuration::get('PS_DIMENSION_UNIT').' +
'.$this->l('Weight ( package ) :').' + '.Configuration::get('PS_WEIGHT_UNIT').' +
+ + + + + + active ? 'style="display:none"' : '').'> + + + + + + + + + + + + + + + +
'.$this->l('Status:').' + getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> + +
+ getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> + +
'.$this->l('Options:').' + getFieldValue($obj, 'available_for_order') ? 'checked="checked" ' : '').' onclick="if ($(this).is(\':checked\')){$(\'#show_price\').attr(\'checked\', \'checked\');$(\'#show_price\').attr(\'disabled\', \'disabled\');}else{$(\'#show_price\').attr(\'disabled\', \'\');}"/> + +
+ getFieldValue($obj, 'show_price') ? 'checked="checked" ' : '').' /> + +
+ getFieldValue($obj, 'online_only') ? 'checked="checked" ' : '').' /> + +
'.$this->l('Condition:').' + +
'.$this->l('Manufacturer:').' +    '.$this->l('Create').' '.$this->l('Create').' +
'.$this->l('Supplier:').' +    '.$this->l('Create').' '.$this->l('Create').' +
+
+ + '; + $this->displayPack($obj); + echo ' '; /* * Form for add a virtual product like software, mp3, etc... */ - $productDownload = new ProductDownload(); - if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'))) - $productDownload = new ProductDownload($id_product_download); + $productDownload = new ProductDownload(); + if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'))) + $productDownload = new ProductDownload($id_product_download); ?> - - - - - - + + + + + - - '; - ?> - - + - - - + +

+

+ + * + +

+ + + + + + + diff --git a/classes/Image.php b/classes/Image.php index 848f90bc..f5a2c58b 100755 --- a/classes/Image.php +++ b/classes/Image.php @@ -226,27 +226,55 @@ class ImageCore extends ObjectModel $imageOld = new Image($row['id_image']); $imageNew = clone $imageOld; $imageNew->id_product = (int)($id_product_new); - // A new id is generated for the cloned image when calling add() - if ($imageNew->add()) - { - $new_path = $imageNew->getPathForCreation(); - foreach ($imagesTypes AS $imageType) - { - if (file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg')) - { - if (!Configuration::get('PS_LEGACY_IMAGES')) - $imageNew->createImgFolder(); - copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg', - $new_path.'-'.$imageType['name'].'.jpg'); - } - } - if (file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg')) - copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg', $new_path.'.jpg'); + + if($imageNew->add()) { + $new_path = $imageNew->getPathForCreation(); - self::replaceAttributeImageAssociationId($combinationImages, (int)($imageOld->id), (int)($imageNew->id)); + if(file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg')) { + copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg', $new_path.'.jpg'); + } + + foreach($imagesTypes AS $imageType) { + if(file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg')) { + if(!Configuration::get('PS_LEGACY_IMAGES')) { + $imageNew->createImgFolder(); + } + copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg', $new_path.'-'.$imageType['name'].'.jpg'); + } else { + if(!Configuration::get('PS_LEGACY_IMAGES')) { + $imageNew->createImgFolder(); + } + imageResize($new_path.'.jpg', _PS_PROD_IMG_DIR_.$imageNew->getExistingImgPath().'-'.$imageType['name'].'.jpg', (int) $imageType['width'], (int) $imageType['height']); + } + } + + self::replaceAttributeImageAssociationId($combinationImages, (int)($imageOld->id), (int)($imageNew->id)); + } else { + return FALSE; } - else - return false; + + // // A new id is generated for the cloned image when calling add() + // if ($imageNew->add()) + // { + // $new_path = $imageNew->getPathForCreation(); + // foreach ($imagesTypes AS $imageType) + // { + // if (file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg')) + // { + // if (!Configuration::get('PS_LEGACY_IMAGES')) + // $imageNew->createImgFolder(); + // copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg', + // $new_path.'-'.$imageType['name'].'.jpg'); + // } + // } + // if (file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg')) + // copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg', $new_path.'.jpg'); + + // self::replaceAttributeImageAssociationId($combinationImages, (int)($imageOld->id), (int)($imageNew->id)); + // } + // else + // return false; + } return self::duplicateAttributeImageAssociations($combinationImages); } diff --git a/js/jquery/jquery.ui.map.js b/js/jquery/jquery.ui.map.js new file mode 100644 index 00000000..25f6e23e --- /dev/null +++ b/js/jquery/jquery.ui.map.js @@ -0,0 +1,371 @@ +/*! + * jQuery FN Google Map 3.0-rc + * http://code.google.com/p/jquery-ui-map/ + * Copyright (c) 2010 - 2012 Johan Säll Larsson + * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php + */ +( function($) { + + /** + * @param name:string + * @param prototype:object + */ + $.a = function(name, prototype) { + + var namespace = name.split('.')[0]; + name = name.split('.')[1]; + + $[namespace] = $[namespace] || {}; + $[namespace][name] = function(options, element) { + if ( arguments.length ) { + this._setup(options, element); + } + }; + + $[namespace][name].prototype = $.extend({ + 'namespace': namespace, + 'pluginName': name + }, prototype); + + $.fn[name] = function(options) { + + var isMethodCall = typeof options === "string", + args = Array.prototype.slice.call(arguments, 1), + returnValue = this; + + if ( isMethodCall && options.substring(0, 1) === '_' ) { + return returnValue; + } + + this.each(function() { + var instance = $.data(this, name); + if (!instance) { + instance = $.data(this, name, new $[namespace][name](options, this)); + } + if (isMethodCall) { + var value = instance[options].apply(instance, args); + if ( options === 'get' || value != null ) { + returnValue = value; + } + } + }); + + return returnValue; + + }; + + }; + + $.a('ui.gmap', { + + /** + * Map options + * @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#MapOptions + */ + options: { + mapTypeId: 'roadmap', + zoom: 5 + }, + + /** + * Get or set options + * @param key:string + * @param options:object + * @return object + */ + option: function(key, options) { + if (options) { + this.options[key] = options; + this.get('map').set(key, options); + return; + } + return this.options[key]; + }, + + /** + * Setup plugin basics, + * @param options:object + * @param element:node + */ + _setup: function(options, element) { + this.el = element; + options = options || {}; + jQuery.extend(this.options, options, { 'center': this._latLng(options.center) }); + this._create(); + if ( this._init ) { this._init(); } + }, + + /** + * Instanciate the Google Maps object + */ + _create: function() { + var self = this; + this.instance = { 'map': new google.maps.Map(self.el, self.options), 'markers': [], 'overlays': [], 'services': [] }; + google.maps.event.addListenerOnce(self.instance.map, 'bounds_changed', function() { $(self.el).trigger('init', self.instance.map); }); + self._call(self.options.callback, self.instance.map); + }, + + /** + * Adds a latitude longitude pair to the bounds. + * @param position:google.maps.LatLng/string + */ + addBounds: function(position) { + var bounds = this.get('bounds', new google.maps.LatLngBounds()); + bounds.extend(this._latLng(position)); + this.get('map').fitBounds(bounds); + }, + + /** + * Helper function to check if a LatLng is within the viewport + * @param marker:google.maps.Marker + */ + inViewport: function(marker) { + var bounds = this.get('map').getBounds(); + return (bounds) ? bounds.contains(marker.getPosition()) : false; + }, + + /** + * Adds a custom control to the map + * @param panel:jquery/node/string + * @param position:google.maps.ControlPosition + * @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#ControlPosition + */ + addControl: function(panel, position) { + this.get('map').controls[position].push(this._unwrap(panel)); + }, + + /** + * Adds a Marker to the map + * @param markerOptions:google.maps.MarkerOptions + * @param callback:function(map:google.maps.Map, marker:google.maps.Marker) (optional) + * @return $(google.maps.Marker) + * @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#MarkerOptions + */ + addMarker: function(markerOptions, callback) { + markerOptions.map = this.get('map'); + markerOptions.position = this._latLng(markerOptions.position); + var marker = new (markerOptions.marker || google.maps.Marker)(markerOptions); + var markers = this.get('markers'); + if ( marker.id ) { + markers[marker.id] = marker; + } else { + markers.push(marker); + } + if ( marker.bounds ) { + this.addBounds(marker.getPosition()); + } + this._call(callback, markerOptions.map, marker); + return $(marker); + }, + + /** + * Clears by type + * @param ctx:string e.g. 'markers', 'overlays', 'services' + */ + clear: function(ctx) { + this._c(this.get(ctx)); + this.set(ctx, []); + }, + + _c: function(obj) { + for ( var property in obj ) { + if ( obj.hasOwnProperty(property) ) { + if ( obj[property] instanceof google.maps.MVCObject ) { + google.maps.event.clearInstanceListeners(obj[property]); + if ( obj[property].setMap ) { + obj[property].setMap(null); + } + } else if ( obj[property] instanceof Array ) { + this._c(obj[property]); + } + obj[property] = null; + } + } + }, + + /** + * Returns the objects with a specific property and value, e.g. 'category', 'tags' + * @param ctx:string in what context, e.g. 'markers' + * @param options:object property:string the property to search within, value:string, operator:string (optional) (AND/OR) + * @param callback:function(marker:google.maps.Marker, isFound:boolean) + */ + find: function(ctx, options, callback) { + var obj = this.get(ctx); + options.value = $.isArray(options.value) ? options.value : [options.value]; + for ( var property in obj ) { + if ( obj.hasOwnProperty(property) ) { + var isFound = false; + for ( var value in options.value ) { + if ( $.inArray(options.value[value], obj[property][options.property]) > -1 ) { + isFound = true; + } else { + if ( options.operator && options.operator === 'AND' ) { + isFound = false; + break; + } + } + } + callback(obj[property], isFound); + } + } + }, + + /** + * Returns an instance property by key. Has the ability to set an object if the property does not exist + * @param key:string + * @param value:object(optional) + */ + get: function(key, value) { + var instance = this.instance; + if ( !instance[key] ) { + if ( key.indexOf('>') > -1 ) { + var e = key.replace(/ /g, '').split('>'); + for ( var i = 0; i < e.length; i++ ) { + if ( !instance[e[i]] ) { + if (value) { + instance[e[i]] = ( (i + 1) < e.length ) ? [] : value; + } else { + return null; + } + } + instance = instance[e[i]]; + } + return instance; + } else if ( value && !instance[key] ) { + this.set(key, value); + } + } + return instance[key]; + }, + + /** + * Triggers an InfoWindow to open + * @param infoWindowOptions:google.maps.InfoWindowOptions + * @param marker:google.maps.Marker (optional) + * @param callback:function (optional) + * @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#InfoWindowOptions + */ + openInfoWindow: function(infoWindowOptions, marker, callback) { + var iw = this.get('iw', infoWindowOptions.infoWindow || new google.maps.InfoWindow); + iw.setOptions(infoWindowOptions); + iw.open(this.get('map'), this._unwrap(marker)); + this._call(callback, iw); + }, + + /** + * Triggers an InfoWindow to close + */ + closeInfoWindow: function() { + if ( this.get('iw') != null ) { + this.get('iw').close(); + } + }, + + /** + * Sets an instance property + * @param key:string + * @param value:object + */ + set: function(key, value) { + this.instance[key] = value; + }, + + /** + * Refreshes the map + */ + refresh: function() { + var map = this.get('map'); + var latLng = map.getCenter(); + $(map).triggerEvent('resize'); + map.setCenter(latLng); + }, + + /** + * Destroys the plugin. + */ + destroy: function() { + this.clear('markers'); + this.clear('services') + this.clear('overlays') + this._c(this.instance); + jQuery.removeData(this.el, this.name); + }, + + /** + * Helper method for calling a function + * @param callback + */ + _call: function(callback) { + if ( callback && $.isFunction(callback) ) { + callback.apply(this, Array.prototype.slice.call(arguments, 1)); + } + }, + + /** + * Helper method for google.maps.Latlng + * @param latLng:string/google.maps.LatLng + */ + _latLng: function(latLng) { + if ( !latLng ) { + return new google.maps.LatLng(0.0, 0.0); + } + if ( latLng instanceof google.maps.LatLng ) { + return latLng; + } else { + latLng = latLng.replace(/ /g,'').split(','); + return new google.maps.LatLng(latLng[0], latLng[1]); + } + }, + + /** + * Helper method for unwrapping jQuery/DOM/string elements + * @param obj:string/node/jQuery + */ + _unwrap: function(obj) { + return (!obj) ? null : ( (obj instanceof jQuery) ? obj[0] : ((obj instanceof Object) ? obj : $('#'+obj)[0]) ) + } + + }); + + jQuery.fn.extend( { + + triggerEvent: function(eventType) { + google.maps.event.trigger(this[0], eventType); + return this; + }, + + addEventListener: function(eventType, eventDataOrCallback, eventCallback) { + if ( google.maps && this[0] instanceof google.maps.MVCObject ) { + google.maps.event.addListener(this[0], eventType, eventDataOrCallback); + } else { + if (eventCallback) { + this.bind(eventType, eventDataOrCallback, eventCallback); + } else { + this.bind(eventType, eventDataOrCallback); + } + } + return this; + }, + + removeEventListener: function(eventType) { + if ( google.maps && this[0] instanceof google.maps.MVCObject ) { + if (eventType) { + google.maps.event.clearListeners(this[0], eventType); + } else { + google.maps.event.clearInstanceListeners(this[0]); + } + } else { + this.unbind(eventType); + } + return this; + } + + }); + + jQuery.each(('click rightclick dblclick mouseover mouseout drag dragend').split(' '), function(i, name) { + jQuery.fn[name] = function(a, b) { + return this.addEventListener(name, a, b); + } + }); + +} (jQuery) ); \ No newline at end of file diff --git a/js/jquery/jquery.ui.map.services.js b/js/jquery/jquery.ui.map.services.js new file mode 100644 index 00000000..bcca2c0f --- /dev/null +++ b/js/jquery/jquery.ui.map.services.js @@ -0,0 +1,63 @@ +/*! + * jQuery UI Google Map 3.0-rc + * http://code.google.com/p/jquery-ui-map/ + * Copyright (c) 2010 - 2012 Johan Säll Larsson + * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php + * + * Depends: + * jquery.ui.map.js + */ +( function($) { + + $.extend($.ui.gmap.prototype, { + + /** + * Computes directions between two or more places. + * @param directionsRequest:google.maps.DirectionsRequest + * @param directionsRendererOptions:google.maps.DirectionsRendererOptions (optional) + * @param callback:function(result:google.maps.DirectionsResult, status:google.maps.DirectionsStatus) + * @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#DirectionsRequest + * @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#DirectionsRendererOptions + * @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#DirectionsResult + */ + displayDirections: function(directionsRequest, directionsRendererOptions, callback) { + var self = this; + var directionService = this.get('services > DirectionsService', new google.maps.DirectionsService()); + var directionRenderer = this.get('services > DirectionsRenderer', new google.maps.DirectionsRenderer()); + if ( directionsRendererOptions ) { + directionRenderer.setOptions(directionsRendererOptions); + } + directionService.route(directionsRequest, function(results, status) { + if ( status === 'OK' ) { + directionRenderer.setDirections(results); + directionRenderer.setMap(self.get('map')); + } else { + directionRenderer.setMap(null); + } + callback(results, status); + }); + }, + + /** + * Displays the panorama for a given LatLng or panorama ID. + * @param panel:jQuery/String/Node + * @param streetViewPanoramaOptions:google.maps.StreetViewPanoramaOptions (optional) + * @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#StreetViewPanoramaOptions + */ + displayStreetView: function(panel, streetViewPanoramaOptions) { + this.get('map').setStreetView(this.get('services > StreetViewPanorama', new google.maps.StreetViewPanorama(this._unwrap(panel), streetViewPanoramaOptions))); + }, + + /** + * A service for converting between an address and a LatLng. + * @param geocoderRequest:google.maps.GeocoderRequest + * @param callback:function(result:google.maps.GeocoderResult, status:google.maps.GeocoderStatus), + * @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#GeocoderResult + */ + search: function(geocoderRequest, callback) { + this.get('services > Geocoder', new google.maps.Geocoder()).geocode(geocoderRequest, callback); + } + + }); + +} (jQuery) ); \ No newline at end of file diff --git a/modules/blockbestsellers/blockbestsellers.php b/modules/blockbestsellers/blockbestsellers.php index 03ea98c7..71b4e1c0 100755 --- a/modules/blockbestsellers/blockbestsellers.php +++ b/modules/blockbestsellers/blockbestsellers.php @@ -111,7 +111,7 @@ class BlockBestSellers extends Module if(!$this->isCached('blockbestsellers_'.(int) $cookie->id_lang.'.tpl', $cache_id)) { $currency = new Currency((int)($params['cookie']->id_currency)); - $bestsellers = ProductSale::getBestSalesVp((int)($params['cookie']->id_lang), 0, 5); + $bestsellers = ProductSale::getBestSalesVp((int)($params['cookie']->id_lang), 0, 5, NULL, NULL, 10); if (!$bestsellers AND !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) return; $best_sellers = array(); @@ -152,7 +152,7 @@ class BlockBestSellers extends Module if(!$this->isCached('blockbestsellers_cart_'.(int) $id_lang.'.tpl', $cache_id)) { $currency = new Currency((int)($params['cookie']->id_currency)); - $bestsellers = ProductSale::getBestSalesVp((int)($params['cookie']->id_lang), 0, 3); + $bestsellers = ProductSale::getBestSalesVp((int)($params['cookie']->id_lang), 0, 3, NULL, NULL, 10); if (!$bestsellers AND !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) return; @@ -195,7 +195,7 @@ class BlockBestSellers extends Module if(!$this->isCached('blockbestsellers_home_'.(int) $cookie->id_lang.'.tpl', $cache_id)) { $currency = new Currency((int)($params['cookie']->id_currency)); - $bestsellers = ProductSale::getBestSalesVp((int)($params['cookie']->id_lang), 0, 5); + $bestsellers = ProductSale::getBestSalesVp((int)($params['cookie']->id_lang), 0, 5, NULL, NULL, 10); if (!$bestsellers AND !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) return; $best_sellers = array(); diff --git a/modules/privatesales/AdminPrivateSalesSales.php b/modules/privatesales/AdminPrivateSalesSales.php index 88368248..87b93d8e 100755 --- a/modules/privatesales/AdminPrivateSalesSales.php +++ b/modules/privatesales/AdminPrivateSalesSales.php @@ -2,6 +2,7 @@ include_once(_PS_ROOT_DIR_.'/modules/privatesales/Sale.php'); class AdminPrivateSalesSales extends AdminTab { + private $imagelist; public function __construct() { diff --git a/modules/soflexibilite/soflexibilite.php b/modules/soflexibilite/soflexibilite.php index 70ccdefd..6bcbae82 100644 --- a/modules/soflexibilite/soflexibilite.php +++ b/modules/soflexibilite/soflexibilite.php @@ -1306,14 +1306,6 @@ class soflexibilite extends CarrierModule $soDelivery->city = $address_invoice->city; $soDelivery->country = Country::getIsoById((int)$address_invoice->id_country); }*/ - $address_delivery = new Address((int)$params['cart']->id_address_delivery); - if (Validate::isLoadedObject($address_delivery)) { - $soDelivery->address1 = $address_delivery->address1; - $soDelivery->address2 = $address_delivery->address2; - $soDelivery->postcode = $address_delivery->postcode; - $soDelivery->city = $address_delivery->city; - $soDelivery->country = Country::getIsoById((int)$address_delivery->id_country); - } // OCARAT modif update for customizations if ($this->ps15x) { @@ -1430,13 +1422,15 @@ class soflexibilite extends CarrierModule require_once dirname(__FILE__).'/classes/SoFlexibiliteWebService.php'; // Customer Name - $address = Db::getInstance()->ExecuteS('SELECT * FROM ps_socolissimo_delivery_info WHERE id_cart = '.pSQL((int)$order->id_cart)); + /*$address = Db::getInstance()->ExecuteS('SELECT * FROM ps_socolissimo_delivery_info WHERE id_cart = '.pSQL((int)$order->id_cart)); if(count($address) > 0) { $address = $address[0]; } if (!empty($address['prname']) && !empty($address['prname'])) { $fullname = sprintf('%s %s', $address['prfirstname'], $address['prname']); - } elseif (!empty($soDelivery->firstname) && !empty($soDelivery->lastname)) { + } else*/ + + if (!empty($soDelivery->firstname) && !empty($soDelivery->lastname)) { $fullname = sprintf('%s %s', $soDelivery->firstname, $soDelivery->lastname); } else { $fullname = sprintf('%s %s', $customer_address->firstname, $customer_address->lastname); @@ -1482,7 +1476,8 @@ class soflexibilite extends CarrierModule 'name' => $fullname, 'libelle' => in_array($soDelivery->type, array('DOM', 'DOS', 'BOM', 'BOS')) ? '' : $soDelivery->libelle, 'prid' => $soDelivery->id_point ? sprintf('%06s', $soDelivery->id_point) : null, - 'company' => $soDelivery->company ? $soDelivery->company : $customer_address->company, + /*'company' => $soDelivery->company ? $soDelivery->company : $customer_address->company,*/ + 'company' => $soDelivery->company, 'prname' => isset($relay_informations->nom) ? $relay_informations->nom : '', 'address1' => isset($relay_informations->adresse1) ? $relay_informations->adresse1 : ( in_array($soDelivery->type, array('DOM', 'DOS', 'BOM', 'BOS')) ? @@ -1498,7 +1493,7 @@ class soflexibilite extends CarrierModule 'city' => isset($relay_informations->localite) ? $relay_informations->localite : $soDelivery->city, 'country' => isset($relay_informations->libellePays) ? $relay_informations->libellePays : ( Tools::strlen($soDelivery->country) == 2 ? - Country::getNameById($this->context->employee->id_lang, Country::getByIso($soDelivery->country)) : + Country::getNameById($this->context->employee->id_lang, strtolower($soDelivery->country) == 'fr'? 8: Country::getByIso($soDelivery->country)) : $soDelivery->country ), 'iso_country' => isset($relay_informations->codePays) ? $relay_informations->codePays : $soDelivery->country, diff --git a/modules/stats_logistic/AdminStatsLogistic.php b/modules/stats_logistic/AdminStatsLogistic.php index d1e76f81..1c855b88 100755 --- a/modules/stats_logistic/AdminStatsLogistic.php +++ b/modules/stats_logistic/AdminStatsLogistic.php @@ -5,10 +5,15 @@ class AdminStatsLogistic extends AdminTab { $this->table = 'stats_logistic'; $this->lang = false; $this->date_begin = date('Y-m-d'); + $this->date_end = date('Y-m-d'); $this->date_stock = date('Y-m-d'); + $this->date_export_begin = date('Y-m-d'); $this->date_export_end = date('Y-m-d'); + + $this->date_expe_begin = date('Y-m-d'); + $this->date_expe_end = date('Y-m-d'); if (!empty($_GET['date_begin'])) { $this->date_begin = $_GET['date_begin']; @@ -193,7 +198,6 @@ class AdminStatsLogistic extends AdminTab { } } if ($result) { - //echo "
";var_dump($result);echo "
";die(); $fname = 'export-remb-'.$this->date_export_begin.'-'.$this->date_export_end.'.csv'; foreach(glob(dirname(__FILE__).'/*.csv') as $filename) { if ($fname == $filename) { @@ -208,6 +212,28 @@ class AdminStatsLogistic extends AdminTab { } else { echo '

'.$this->l('No sale found.').'

'; } + } elseif (Tools::getValue('submitExportExp')) { + $this->date_expe_begin = Tools::getValue('date_expe_begin', $this->date_expe_begin); + $this->date_expe_end = Tools::getValue('date_expe_end', $this->date_expe_end); + + $details = $this->getShippingDetails(); + if ($details) { + foreach ($details as $key => &$row) { + $sale_info = $this->getSaleInfo((int)$row['id_sale']); + $row['sale_title'] = $sale_info['title']; + } + + $fname = 'export-expe-'.$this->date_expe_begin.'-'.$this->date_expe_end.'.csv'; + foreach(glob(dirname(__FILE__).'/*.csv') as $filename) { + if ($fname == $filename) { + unlink($filename); + } + } + $this->exportExpeCSV($details, $fname); + echo '

'.$this->l('Export complete.').' '.$this->l('Click here to download the file').'

'; + } else { + echo '

'.$this->l('No result for these dates.').'

'; + } } } @@ -305,6 +331,7 @@ class AdminStatsLogistic extends AdminTab { $poles[3]['name'] = 'Pôle 4 : Postes complementaires'; $poles[4]['name'] = 'Pôle 5 : Multi'; $poles[5]['name'] = 'Pôle 6 : Autre'; + $total_quantity = 0; foreach ($stats as $key => $stat) { if (!isset($stat['id_employee'])) { continue; @@ -349,7 +376,7 @@ class AdminStatsLogistic extends AdminTab { $total_quantity += $stat['quantity']; } $total_colis = $this->getTotalColis(); - $total_quantity = 0; + echo '

Stats de la logistique



-

id OR Tools::getValue('is_virtual_good')=='true') AND $productDownload->active) echo 'checked="checked"' ?> /> -

-
id OR !$productDownload->active) echo 'style="display:none;"' ?> > - -

- l('Your download repository is not writable.'); ?>
- -

- - id) echo '' ?> -

- checkFile()): ?> + //]]> + + + '; + ?> +

+

id OR Tools::getValue('is_virtual_good')=='true') AND $productDownload->active) echo 'checked="checked"' ?> /> +

+
id OR !$productDownload->active) echo 'style="display:none;"' ?> > + +

+ l('Your download repository is not writable.'); ?>
+ +

+ + id) echo '' ?> +

+ checkFile()): ?> -

- id): ?> -

- l('This product is missing') ?>:
- physically_filename ?> -

- -

l('Your server\'s maximum upload file size is') . ': '.$upload_mb.$this->l('Mb') ?>

- - -

- -
- - - -
- - - - l('This is the link').': '.$productDownload->getHtmlLink(false, true) ?> - l('Delete this file') ?> - -

-

- - - -

+
+ id): ?> +

+ l('This product is missing') ?>:
+ physically_filename ?> +

+ +

l('Your server\'s maximum upload file size is') . ': '.$upload_mb.$this->l('Mb') ?>

+ + +

+ +
+ + + +
+ + + + l('This is the link').': '.$productDownload->getHtmlLink(false, true) ?> + l('Delete this file') ?> + +

+

+ + + +

-
-
+
+
-

- - - -

-

- - + + + +

+

+ + l('Format: YYYY-MM-DD'); ?> - -

-

- - * - -

-
- -
-


'.$this->l('Pre-tax wholesale price:').'
@@ -453,21 +480,41 @@ class AdminStatsLogistic extends AdminTab { } echo '
'; - if( $cookie->id_employee == 1) { - echo '

Export Remboursemments

+ + echo '

Export Remboursements

+
+

Exporter le détail des ventes dont la date de début est comprise entre :

+
' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'
+
'; + + if ($cookie->id_employee == 1 || $cookie->id_employee == 2 || $cookie->id_employee == 7) { + echo '

Export Expeditions La Poste

+

Exporter le détail des expeditions dont la date est comprise entre :

' .'' .'' - .'' + .'' .'' .'' .'' - .'' + .'' .'' .'' .'' - .'' + .'' .'
' ; @@ -544,6 +591,19 @@ class AdminStatsLogistic extends AdminTab { '); } + public function getShippingDetails() { + return Db::getInstance()->ExecuteS(' + SELECT pws.`id_order_detail`, pws.`shipping_number`, pws.`date_add`, pws.`quantity`, e.`email` AS `poste`, od.`id_order`, od.`product_id`, od.`product_attribute_id`, od.`product_name`, psc.`id_sale`, od.`product_quantity`, + ROUND(((od.`product_price` * (1 - od.`reduction_percent` / 100) - od.`reduction_amount`) * (1 - od.`group_reduction` / 100) * (1 + od.`tax_rate` / 100)), 6) AS `price` + FROM `'._DB_PREFIX_.'lapostews` pws + LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = pws.`id_order_detail`) + LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.`id_employee` = pws.`id_employee`) + LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` psc ON (psc.`id_product` = od.`product_id`) + WHERE pws.`date_add` BETWEEN "'.pSQL($this->date_expe_begin).'" AND "'.pSQL($this->date_expe_end).'" + ORDER BY pws.`date_add` ASC + '); + } + public function getSales() { return Db::getInstance()->ExecuteS(' SELECT p.`id_sale`, p.`date_start`, l.`name` as title @@ -555,6 +615,17 @@ class AdminStatsLogistic extends AdminTab { '); } + public function getSaleInfo($id_sale) { + return Db::getInstance()->getRow(' + SELECT p.`date_start`, l.`name` as title + FROM `'._DB_PREFIX_.'privatesale` p + LEFT JOIN `ps_privatesale_category` c ON (c.`id_sale` = p.`id_sale`) + LEFT JOIN `ps_category_lang` l ON (l.`id_category` = p.`id_category`) + WHERE p.`id_sale` = '.(int)$id_sale.' + AND l.`id_lang` = '. (int) Context::getContext()->language->id.' + '); + } + public function getProducts($id_sale) { $product_ids = array(); foreach(Db::getInstance()->ExecuteS(' @@ -567,6 +638,38 @@ class AdminStatsLogistic extends AdminTab { return $product_ids; } + public function exportExpeCSV ($items, $filename) { + $fp = fopen(dirname(__FILE__).'/'.$filename, 'w'); + $delim = ';'; + + $row_definition = array( + 'shipping_number' => 'N. de suivi', + 'date_add' => 'date d\'expe', + 'poste' => 'Poste d\'expe', + 'id_order' => 'id_order', + 'id_sale' => 'id_sale', + 'sale_title' => 'sale_title', + 'product_id' => 'id_product', + 'product_name' => 'product_name', + 'price' => 'product_price', + 'product_quantity' => 'Quantite envoyee', + ); + + $data=array(); + foreach ($row_definition as $col) { + $data[] = $col; + } + fputcsv ($fp,$data,$delim); + foreach ($items as $item) { + $data = array(); + foreach ($row_definition as $key => $col) { + $data[] = (isset($item[$key]) ? $item[$key] : ''); + } + fputcsv ($fp,array_map('utf8_decode',array_values($data)),$delim); + } + fclose($fp); + } + public function exportCSV ($result, $filename) { //$fp = fopen("php://output", 'w'); $fp = fopen(dirname(__FILE__).'/'.$filename, 'w'); diff --git a/override/classes/AttributeGroup.php b/override/classes/AttributeGroup.php new file mode 100644 index 00000000..918d3df4 --- /dev/null +++ b/override/classes/AttributeGroup.php @@ -0,0 +1,47 @@ +ExecuteS(' + SELECT pac.`id_attribute`, pa.`id_product_attribute` + FROM `'._DB_PREFIX_.'product_attribute` pa LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pa.`id_product_attribute` = pac.`id_product_attribute`) + WHERE pac.`id_attribute`=0 + '); + $toRemove = array(); + foreach ($attributeCombinations AS $attributeCombination) + if ((int)($attributeCombination['id_attribute']) == 0) + $toRemove[] = (int)($attributeCombination['id_product_attribute']); + if (!empty($toRemove) AND Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'product_attribute` WHERE `id_product_attribute` IN ('.implode(', ', $toRemove).')') === false) + return false; + return true; + } + + public function delete() + { + /* Select children in order to find linked combinations */ + $attributeIds = Db::getInstance()->ExecuteS('SELECT `id_attribute` FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)($this->id)); + if ($attributeIds === false) + return false; + /* Removing attributes to the found combinations */ + $toRemove = array(); + foreach ($attributeIds AS $attribute) + $toRemove[] = (int)($attribute['id_attribute']); + if (!empty($toRemove) AND Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'product_attribute_combination` WHERE `id_attribute` IN ('.implode(', ', $toRemove).')') === false) + return false; + /* Remove combinations if they do not possess attributes anymore */ + if (!self::cleanDeadCombinations()) + return false; + /* Also delete related attributes */ + if (Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'attribute_lang` WHERE `id_attribute` IN (SELECT id_attribute FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)($this->id).')') === false OR Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)($this->id)) === false) + return false; + $return = parent::delete(); + if($return) + Module::hookExec('afterDeleteAttributeGroup', array('id_attribute_group' => $this->id)); + return $return; + } +} diff --git a/override/classes/FrontController.php b/override/classes/FrontController.php index ad69b939..71b92e1c 100755 --- a/override/classes/FrontController.php +++ b/override/classes/FrontController.php @@ -445,7 +445,7 @@ class FrontController extends FrontControllerCore { public function setMedia() { global $cookie; - Tools::addCSS(_THEME_CSS_DIR_.'style.css?v=30'); + Tools::addCSS(_THEME_CSS_DIR_.'style.css?v=31'); Tools::addJS(array(_PS_JS_DIR_.'scripts.js')); if(Tools::isSubmit('live_edit') AND Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_))) { diff --git a/override/classes/Product.php b/override/classes/Product.php index 1dc96009..1bbc4f60 100644 --- a/override/classes/Product.php +++ b/override/classes/Product.php @@ -2,69 +2,69 @@ class Product extends ProductCore { public $description_more; - public $description_delivery; - public $videos; + public $description_delivery; + public $videos; - /** - * @Override - */ - protected $fieldsValidateLang = array( - 'meta_description' => 'isGenericName', 'meta_keywords' => 'isGenericName', - 'meta_title' => 'isGenericName', 'link_rewrite' => 'isLinkRewrite', 'name' => 'isCatalogName', - 'description' => 'isString', 'description_short' => 'isString', 'available_now' => 'isGenericName', 'available_later' => 'IsGenericName', - 'description_more' => 'isString','videos' => 'isString', 'description_delivery' => 'isString'); + /** + * @Override + */ + protected $fieldsValidateLang = array( + 'meta_description' => 'isGenericName', 'meta_keywords' => 'isGenericName', + 'meta_title' => 'isGenericName', 'link_rewrite' => 'isLinkRewrite', 'name' => 'isCatalogName', + 'description' => 'isString', 'description_short' => 'isString', 'available_now' => 'isGenericName', 'available_later' => 'IsGenericName', + 'description_more' => 'isString','videos' => 'isString', 'description_delivery' => 'isString'); - /** - * @Override - * Check then return multilingual fields for database interaction - * - * @return array Multilingual fields - */ - public function getTranslationsFieldsChild() - { - self::validateFieldsLang(); + /** + * @Override + * Check then return multilingual fields for database interaction + * + * @return array Multilingual fields + */ + public function getTranslationsFieldsChild() + { + self::validateFieldsLang(); - $fieldsArray = array('meta_description', 'meta_keywords', 'meta_title', 'link_rewrite', 'name', 'available_now', 'available_later'); - $fields = array(); - $languages = Language::getLanguages(false); - $defaultLanguage = Configuration::get('PS_LANG_DEFAULT'); - foreach ($languages as $language) - { - $fields[$language['id_lang']]['id_lang'] = $language['id_lang']; - $fields[$language['id_lang']][$this->identifier] = (int)($this->id); - $fields[$language['id_lang']]['description'] = (isset($this->description[$language['id_lang']])) ? pSQL($this->description[$language['id_lang']], true) : ''; - $fields[$language['id_lang']]['description_short'] = (isset($this->description_short[$language['id_lang']])) ? pSQL($this->description_short[$language['id_lang']], true) : ''; - $fields[$language['id_lang']]['description_more'] = (isset($this->description_more[$language['id_lang']])) ? pSQL($this->description_more[$language['id_lang']], true) : ''; - $fields[$language['id_lang']]['videos'] = (isset($this->videos[$language['id_lang']])) ? pSQL($this->videos[$language['id_lang']], true) : ''; - $fields[$language['id_lang']]['description_delivery'] = (isset($this->description_delivery[$language['id_lang']])) ? pSQL($this->description_delivery[$language['id_lang']], true) : ''; - foreach ($fieldsArray as $field) - { - if (!Validate::isTableOrIdentifier($field)) - die(Tools::displayError()); + $fieldsArray = array('meta_description', 'meta_keywords', 'meta_title', 'link_rewrite', 'name', 'available_now', 'available_later'); + $fields = array(); + $languages = Language::getLanguages(false); + $defaultLanguage = Configuration::get('PS_LANG_DEFAULT'); + foreach ($languages as $language) + { + $fields[$language['id_lang']]['id_lang'] = $language['id_lang']; + $fields[$language['id_lang']][$this->identifier] = (int)($this->id); + $fields[$language['id_lang']]['description'] = (isset($this->description[$language['id_lang']])) ? pSQL($this->description[$language['id_lang']], true) : ''; + $fields[$language['id_lang']]['description_short'] = (isset($this->description_short[$language['id_lang']])) ? pSQL($this->description_short[$language['id_lang']], true) : ''; + $fields[$language['id_lang']]['description_more'] = (isset($this->description_more[$language['id_lang']])) ? pSQL($this->description_more[$language['id_lang']], true) : ''; + $fields[$language['id_lang']]['videos'] = (isset($this->videos[$language['id_lang']])) ? pSQL($this->videos[$language['id_lang']], true) : ''; + $fields[$language['id_lang']]['description_delivery'] = (isset($this->description_delivery[$language['id_lang']])) ? pSQL($this->description_delivery[$language['id_lang']], true) : ''; + foreach ($fieldsArray as $field) + { + if (!Validate::isTableOrIdentifier($field)) + die(Tools::displayError()); - /* Check fields validity */ - if (isset($this->{$field}[$language['id_lang']]) AND !empty($this->{$field}[$language['id_lang']])) - $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$language['id_lang']]); - elseif (in_array($field, $this->fieldsRequiredLang)) - { - if ($this->{$field} != '') - $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$defaultLanguage]); - } - else - $fields[$language['id_lang']][$field] = ''; - } - } - return $fields; - } + /* Check fields validity */ + if (isset($this->{$field}[$language['id_lang']]) AND !empty($this->{$field}[$language['id_lang']])) + $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$language['id_lang']]); + elseif (in_array($field, $this->fieldsRequiredLang)) + { + if ($this->{$field} != '') + $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$defaultLanguage]); + } + else + $fields[$language['id_lang']][$field] = ''; + } + } + return $fields; + } - public function getCustomFields() { - $customs_data = Db::getInstance()->getRow(' - SELECT `nc8`, `id_country` - FROM `'._DB_PREFIX_.'product_customs` - WHERE id_product = '.(int)$this->id - ); - return $customs_data; - } + public function getCustomFields() { + $customs_data = Db::getInstance()->getRow(' + SELECT `nc8`, `id_country` + FROM `'._DB_PREFIX_.'product_customs` + WHERE id_product = '.(int)$this->id + ); + return $customs_data; + } /** * @Override diff --git a/override/classes/ProductSale.php b/override/classes/ProductSale.php index e0cc0490..f44b7cbf 100644 --- a/override/classes/ProductSale.php +++ b/override/classes/ProductSale.php @@ -1,7 +1,7 @@