Merge pull request #10158 from defrance/patch-135
Refactoring list with dol_sql_datefilter function (end)
This commit is contained in:
commit
4b90f88793
@ -6,7 +6,8 @@
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -522,39 +523,20 @@ if ($search_product_category > 0) $sql.= " AND cp.fk_categorie = ".$search_produ
|
||||
|
||||
//Required triple check because statut=0 means draft filter
|
||||
if (GETPOST('statut', 'intcomma') !== '')
|
||||
{
|
||||
$sql .= " AND cf.fk_statut IN (".$db->escape($db->escape(GETPOST('statut', 'intcomma'))).")";
|
||||
}
|
||||
|
||||
if ($search_status != '' && $search_status >= 0)
|
||||
{
|
||||
$sql.=" AND cf.fk_statut IN (".$db->escape($search_status).")";
|
||||
}
|
||||
if ($search_ordermonth > 0)
|
||||
{
|
||||
if ($search_orderyear > 0 && empty($search_orderday))
|
||||
$sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_get_first_day($search_orderyear,$search_ordermonth,false))."' AND '".$db->idate(dol_get_last_day($search_orderyear,$search_ordermonth,false))."'";
|
||||
else if ($search_orderyear > 0 && ! empty($search_orderday))
|
||||
$sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_ordermonth, $search_orderday, $search_orderyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_ordermonth, $search_orderday, $search_orderyear))."'";
|
||||
else
|
||||
$sql.= " AND date_format(cf.date_commande, '%m') = '".$db->escape($search_ordermonth)."'";
|
||||
}
|
||||
else if ($search_orderyear > 0)
|
||||
{
|
||||
$sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_get_first_day($search_orderyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_orderyear,12,false))."'";
|
||||
}
|
||||
if ($search_deliverymonth > 0)
|
||||
{
|
||||
if ($search_deliveryyear > 0 && empty($search_deliveryday))
|
||||
$sql.= " AND cf.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_deliveryyear,$search_deliverymonth,false))."' AND '".$db->idate(dol_get_last_day($search_deliveryyear,$search_deliverymonth,false))."'";
|
||||
else if ($search_deliveryyear > 0 && ! empty($search_deliveryday))
|
||||
$sql.= " AND cf.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_eliverymonth, $search_deliveryday, $search_deliveryyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_deliverymonth, $search_deliveryday, $search_deliveryyear))."'";
|
||||
else
|
||||
$sql.= " AND date_format(cf.date_livraison, '%m') = '".$db->escape($search_deliverymonth)."'";
|
||||
}
|
||||
else if ($search_deliveryyear > 0)
|
||||
{
|
||||
$sql.= " AND cf.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_deliveryyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_deliveryyear,12,false))."'";
|
||||
}
|
||||
|
||||
$sql.= dol_sql_datefilter(
|
||||
"cf.date_commande",
|
||||
$search_orderday, $search_ordermonth, $search_orderyear
|
||||
);
|
||||
$sql.= dol_sql_datefilter(
|
||||
"cf.date_livraison",
|
||||
$search_deliveryday, $search_deliverymonth, $search_deliveryyear
|
||||
);
|
||||
|
||||
if ($search_town) $sql.= natural_search('s.town', $search_town);
|
||||
if ($search_zip) $sql.= natural_search("s.zip",$search_zip);
|
||||
if ($search_state) $sql.= natural_search("state.nom",$search_state);
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
* Copyright (C) 2015 Abbes Bahfir <bafbes@gmail.com>
|
||||
* Copyright (C) 2015-2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2017 Josep Lluís Amador <joseplluis@lliuretic.cat>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -329,32 +330,10 @@ if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $searc
|
||||
if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
|
||||
if ($search_status != '' && $search_status >= 0) $sql.= " AND f.fk_statut = ".$db->escape($search_status);
|
||||
if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode."";
|
||||
if ($month > 0)
|
||||
{
|
||||
if ($year > 0 && empty($day))
|
||||
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
|
||||
else if ($year > 0 && ! empty($day))
|
||||
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
|
||||
else
|
||||
$sql.= " AND date_format(f.datef, '%m') = '".$month."'";
|
||||
}
|
||||
else if ($year > 0)
|
||||
{
|
||||
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
|
||||
}
|
||||
if ($month_lim > 0)
|
||||
{
|
||||
if ($year_lim > 0 && empty($day_lim))
|
||||
$sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,$month_lim,false))."' AND '".$db->idate(dol_get_last_day($year_lim,$month_lim,false))."'";
|
||||
else if ($year_lim > 0 && ! empty($day_lim))
|
||||
$sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_lim, $day_lim, $year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_lim, $day_lim, $year_lim))."'";
|
||||
else
|
||||
$sql.= " AND date_format(f.date_lim_reglement, '%m') = '".$db->escape($month_lim)."'";
|
||||
}
|
||||
else if ($year_lim > 0)
|
||||
{
|
||||
$sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'";
|
||||
}
|
||||
|
||||
$sql.= dol_sql_datefilter( "f.datef", $day, $month, $year);
|
||||
$sql.= dol_sql_datefilter( "f.date_lim_reglement", $day_lim, $month_lim, $year_lim);
|
||||
|
||||
if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'";
|
||||
if ($search_label) $sql .= natural_search('f.libelle', $search_label);
|
||||
if ($search_status != '' && $search_status >= 0)
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
|
||||
* Copyright (C) 2013-2018 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012-2016 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2012-2016 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -190,49 +191,22 @@ if(!empty($search_ref))
|
||||
}
|
||||
|
||||
// Start date
|
||||
if($search_year_start > 0) {
|
||||
if($search_month_start > 0) {
|
||||
$filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($search_year_start,$search_month_start,1))."' AND '".$db->idate(dol_get_last_day($search_year_start,$search_month_start,1))."')";
|
||||
//$filter.= " AND date_format(cp.date_debut, '%Y-%m') = '$search_year_start-$search_month_start'";
|
||||
} else {
|
||||
$filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($search_year_start,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_start,12,1))."')";
|
||||
//$filter.= " AND date_format(cp.date_debut, '%Y') = '$search_year_start'";
|
||||
}
|
||||
} else {
|
||||
if($search_month_start > 0) {
|
||||
$filter.= " AND date_format(cp.date_debut, '%m') = '".$db->escape($search_month_start)."'";
|
||||
}
|
||||
}
|
||||
$sql.= dol_sql_datefilter(
|
||||
"cp.date_debut",
|
||||
$search_day_start, $search_month_start, $search_year_start
|
||||
);
|
||||
|
||||
// End date
|
||||
if($search_year_end > 0) {
|
||||
if($search_month_end > 0) {
|
||||
$filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($search_year_end,$search_month_end,1))."' AND '".$db->idate(dol_get_last_day($search_year_end,$search_month_end,1))."')";
|
||||
//$filter.= " AND date_format(cp.date_fin, '%Y-%m') = '$search_year_end-$search_month_end'";
|
||||
} else {
|
||||
$filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($search_year_end,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_end,12,1))."')";
|
||||
//$filter.= " AND date_format(cp.date_fin, '%Y') = '$search_year_end'";
|
||||
}
|
||||
} else {
|
||||
if($search_month_end > 0) {
|
||||
$filter.= " AND date_format(cp.date_fin, '%m') = '".$db->escape($search_month_end)."'";
|
||||
}
|
||||
}
|
||||
$sql.= dol_sql_datefilter(
|
||||
"cp.date_fin",
|
||||
$search_day_end, $search_month_end, $search_year_end
|
||||
);
|
||||
|
||||
// Create date
|
||||
if($search_year_create > 0) {
|
||||
if($search_month_create > 0) {
|
||||
$filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($search_year_create,$search_month_create,1))."' AND '".$db->idate(dol_get_last_day($search_year_create,$search_month_create,1))."')";
|
||||
//$filter.= " AND date_format(cp.date_create, '%Y-%m') = '$search_year_create-$search_month_create'";
|
||||
} else {
|
||||
$filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($search_year_create,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_create,12,1))."')";
|
||||
//$filter.= " AND date_format(cp.date_create, '%Y') = '$search_year_create'";
|
||||
}
|
||||
} else {
|
||||
if($search_month_create > 0) {
|
||||
$filter.= " AND date_format(cp.date_create, '%m') = '".$db->escape($search_month_create)."'";
|
||||
}
|
||||
}
|
||||
$sql.= dol_sql_datefilter(
|
||||
"cp.date_create",
|
||||
$search_day_create, $search_month_create, $search_year_create
|
||||
);
|
||||
|
||||
// Employee
|
||||
if(!empty($search_employee) && $search_employee != -1) {
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -77,8 +78,10 @@ $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alp
|
||||
$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
|
||||
$year=GETPOST("year");
|
||||
$month=GETPOST("month");
|
||||
$day=GETPOST("day");
|
||||
$yearvalid=GETPOST("yearvalid");
|
||||
$monthvalid=GETPOST("monthvalid");
|
||||
$dayvalid=GETPOST("dayvalid");
|
||||
|
||||
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
@ -196,8 +199,10 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
|
||||
$search_author='';
|
||||
$yearvalid='';
|
||||
$monthvalid='';
|
||||
$dayvalid='';
|
||||
$year='';
|
||||
$month='';
|
||||
$day='';
|
||||
$search_status='';
|
||||
$object_statut='';
|
||||
}
|
||||
@ -284,32 +289,10 @@ if ($search_montant_ttc != '') $sql.= natural_search("sp.total", $search_montant
|
||||
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
||||
if ($socid) $sql.= ' AND s.rowid = '.$socid;
|
||||
if ($search_status >= 0 && $search_status != '') $sql.= ' AND sp.fk_statut IN ('.$db->escape($search_status).')';
|
||||
if ($month > 0)
|
||||
{
|
||||
if ($year > 0 && empty($day))
|
||||
$sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
|
||||
else if ($year > 0 && ! empty($day))
|
||||
$sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
|
||||
else
|
||||
$sql.= " AND date_format(sp.date_livraison, '%m') = '".$month."'";
|
||||
}
|
||||
else if ($year > 0)
|
||||
{
|
||||
$sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
|
||||
}
|
||||
if ($monthvalid > 0)
|
||||
{
|
||||
if ($yearvalid > 0 && empty($dayvalid))
|
||||
$sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,$monthvalid,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,$monthvalid,false))."'";
|
||||
else if ($yearvalid > 0 && ! empty($dayvalid))
|
||||
$sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $monthvalid, $dayvalid, $yearvalid))."' AND '".$db->idate(dol_mktime(23, 59, 59, $monthvalid, $dayvalid, $yearvalid))."'";
|
||||
else
|
||||
$sql.= " AND date_format(sp.date_valid, '%m') = '".$monthvalid."'";
|
||||
}
|
||||
else if ($yearvalid > 0)
|
||||
{
|
||||
$sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,1,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,12,false))."'";
|
||||
}
|
||||
|
||||
$sql.= dol_sql_datefilter("sp.date_livraison", $day, $month, $year);
|
||||
$sql.= dol_sql_datefilter("sp.date_valid", $dayvalid, $monthvalid, $yearvalid);
|
||||
|
||||
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
|
||||
if ($search_user > 0)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user