Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop

This commit is contained in:
Christophe Latour 2017-10-11 16:16:53 +02:00
commit b93e3951b1
8 changed files with 292 additions and 36 deletions

View File

@ -1669,7 +1669,7 @@ class AdminOrders extends AdminTab
$returnable = array();
foreach ($products as $k => $product) {
$product['id_sale'] = $product_psale[(int) $product['product_id']];
$qty = OrderReturn::getOrderDetailReturnQty($product);
$qty = OrderReturn::getOrderDetailReturnQty($product, $currentState->id);
if($qty > 0) {
$returnable[$product['id_order_detail']] = array($product['product_name'], $qty);
}

View File

@ -742,6 +742,39 @@ class AdminProducts extends AdminTab
}
}
/* @Override - Antadis, clean image position when bug occured */
elseif (Tools::isSubmit('cleanImagePositions') && Tools::getValue('id_product')){
if (Validate::isLoadedObject($object = $this->loadObject())){
foreach (Db::getInstance()->ExecuteS('
SELECT `id_image`
FROM `'._DB_PREFIX_.'image`
WHERE `id_product` = '. (int)$object->id .'
ORDER BY position ASC') as $key => $value) {
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'image`
SET `position` = (`position` + 99)
WHERE `id_image` = '. (int)$value['id_image']
);
}
foreach (Db::getInstance()->ExecuteS('
SELECT `id_image`
FROM `'._DB_PREFIX_.'image`
WHERE `id_product` = '. (int)$object->id .'
ORDER BY position ASC') as $key => $value) {
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'image`
SET `position` = '.($key+1).'
WHERE `id_image` = '. (int)$value['id_image']
);
}
Tools::redirectAdmin($currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&update'.$this->table.'&tabs=1'.'&token='.($token ? $token : $this->token));
} else {
$this->_errors[] = Tools::displayError('Product doesn\'t exist');
}
}
/* @Override - Antadis, delete some images in same time */
elseif (Tools::isSubmit('deleteImages') && Tools::getValue('ids_image'))
{
@ -3980,7 +4013,10 @@ class AdminProducts extends AdminTab
</td>
</tr>
</table>
<p><button name="deleteImages" id="deleteImages" class="button" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');">'.$this->l('Supprimer la selection').'</button></p>
<p>
<button name="deleteImages" id="deleteImages" class="button" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');">'.$this->l('Supprimer la selection').'</button>
<button name="cleanImagePositions" id="cleanImagePositions" class="button" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');">'.$this->l('Cleaner les positions des images').'</button>
</p>
</div>';
echo '
<script type="text/javascript" src="../js/attributesBack.js"></script>

View File

@ -118,6 +118,9 @@ class AdminAntTrackingTag extends AdminTab
{
$customer_numbers = AntTrackingTag::getCountCustomerByTag((int)$tag['id_trackingtag']);
$total = 0;
foreach ($customer_numbers as $info) {
$total += (int)$info['nb'];
}
$this->_html .='
<tr>
@ -125,16 +128,9 @@ class AdminAntTrackingTag extends AdminTab
<td valign="middle" align="left"><b>'.$tag['name'].'</b></td>
<td valign="middle" align="left"><b>'.$tag['tag'].'</b></td>
<td align="center">'.((int)$tag['enabled']?'<span class="anticon anticon-checkmark text-green-light"></span>':'<span class="anticon anticon-cross text-rose"></span>').'</td>
<td valign="middle" align="center">';
foreach ($customer_numbers as $info) {
$total += (int)$info['nb'];
$this->_html.='
<button class="btn btn-primary btn-xs" type="button">
'.$info['value'].' <span class="badge">'.$info['nb'].'</span>
</button> ';
}
$this->_html.=
'</td>
<td valign="middle" align="center">
<a class="text-purple-dark" data-toggle="collapse" data-target=".row_more_'.$tag['id_trackingtag'].'"><span style="font-size:21px;cursor:pointer" class="anticon anticon-info"></span></a>
</td>
<td valign="middle" align="center">'.$total.'</td>
<td valign="middle" align="center">
<div class="input-group-btn" role="group" aria-label="...">
@ -142,6 +138,22 @@ class AdminAntTrackingTag extends AdminTab
<a href="'.$_current_index.'&deleteTag=1&id='.$tag['id_trackingtag'].'" class="btn btn-default"><span class="anticon anticon-bin"></span></a>
</div>
</td>
</tr>
<tr class="collapse row_more_'.$tag['id_trackingtag'].'">
<td colspan="7">
Compteurs ordonnés par Nb
</td>
</tr>
<tr class="collapse row_more_'.$tag['id_trackingtag'].'">
<td colspan="7">';
foreach ($customer_numbers as $info) {
$this->_html.='
<button class="btn btn-primary btn-xs" type="button" style="margin-bottom:5px;">
Base: '.$info['value'].' <span class="badge">Nb: '.$info['nb'].'</span>
</button> ';
}
$this->_html.='
</td>
</tr>';
}
$this->_html .='

View File

@ -99,7 +99,8 @@ class AntTrackingTag extends ObjectModel
SELECT COUNT(id_customer) as `nb`, `value`
FROM `"._DB_PREFIX_."ant_trackingtag_customer`
WHERE `id_trackingtag` = " . (int)$id_trackingtag."
GROUP BY `value`"
GROUP BY `value`
ORDER BY `nb` DESC"
);
}

