fix conflicts

This commit is contained in:
Marion Muszynski 2017-02-23 12:46:49 +01:00
commit 8191e443ff
4 changed files with 94 additions and 22 deletions

View File

@ -853,6 +853,22 @@ class HelperFormBootstrap{
</div>';
}
public static function displaySuccess($message){
echo '<div class="col-sm-6 col-sm-offset-3 alert-custom alert-ok" style="margin-bottom: 10px;">
<i class="glyphicon glyphicon-ok"></i> <span class="text-alert">'.$message.'</span>
</div>';
}
public static function displayWarning($message){
echo '<div class="col-sm-6 col-sm-offset-3 alert-custom alert-warning" style="margin-bottom: 10px;">
<i class="anticon anticon-notification"></i> <span class="text-alert">'.$message.'</span>
</div>';
}
public static function displayErrors($message){
echo '<div class="col-sm-6 col-sm-offset-3 alert-custom alert-error" style="margin-bottom: 10px;">
<i class="anticon anticon-warning"></i> <span class="text-alert">'.$message.'</span>
</div>';
}
public function displayFlags($languages, $default_language, $ids, $id, $return = false, $use_vars_instead_of_ids = false, $link_flag_img = "../img/l/", $display ='block')
{
if (sizeof($languages) == 1)

View File

@ -271,11 +271,23 @@ div.tagsinput span.tag a {
background-color: #FFA74E;
border: 1px solid #FFA74E;
}
#content .alter-warning i.glyphicon,
#content .alert-warning span.glyphicon,
#content .alert-warning i.anticon,
#content .alert-warning span.anticon{
opacity: 0.5;
}
#content .alert-error{
color: #fff;
background-color: #E36363;
border: 1px solid #C22222;
}
#content .alter-error i.glyphicon,
#content .alert-error span.glyphicon,
#content .alert-error i.anticon,
#content .alert-error span.anticon{
opacity: 0.6;
}
/* form */
.form-control {

View File

@ -20,7 +20,7 @@ class AdminAntConfigurations extends AdminTab
Configuration::updateValue('ANT_CARRIERS_OOH', Tools::getValue('carriers_ooh'));
Configuration::updateValue('ANT_CARRIERS_SPECIAL', Tools::getValue('carriers_special'));
HelperFormBootstrap::echoConfirmation($this->l('Configurations mises à jour'));
HelperFormBootstrap::displaySuccess($this->l('Configurations mises à jour'));
} elseif(Tools::isSubmit('submitProductSaleCache')) {
$fileName = 'cron_sale_cache.php';
@ -28,9 +28,9 @@ class AdminAntConfigurations extends AdminTab
$hour = (int) date('H');
$min = (int) date('i');
if($output > 2){
HelperFormBootstrap::echoError($this->l('Association automatique en cours, réessayez plus tard'));
HelperFormBootstrap::displayErrors($this->l('Association automatique en cours, réessayez plus tard'));
}elseif ($hour%3 == 0 && $min <= 20 && $min >= 10 ){
HelperFormBootstrap::echoError($this->l('Association automatique en cours, réessayez plus tard'));
HelperFormBootstrap::displayErrors($this->l('Association automatique en cours, réessayez plus tard'));
} else {
$min_id_product = Db::getInstance()->getValue('
SELECT MIN(`id_product`) FROM `'._DB_PREFIX_.'product` WHERE `date_add` > DATE_SUB(NOW(), INTERVAL 10 DAY)
@ -65,9 +65,9 @@ class AdminAntConfigurations extends AdminTab
NOW()
)
');
HelperFormBootstrap::echoConfirmation($this->l('Produits associés aux ventes depuis le produit #').$min_id_product);
HelperFormBootstrap::displaySuccess($this->l('Produits associés aux ventes depuis le produit #').$min_id_product);
} else {
HelperFormBootstrap::echoError($this->l('Pas de produit ajouté depuis 10 jours'));
HelperFormBootstrap::displayErrors($this->l('Pas de produit ajouté depuis 10 jours'));
}
}
} elseif(Tools::isSubmit('submitCategorySaleCache')) {
@ -85,13 +85,13 @@ class AdminAntConfigurations extends AdminTab
NOW()
)
');
HelperFormBootstrap::echoConfirmation($this->l('Categories associés à la vente ').$id_sale);
HelperFormBootstrap::displaySuccess($this->l('Categories associés à la vente ').$id_sale);
} else {
HelperFormBootstrap::echoError($this->l('Veuillez choisir une vente'));
HelperFormBootstrap::displayErrors($this->l('Veuillez choisir une vente'));
}
} elseif(Tools::isSubmit('submitUpdateLoyaltyOrders') && $cookie->id_employee == 1) {
$nb_credits = $this->updateLoyaltyOrders();
HelperFormBootstrap::echoConfirmation($this->l('Credit fidélité mis à jour : ').$nb_credits);
HelperFormBootstrap::displaySuccess($this->l('Credit fidélité mis à jour : ').$nb_credits);
} elseif(
(Tools::isSubmit('submitUpdateCacheSale') || Tools::isSubmit('submitShowProductCacheSale'))
&& $cookie->id_employee == 1)
@ -111,7 +111,7 @@ class AdminAntConfigurations extends AdminTab
if(Tools::isSubmit('submitShowProductCacheSale')) {
// show product
$result = implode(', ',$products_ids);
HelperFormBootstrap::echoConfirmation($this->l('Produits concernés ').'('.count($products_ids).') :<br />'.wordwrap($result, 100, "<br />"));
HelperFormBootstrap::displaySuccess($this->l('Produits concernés ').'('.count($products_ids).') :<br />'.wordwrap($result, 100, "<br />"));
} elseif(Tools::isSubmit('submitUpdateCacheSale')) {
// update product_ps_cache
@ -133,22 +133,37 @@ class AdminAntConfigurations extends AdminTab
WHERE p.`id_category_default` = '.$id_category.'
)
');
HelperFormBootstrap::echoConfirmation($this->l('Association vente produit mise à jour: #').$id_category);
HelperFormBootstrap::displaySuccess($this->l('Association vente produit mise à jour: #').$id_category);
}
} else{
HelperFormBootstrap::echoError($this->l('Pas de produits trouvés dans cette catégorie :#').$id_category);
HelperFormBootstrap::displayErrors($this->l('Pas de produits trouvés dans cette catégorie :#').$id_category);
}
} else {
HelperFormBootstrap::echoError($this->l('Veuillez choisir une categorie'));
HelperFormBootstrap::displayErrors($this->l('Veuillez choisir une categorie'));
}
} elseif(Tools::isSubmit('submitExportDiscount')){
HelperFormBootstrap::echoError($this->l('L\'outils n\'est pas encore disponible'));
HelperFormBootstrap::displayWarning($this->l('L\'outils n\'est pas encore disponible'));
// $results = DB::getInstance()->ExecuteS('
// SELECT dh.`id_customer`, o.`id_order`, dh.`name`, o.`value`
// SELECT dh.`id_customer`, dh.`date_add` as `date_generate`,o.`id_order`, dh.`name`, o.`value`
// FROM `'._DB_PREFIX_.'ant_discount_history` dh
// LEFT JOIN `'._DB_PREFIX_.'order_discount` o ON (o.`id_discount` = dh.`id_discount`)
// WHERE 1
// ');
// if($results) {
// $row_definition = array(
// 'id_customer' => 'Client ID',
// 'id_order' => 'Commande ID',
// 'name' => 'Bon de réduction',
// 'value' => 'Valeur',
// 'date_generate' => 'Date de génération',
// );
// header("Content-Type: text/csv; charset=UTF-8");
// header("Content-Disposition: attachment;filename=export-".date('dmYHi').".csv;");
// $this->exportCsv($cmd);
// die();
// } else {
// HelperFormBootstrap::displayWarning($this->l('Aucun résultat trouvé'));
// }
}
}
@ -408,7 +423,7 @@ class AdminAntConfigurations extends AdminTab
}
$form .= $helperForm->renderStyle();
$form .= '<div class="row">'.$helperForm->renderForm(false, NULL, NULL, true).'</div>';
$form .= '<div class="clearfix"></div><div class="row">'.$helperForm->renderForm(false, NULL, NULL, true).'</div>';
$form .= $helperForm->renderScript();
echo $form;
@ -457,4 +472,26 @@ class AdminAntConfigurations extends AdminTab
AND oh.`id_order_state` = 4 AND lo.`id_loyalty_state` NOT IN (2,4)
');
}
public function exportCmdCsv($items, $row_definition){
ob_clean();
$fp = fopen('php://output', 'w');
$delim = ';';
// first row
$data=array();
foreach ($row_definition as $col_name ) {
$data[]=Tools::htmlentitiesDecodeUTF8($col_name);
}
fputcsv ($fp,$data,$delim);
foreach ($items as $item) {
$data = array();
foreach ($row_definition as $key => $col) {
$data[] = (isset($item[$key]) ? $item[$key] : '');
}
fputcsv ($fp,array_map('utf8_decode',array_values($data)),$delim);
}
fclose($fp);
}
}

