Merge branch 'update-CreationCat' into develop

This commit is contained in:
Marion Muszynski 2017-10-04 13:25:50 +02:00
commit 2a5b0712e9
3 changed files with 123 additions and 4 deletions

View File

@ -156,7 +156,7 @@ if (Tools::isSubmit('submitMessage')) {
// local
// $smarty->assign('confirmation', 1);
}
if ($contact->customer_service)
{
if ((int)$id_customer_thread)
@ -172,6 +172,9 @@ if (Tools::isSubmit('submitMessage')) {
$first_product = explode("_", $id_products[0]);
$ct->id_product = (int)$first_product[0];
}
if (!isset($customer->id) || !$customer->id){
$ct->id_customer = 0;
}
$ct->update();
}
else
@ -212,9 +215,9 @@ if (Tools::isSubmit('submitMessage')) {
if (Tools::getValue('product_'.$val.'_qty')) {
$qty = (int)Tools::getValue('product_'.$val.'_qty');
}
$p = explode("_", $val);
// Check quantity in db
if (($resultOld = Db::getInstance()->getRow('SELECT `product_return_quantity` FROM `'._DB_PREFIX_.'support_product_customerthread`
WHERE `id_customer_thread` = '.(int)$ct->id.' AND `id_product_attribute` = '.(int)$p[1].' AND `id_product` = '.(int)$p[0])) !== false) {

View File

@ -166,6 +166,60 @@ class AdminPrivateSalesSales extends AdminTab {
}
</style>';
echo $helperForm->renderStyle();
$helperForm->_forms = array(
array(
'action' => $base_link,
'title' => $this->l('Creation Catégorie principale (pour éviter de changer d\'onglet)'),
'icon' => '<span class="glyphicon glyphicon-list"></span> ',
'class' => 'form-horizontal',
'id' => 'form-category',
'class_div' => 'col-md-12',
//'information' => 'Création catégorie principale',
'sections' => array(
array(
'inputs' => array(
array(
'type' => 'simpleText',
'label' => $this->l('Catégorie : '),
'label-class' => 'col-md-2',
'input-class' => 'col-md-6',
'name' => 'category',
),
array(
'type' => 'uploadImage',
'label' => $this->l('Logo : '),
'label-class' => 'col-md-2',
'input-class' => 'col-md-6',
'name' => 'image_thumb',
'id' => 'preview_thumb',
),
array(
'type' => 'uploadImage',
'label' => $this->l('Image Latérale : '),
'label-class' => 'col-md-2',
'input-class' => 'col-md-6',
'name' => 'image_category',
'id' => 'preview_category',
),
),
),
),
'actions' => array(
array(
'type' => 'submit',
'class' => 'btn-primary',
'name' => 'submitCategoryAdd',
'value' => $this->l('Ajouter')
)
),
'actions-class' => 'text-right',
),
);
echo '<div class="row">'.$helperForm->renderForm(false, NULL, NULL, true).'</div>';
$helperForm->_forms = array();
$helperForm->_html = '';
echo '<div class="panel">
<div class="panel-title">
<h2>'.$this->l('Edit a sale').'</h2>
@ -1133,7 +1187,53 @@ class AdminPrivateSalesSales extends AdminTab {
public function postProcess() {
global $cookie, $currentIndex;
if(Tools::isSubmit('submitSaleAdd')) {
if(Tools::isSubmit('submitCategoryAdd')) {
$date = date('Y') . '-' . date('m');
$name = Tools::getValue('category');
$meta_name = 'Vente privée '.$name;
$meta_name_es = 'Venta privada '.$name;
$category = new Category();
$category->id_parent = 1;
$category->active = 1;
$category->name[2] = $name;
$category->name[3] = $name;
$category->description[2] = $date;
$category->description[3] = $date;
$category->meta_title[2] = $meta_name;
$category->meta_title[3] = $meta_name_es;
$category->meta_keywords[2] = $meta_name;
$category->meta_keywords[3] = $meta_name_es;
$category->meta_description[2] = $meta_name;
$category->meta_description[3] = $meta_name_es;
$category->link_rewrite[2] = $this->str2url($name);
$category->link_rewrite[3] = $category->link_rewrite[2];
$category->groupBox = $groups;
if($category->add()) {
if (isset($_FILES['image_thumb']) && $_FILES['image_thumb']['name'] != NULL) {
copy($_FILES['image_thumb']['tmp_name'], _PS_CAT_IMG_DIR_.$category->id.'_thumb_vp_2.jpg');
copy($_FILES['image_thumb']['tmp_name'], _PS_CAT_IMG_DIR_.$category->id.'_thumb_vp_3.jpg');
}
// if (isset($_FILES['image_mobile']) && $_FILES['image_mobile']['name'] != NULL) {
// copy($_FILES['image_mobile']['tmp_name'], _PS_CAT_IMG_DIR_.$category->id.'_mobile_vp_2.jpg');
// copy($_FILES['image_mobile']['tmp_name'], _PS_CAT_IMG_DIR_.$category->id.'_mobile_vp_3.jpg');
// }
if (isset($_FILES['image_category']) && $_FILES['image_category']['name'] != NULL) {
copy($_FILES['image_category']['tmp_name'], _PS_CAT_IMG_DIR_.$category->id.'.jpg');
if (file_exists(_PS_CAT_IMG_DIR_.$category->id.'.jpg')) {
$imagesTypes = ImageType::getImagesTypes('categories');
foreach ($imagesTypes AS $k => $imageType) {
imageResize(_PS_CAT_IMG_DIR_.$category->id.'.jpg', _PS_CAT_IMG_DIR_.$category->id.'-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height']));
}
}
}
Category::regenerateEntireNtree();
HelperFormBootstrap::echoConfirmation('Catégorie créée <a target="_blank" href="?tab=AdminCatalog&addcategory&id_category='.$category->id.'&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'"> Voir </a>');
} else {
HelperFormBootstrap::echoError('Un problème est survenue lors de la création de catégorie');
}
} elseif(Tools::isSubmit('submitSaleAdd')) {
if (Sale::getSaleFromCategory(Tools::getValue('id_category'))) {
return false;
}
@ -1331,4 +1431,18 @@ class AdminPrivateSalesSales extends AdminTab {
// }
// }
}
public function str2url($string, $slug = '-', $extra = null)
{
return strtolower(trim(preg_replace('~[^0-9a-z' . preg_quote($extra, '~') . ']+~i', $slug, $this->unaccent($string)), $slug));
}
public function unaccent($string) // normalizes (romanization) accented chars
{
if (strpos($string = htmlentities($string, ENT_QUOTES, 'UTF-8'), '&') !== false) {
$string = html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|tilde|uml);~i', '$1', $string), ENT_QUOTES, 'UTF-8');
}
return $string;
}
}

View File

@ -159,6 +159,8 @@ class ContactController extends ContactControllerCore {
$ct->id_order = $id_order;
if ($id_product = (int)Tools::getValue('id_product'))
$ct->id_product = $id_product;
if (!isset($customer->id) || !$customer->id)
$ct->id_customer = 0;
$ct->update();
}
else