Skip to content

Commit

Permalink
FIX #7824
Browse files Browse the repository at this point in the history
Conflicts:
	htdocs/product/stock/replenishorders.php
  • Loading branch information
eldy committed Nov 17, 2017
1 parent 783efd1 commit 42b7d80
Showing 1 changed file with 73 additions and 18 deletions.
91 changes: 73 additions & 18 deletions htdocs/product/stock/replenishorders.php
Expand Up @@ -29,7 +29,8 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
require_once './lib/replenishment.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/lib/replenishment.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';

$langs->load("products");
$langs->load("stocks");
Expand All @@ -39,6 +40,46 @@
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service');

$sall = GETPOST('search_all', 'alphanohtml');
$sref = GETPOST('search_ref', 'alpha');
$snom = GETPOST('search_nom', 'alpha');
$suser = GETPOST('search_user', 'alpha');
$sttc = GETPOST('search_ttc', 'alpha');
$page = GETPOST('page', 'int');
$sproduct = GETPOST('sproduct', 'int');
$search_dateyear = GETPOST('search_dateyear', 'int');
$search_datemonth = GETPOST('search_datemonth', 'int');
$search_dateday = GETPOST('search_dateday', 'int');
$search_date = dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear);

$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield");
$sortorder = GETPOST("sortorder");
if (!$sortorder) $sortorder = 'DESC';
if (!$sortfield) $sortfield = 'cf.date_creation';
$page = GETPOST("page");
if ($page < 0) $page = 0;
$offset = $limit * $page;


/*
* Actions
*/

if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
$sall="";
$sref="";
$snom="";
$suser="";
$sttc="";
$search_date='';
$search_datemonth='';
$search_dateday='';
$search_dateyear='';
$sproduct=0;
}



/*
Expand Down Expand Up @@ -120,17 +161,18 @@
if ($sttc) {
$sql .= ' AND cf.total_ttc = ' . price2num($sttc);
}
if ($sdate)
if ($search_datemonth > 0)
{
if (GETPOST('search_datemonth', 'int') && GETPOST('search_dateday', 'int') && GETPOST('search_dateyear', 'int'))
{
$date = dol_mktime(0, 0, 0, GETPOST('search_datemonth', 'int'), GETPOST('search_dateday', 'int'), GETPOST('search_dateyear', 'int'));
}
else
{
$date = dol_stringtotime($sdate);
}
$sql .= " AND cf.date_creation = '" . $db->idate($date) . "'";
if ($search_dateyear > 0 && empty($search_dateday))
$sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_get_first_day($search_dateyear,$search_datemonth,false))."' AND '".$db->idate(dol_get_last_day($search_dateyear,$search_datemonth,false))."'";
else if ($search_dateyear > 0 && ! empty($search_dateday))
$sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_datemonth, $search_dateday, $search_dateyear))."'";
else
$sql.= " AND date_format(cf.date_creation, '%m') = '".$search_datemonth."'";
}
else if ($search_dateyear > 0)
{
$sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_get_first_day($search_dateyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_dateyear,12,false))."'";
}
if ($sall) {
$sql .= ' AND (cf.ref LIKE "%' . $db->escape($sall) . '%" ';
Expand Down Expand Up @@ -159,6 +201,18 @@

print_barre_liste('', $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num, 0, '');

$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($sref) $param.='&search_ref='.urlencode($sref);
if ($snom) $param.='&search_nom='.urlencode($snom);
if ($suser) $param.='&search_user='.urlencode($suser);
if ($sttc) $param.='&search_ttc='.urlencode($sttc);
if ($search_dateyear) $param.='&search_dateyear='.urlencode($search_dateyear);
if ($search_datemonth) $param.='&search_datemonth='.urlencode($search_datemonth);
if ($search_dateday) $param.='&search_dateday='.urlencode($search_dateday);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);

print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';

print '<table class="noborder" width="100%">'.
Expand All @@ -168,7 +222,7 @@
$_SERVER['PHP_SELF'],
'cf.ref',
'',
'',
$param,
'',
$sortfield,
$sortorder
Expand All @@ -178,7 +232,7 @@
$_SERVER['PHP_SELF'],
's.nom',
'',
'',
$param,
'',
$sortfield,
$sortorder
Expand All @@ -188,7 +242,7 @@
$_SERVER['PHP_SELF'],
'u.login',
'',
'',
$param,
'',
$sortfield,
$sortorder
Expand All @@ -198,7 +252,7 @@
$_SERVER['PHP_SELF'],
'cf.total_ttc',
'',
'',
$param,
'',
$sortfield,
$sortorder
Expand All @@ -208,7 +262,7 @@
$_SERVER['PHP_SELF'],
'cf.date_creation',
'',
'',
$param,
'',
$sortfield,
$sortorder
Expand All @@ -218,11 +272,12 @@
$_SERVER['PHP_SELF'],
'cf.fk_statut',
'',
'',
$param,
'align="right"',
$sortfield,
$sortorder
);

print '</tr>'.

'<tr class="liste_titre">'.
Expand All @@ -239,7 +294,7 @@
'<input type="text" class="flat" name="search_ttc" value="' . $sttc . '">'.
'</td>'.
'<td class="liste_titre">'.
$form->select_date('', 'search_date', 0, 0, 1, '', 1, 0, 1, 0, '').
$form->select_date($search_date, 'search_date', 0, 0, 1, '', 1, 0, 1, 0, '').
'</td>'.
'<td class="liste_titre" align="right">';
$src = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png';
Expand Down

0 comments on commit 42b7d80

Please sign in to comment.