Merge branch 'ticket-12391-DiscountForNoneOrder_part2'

This commit is contained in:
Marion Muszynski 2017-02-23 13:33:28 +01:00
commit 21a1230a66
2 changed files with 59 additions and 29 deletions

View File

@ -290,7 +290,7 @@ class HelperFormBootstrap{
$this->_html .='
<div class="form-group '.(isset($p['class-group'])?$p['class-group']:'').'">
'.(isset($p['label']) && $p['label'] ?'<label class="control-label '.$p['label-class'].'" for="'.(isset($p['id']) ? $p['id'] : $p['name']).'">'.$p['label'].'</label>':'').'
<div class="input-group">
<div class="input-group input-group-sm">
'.(isset($p['before']) && $p['before'] ?'<div class="input-group-addon">'.$p['before'].'</div>':'').'
<input type="text" class="form-control" name="'.$p['name'].'" id="'.(isset($p['id']) ? $p['id'] : $p['name']).'" placeholder="'.((isset($p['placeholder']) && $p['placeholder'])?$p['placeholder']:'').'">
'.(isset($p['after']) && $p['after'] ?'<div class="input-group-addon">'.$p['after'].'</div>':'').'
@ -327,7 +327,7 @@ class HelperFormBootstrap{
$this->_html .='
<div class="form-group">
'.(isset($p['label']) && $p['label'] ?'<label class="'.(isset($p['label-class']) && $p['label-class'] ?$p['label-class']:'').'" for="'.(isset($p['id']) ? $p['id'] : $p['name']).'">'.$p['label'].'</label>':'').'
<div class="input-group '.(isset($p['input-class'])?$p['input-class']:'').'">
<div class="input-group input-group-sm '.(isset($p['input-class'])?$p['input-class']:'').'">
'.(isset($p['before']) && $p['before'] ?'<div class="input-group-addon">'.$p['before'].'</div>':'').'
<input type="text" class="form-control" value="'.(isset($p['value'])?$p['value']:'').'" name="'.$p['name'].'" id="'.(isset($p['id']) ? $p['id'] : $p['name']).'" placeholder="'.((isset($p['placeholder']) && $p['placeholder'])?$p['placeholder']:'').'">
'.(isset($p['after']) && $p['after'] ?'<div class="input-group-addon">'.$p['after'].'</div>':'').'
@ -338,7 +338,7 @@ class HelperFormBootstrap{
<div class="'.(isset($p['class-to'])?$p['class-to']:'').'">
<div class="form-group">
'.(isset($p['label-to']) && $p['label-to'] ?'<label class="'.(isset($p['label-class']) && $p['label-class'] ?$p['label-class']:'').'" for="'.(isset($p['id-to']) ? $p['id-to'] : $p['name-to']).'">'.$p['label-to'].'</label>':'').'
<div class="input-group '.(isset($p['input-to-class'])?$p['input-to-class']:'').'">
<div class="input-group input-group-sm '.(isset($p['input-to-class'])?$p['input-to-class']:'').'">
'.(isset($p['before-to']) && $p['before-to'] ?'<div class="input-group-addon">'.$p['before-to'].'</div>':'').'
<input type="text" class="form-control" value="'.(isset($p['value-to'])?$p['value-to']:'').'" name="'.$p['name-to'].'" id="'.(isset($p['id-to']) ? $p['id-to'] : $p['name-to']).'" placeholder="'.((isset($p['placeholder-to']) && $p['placeholder-to'])?$p['placeholder-to']:'').'">
'.(isset($p['after-to']) && $p['after-to'] ?'<div class="input-group-addon">'.$p['after-to'].'</div>':'').'

View File

@ -140,18 +140,23 @@ class AdminAntConfigurations extends AdminTab
HelperFormBootstrap::displayErrors($this->l('Veuillez choisir une categorie'));
}
} elseif(Tools::isSubmit('submitExportDiscount')){
ini_set('memory_limit', '4G');
$from = Tools::getValue('date_from');
$to = Tools::getValue('date_to');
$results = DB::getInstance()->ExecuteS('
SELECT dh.`id_customer`, dh.`date_add` as `date_generate`,od.`id_order`, dh.`code`, od.`value`, o.`total_paid_real`,o.`date_add` as `date_order`
FROM `'._DB_PREFIX_.'ant_discount_history` dh
LEFT JOIN `'._DB_PREFIX_.'order_discount` od ON (od.`id_discount` = dh.`id_discount`)
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = od.`id_order`)
WHERE 1
'.($from && !empty($from)?' AND dh.`date_add` > "'.$from.' 00:00:00"':'').'
'.($to && !empty($to)?' AND dh.`date_add` < "'.$to.' 00:00:00"':'').'
');
if($results) {
$row_definition = array(
'id_customer' => 'Client ID',
'id_order' => 'Commande ID',
'name' => 'Bon de réduction',
'code' => 'Bon de réduction',
'value' => 'Valeur Bon',
'total_paid_real' => 'Total Commande',
'date_generate' => 'Date création du bon',
@ -239,43 +244,62 @@ class AdminAntConfigurations extends AdminTab
$helperForm = new HelperFormBootstrap();
$helperForm->_select2 = true;
$helperForm->_inputMask = true;
$helperForm->_forms = array(
array(
'action' => $base_link,
'title' => $this->l('Association Produits'),
'icon' => '<span class="glyphicon glyphicon-refresh"></span> ',
'class' => 'form-horizontal',
'class_div' => 'col-md-3',
'information' => 'Permet d\'associer les produits aux ventes lorsque le cron n\'est pas encore passé',
'sections' => array(
'action' => $base_link,
'title' => $this->l('Outils - Suivi bons réduction'),
'icon' => '<span class="glyphicon glyphicon-cog"></span> ',
'class' => 'form-horizontal',
'class_div' => 'col-md-4',
// 'information' => 'Petit outils d\'exports utiles pour les suivis',
'sections' => array(
array(
'inputs' => array(
array(
'type' => 'submit',
'class' => 'btn-primary',
'name' => 'submitProductSaleCache',
'value' => $this->l('Mettre à jour l\'association'),
'type' => 'simpleDate',
'period' => true,
'class-from' => 'col-md-6',
'class-to' => 'col-md-6',
// 'label' => 'De :',
// 'label-to' => 'A :',
'id' => 'date_from',
'id-to' => 'date_to',
'name' => 'date_from',
'name-to' => 'date_to',
'before' => '<span class="glyphicon glyphicon-calendar"></span>',
'before-to' => '<span class="glyphicon glyphicon-calendar"></span>',
),
),
'actions' => array(
array(
'type' => 'submit',
'class' => 'btn-primary',
'name' => 'submitExportDiscount',
'value' => $this->l('Exporter Suivi Code promo'),
),
),
'actions-class' => 'text-right',
),
),
)
),
);
$helperForm->_forms[] = array(
'action' => $base_link,
'title' => $this->l('Outils'),
'icon' => '<span class="glyphicon glyphicon-cog"></span> ',
'class' => 'form-horizontal',
'class_div' => 'col-md-3',
'information' => 'Petit outils d\'exports utiles pour les suivis',
'sections' => array(
'action' => $base_link,
'title' => $this->l('Association Produits'),
'icon' => '<span class="glyphicon glyphicon-refresh"></span> ',
'class' => 'form-horizontal',
'class_div' => 'col-md-3',
'information' => 'Permet d\'associer les produits aux ventes lorsque le cron n\'est pas encore passé',
'sections' => array(
array(
'inputs' => array(
array(
'type' => 'submit',
'class' => 'btn-default',
'name' => 'submitExportDiscount',
'value' => $this->l('Exporter Suivi Code promo'),
'class' => 'btn-primary',
'name' => 'submitProductSaleCache',
'value' => $this->l('Mettre à jour l\'association'),
),
),
),
@ -286,7 +310,7 @@ class AdminAntConfigurations extends AdminTab
'title' => $this->l('Association categories/ventes'),
'icon' => '<span class="glyphicon glyphicon-cog"></span> ',
'class' => 'form-horizontal',
'class_div' => 'col-md-6',
'class_div' => 'col-md-5',
'sections' => array(
array(
'inputs' => array(
@ -405,7 +429,13 @@ class AdminAntConfigurations extends AdminTab
'actions-class' => 'text-center',
);
}
$helperForm->_js .= '
<script>
$(document).ready(function() {
$("#date_from").inputmask("9999-99-99");
$("#date_to").inputmask("9999-99-99");
});
</script>';
$form .= $helperForm->renderStyle();
$form .= '<div class="clearfix"></div><div class="row">'.$helperForm->renderForm(false, NULL, NULL, true).'</div>';
$form .= $helperForm->renderScript();
@ -457,7 +487,7 @@ class AdminAntConfigurations extends AdminTab
');
}
public function exportCmdCsv($items, $row_definition){
public function exportCsv($items, $row_definition){
ob_clean();
$fp = fopen('php://output', 'w');
$delim = ';';