Merge branch 'ticket-eanUpgrade' into develop

This commit is contained in:
Marion Muszynski 2016-09-20 14:49:30 +02:00
commit 430cabc449
5 changed files with 431 additions and 368 deletions

View File

@ -1815,6 +1815,7 @@ class AdminProducts extends AdminTab
echo '<input type="checkbox" name="blocks[]" value="short_description"> Description courte ';
echo '<input type="checkbox" name="blocks[]" value="description"> Bon à savoir ';
echo '<input type="checkbox" name="blocks[]" value="description_more"> Les plus ';
echo '<input type="checkbox" name="blocks[]" value="description_comment"> Commentaires (braderie) ';
echo '<input type="checkbox" name="blocks[]" value="videos"> Vidéos ';
echo '<input type="checkbox" name="blocks[]" value="description_delivery"> Livraison ';
@ -3404,6 +3405,16 @@ class AdminProducts extends AdminTab
echo ' <div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').';float: left;">
<textarea class="other_textarea" cols="100" rows="3" id="description_more_'.$language['id_lang'].'" name="description_more_'.$language['id_lang'].'">'.htmlentities(stripslashes($this->getFieldValue($obj, 'description_more', $language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
</div>';
echo ' </td>
</tr>
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
<tr>
<td class="col-left">'.$this->l('Comments :').'<br /><br /></td>
<td style="padding-bottom:5px;" class="translatable">';
foreach ($this->_languages as $language)
echo ' <div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').';float: left;">
<textarea class="other_textarea" cols="100" rows="3" id="description_comment_'.$language['id_lang'].'" name="description_comment_'.$language['id_lang'].'">'.htmlentities(stripslashes($this->getFieldValue($obj, 'description_comment', $language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
</div>';
echo ' </td>
</tr>
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>

View File

@ -129,11 +129,19 @@ class AdminBraderie extends AdminTab
$("#hidden_attribute_id").val(0);
}
$("#hidden_product_id").val($product_id);
if(response.comments != null){
tinymce.activeEditor.setContent(response.comments);
} else {
tinymce.activeEditor.setContent("");
}
$("#comment_input_group").show();
$("#error").empty();
$("#input_storage").focus();
},
error: function(xhr) {
$("#ean_from_product").empty();
$("#input_comment").val("");
$("#comment_input_group").hide();
$("#error").empty().append(JSON.parse(xhr.responseText));
}
});
@ -155,6 +163,10 @@ class AdminBraderie extends AdminTab
return false;
});
// $("#input_comment").change(function(event) {
// $("#input_storage").focus();
// });
$("#input_storage").change(function(event) {
event.preventDefault();
if ($product_id == undefined || $product_id == 0) {
@ -175,7 +187,6 @@ class AdminBraderie extends AdminTab
}
$("#hidden_product_id").val($product_id);
$.ajax({
type: \'POST\',
url: \''._MODULE_DIR_.'braderie/ajax.php?action=addToSellout'.'\',
@ -187,11 +198,13 @@ class AdminBraderie extends AdminTab
storage: $("#input_storage").val(),
product: $("#hidden_product_id").val(),
quantity: $("#input_quantity").val(),
attribute: $("#hidden_attribute_id").val()
attribute: $("#hidden_attribute_id").val(),
comment: tinymce.activeEditor.getContent()
},
success: function(response) {
$("#error").empty().append(response);
$("#input_ean, #input_storage").val("");
$("#comment_input_group").hide();
$("#input_quantity").val(1);
$("#ean_from_product").empty();
$("#input_ean").focus();
@ -263,6 +276,50 @@ class AdminBraderie extends AdminTab
});
</script>';
$iso = Language::getIsoById((int)($cookie->id_lang));
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en');
$ad = dirname($_SERVER["PHP_SELF"]);
$this->_html.= '
<script type="text/javascript">
var iso = \''.$isoTinyMCE.'\' ;
var pathCSS = \''._THEME_CSS_DIR_.'\' ;
var ad = \''.$ad.'\' ;
</script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce.inc.js"></script>
<script type="text/javascript">
// other_textarea different config
$(function() {
tinymce.init({
mode : "specific_textareas",
theme : "advanced",
skin:"cirkuit",
editor_selector : "other_textarea",
editor_deselector : "noEditor",
plugins : "safari,pagebreak,style,table,advimage,advlink,inlinepopups,media,contextmenu,paste,fullscreen,xhtmlxtras,preview",
// Theme options
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,,|,forecolor,backcolor",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false,
content_css : pathCSS+"global.css",
document_base_url : ad,
width: "200",
height: "200",
font_size_style_values : "8pt, 10pt, 12pt, 14pt, 18pt, 24pt, 36pt",
elements : "nourlconvert,ajaxfilemanager",
file_browser_callback : "ajaxfilemanager",
entity_encoding: "raw",
convert_urls : false,
language : iso,
extended_valid_elements: "iframe[src,width,height,frameborder,marginwidth,marginheight],script[type,src]",
});
});
</script>';
echo $this->_html;
}
@ -287,8 +344,9 @@ class AdminBraderie extends AdminTab
vertical-align:middle;
margin: 5px;
}
#error, #ean_from_product { margin-left: 210px; width: 312px;}
#error, #ean_from_product { margin-left: 205px; width: 312px;}
#error { font-weight: bold; margin-bottom: 20px; color: #CC0000; }
.margin-form {padding: 0 0 1em 10px;}
</style>
<fieldset>
<legend>'.$this->l('Braderie').'</legend>';
@ -322,6 +380,10 @@ class AdminBraderie extends AdminTab
<input type="text" name="ean" id="input_ean">
<div id="ean_from_product"></div>
</div>
<div class="margin-form" id="comment_input_group" style="display: none;">
<label>'.$this->l('Commentaires').' : </label>
<textarea class="other_textarea" cols="49" rows="3" id="input_comment" name="input_comment"></textarea>
</div>
<div class="margin-form" id="storage_input_group" style="display: none;">
<label>'.$this->l('Emplacement').' : </label>
<input type="text" name="storage" id="input_storage">

