Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop
This commit is contained in:
commit
467867f10e
@ -272,12 +272,6 @@ if (isset($_GET['updatePositionDrag'])){
|
||||
foreach ($_positions as $id => $value) {
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = '. (int)$value['new'].' WHERE id_sale = '. $id);
|
||||
}
|
||||
// die(json_encode(array(
|
||||
// "position" => $position,
|
||||
// "position_initial" => $position_initial,
|
||||
// "new_position" => $new_position,
|
||||
// "sale_positions" => $_positions,
|
||||
// )));
|
||||
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = '. (int)$new_position.' WHERE id_sale = '. $id_sale);
|
||||
|
||||
|
@ -898,7 +898,9 @@ class AdminImport extends AdminTab
|
||||
$image->id_product = (int)($product->id);
|
||||
$image->position = Image::getHighestPosition($product->id) + 1;
|
||||
$image->cover = (!$key AND !$productHasImages) ? true : false;
|
||||
$image->legend = self::createMultiLangField($product->name);
|
||||
if(isset($product->name[2])){
|
||||
$image->legend = self::createMultiLangField($product->name[2]);
|
||||
}
|
||||
if (($fieldError = $image->validateFields(UNFRIENDLY_ERROR, true)) === true AND ($langFieldError = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true AND $image->add())
|
||||
{
|
||||
if (!self::copyImg($product->id, $image->id, $url))
|
||||
|
@ -72,6 +72,17 @@ class AdminAntSupplierDemand extends AdminTab
|
||||
},
|
||||
locale:"fr"
|
||||
});
|
||||
|
||||
if($("select#id_state").val()==5){
|
||||
$("select#solution").show();
|
||||
}
|
||||
$("select#id_state").change(function(){
|
||||
if($(this).val()==5){
|
||||
$("select#solution").show();
|
||||
} else {
|
||||
$("select#solution").hide();
|
||||
}
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
|
||||
@ -143,6 +154,7 @@ class AdminAntSupplierDemand extends AdminTab
|
||||
$supplier_demands = SupplierDemand::getDemands($query_state);
|
||||
}
|
||||
$states = SupplierDemand::$states;
|
||||
$solutions = SupplierDemand::$solutions;
|
||||
$counts = array(
|
||||
"done" => SupplierDemand::getCountDemands(array(5)),
|
||||
"no_answered" => SupplierDemand::getCountDemands(array(4)),
|
||||
@ -190,6 +202,7 @@ class AdminAntSupplierDemand extends AdminTab
|
||||
<th class="text-center">'.$this->l('Status').'</th>
|
||||
<th class="text-center">'.$this->l('Date').'</th>
|
||||
<th class="text-center">'.$this->l('Renewed').'</th>
|
||||
<th class="text-center">'.$this->l('Solution').'</th>
|
||||
<th class="text-center">'.$this->l('Action').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -207,6 +220,7 @@ class AdminAntSupplierDemand extends AdminTab
|
||||
<td valign="middle" align="center"><span class="'.$states[$supplier_demand['id_state']]['icon'].'"></span> '.$states[$supplier_demand['id_state']]['name'].'</td>
|
||||
<td valign="middle" align="center">'.date('d/m/Y',strtotime($supplier_demand['date_add'])).'</td>
|
||||
<td valign="middle" align="center">'.($renews_number>1?'<span class="label label-danger">'.$renews_number.'</span>':'<span class="label label-default">'.$renews_number.'</span>').'</td>
|
||||
<td valign="middle" align="center">'.((int)$supplier_demand['solution']>0?$solutions[(int)$supplier_demand['solution']]:'/').'</td>
|
||||
<td valign="middle" align="center">
|
||||
<div class="input-group-btn" role="group" aria-label="...">
|
||||
<a href="'.$_current_index.'&updateSupplierDemand=1&id='.$supplier_demand['id_supplier_demand'].'" class="btn btn-default"><span class="anticon anticon-pencil2"></span></a>
|
||||
@ -228,6 +242,7 @@ class AdminAntSupplierDemand extends AdminTab
|
||||
global $cookie, $currentIndex;
|
||||
$_current_index = ($this->config_tab ? $currentIndex . '&token=' . Tools::getAdminTokenLite($this->controller) : $_SERVER['REQUEST_URI']);
|
||||
$states = SupplierDemand::$states;
|
||||
$solutions = SupplierDemand::$solutions;
|
||||
$customer = SupplierDemand::getCustomer($this->_object->id);
|
||||
$histories = SupplierDemand::getHistoryStatic($this->_object->id);
|
||||
$product = SupplierDemand::getProductStatic($this->_object->id);
|
||||
@ -357,10 +372,18 @@ class AdminAntSupplierDemand extends AdminTab
|
||||
<form style="padding:10px 20px;background:#efefef;" action="'.$_current_index.'&updateSupplierDemand=1&id='.$this->_object->id.'" method="post">
|
||||
<input type="hidden" name="id_supplier_demand" value="'.$this->_object->id.'" />
|
||||
<div class="form-group">
|
||||
<select class="form-control" name="id_state">';
|
||||
<select class="form-control" name="id_state" id="id_state">';
|
||||
foreach ($states as $key => $state) {
|
||||
$this->_html .= '<option value="'.$key.'"'.($this->_object->id_state == $key ? ' selected="selected"' : '').'>'.$state['name'].'</option>';
|
||||
}
|
||||
$this->_html.='</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<select class="form-control" name="solution" id="solution" style="display:none;">
|
||||
<option value="0">'.$this->l('Solution...').'</option>';
|
||||
foreach ($solutions as $key => $solution) {
|
||||
$this->_html .= '<option value="'.$key.'"'.($this->_object->solution == $key ? ' selected="selected"' : '').'>'.$solution.'</option>';
|
||||
}
|
||||
$this->_html.='</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@ -392,7 +415,14 @@ class AdminAntSupplierDemand extends AdminTab
|
||||
$supplierDemand->comment = Tools::getValue('comment');
|
||||
}
|
||||
if(Tools::getValue('id_state')){
|
||||
$supplierDemand->id_state = (int)Tools::getValue('id_state');
|
||||
$id_state = (int)Tools::getValue('id_state');
|
||||
if($id_state == 5 && (!Tools::getValue('solution') || Tools::getValue('solution') == 0)){
|
||||
return HelperFormBootstrap::displayErrors($this->l('You have to choose a solution'));
|
||||
}
|
||||
if(Tools::getValue('solution')){
|
||||
$supplierDemand->solution = (int)Tools::getValue('solution');
|
||||
}
|
||||
$supplierDemand->id_state = $id_state;
|
||||
$supplierDemand->addHistory();
|
||||
}
|
||||
} else {
|
||||
@ -406,7 +436,7 @@ class AdminAntSupplierDemand extends AdminTab
|
||||
if ($supplierDemand->save()) {
|
||||
return HelperFormBootstrap::displaySuccess($this->l('Demand has been created'));
|
||||
} else {
|
||||
return HelperFormBootstrap::displayError($this->l('Error occured while creating demand'));
|
||||
return HelperFormBootstrap::displayErrors($this->l('Error occured while creating demand'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ class Ant_Supplierdemand extends Module
|
||||
`qty` INTEGER NOT NULL,
|
||||
`id_state` INTEGER NOT NULL DEFAULT 1,
|
||||
`comment` TEXT,
|
||||
`solution` INTEGER NOT NULL DEFAULT 0,
|
||||
`date_add` DATETIME NOT NULL,
|
||||
`date_upd` DATETIME NOT NULL,
|
||||
PRIMARY KEY(`id_supplier_demand`)
|
||||
|
@ -28,11 +28,18 @@ class SupplierDemand extends ObjectModel
|
||||
),
|
||||
);
|
||||
|
||||
public static $solutions = array(
|
||||
1 => 'Remboursement/Avoir',
|
||||
2 => 'Remplacement du produit',
|
||||
3 => 'Autre'
|
||||
);
|
||||
|
||||
public $id_order;
|
||||
public $id_order_detail;
|
||||
public $qty;
|
||||
public $id_state;
|
||||
public $comment;
|
||||
public $solution;
|
||||
public $date_add;
|
||||
public $date_upd;
|
||||
|
||||
@ -43,6 +50,7 @@ class SupplierDemand extends ObjectModel
|
||||
'qty' => 'isUnsignedId',
|
||||
'id_state' => 'isUnsignedId',
|
||||
'comment' => 'isString',
|
||||
'solution' => 'isInt',
|
||||
'date_add' => 'isDate',
|
||||
'date_upd' => 'isDate',
|
||||
);
|
||||
@ -60,6 +68,7 @@ class SupplierDemand extends ObjectModel
|
||||
$fields['qty'] = (int)$this->qty;
|
||||
$fields['id_state'] = (int)$this->id_state;
|
||||
$fields['comment'] = pSQL($this->comment);
|
||||
$fields['solution'] = (int)$this->solution;
|
||||
$fields['date_add'] = pSQL($this->date_add);
|
||||
$fields['date_upd'] = pSQL($this->date_upd);
|
||||
|
||||
|
@ -955,6 +955,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
<button type="submit" name="not_ended" class="tri btn btn-default active">Ventes actuelles</button>
|
||||
<button type="submit" name="finished" class="tri btn btn-default">Ventes terminées</button>
|
||||
<button type="submit" name="all" class="tri btn btn-default">Toutes les ventes</button>
|
||||
<!--a style="cursor: pointer;" onclick="resortPosition();" class="btn btn-default">Resort</a-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
@ -1291,5 +1292,17 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
Sale::unlockPosition($id_sale);
|
||||
Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesSales'));
|
||||
}
|
||||
// elseif(isset($_GET['resort_position'])){
|
||||
// $nb_sales = Db::getInstance()->getValue('
|
||||
// SELECT COUNT(p.`id_sale`)
|
||||
// FROM `ps_privatesale` p
|
||||
// WHERE CAST(p.`date_start` AS DATE) = CAST(NOW() AS DATE)
|
||||
// AND `date_end` > NOW()
|
||||
// ');
|
||||
|
||||
// if($nb_sales>0) {
|
||||
// Sale::sortActiveSaleAfterAdd($nb_sales);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -268,8 +268,12 @@ class Sale {
|
||||
)
|
||||
');
|
||||
}
|
||||
|
||||
self::sortActiveSaleAfterAdd();
|
||||
// $today = strtotime(date("Y-m-d H:i:s"));
|
||||
// $start = strtotime($sale->date_start);
|
||||
// $end = strtotime($sale->date_end);
|
||||
// if($start <= $today && $end > $today){
|
||||
// self::sortActiveSaleAfterAdd(1);
|
||||
// }
|
||||
|
||||
Module::hookExec('privatesales_create', array('sale' => $this));
|
||||
}
|
||||
@ -299,12 +303,14 @@ class Sale {
|
||||
}
|
||||
}
|
||||
|
||||
public static function sortActiveSaleAfterAdd(){
|
||||
public static function sortActiveSaleAfterAdd($nb = 1){
|
||||
for ($i=0; $i < $nb; $i++) {
|
||||
foreach(Db::getInstance()->executeS('
|
||||
SELECT id_sale, position
|
||||
FROM '._DB_PREFIX_.'privatesale
|
||||
WHERE lock_position = 1
|
||||
AND `date_end` > NOW()
|
||||
AND `date_start` < NOW()
|
||||
ORDER BY position DESC
|
||||
') as $sale){
|
||||
$pos = $sale['position']+1;
|
||||
@ -313,6 +319,7 @@ class Sale {
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = position+1 WHERE id_sale = '. $sale['id_sale']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function rrmdir($dir) {
|
||||
if(is_dir($dir)) {
|
||||
|
19
modules/privatesales/cron_position.php
Normal file
19
modules/privatesales/cron_position.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
if(isset($_SERVER['REMOTE_ADDR'])) exit;
|
||||
$_SERVER['SERVER_PORT'] = 80;
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
|
||||
include(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
include(dirname(__FILE__).'/Sale.php');
|
||||
|
||||
|
||||
$nb_sales = Db::getInstance()->getValue('
|
||||
SELECT COUNT(p.`id_sale`)
|
||||
FROM `ps_privatesale` p
|
||||
WHERE CAST(p.`date_start` AS DATE) = CAST(NOW() AS DATE)
|
||||
AND `date_end` > NOW()
|
||||
');
|
||||
|
||||
if($nb_sales>0) {
|
||||
Sale::sortActiveSaleAfterAdd($nb_sales);
|
||||
}
|
@ -21,3 +21,6 @@ function itemLockPosition(linkId) {
|
||||
function itemUnLockPosition(linkId) {
|
||||
document.location.href = current_location + "&id=" + linkId + "&unlock_position=1";
|
||||
}
|
||||
function resortPosition() {
|
||||
document.location.href = current_location + "&resort_position=1";
|
||||
}
|
||||
|
@ -62,6 +62,19 @@ class MakeStats {
|
||||
return (float)( $values['product_price']*( 1-($values['reduction_percent']/100) ) );
|
||||
}
|
||||
|
||||
public static function getItemPackSoldQuantity($id_item)
|
||||
{
|
||||
$query = Db::getInstance()->getRow('
|
||||
SELECT SUM(od.`product_quantity` - od.`product_quantity_reinjected`) as quantity_sold , p.`quantity`
|
||||
FROM `'._DB_PREFIX_.'pack` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`product_id` = p.`id_product_pack`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state_current` oc ON (oc.`id_order`=od.`id_order`)
|
||||
WHERE oc.`id_order_state` IN (13,4,17,9,1,11,10,5,14,12,2,3,18)
|
||||
AND p.`id_product_item` = '.(int)$id_item.'
|
||||
');
|
||||
return ($query['quantity_sold'] * $query['quantity']);
|
||||
}
|
||||
|
||||
public static function record_sort($records, $field, $reverse=false)
|
||||
{
|
||||
$hash = array();
|
||||
@ -142,9 +155,13 @@ class MakeStats {
|
||||
|
||||
if (isset($line['product_quantity'])) {
|
||||
$quantity = $line['product_quantity'] - $line['product_quantity_reinjected'];
|
||||
} else {
|
||||
if(Pack::isPacked($line['product_id'])){
|
||||
$quantity = self::getItemPackSoldQuantity($line['product_id']);
|
||||
} else {
|
||||
$quantity = 0;
|
||||
}
|
||||
}
|
||||
$stock = (isset($line['attribute_quantity']))?$line['attribute_quantity']:$line['stock'];
|
||||
|
||||
if($by_product_price) {
|
||||
|
Loading…
Reference in New Issue
Block a user