View File

@ -170,7 +170,7 @@ class AdminPrivateSalesSales extends AdminTab {
$helperForm->_forms = array(
array(
'action' => $base_link,
'title' => $this->l('Creation Catégorie principale (pour éviter de changer d\'onglet)'),
'title' => $this->l('Création Catégorie principale'),
'icon' => '<span class="glyphicon glyphicon-list"></span> ',
'class' => 'form-horizontal',
'id' => 'form-category',

View File

@ -85,7 +85,8 @@ class AdminStatsLogistic extends AdminTab {
$result[(int)$sale['id_sale']]['nb_pole_1'] = 0;
$result[(int)$sale['id_sale']]['nb_pole_2'] = 0;
$result[(int)$sale['id_sale']]['nb_pole_3'] = 0;
// $result[(int)$sale['id_sale']]['nb_pole_4'] = 0;
$result[(int)$sale['id_sale']]['nb_pole_4'] = 0;
$result[(int)$sale['id_sale']]['nb_pole_5'] = 0;
// $result[(int)$sale['id_sale']]['nb_pole_5'] = 0;
// $result[(int)$sale['id_sale']]['nb_pole_6'] = 0;
@ -167,24 +168,32 @@ class AdminStatsLogistic extends AdminTab {
$nb_package += count($value);
switch ($id_employee) {
case '22':
case '35':
case '24':
$result[(int)$sale['id_sale']]['nb_pole_1'] += count($value);
break;
case '66':
case '36':
case '25':
case '44':
$result[(int)$sale['id_sale']]['nb_pole_2'] += count($value);
break;
default:
case '47':
case '48':
$result[(int)$sale['id_sale']]['nb_pole_3'] += count($value);
break;
case '35':
case '36':
$result[(int)$sale['id_sale']]['nb_pole_4'] += count($value);
break;
default:
$result[(int)$sale['id_sale']]['nb_pole_5'] += count($value);
break;
}
}
$result[(int)$sale['id_sale']]['nb_package'] = $nb_package;
$result[(int)$sale['id_sale']]['nb_pole_1'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_1'] / $nb_package)*100,2);
$result[(int)$sale['id_sale']]['nb_pole_2'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_2'] / $nb_package)*100,2);
$result[(int)$sale['id_sale']]['nb_pole_3'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_3'] / $nb_package)*100,2);
// $result[(int)$sale['id_sale']]['nb_pole_4'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_4'] / $nb_package)*100,2);
// $result[(int)$sale['id_sale']]['nb_pole_5'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_5'] / $nb_package)*100,2);
$result[(int)$sale['id_sale']]['nb_pole_4'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_4'] / $nb_package)*100,2);
$result[(int)$sale['id_sale']]['nb_pole_5'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_5'] / $nb_package)*100,2);
// $result[(int)$sale['id_sale']]['nb_pole_6'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_6'] / $nb_package)*100,2);
}
}
@ -321,13 +330,11 @@ class AdminStatsLogistic extends AdminTab {
'employee' => array(),
);
}
$poles[0]['name'] = 'LA POSTE';
$poles[1]['name'] = 'MONDIAL RELAY';
$poles[2]['name'] = 'AUTRES';
// $poles[3]['name'] = 'Pôle 4 : Multi';
// $poles[4]['name'] = 'Pôle 5 : Mondial Relay';
// $poles[5]['name'] = 'Pôle 6 : Braderie';
// $poles[6]['name'] = 'Pôle 7 : Postes complémentaires';
$poles[0]['name'] = 'Pôle 1';
$poles[1]['name'] = 'Pôle 2';
$poles[2]['name'] = 'Pôle 3';
$poles[3]['name'] = 'Multi';
$poles[4]['name'] = 'Postes Complémentaires';
$total_quantity = 0;
/**
@ -353,22 +360,34 @@ class AdminStatsLogistic extends AdminTab {
switch ((int)$stat['id_employee']) {
//case '52':
case '22':
case '35':
case '24':
$poles[0]['recap']['quantity'] += $stat['quantity'];
$poles[0]['recap']['nb_package'] += $stat['nb_package'];
$poles[0]['employee'][] = $stat;
break;
case '66':
case '36':
case '25':
case '44':
$poles[1]['recap']['quantity'] += $stat['quantity'];
$poles[1]['recap']['nb_package'] += $stat['nb_package'];
$poles[1]['employee'][] = $stat;
break;
default:
case '47':
case '48':
$poles[2]['recap']['quantity'] += $stat['quantity'];
$poles[2]['recap']['nb_package'] += $stat['nb_package'];
$poles[2]['employee'][] = $stat;
break;
case '35':
case '36':
$poles[3]['recap']['quantity'] += $stat['quantity'];
$poles[3]['recap']['nb_package'] += $stat['nb_package'];
$poles[3]['employee'][] = $stat;
break;
default:
$poles[4]['recap']['quantity'] += $stat['quantity'];
$poles[4]['recap']['nb_package'] += $stat['nb_package'];
$poles[4]['employee'][] = $stat;
break;
}
$total_quantity += $stat['quantity'];
}

View File

@ -1,13 +1,13 @@
<?php
class OrderReturn extends OrderReturnCore {
public static function getOrderDetailReturnQty($product) {
public static function getOrderDetailReturnQty($product, $id_state = 0) {
if(Db::getInstance()->getRow('
SELECT `id_order`
FROM `'._DB_PREFIX_.'shipping_history`
WHERE `id_order` = '.(int) $product['id_order'].'
AND `id_sale` = '.(int) $product['id_sale'].'
')) {
') || ($id_state != 0 && $id_state == 4)) {
$qty = (int) $product['product_quantity'] - max((int) $product['product_quantity_refunded'], (int) $product['product_quantity_return']);
} else {
$qty = (int) Db::getInstance()->getValue('

View File

@ -1,5 +1,193 @@
<?php
class AddressController extends AddressControllerCore {
/**
* @Override - Antadis
**/
public function preProcess()
{
FrontController::preProcess();
if ($back = Tools::getValue('back'))
self::$smarty->assign('back', Tools::safeOutput($back));
if ($mod = Tools::getValue('mod'))
self::$smarty->assign('mod', Tools::safeOutput($mod));
if (Tools::isSubmit('ajax') AND Tools::isSubmit('type'))
{
if (Tools::getValue('type') == 'delivery')
$id_address = isset(self::$cart->id_address_delivery) ? (int)self::$cart->id_address_delivery : 0;
elseif (Tools::getValue('type') == 'invoice')
$id_address = (isset(self::$cart->id_address_invoice) AND self::$cart->id_address_invoice != self::$cart->id_address_delivery) ? (int)self::$cart->id_address_invoice : 0;
else
exit;
}
else
$id_address = (int)Tools::getValue('id_address', 0);
if ($id_address)
{
$this->_address = new Address((int)$id_address);
if (Validate::isLoadedObject($this->_address) AND Customer::customerHasAddress((int)(self::$cookie->id_customer), (int)($id_address)))
{
if (Tools::isSubmit('delete'))
{
if (self::$cart->id_address_invoice == $this->_address->id)
unset(self::$cart->id_address_invoice);
if (self::$cart->id_address_delivery == $this->_address->id)
unset(self::$cart->id_address_delivery);
if ($this->_address->delete())
Tools::redirect('addresses.php');
$this->errors[] = Tools::displayError('This address cannot be deleted.');
}
self::$smarty->assign(array('address' => $this->_address, 'id_address' => (int)$id_address));
}
elseif (Tools::isSubmit('ajax'))
exit;
else
Tools::redirect('addresses.php');
}
if (Tools::isSubmit('submitAddress'))
{
$address = new Address();
$this->errors = $address->validateControler();
$address->id_customer = (int)(self::$cookie->id_customer);
if (Tools::getValue('address1') AND strlen(Tools::getValue('address1'))>40){
$this->errors[] = Tools::displayError('Your address is too long, complete the address complement if necessary');
}
if (Tools::getValue('address2') AND strlen(Tools::getValue('address2'))>40){
$this->errors[] = Tools::displayError('Your address is too long');
}
if (!Tools::getValue('phone') AND !Tools::getValue('phone_mobile'))
$this->errors[] = Tools::displayError('You must register at least one phone number');
if (!$country = new Country((int)$address->id_country) OR !Validate::isLoadedObject($country))
die(Tools::displayError());
/* US customer: normalize the address */
if ($address->id_country == Country::getByIso('US'))
{
include_once(_PS_TAASC_PATH_.'AddressStandardizationSolution.php');
$normalize = new AddressStandardizationSolution;
$address->address1 = $normalize->AddressLineStandardization($address->address1);
$address->address2 = $normalize->AddressLineStandardization($address->address2);
}
$zip_code_format = $country->zip_code_format;
if ($country->need_zip_code)
{
if (($postcode = Tools::getValue('postcode')) AND $zip_code_format)
{
$zip_regexp = '/^'.$zip_code_format.'$/ui';
$zip_regexp = str_replace(' ', '( |)', $zip_regexp);
$zip_regexp = str_replace('-', '(-|)', $zip_regexp);
$zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
$zip_regexp = str_replace('C', $country->iso_code, $zip_regexp);
if (!preg_match($zip_regexp, $postcode))
$this->errors[] = '<strong>'.Tools::displayError('Zip/ Postal code').'</strong> '.Tools::displayError('is invalid.').'<br />'.Tools::displayError('Must be typed as follows:').' '.str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
}
elseif ($zip_code_format)
$this->errors[] = '<strong>'.Tools::displayError('Zip/ Postal code').'</strong> '.Tools::displayError('is required.');
elseif ($postcode AND !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
$this->errors[] = '<strong>'.Tools::displayError('Zip/ Postal code').'</strong> '.Tools::displayError('is invalid.').'<br />'.Tools::displayError('Must be typed as follows:').' '.str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
}
if ($country->isNeedDni() AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni'))))
$this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
elseif (!$country->isNeedDni())
$address->dni = NULL;
if (Configuration::get('PS_TOKEN_ENABLE') == 1 AND
strcmp(Tools::getToken(false), Tools::getValue('token')) AND
self::$cookie->isLogged(true) === true)
$this->errors[] = Tools::displayError('Invalid token');
if ((int)($country->contains_states) AND !(int)($address->id_state))
$this->errors[] = Tools::displayError('This country requires a state selection.');
if (!sizeof($this->errors))
{
if (isset($id_address))
{
$country = new Country((int)($address->id_country));
if (Validate::isLoadedObject($country) AND !$country->contains_states)
$address->id_state = 0;
$address_old = new Address((int)$id_address);
if (Validate::isLoadedObject($address_old) AND Customer::customerHasAddress((int)self::$cookie->id_customer, (int)$address_old->id))
{
if ($address_old->isUsed())
{
$address_old->delete();
if (!Tools::isSubmit('ajax'))
{
$to_update = false;
if (self::$cart->id_address_invoice == $address_old->id)
{
$to_update = true;
self::$cart->id_address_invoice = 0;
}
if (self::$cart->id_address_delivery == $address_old->id)
{
$to_update = true;
self::$cart->id_address_delivery = 0;
}
if ($to_update)
self::$cart->update();
}
}
else
{
$address->id = (int)($address_old->id);
$address->date_add = $address_old->date_add;
}
}
}
elseif (self::$cookie->is_guest)
Tools::redirect('addresses.php');
if ($result = $address->save())
{
/* In order to select this new address : order-address.tpl */
if ((bool)(Tools::getValue('select_address', false)) == true OR (Tools::isSubmit('ajax') AND Tools::getValue('type') == 'invoice'))
{
/* This new adress is for invoice_adress, select it */
self::$cart->id_address_invoice = (int)($address->id);
self::$cart->update();
}
if (Tools::isSubmit('ajax'))
{
$return = array(
'hasError' => !empty($this->errors),
'errors' => $this->errors,
'id_address_delivery' => self::$cart->id_address_delivery,
'id_address_invoice' => self::$cart->id_address_invoice
);
die(Tools::jsonEncode($return));
}
Tools::redirect($back ? ($mod ? $back.'&back='.$mod : $back) : 'addresses.php');
}
$this->errors[] = Tools::displayError('An error occurred while updating your address.');
}
}
elseif (!$id_address)
{
$customer = new Customer((int)(self::$cookie->id_customer));
if (Validate::isLoadedObject($customer))
{
$_POST['firstname'] = $customer->firstname;
$_POST['lastname'] = $customer->lastname;
}
}
if (Tools::isSubmit('ajax') AND sizeof($this->errors))
{
$return = array(
'hasError' => !empty($this->errors),
'errors' => $this->errors
);
die(Tools::jsonEncode($return));
}
}
public function process()
{
parent::process();
@ -38,9 +226,9 @@ class AddressController extends AddressControllerCore {
self::$smarty->assign('vat_display', 0);
self::$smarty->assign('ajaxurl', _MODULE_DIR_);
self::$smarty->assign('vatnumber_ajax_call', (int)file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'));
self::$smarty->assign(array(
'address_ac_token' => (self::$cookie->isLogged()? Tools::encrypt(date('Y-m-d').self::$cookie->id_customer.'Wb62nI1mcPdwyqqt'): ''),
'countries_list' => $countriesList,