Merge branch 'task-ImgMobileCategories' into develop

This commit is contained in:
Marion Muszynski 2017-09-25 10:59:58 +02:00
commit 80c6a3db16
4 changed files with 112 additions and 16 deletions

View File

@ -67,7 +67,7 @@ class AdminCategories extends AdminTab
protected function recurseCategoryTreeFlat($id_category, $category_selected, $level_start = 0) protected function recurseCategoryTreeFlat($id_category, $category_selected, $level_start = 0)
{ {
global $currentIndex; global $currentIndex;
$id_lang = _USER_ID_LANG_; $id_lang = _USER_ID_LANG_;
$categoriesOption = ""; $categoriesOption = "";
$active = false; $active = false;
@ -96,14 +96,14 @@ class AdminCategories extends AdminTab
$categoriesOption.= $children; $categoriesOption.= $children;
} }
} }
return $categoriesOption; return $categoriesOption;
} }
protected function displayListTree() protected function displayListTree()
{ {
global $currentIndex; global $currentIndex;
if ($this->_category->id_category == 1) { if ($this->_category->id_category == 1) {
echo ""; echo "";
} }
@ -117,7 +117,7 @@ class AdminCategories extends AdminTab
if (count($categoryParents) > 0) { if (count($categoryParents) > 0) {
$categoryRoot = $categoryParents[count($categoryParents)-1]; $categoryRoot = $categoryParents[count($categoryParents)-1];
} }
if ($categoryRoot) { if ($categoryRoot) {
echo '<select id="selectCategory" style="margin:0 5px;padding:4px;font-size:14px;" echo '<select id="selectCategory" style="margin:0 5px;padding:4px;font-size:14px;"
onchange="document.location=$(this).find(\'option:selected\').data(\'url\');">'; onchange="document.location=$(this).find(\'option:selected\').data(\'url\');">';
@ -132,7 +132,7 @@ class AdminCategories extends AdminTab
} }
} }
} }
public function displayListContent($token = NULL) public function displayListContent($token = NULL)
{ {
global $currentIndex, $cookie; global $currentIndex, $cookie;
@ -456,7 +456,7 @@ class AdminCategories extends AdminTab
echo '<br/><a onclick="return confirm(\''.$this->l('Regenerate entire categories tree ?').'\');" class="button btn" href="'.__PS_BASE_URI__.substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)).'?tab=AdminCatalog&regenerateTree&token='.($token!=NULL ? $token : $this->token).'"">' . $this->l('Regenerate NTree') . '</a>'; echo '<br/><a onclick="return confirm(\''.$this->l('Regenerate entire categories tree ?').'\');" class="button btn" href="'.__PS_BASE_URI__.substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)).'?tab=AdminCatalog&regenerateTree&token='.($token!=NULL ? $token : $this->token).'"">' . $this->l('Regenerate NTree') . '</a>';
$this->displayListTree(); $this->displayListTree();
echo '<br/>'; echo '<br/>';
$this->displayList($token); $this->displayList($token);
echo '</div>'; echo '</div>';
} }
@ -486,8 +486,7 @@ class AdminCategories extends AdminTab
} }
} }
// @Override Antadis // @Override Antadis - Delete Image Thumb && Mobile
/* Delete Image Thumb */
elseif (isset($_GET['deleteImageThumb']) && isset($_GET['id_lang'])) elseif (isset($_GET['deleteImageThumb']) && isset($_GET['id_lang']))
{ {
if (Validate::isLoadedObject($object = $this->loadObject())) { if (Validate::isLoadedObject($object = $this->loadObject())) {
@ -495,6 +494,14 @@ class AdminCategories extends AdminTab
Tools::redirectAdmin($currentIndex.'&updatecategory&token='.Tools::getValue('token').'&id_category='.(int)($object->id)); Tools::redirectAdmin($currentIndex.'&updatecategory&token='.Tools::getValue('token').'&id_category='.(int)($object->id));
} }
}
elseif (isset($_GET['deleteImageMobile']) && isset($_GET['id_lang']))
{
if (Validate::isLoadedObject($object = $this->loadObject())) {
$this->deleteImageMobile($object,$_GET['id_lang']);
Tools::redirectAdmin($currentIndex.'&updatecategory&token='.Tools::getValue('token').'&id_category='.(int)($object->id));
}
} }
// @EndOverride Antadis // @EndOverride Antadis
@ -515,6 +522,7 @@ class AdminCategories extends AdminTab
// @Override Antadis // @Override Antadis
foreach (Language::getLanguages(FALSE) as $language) { foreach (Language::getLanguages(FALSE) as $language) {
$this->deleteImageThumb($object, $language['id_lang']); $this->deleteImageThumb($object, $language['id_lang']);
$this->deleteImageMobile($object, $language['id_lang']);
} }
// @End Antadis // @End Antadis
$object->deleteImage(); $object->deleteImage();