View File

@ -14,25 +14,32 @@ CREATE TABLE `ps_ant_discount_history` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
*/
$_SERVER['HTTP_HOST'] = 'wwww.bebeboutik.dev';
$_SERVER['SERVER_NAME'] = 'www.bebeboutik.dev';
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
$_SERVER['SERVER_NAME'] = 'www.bebeboutik.com';
$_SERVER['HTTP_PORT'] = 80;
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
include dirname(__FILE__).'/../../config/config.inc.php';
$user_discounts = array();
foreach(Db::getInstance()->ExecuteS('
SELECT `id_customer`
FROM `'._DB_PREFIX_.'ant_discount_history`
WHERE 1
') as $customer) {
$user_discounts[(int)$customer['id_customer']] = (int)$customer['id_customer'];
}
// Create Discount
$customers = Db::getInstance()->ExecuteS('
SELECT c.`id_customer`
FROM `'._DB_PREFIX_.'customer` c
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_customer` = c.`id_customer`)
LEFT JOIN `'._DB_PREFIX_.'ant_discount_history` dh ON (dh.`id_customer` = c.`id_customer`)
WHERE c.`date_add` < DATE_SUB(NOW(), INTERVAL 90 DAY)
AND o.`id_order` IS NULL
AND dh.`id_discount_history` IS NULL
AND c.`id_customer` NOT IN ('.implode(',',$user_discounts).')
ORDER BY c.id_customer DESC
');
foreach($customers as $customer){
if($discount = generateDiscount((int)$customer['id_customer'])) {
registerCustomer((int)$customer['id_customer'],$discount);
@ -70,7 +77,7 @@ function generateDiscount($id_customer)
$discount->quantity = 1;
$discount->quantity_per_user = 1;
$discount->date_from = date('Y-m-d H:i:s');
$discount->date_to = (date('Y') + 1).date('-m-d H:i:s');
$discount->date_to = (date('Y') + 1).date('-m-d').' 23:59:59';
$name = 'KDO-'. Tools::passwdGen(8);
if(Discount::discountExists($name))
@ -113,4 +120,4 @@ function registerCustomer($id_customer,$discount) {
NOW()
)
');
}
}