diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 799766c5775..844b7e9f700 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -28,16 +28,21 @@ require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->load("orders"); $langs->load("sendings"); +$orderyear=GETPOST("orderyear","int"); +$ordermonth=GETPOST("ordermonth","int"); +$orderday=GETPOST("orderday","int"); $sall=GETPOST('search_all'); $search_ref=GETPOST('search_ref'); $search_refsupp=GETPOST('search_refsupp'); @@ -76,6 +81,9 @@ if (! $sortorder) $sortorder='DESC'; // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { + $ordermonth=''; + $orderyear=''; + $orderday=''; $search_ref=''; $search_refsupp=''; $search_company=''; @@ -109,6 +117,7 @@ $thirdpartytmp = new Fournisseur($db); $commandestatic=new CommandeFournisseur($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); +$formother = new FormOther($db); $title = $langs->trans("SuppliersOrders"); if ($socid > 0) @@ -185,7 +194,7 @@ if (GETPOST('statut', 'alpha') !== '') $sql .= " AND cf.fk_statut IN (".GETPOST('statut', 'alpha').")"; } -if ($billed !== '') +if ($billed != '' && $billed >= 0) { $sql .= " AND cf.billed = ".$billed; } @@ -199,7 +208,19 @@ if ($search_status != '' && $search_status >= 0) if (strstr($search_status, ',')) $sql.=" AND cf.fk_statut IN (".$db->escape($search_status).")"; else $sql.=" AND cf.fk_statut = ".$search_status; } - +if ($ordermonth > 0) +{ + if ($orderyear > 0 && empty($orderday)) + $sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_get_first_day($orderyear,$ordermonth,false))."' AND '".$db->idate(dol_get_last_day($orderyear,$ordermonth,false))."'"; + else if ($orderyear > 0 && ! empty($orderday)) + $sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $ordermonth, $orderday, $orderyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $ordermonth, $orderday, $orderyear))."'"; + else + $sql.= " AND date_format(cf.date_commande, '%m') = '".$ordermonth."'"; +} +else if ($orderyear > 0) +{ + $sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_get_first_day($orderyear,1,false))."' AND '".$db->idate(dol_get_last_day($orderyear,12,false))."'"; +} $sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = 0; @@ -219,6 +240,9 @@ if ($resql) $i = 0; $param=""; + if ($orderday) $param.='&orderday='.$orderday; + if ($ordermonth) $param.='&ordermonth='.$ordermonth; + if ($orderyear) $param.='&orderyear='.$orderyear; if ($search_ref) $param.="&search_ref=".$search_ref; if ($search_company) $param.="&search_company=".$search_company; if ($search_user) $param.="&search_user=".$search_user; @@ -245,7 +269,7 @@ if ($resql) print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - print ''; + print '
'; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"cf.ref","",$param,'',$sortfield,$sortorder); if (empty($conf->global->SUPPLIER_ORDER_HIDE_REF_SUPPLIER)) print_liste_field_titre($langs->trans("RefSupplier"),$_SERVER["PHP_SELF"],"cf.ref_supplier","",$param,'',$sortfield,$sortorder); @@ -274,7 +298,11 @@ if ($resql) print ''; print ''; print ''; - print ''; + print ''; print ''; print '"; // Amount net - print '"; + print '"; // Amount with tax - print '"; + print '"; // Date - print "
 '; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($orderyear?$orderyear:-1,'orderyear',1, 20, 5); + print ' '; $formorder->selectSupplierOrderStatus((strstr($search_status, ',')?-1:$search_status),1,'search_status'); @@ -347,13 +375,13 @@ if ($resql) print "'.price($obj->total_ht)."'.price($obj->total_ht)."'.price($obj->total_ttc)."'.price($obj->total_ttc).""; + print ''; if ($obj->dc) { print dol_print_date($db->jdate($obj->dc),"day");