View File

@ -1244,6 +1244,31 @@ class AdminOrders extends AdminTab
echo '<p><b>Numéro de suivi </b> : '. $number['shipping_number'] .' ajouté le '. $date->format('d m Y') .'</p>'; echo '<p><b>Numéro de suivi </b> : '. $number['shipping_number'] .' ajouté le '. $date->format('d m Y') .'</p>';
} }
} }
// assign delay to Products
if (Module::isInstalled('privatesales_delay')) {
if (!class_exists('SaleDelay')) {
require_once _PS_ROOT_DIR_.'/modules/privatesales_delay/saledelay.php';
}
$delay_products = SaleDelay::associateDelay($products);
$delays = array_keys($delay_products);
$date = new DateTime($order->date_add);
$delivery_date = SaleDelay::getDeliveryDate($delays, null, $date, true);
foreach($delivery_date as $k => $date) {
if($k == 1) {
echo '<p class="delivery-date">
'.$this->l('Date d\'expédition : entre le').' <strong>'.$date['date_start']->format('d/m/Y').'</strong> '.$this->l('et le').' <strong>'.$date['date_end']->format('d/m/Y').'</strong>
</p>';
} elseif ($k == 5){
echo '<p class="delivery-date">'.$this->l('Date d\'expédition :').' <strong>'.$this->l('avant le 24/12').'</strong></p>';
} elseif ($k == 8){
echo '<p class="delivery-date">'.$this->l('Date d\'expédition :').' <strong>'.$this->l('envoi en 48h').'</strong></p>';
} elseif ($k == 9){
echo '<p class="delivery-date">'.$this->l('Date d\'expédition :').' '.$this->l('Delai indiqué sur la fiche produit').'</p>';
}
}
}
echo '<legend><img src="../img/admin/delivery.gif" /> '.$this->l('Shipping information').'</legend> echo '<legend><img src="../img/admin/delivery.gif" /> '.$this->l('Shipping information').'</legend>
'.$this->l('Total weight:').' <b>'.number_format($order->getTotalWeight(), 3).' '.Configuration::get('PS_WEIGHT_UNIT').'</b><br /> '.$this->l('Total weight:').' <b>'.number_format($order->getTotalWeight(), 3).' '.Configuration::get('PS_WEIGHT_UNIT').'</b><br />
'.$this->l('Carrier:').' <b>'.($carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name).'</b><br /> '.$this->l('Carrier:').' <b>'.($carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name).'</b><br />

View File