View File

@ -59,7 +59,7 @@ function getProductId()
}
$result = Db::getInstance()->getRow('
SELECT p.`id_product`, p.`reference`, pl.`name`, i.`id_image`
SELECT p.`id_product`, p.`reference`, pl.`name`, pl.`description_comment` as comments, i.`id_image`
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
@ -71,7 +71,7 @@ function getProductId()
if (empty($result)) {
$result = Db::getInstance()->getRow('
SELECT pa.*, pl.`name`, p.`reference` as product_reference, al.`name` as attribute_name, ia.`id_image` as id_image_attribute, i.`id_image`
SELECT pa.*, pl.`name`, pl.`description_comment` as comments, p.`reference` as product_reference, al.`name` as attribute_name, ia.`id_image` as id_image_attribute, i.`id_image`
FROM `'._DB_PREFIX_.'product_attribute` pa
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = pa.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
@ -183,6 +183,8 @@ function addToSellout()
return Tools::displayError('L\'emplacement n\'est pas valide');
}
$comment = Tools::getValue('comment', false);
//$category_name = Tools::getValue('category_name', false);
//$product_name = Tools::getValue('product_name', false);
$ean13 = Tools::getValue('ean', false);
@ -199,17 +201,6 @@ function addToSellout()
$languages = Language::getLanguages(false);
foreach ($languages as $key => $language) {
/*if(!$category_name) {
$category_name = Db::getInstance()->getRow('
SELECT cl.`name`
FROM `'._DB_PREFIX_.'category_lang` cl
LEFT JOIN `'._DB_PREFIX_.'privatesale` ps ON (ps.`id_category` = cl.`id_category`)
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` pps ON (pps.`id_sale` = ps.`id_sale`)
WHERE pps.`id_product` = '.(int)$id_product_old.'
AND cl.`id_lang` = '.(int)$language['id_lang']
);
$category_name = $category_name['name'];
}*/
// récupération de la catégorie originale (nom de la première catégorie)
$category_name = Db::getInstance()->getRow('
@ -267,6 +258,9 @@ function addToSellout()
}
$product->id_category_default = (int)$category;
if ($comment) {
$product->description_comment[2] = $comment;
}
if ($product->add()) {
if (!$id_attribute) {
@ -283,28 +277,12 @@ function addToSellout()
$product->UpdateCategories(array((int)$category,(int)$parent_category));
/*$max_position = Db::getInstance()->getValue("SELECT MAX(cp.`position`) AS max FROM `"._DB_PREFIX_."category_product` cp WHERE cp.`id_category`=" . (int)$category);
$add_category = Db::getInstance()->Execute("INSERT INTO `"._DB_PREFIX_."category_product` (`id_product`, `id_category`, `position`)
VALUES (
'". $product->id ."',
'". (int)$category ."',
'". (int)($max_position + 1 ) ."'
)");
$max_position_in_parent = Db::getInstance()->getValue("SELECT MAX(cp.`position`) AS max FROM `"._DB_PREFIX_."category_product` cp WHERE cp.`id_category`=" . (int)$parent_category);
$add_parent_category = Db::getInstance()->Execute("INSERT INTO `"._DB_PREFIX_."category_product` (`id_product`, `id_category`, `position`)
VALUES (
'". $product->id ."',
'". (int)$parent_category ."',
'". (int)($max_position_in_parent + 1 ) ."'
)");*/
if ($product->hasAttributes())
Product::updateDefaultAttribute($product->id);
Image::duplicateProductImages($id_product_old, $product->id, $combinationImages);
}
return Tools::displayError('Le produit à été mis dans la braderie');
return Tools::displayError('Le produit ajoute dans la braderie');
}
function pSQLArray($data)

View File

@ -13,6 +13,7 @@ class AdminEditFast extends AdminTab {
$short_description = Tools::getValue('short_description', array());
$description = Tools::getValue('description', array());
$description_more = Tools::getValue('description_more', array());
$description_comment = Tools::getValue('description_comment', array());
$description_delivery = Tools::getValue('description_delivery', array());
$videos = Tools::getValue('videos', array());
$reference = Tools::getValue('reference');
@ -44,6 +45,9 @@ class AdminEditFast extends AdminTab {
if(isset($description_more[$product->id])){
$product->description_more[(int) $id_lang_fast] = $description_more[$product->id];
}
if(isset($description_comment[$product->id])){
$product->description_comment[(int) $id_lang_fast] = $description_comment[$product->id];
}
if(isset($description_delivery[$product->id])){
$product->description_delivery[(int) $id_lang_fast] = $description_delivery[$product->id];
}
@ -78,6 +82,7 @@ class AdminEditFast extends AdminTab {
'short_description',
'description',
'description_more',
'description_comment',
'description_delivery',
'videos'
);
@ -160,6 +165,11 @@ class AdminEditFast extends AdminTab {
$form .= '<textarea name="description_more['. (int) $product->id.']" class="rte" id="" cols="10" rows="10">'.$product->description_more.'</textarea>';
$form .= '<br /><br />';
}
if (in_array('description_comment',$blocks)) {
$form .= '<label>Commentaires (braderie)</label>';
$form .= '<textarea name="description_comment['. (int) $product->id.']" class="rte" id="" cols="10" rows="10">'.$product->description_comment.'</textarea>';
$form .= '<br /><br />';
}
if (in_array('videos',$blocks)) {
$form .= '<label>Videos</label>';
$form .= '<textarea name="videos['. (int) $product->id.']" class="rte" id="" cols="10" rows="10">'.$product->videos.'</textarea>';

View File

@ -2,6 +2,7 @@
class Product extends ProductCore
{
public $description_more;
public $description_comment;
public $description_delivery;
public $videos;
@ -12,7 +13,7 @@ class Product extends ProductCore
'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');
'description_more' => 'isString', 'description_comment' => 'isString', 'videos' => 'isString', 'description_delivery' => 'isString');
/**
* @Override
@ -35,6 +36,7 @@ class Product extends ProductCore
$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']]['description_comment'] = (isset($this->description_comment[$language['id_lang']])) ? pSQL($this->description_comment[$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)