diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index fae93a98b2f..1a722fb62be 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -106,10 +106,10 @@ class Facture extends CommonObject var $errno = 0; /** - \brief Constructeur de la classe - \param DB handler acc�s base de donn�es - \param socid id societe ('' par defaut) - \param facid id facture ('' par defaut) + * \brief Constructeur de la classe + * \param DB handler acces base de donnees + * \param socid id societe ('' par defaut) + * \param facid id facture ('' par defaut) */ function Facture($DB, $socid='', $facid='') { diff --git a/htdocs/lib/date.lib.php b/htdocs/lib/date.lib.php index a0f8613a8b6..c767154ed78 100644 --- a/htdocs/lib/date.lib.php +++ b/htdocs/lib/date.lib.php @@ -78,7 +78,7 @@ function ConvertSecondToTime($iSecond,$format='all',$lengthOfDay=86400) } else if ($format == 'min') { - $sTime=dol_print_date($iSecond,'%m',true); + $sTime=dol_print_date($iSecond,'%M',true); } return $sTime; } @@ -125,6 +125,42 @@ function dol_get_next_month ($month, $year) } +/** \brief Return GMT time with international string format for first day of a month or year + * \param year Year + * \param month Month + * \return Timestamp Date for first day with format YYYY-MM-DD + */ +function dol_get_first_day($year,$month=1) +{ + return dol_date('Y-m-d',dol_mktime(12,0,0,$month,1,$year,1),1); +} + + +/** \brief Return GMT time with international string format for last day of a month or year + * \param year Year + * \param month Month + * \return Timestamp Date for first day with format YYYY-MM-DD + */ +function dol_get_last_day($year,$month=12) +{ + if ($month == 12) + { + $month = 1; + $year += 1; + } + else + { + $month += 1; + } + + // On se deplace au debut du mois suivant, et on retire un jour + $datelim=dol_mktime(12,0,0,$month,1,$year,1); + $datelim -= (3600 * 24); + + return dol_date('Y-m-d',$datelim,1); +} + + /** * \brief Fonction retournant le nombre de jour fieries samedis et dimanches entre 2 dates entrees en timestamp * \remarks Called by function num_open_day diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index e33522c2621..a40c80464ee 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -30,24 +30,38 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/stock.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); $langs->load("products"); $langs->load("stocks"); if (!$user->rights->produit->lire) accessforbidden(); -$page = $_GET["page"]; -$sortfield = $_GET["sortfield"]; -$sortorder = $_GET["sortorder"]; $idproduct = isset($_GET["idproduct"])?$_GET["idproduct"]:$_PRODUCT["idproduct"]; $year = isset($_GET["year"])?$_GET["year"]:$_POST["year"]; $month = isset($_GET["month"])?$_GET["month"]:$_POST["month"]; +$search_product = isset($_REQUEST["search_product"])?$_REQUEST["search_product"]:''; +$search_warehouse = isset($_REQUEST["search_warehouse"])?$_REQUEST["search_warehouse"]:''; +$search_user = isset($_REQUEST["search_user"])?$_REQUEST["search_user"]:''; +$page = $_GET["page"]; +$sortfield = $_GET["sortfield"]; +$sortorder = $_GET["sortorder"]; if ($page < 0) $page = 0; $offset = $conf->liste_limit * $page; if (! $sortfield) $sortfield="m.datem"; if (! $sortorder) $sortorder="DESC"; +if ($_REQUEST["button_removefilter"]) +{ + $year=''; + $month=''; + $search_product=""; + $search_warehouse=""; + $search_user=""; + $sall=""; +} + /* * View @@ -55,14 +69,17 @@ if (! $sortorder) $sortorder="DESC"; $productstatic=new Product($db); $warehousestatic=new Entrepot($db); +$userstatic=new User($db); $form=new Form($db); $sql = "SELECT p.rowid, p.label as produit, p.fk_product_type as type,"; $sql.= " s.label as stock, s.rowid as entrepot_id,"; -$sql.= " m.rowid as mid, m.value, m.datem"; -$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as s"; -$sql.= ", ".MAIN_DB_PREFIX."stock_mouvement as m"; -$sql.= ", ".MAIN_DB_PREFIX."product as p"; +$sql.= " m.rowid as mid, m.value, m.datem, m.fk_user_author,"; +$sql.= " u.login"; +$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as s,"; +$sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m,"; +$sql.= " ".MAIN_DB_PREFIX."product as p"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_author = u.rowid"; if ($conf->categorie->enabled && !$user->rights->categorie->voir) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; @@ -72,7 +89,9 @@ $sql.= " WHERE m.fk_product = p.rowid"; $sql.= " AND m.fk_entrepot = s.rowid"; $sql.= " AND s.entity = ".$conf->entity; if ($_GET["id"]) -$sql.= " AND s.rowid ='".$_GET["id"]."'"; +{ + $sql.= " AND s.rowid ='".$_GET["id"]."'"; +} if ($conf->categorie->enabled && !$user->rights->categorie->voir) { $sql.= " AND COALESCE(c.visible,1)=1"; @@ -80,14 +99,25 @@ if ($conf->categorie->enabled && !$user->rights->categorie->voir) if ($month > 0) { if ($year > 0) - $sql.= " AND date_format(m.datem, '%Y-%m') = '$year-$month'"; + $sql.= " AND m.datem between '".dol_get_first_day($year,$month)."' AND '".dol_get_last_day($year,$month)."'"; else $sql.= " AND date_format(m.datem, '%m') = '$month'"; } -if ($year > 0) $sql .= " AND date_format(m.datem, '%Y') = $year"; -if (! empty($_GET['search_product'])) +else if ($year > 0) { - $sql.= " AND p.label LIKE '%".addslashes($_GET['search_product'])."%'"; + $sql.= " AND m.datem between '".dol_get_first_day($year)."' AND '".dol_get_last_day($year)."'"; +} +if (! empty($search_product)) +{ + $sql.= " AND p.label LIKE '%".addslashes($search_product)."%'"; +} +if (! empty($search_warehouse)) +{ + $sql.= " AND s.label LIKE '%".addslashes($search_warehouse)."%'"; +} +if (! empty($search_user)) +{ + $sql.= " AND u.login LIKE '%".addslashes($search_user)."%'"; } if (! empty($_GET['idproduct'])) { @@ -96,6 +126,7 @@ if (! empty($_GET['idproduct'])) $sql.= " ORDER BY $sortfield $sortorder "; $sql.= $db->plimit($conf->liste_limit + 1 ,$offset); +//print $sql; $resql = $db->query($sql) ; if ($resql) { @@ -125,7 +156,7 @@ if ($resql) /* - * Show tab only if we ask a particular warehous + * Show tab only if we ask a particular warehouse */ if ($_GET["id"]) { @@ -209,11 +240,12 @@ if ($resql) print ''; print ""; - //print_liste_field_titre($langs->trans("Id"),"mouvement.php", "m.rowid","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),"mouvement.php", "m.datem","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Product"),"mouvement.php", "p.ref","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Warehouse"),"mouvement.php", "s.label","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Units"),"mouvement.php", "m.value","",$param,'align="right"',$sortfield,$sortorder); + //print_liste_field_titre($langs->trans("Id"),$_SERVER["PHP_SELF"], "m.rowid","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"], "m.datem","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Product"),$_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Warehouse"),$_SERVER["PHP_SELF"], "s.label","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Units"),$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre @@ -230,10 +262,14 @@ if ($resql) print ''; - print ''; + print ''; print ''; print "\n"; print ''; @@ -261,6 +297,12 @@ if ($resql) $warehousestatic->libelle=$objp->stock; print $warehousestatic->getNomUrl(1); print "\n"; + // Author + print '\n"; // Value print '
'; print ''; print ''; - print ' '; + print ''; + print ''; + print ''; + print ''; print ''; + print '  '; print '
'; + $userstatic->id=$objp->fk_user_author; + $userstatic->nom=$objp->login; + print $userstatic->getNomUrl(1); + print "'; if ($objp->value > 0) print '+'; diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index ccc26f81861..a9af33a243d 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -483,7 +483,7 @@ class Propal extends CommonObject /** * \brief Supprime une ligne de detail - * \param idligne Id de la ligne detail � supprimer + * \param idligne Id de la ligne detail a supprimer * \return int >0 si ok, <0 si ko */ function delete_product($idligne)