diff --git a/admin-dev/tabs/AdminProducts.php b/admin-dev/tabs/AdminProducts.php index 46a9292ed..9b5d103d4 100644 --- a/admin-dev/tabs/AdminProducts.php +++ b/admin-dev/tabs/AdminProducts.php @@ -484,27 +484,36 @@ class AdminProducts extends AdminTab $this->_errors[] = Tools::displayError('This attribute already exists.'); else { - $product->updateProductAttribute($id_product_attribute, - Tools::getValue('attribute_wholesale_price'), - Tools::getValue('attribute_price') * Tools::getValue('attribute_price_impact'), - Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact'), - Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact'), - Tools::getValue('attribute_ecotax'), - false, - Tools::getValue('id_image_attr'), - Tools::getValue('attribute_reference'), - Tools::getValue('attribute_supplier_reference'), - Tools::getValue('attribute_ean13'), - Tools::getValue('attribute_default'), - Tools::getValue('attribute_location'), - Tools::getValue('attribute_upc'), - Tools::getValue('minimal_quantity')); - if ($id_reason = (int)Tools::getValue('id_mvt_reason') AND (int)Tools::getValue('attribute_mvt_quantity') > 0 AND $id_reason > 0) + if (Validate::isDateFormat(Tools::getValue('available_date_combi'))) { - if (!$product->addStockMvt(Tools::getValue('attribute_mvt_quantity'), $id_reason, $id_product_attribute, NULL, $this->context->employee->id)) - $this->_errors[] = Tools::displayError('An error occurred while updating qty.'); + $product->updateProductAttribute($id_product_attribute, + Tools::getValue('attribute_wholesale_price'), + Tools::getValue('attribute_price') * Tools::getValue('attribute_price_impact'), + Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact'), + Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact'), + Tools::getValue('attribute_ecotax'), + false, + Tools::getValue('id_image_attr'), + Tools::getValue('attribute_reference'), + Tools::getValue('attribute_supplier_reference'), + Tools::getValue('attribute_ean13'), + Tools::getValue('attribute_default'), + Tools::getValue('attribute_location'), + Tools::getValue('attribute_upc'), + Tools::getValue('minimal_quantity'), + Tools::getValue('available_date_combi')); + + if ($id_reason = (int)Tools::getValue('id_mvt_reason') AND (int)Tools::getValue('attribute_mvt_quantity') > 0 AND $id_reason > 0) + { + if (!$product->addStockMvt(Tools::getValue('attribute_mvt_quantity'), $id_reason, $id_product_attribute, NULL, $this->context->employee->id)) + $this->_errors[] = Tools::displayError('An error occurred while updating qty.'); + } + Hook::updateProductAttribute((int)$id_product_attribute); + } + else + { + $this->_errors[] = Tools::displayError('Invalid date format.'); } - Hook::updateProductAttribute((int)$id_product_attribute); } } else @@ -2631,8 +2640,27 @@ class AdminProducts extends AdminTab '.$this->l('Forbidden characters:').' <>;=#{} '; echo ' - + '; + // Check if product has combination, to display the available date only for the product or for each combination + if (Combination::isFeatureActive()) + $countAttributes = (int)Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.(int)$obj->id); + + if (isset($countAttributes) && $countAttributes == 0) + { + echo ' +
+ \''.$product_attribute['quantity'].'\', \''.($attrImage ? $attrImage->id : 0).'\', Array('.$jsList.'), \''.$id_product_attribute.'\', \''.$product_attribute['default_on'].'\', \''.$product_attribute['ecotax'].'\', \''.$product_attribute['location'].'\', \''.$product_attribute['upc'].'\', \''.$product_attribute['minimal_quantity'].'\', \''.$available_date.'\'); calcImpactPriceTI();" />
'.(!$product_attribute['default_on'] ? '
' : '').'
diff --git a/classes/Combination.php b/classes/Combination.php
index f8ac8f97f..8823fb85a 100644
--- a/classes/Combination.php
+++ b/classes/Combination.php
@@ -51,6 +51,8 @@ class CombinationCore extends ObjectModel
public $default_on;
+ public $available_date_combi;
+
protected $fieldsRequired = array(
'id_product',
);
@@ -76,6 +78,7 @@ class CombinationCore extends ObjectModel
'quantity' => 'isUnsignedInt',
'weight' => 'isFloat',
'default_on' => 'isBool',
+ 'available_date_combi' => 'isDate',
);
protected $table = 'product_attribute';
@@ -108,6 +111,7 @@ class CombinationCore extends ObjectModel
$fields['quantity'] = (int)($this->quantity);
$fields['weight'] = pSQL($this->weight);
$fields['default_on'] = (int)($this->default_on);
+ $fields['available_date_combi'] = pSQL($this->available_date_combi);
return $fields;
}
diff --git a/classes/Product.php b/classes/Product.php
index 8e915fb6e..a8a3f84d4 100644
--- a/classes/Product.php
+++ b/classes/Product.php
@@ -174,6 +174,9 @@ class ProductCore extends ObjectModel
/** @var boolean Product available for order */
public $available_for_order = 1;
+ /** @var string Object available order date */
+ public $available_date;
+
/** @var enum Product condition (new, used, refurbished) */
public $condition;
@@ -246,6 +249,7 @@ class ProductCore extends ObjectModel
'text_fields' => 'isUnsignedInt',
'active' => 'isBool',
'available_for_order' => 'isBool',
+ 'available_date' => 'isDate',
'condition' => 'isGenericName',
'show_price' => 'isBool',
'ean13' => 'isEan13',
@@ -376,6 +380,7 @@ class ProductCore extends ObjectModel
$fields['text_fields'] = (int)($this->text_fields);
$fields['active'] = (int)($this->active);
$fields['available_for_order'] = (int)($this->available_for_order);
+ $fields['available_date'] = pSQL($this->available_date);
$fields['condition'] = pSQL($this->condition);
$fields['show_price'] = (int)($this->show_price);
$fields['indexed'] = 0; // Reset indexation every times
@@ -1036,7 +1041,7 @@ class ProductCore extends ObjectModel
* @param string $minimal_quantity Minimal quantity
* @return array Update result
*/
- public function updateProductAttribute($id_product_attribute, $wholesale_price, $price, $weight, $unit, $ecotax, $quantity, $id_images, $reference, $supplier_reference, $ean13, $default, $location = NULL, $upc = NULL, $minimal_quantity)
+ public function updateProductAttribute($id_product_attribute, $wholesale_price, $price, $weight, $unit, $ecotax, $quantity, $id_images, $reference, $supplier_reference, $ean13, $default, $location = NULL, $upc = NULL, $minimal_quantity, $available_date_combi)
{
Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'product_attribute_combination`
@@ -1056,7 +1061,8 @@ class ProductCore extends ObjectModel
'ean13' => pSQL($ean13),
'upc' => pSQL($upc),
'default_on' => (int)($default),
- 'minimal_quantity' => (int)($minimal_quantity)
+ 'minimal_quantity' => (int)($minimal_quantity),
+ 'available_date_combi' => pSQL($available_date_combi)
);
if ($quantity)
@@ -2292,7 +2298,7 @@ class ProductCore extends ObjectModel
if (!Combination::isFeatureActive())
return array();
$sql = 'SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name, a.`id_attribute`, al.`name` AS attribute_name,
- a.`color` AS attribute_color, pa.`id_product_attribute`, stock.quantity, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference`, pa.`unit_price_impact`, pa.`minimal_quantity`
+ a.`color` AS attribute_color, pa.`id_product_attribute`, stock.quantity, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference`, pa.`unit_price_impact`, pa.`minimal_quantity`, pa.`available_date_combi`
FROM `'._DB_PREFIX_.'product_attribute` pa
'.Product::sqlStock('pa', 'pa').'
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute`
diff --git a/controllers/ProductController.php b/controllers/ProductController.php
index a8cceb02e..c08726317 100644
--- a/controllers/ProductController.php
+++ b/controllers/ProductController.php
@@ -289,6 +289,9 @@ class ProductControllerCore extends FrontController
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0;
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int)($row['quantity']);
+ //french date format
+ $availableDateCombi = date('j-m-Y',strtotime($row['available_date_combi']));
+
$combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name'];
$combinations[$row['id_product_attribute']]['attributes'][] = (int)($row['id_attribute']);
$combinations[$row['id_product_attribute']]['price'] = (float)($row['price']);
@@ -298,6 +301,7 @@ class ProductControllerCore extends FrontController
$combinations[$row['id_product_attribute']]['reference'] = $row['reference'];
$combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact'];
$combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity'];
+ $combinations[$row['id_product_attribute']]['available_date_combi'] = $availableDateCombi;
$combinations[$row['id_product_attribute']]['id_image'] = isset($combinationImages[$row['id_product_attribute']][0]['id_image']) ? $combinationImages[$row['id_product_attribute']][0]['id_image'] : -1;
}
diff --git a/install-dev/sql/db.sql b/install-dev/sql/db.sql
index b55e12548..e50ac59a8 100644
--- a/install-dev/sql/db.sql
+++ b/install-dev/sql/db.sql
@@ -1177,6 +1177,7 @@ CREATE TABLE `PREFIX_product` (
`text_fields` tinyint(4) NOT NULL default '0',
`active` tinyint(1) unsigned NOT NULL default '0',
`available_for_order` tinyint(1) NOT NULL default '1',
+ `available_date` datetime NOT NULL,
`condition` ENUM('new', 'used', 'refurbished') NOT NULL DEFAULT 'new',
`show_price` tinyint(1) NOT NULL default '1',
`indexed` tinyint(1) NOT NULL default '0',
@@ -1209,6 +1210,7 @@ CREATE TABLE `PREFIX_product_attribute` (
`unit_price_impact` decimal(17,2) NOT NULL default '0.00',
`default_on` tinyint(1) unsigned NOT NULL default '0',
`minimal_quantity` int(10) unsigned NOT NULL DEFAULT '1',
+ `available_date_combi` datetime NOT NULL,
PRIMARY KEY (`id_product_attribute`),
KEY `product_attribute_product` (`id_product`),
KEY `reference` (`reference`),
@@ -1908,4 +1910,4 @@ CREATE TABLE `PREFIX_discount_shop` (
`id_shop` INT( 11 ) UNSIGNED NOT NULL,
PRIMARY KEY (`id_discount`, `id_shop`),
KEY `id_shop` (`id_shop`)
-) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
\ No newline at end of file
+) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
diff --git a/install-dev/sql/upgrade/1.5.0.1.sql b/install-dev/sql/upgrade/1.5.0.1.sql
index c8c2ca107..5bd4936fc 100644
--- a/install-dev/sql/upgrade/1.5.0.1.sql
+++ b/install-dev/sql/upgrade/1.5.0.1.sql
@@ -70,4 +70,8 @@ INSERT INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) VAL
('PS_SHOW_NEW_CUSTOMERS', '1', NOW(), NOW()),
('PS_SHOW_NEW_MESSAGES', '1', NOW(), NOW()),
('PS_FEATURE_FEATURE_ACTIVE', '1', NOW(), NOW()),
-('PS_COMBINATION_FEATURE_ACTIVE', '1', NOW(), NOW());
\ No newline at end of file
+('PS_COMBINATION_FEATURE_ACTIVE', '1', NOW(), NOW());
+
+ALTER TABLE `PREFIX_product` ADD `available_date` DATETIME NOT NULL AFTER `available_for_order`
+
+ALTER TABLE `ps_product_attribute` ADD `available_date_combi` DATETIME NOT NULL
diff --git a/js/attributesBack.js b/js/attributesBack.js
index 0baedf890..90c5bbb80 100644
--- a/js/attributesBack.js
+++ b/js/attributesBack.js
@@ -26,7 +26,7 @@
var storeUsedGroups = {};
-function fillCombinaison(wholesale_price, price_impact, weight_impact, unit_impact, reference, supplier_reference, ean, quantity, image, old_attr, id_product_attribute, default_attribute, eco_tax, location, upc, minimal_quantity)
+function fillCombinaison(wholesale_price, price_impact, weight_impact, unit_impact, reference, supplier_reference, ean, quantity, image, old_attr, id_product_attribute, default_attribute, eco_tax, location, upc, minimal_quantity, available_date_combi)
{
init_elems();
$('#stock_mvt_attribute').show();
@@ -34,6 +34,10 @@ function fillCombinaison(wholesale_price, price_impact, weight_impact, unit_impa
$('#attribute_quantity').html(quantity);
$('#attribute_quantity').show();
$('#attr_qty_stock').show();
+ if(available_date_combi!=undefined)
+ getE('available_date_combi').value = available_date_combi;
+ else
+ getE('available_date_combi').value = '0000-00-00';
getE('minimal_quantity').value = minimal_quantity;
getE('attribute_reference').value = reference;
getE('attribute_supplier_reference').value = supplier_reference;
diff --git a/themes/prestashop/css/product.css b/themes/prestashop/css/product.css
index 42a430f74..57633cd57 100755
--- a/themes/prestashop/css/product.css
+++ b/themes/prestashop/css/product.css
@@ -99,7 +99,7 @@
float: right
}
#primary_block #buy_block span.our_price_display { float: right }
-#primary_block #buy_block span#availability_label {
+#primary_block #buy_block span#availability_label, #primary_block #buy_block span#availability_date_label {
float: left;
margin-right: 1em
}
diff --git a/themes/prestashop/js/product.js b/themes/prestashop/js/product.js
index f2423f1ca..f49a96d0a 100644
--- a/themes/prestashop/js/product.js
+++ b/themes/prestashop/js/product.js
@@ -50,7 +50,7 @@ function oosHookJsCode()
}
//add a combination of attributes in the global JS sytem
-function addCombination(idCombination, arrayOfIdAttributes, quantity, price, ecotax, id_image, reference, unit_price, minimal_quantity)
+function addCombination(idCombination, arrayOfIdAttributes, quantity, price, ecotax, id_image, reference, unit_price, minimal_quantity, available_date_combi)
{
globalQuantity += quantity;
@@ -64,6 +64,7 @@ function addCombination(idCombination, arrayOfIdAttributes, quantity, price, eco
combination['reference'] = reference;
combination['unit_price'] = unit_price;
combination['minimal_quantity'] = minimal_quantity;
+ combination['available_date_combi'] = available_date_combi;
combinations.push(combination);
}
@@ -119,6 +120,9 @@ function findCombination(firstTime)
if (combinations[combination]['image'] && combinations[combination]['image'] != -1)
displayImage( $('#thumb_'+combinations[combination]['image']).parent() );
+ //get available_date for combination product
+ selectedCombination['available_date_combi'] = combinations[combination]['available_date_combi'];
+
//update the display
updateDisplay();
@@ -163,6 +167,10 @@ function updateDisplay()
//hide the hook out of stock
$('#oosHook').hide();
+
+ //hide availability date
+ $('#availability_date_label').hide();
+ $('#availability_date_value').hide();
//availability value management
if (availableNowValue != '')
@@ -233,7 +241,25 @@ function updateDisplay()
$('#oosHook').hide();
}
$('#availability_statut:hidden').show();
-
+
+ //display availability date
+ var date_combi = selectedCombination['available_date_combi'];
+ tab_date = date_combi.split('-');
+ var time_combi = new Date(tab_date[2], tab_date[1], tab_date[0]);
+ time_combi.setMonth(time_combi.getMonth()-1);
+ var now = new Date();
+ // date displayed only if time_combi
+ if (now.getTime() < time_combi.getTime())
+ {
+ $('#availability_date_value').text(selectedCombination['available_date_combi']);
+ $('#availability_date_label').show();
+ $('#availability_date_value').show();
+ }
+ else
+ {
+ $('#availability_date_label').hide();
+ $('#availability_date_value').hide();
+ }
//show the 'add to cart' button ONLY IF it's possible to buy when out of stock AND if it was previously invisible
if (allowBuyWhenOutOfStock && !selectedCombination['unavailable'] && productAvailableForOrder == 1)
diff --git a/themes/prestashop/lang/fr.php b/themes/prestashop/lang/fr.php
index 8a602795b..305237de4 100644
--- a/themes/prestashop/lang/fr.php
+++ b/themes/prestashop/lang/fr.php
@@ -414,9 +414,9 @@ $_LANG['order-opc-new-account_bd9014fe70f4f8bb1beed74e3b708483'] = 'Code postal'
$_LANG['order-opc-new-account_57d056ed0984166336b7879c2af3657f'] = 'Ville';
$_LANG['order-opc-new-account_59716c97497eb9694541f7c3d37b1a4d'] = 'Pays';
$_LANG['order-opc-new-account_7cb32e708d6b961d476baced73d362bb'] = 'Numéro de TVA';
+$_LANG['order-opc-new-account_46a2a41cc6e552044816a2d04634545d'] = 'État';
$_LANG['order-opc-new-account_b60bb13a87fe3ae5463aeb0980a5a8a1'] = 'Numéro d\'identification fiscale';
$_LANG['order-opc-new-account_ea318a4ad37f0c2d2c368e6c958ed551'] = 'DNI / NIF / NIE';
-$_LANG['order-opc-new-account_46a2a41cc6e552044816a2d04634545d'] = 'État';
$_LANG['order-opc-new-account_0f68b904e33d9ac04605aecc958bcf52'] = 'Informations complémentaires';
$_LANG['order-opc-new-account_fe66abce284ec8589e7d791185b5c442'] = 'Téléphone';
$_LANG['order-opc-new-account_41c2fff4867cc204120f001e7af20f7a'] = 'Téléphone portable';
@@ -449,7 +449,6 @@ $_LANG['order-payment_f5bf48aa40cad7891eb709fcf1fde128'] = 'produit';
$_LANG['order-payment_86024cad1e83101d97359d7351051156'] = 'produits';
$_LANG['order-payment_59319ac504f7ad04ae16126cf49e7f7e'] = 'Votre méthode de paiement';
$_LANG['order-payment_9e6d9b3daa15e41d36806a289c42674d'] = 'Choisissez votre méthode de paiement';
-$_LANG['order-payment_df33aeec3bf8aa7e8c63b2c4b04898c5'] = 'Merci de choisir votre moyen de paiement afin de régler la somme de';
$_LANG['order-payment_1f87346a16cf80c372065de3c54c86d9'] = 'TTC';
$_LANG['order-payment_8e1263b23607508e7ba8ff39aec8031d'] = 'Aucun module de paiement n\'a encore été installé.';
$_LANG['order-payment_dd1f775e443ff3b9a89270713580a51b'] = 'Précédent';
@@ -563,6 +562,7 @@ $_LANG['product_2c59ffd0a6631127450d729861975719'] = 'Quantité :';
$_LANG['product_07d814a3df5cfd2d637e77b215519034'] = 'Vous devez ajouter au minimum ';
$_LANG['product_f3bbad73b35f19730399b3da21c3ef32'] = ' quantités pour acheter ce produit.';
$_LANG['product_8c751c4aab0db0b811cdfbddf0b4ea56'] = 'Disponibilité :';
+$_LANG['product_0aaaa7c13d1b589640482d1e53135eb4'] = 'Réapprovisionnement le:';
$_LANG['product_4b98be16b76b0941840140f2043432a9'] = 'pièce disponible';
$_LANG['product_e16d56df08bbd47e53e153fc6dfc8ad8'] = 'pièces disponibles';
$_LANG['product_0d83f0026f6d2923b2aa3a208156918c'] = 'Attention : dernières pièces disponibles !';
@@ -573,8 +573,8 @@ $_LANG['product_8beee69f53dcd358f9e333de43a3f506'] = 'quantités';
$_LANG['product_221d2a4bfdae13dbd5aeff3b02adb8c1'] = 'quantité';
$_LANG['product_71948aa4f6e12cdaa5e2e63a5eb8f142'] = 'En savoir plus';
$_LANG['product_7dcd185f890fd28f69d1ed210292d77f'] = 'Fiche technique';
-$_LANG['product_801ab24683a4a8c433c6eb40c48bcd9d'] = 'Télécharger';
$_LANG['product_98edb85b00d9527ad5acebe451b3fae6'] = 'Accessoires';
+$_LANG['product_801ab24683a4a8c433c6eb40c48bcd9d'] = 'Télécharger';
$_LANG['product_d3da97e2d9aee5c8fbe03156ad051c99'] = 'Plus';
$_LANG['product_4351cfebe4b61d8aa5efa1d020710005'] = 'Voir';
$_LANG['product_cb3c718c905f00adbb6735f55bfb38ef'] = 'Disponible avec différentes options';
diff --git a/themes/prestashop/product.tpl b/themes/prestashop/product.tpl
index 805a2f9e0..bcc28733d 100644
--- a/themes/prestashop/product.tpl
+++ b/themes/prestashop/product.tpl
@@ -108,7 +108,7 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus
{if isset($groups)}
// Combinations
{foreach from=$combinations key=idCombination item=combination}
- addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}', {$combination.unit_impact}, {$combination.minimal_quantity});
+ addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}', {$combination.unit_impact}, {$combination.minimal_quantity}, '{$combination.available_date_combi}');
{/foreach}
// Colors
{if $colors|@count > 0}
@@ -340,6 +340,11 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus
quantity <= 0} class="warning_inline"{/if}>
{if $product->quantity <= 0}{if $allow_oosp}{$product->available_later}{else}{l s='This product is no longer in stock'}{/if}{else}{$product->available_now}{/if}
+
+ {if ($product->available_date && $product->available_date != 0) && ($product->available_date|date_format:"%Y-%m-%d" >= $smarty.now|date_format:"%Y-%m-%d") && $product->quantity <= 0}