@ -42,7 +42,12 @@ class AdminAntCreationcategories extends AdminTab
if($category->add()) { if($category->add()) {
if (isset($_FILES['image_thumb']) && $_FILES['image_thumb']['name'] != NULL) { if (isset($_FILES['image_thumb']) && $_FILES['image_thumb']['name'] != NULL) {
copy($_FILES['image_thumb']['tmp_name'], _PS_CAT_IMG_DIR_.$category->id.'_thumb_vp.jpg'); 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) { if (isset($_FILES['image_category']) && $_FILES['image_category']['name'] != NULL) {
copy($_FILES['image_category']['tmp_name'], _PS_CAT_IMG_DIR_.$category->id.'.jpg'); copy($_FILES['image_category']['tmp_name'], _PS_CAT_IMG_DIR_.$category->id.'.jpg');
@ -219,6 +224,14 @@ class AdminAntCreationcategories extends AdminTab
'name' => 'image_category', 'name' => 'image_category',
'id' => 'preview_category', 'id' => 'preview_category',
), ),
array(
'type' => 'uploadImage',
'label' => $this->l('Image Application : '),
'label-class' => 'col-md-2',
'input-class' => 'col-md-6',
'name' => 'image_mobile',
'id' => 'preview_mobile',
),
array( array(
'type' => 'tag', 'type' => 'tag',
'label' => $this->l('Sous Catégorie : '), 'label' => $this->l('Sous Catégorie : '),

View File

@ -32,7 +32,7 @@ class Category extends CategoryCore {
Module::hookExec('categoryUpdate', array('category' => $this)); Module::hookExec('categoryUpdate', array('category' => $this));
return $ret; return $ret;
} }
public function updatePosition($way, $position) public function updatePosition($way, $position)
{ {
if (!$res = Db::getInstance()->ExecuteS(' if (!$res = Db::getInstance()->ExecuteS('
@ -43,17 +43,17 @@ class Category extends CategoryCore {
)) { )) {
return false; return false;
} }
foreach ($res AS $category) { foreach ($res AS $category) {
if ((int)($category['id_category']) == (int)($this->id)) { if ((int)($category['id_category']) == (int)($this->id)) {
$movedCategory = $category; $movedCategory = $category;
} }
} }
if (!isset($movedCategory) || !isset($position)) { if (!isset($movedCategory) || !isset($position)) {
return false; return false;
} }
// < and > statements rather than BETWEEN operator // < and > statements rather than BETWEEN operator
// since BETWEEN is treated differently according to databases // since BETWEEN is treated differently according to databases
$result = (Db::getInstance()->Execute(' $result = (Db::getInstance()->Execute('
@ -69,9 +69,9 @@ class Category extends CategoryCore {
SET `position` = '.(int)($position).' SET `position` = '.(int)($position).'
WHERE `id_parent` = '.(int)($movedCategory['id_parent']).' WHERE `id_parent` = '.(int)($movedCategory['id_parent']).'
AND `id_category`='.(int)($movedCategory['id_category']))); AND `id_category`='.(int)($movedCategory['id_category'])));
Module::hookExec('categoryUpdate', array('category' => $this, 'position' => true)); Module::hookExec('categoryUpdate', array('category' => $this, 'position' => true));
return $result; return $result;
} }
@ -522,4 +522,54 @@ class Category extends CategoryCore {
return $result; return $result;
} }
public function deleteImage()
{
if (!$this->id)
return false;
/* Deleting object images and thumbnails (cache) */
if ($this->image_dir)
{
if (file_exists($this->image_dir.$this->id.'.'.$this->image_format)
&& !unlink($this->image_dir.$this->id.'.'.$this->image_format))
return false;
}
if (file_exists(_PS_TMP_IMG_DIR_.$this->table.'_'.$this->id.'.'.$this->image_format)
&& !unlink(_PS_TMP_IMG_DIR_.$this->table.'_'.$this->id.'.'.$this->image_format))
return false;
if (file_exists(_PS_TMP_IMG_DIR_.$this->table.'_mini_'.$this->id.'.'.$this->image_format)
&& !unlink(_PS_TMP_IMG_DIR_.$this->table.'_mini_'.$this->id.'.'.$this->image_format))
return false;
$types = ImageType::getImagesTypes();
foreach ($types AS $image_type)
if (file_exists($this->image_dir.$this->id.'-'.stripslashes($image_type['name']).'.'.$this->image_format)
&& !unlink($this->image_dir.$this->id.'-'.stripslashes($image_type['name']).'.'.$this->image_format))
return false;
// @Override Antadis
foreach (Language::getLanguages(FALSE) as $language) {
$this->deleteImageThumb($language['id_lang']);
$this->deleteImageMobile($language['id_lang']);
}
// @End Override
return true;
}
// @Adding Antadis
public function deleteImageThumb($id_lang)
{
if(file_exists(_PS_ROOT_DIR_.'/img/c/'.$this->id.'_thumb_vp_'.(int)$id_lang.'.jpg')) {
unlink(_PS_ROOT_DIR_.'/img/c/'.$this->id.'_thumb_vp_'.(int)$id_lang.'.jpg');
}
}
// @Adding Antadis
public function deleteImageMobile($id_lang)
{
if(file_exists(_PS_ROOT_DIR_.'/img/c/'.$this->id.'_mobile_vp_'.(int)$id_lang.'.jpg')) {
unlink(_PS_ROOT_DIR_.'/img/c/'.$this->id.'_mobile_vp_'.(int)$id_lang.'.jpg');
}
}
} }