mouvement.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <?php
  2. /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/product/stock/mouvement.php
  21. * \ingroup stock
  22. * \brief Page to list stock movements
  23. */
  24. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  33. $langs->load("products");
  34. $langs->load("stocks");
  35. // Security check
  36. $result=restrictedArea($user,'stock');
  37. $id=GETPOST('id','int');
  38. $product_id=GETPOST("product_id");
  39. $action=GETPOST('action');
  40. $cancel=GETPOST('cancel');
  41. $idproduct = GETPOST('idproduct','int');
  42. $year = GETPOST("year");
  43. $month = GETPOST("month");
  44. $search_movement = GETPOST("search_movement");
  45. $search_product_ref = trim(GETPOST("search_product_ref"));
  46. $search_product = trim(GETPOST("search_product"));
  47. $search_warehouse = trim(GETPOST("search_warehouse"));
  48. $search_user = trim(GETPOST("search_user"));
  49. $page = GETPOST("page",'int');
  50. $sortfield = GETPOST("sortfield",'alpha');
  51. $sortorder = GETPOST("sortorder",'alpha');
  52. if ($page < 0) $page = 0;
  53. $offset = $conf->liste_limit * $page;
  54. if (! $sortfield) $sortfield="m.datem";
  55. if (! $sortorder) $sortorder="DESC";
  56. if (GETPOST("button_removefilter"))
  57. {
  58. $year='';
  59. $month='';
  60. $search_movement="";
  61. $search_product_ref="";
  62. $search_product="";
  63. $search_warehouse="";
  64. $search_user="";
  65. $sall="";
  66. }
  67. /*
  68. * Actions
  69. */
  70. if ($cancel) $action='';
  71. // Correct stock
  72. if ($action == "correct_stock" && ! $_POST["cancel"])
  73. {
  74. if (is_numeric($_POST["nbpiece"]) && $product_id)
  75. {
  76. $product = new Product($db);
  77. $result=$product->fetch($product_id);
  78. $result=$product->correct_stock(
  79. $user,
  80. $id,
  81. $_POST["nbpiece"],
  82. $_POST["mouvement"],
  83. $_POST["label"],
  84. 0
  85. ); // We do not change value of stock for a correction
  86. if ($result > 0)
  87. {
  88. header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
  89. exit;
  90. }
  91. }
  92. else $action='';
  93. }
  94. /*
  95. * View
  96. */
  97. $productstatic=new Product($db);
  98. $warehousestatic=new Entrepot($db);
  99. $movement=new MouvementStock($db);
  100. $userstatic=new User($db);
  101. $form=new Form($db);
  102. $formother=new FormOther($db);
  103. $formproduct=new FormProduct($db);
  104. $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type,";
  105. $sql.= " e.label as stock, e.rowid as entrepot_id,";
  106. $sql.= " m.rowid as mid, m.value, m.datem, m.fk_user_author, m.label, m.fk_origin, m.origintype,";
  107. $sql.= " u.login";
  108. $sql.= " FROM (".MAIN_DB_PREFIX."entrepot as e,";
  109. $sql.= " ".MAIN_DB_PREFIX."product as p,";
  110. $sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m)";
  111. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
  112. $sql.= " WHERE m.fk_product = p.rowid";
  113. $sql.= " AND m.fk_entrepot = e.rowid";
  114. $sql.= " AND e.entity = ".$conf->entity;
  115. if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0";
  116. if ($id)
  117. {
  118. $sql.= " AND e.rowid ='".$id."'";
  119. }
  120. if ($month > 0)
  121. {
  122. if ($year > 0)
  123. $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
  124. else
  125. $sql.= " AND date_format(m.datem, '%m') = '$month'";
  126. }
  127. else if ($year > 0)
  128. {
  129. $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
  130. }
  131. if (! empty($search_movement))
  132. {
  133. $sql.= " AND m.label LIKE '%".$db->escape($search_movement)."%'";
  134. }
  135. if (! empty($search_product_ref))
  136. {
  137. $sql.= " AND p.ref LIKE '%".$db->escape($search_product_ref)."%'";
  138. }
  139. if (! empty($search_product))
  140. {
  141. $sql.= " AND p.label LIKE '%".$db->escape($search_product)."%'";
  142. }
  143. if (! empty($search_warehouse))
  144. {
  145. $sql.= " AND e.label LIKE '%".$db->escape($search_warehouse)."%'";
  146. }
  147. if (! empty($search_user))
  148. {
  149. $sql.= " AND u.login LIKE '%".$db->escape($search_user)."%'";
  150. }
  151. if ($idproduct > 0)
  152. {
  153. $sql.= " AND p.rowid = '".$idproduct."'";
  154. }
  155. $sql.= $db->order($sortfield,$sortorder);
  156. $sql.= $db->plimit($conf->liste_limit+1, $offset);
  157. //print $sql;
  158. $resql = $db->query($sql);
  159. if ($resql)
  160. {
  161. $num = $db->num_rows($resql);
  162. if ($idproduct)
  163. {
  164. $product = new Product($db);
  165. $product->fetch($idproduct);
  166. }
  167. if ($id > 0)
  168. {
  169. $entrepot = new Entrepot($db);
  170. $result = $entrepot->fetch($id);
  171. if ($result < 0)
  172. {
  173. dol_print_error($db);
  174. }
  175. }
  176. $i = 0;
  177. $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
  178. $texte = $langs->trans("ListOfStockMovements");
  179. if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')';
  180. llxHeader("",$texte,$help_url);
  181. /*
  182. * Show tab only if we ask a particular warehouse
  183. */
  184. if ($id)
  185. {
  186. $head = stock_prepare_head($entrepot);
  187. dol_fiche_head($head, 'movements', $langs->trans("Warehouse"), 0, 'stock');
  188. print '<table class="border" width="100%">';
  189. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/liste.php">'.$langs->trans("BackToList").'</a>';
  190. // Ref
  191. print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
  192. print $form->showrefnav($entrepot, 'id', $linkback, 1, 'rowid', 'libelle');
  193. print '</td>';
  194. print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
  195. // Description
  196. print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">'.dol_htmlentitiesbr($entrepot->description).'</td></tr>';
  197. // Address
  198. print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">';
  199. print $entrepot->address;
  200. print '</td></tr>';
  201. // Town
  202. print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$entrepot->zip.'</td>';
  203. print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$entrepot->town.'</td></tr>';
  204. // Country
  205. print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
  206. if (! empty($entrepot->country_code))
  207. {
  208. $img=picto_from_langcode($entrepot->country_code);
  209. print ($img?$img.' ':'');
  210. print $entrepot->country;
  211. }
  212. print '</td></tr>';
  213. // Status
  214. print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->getLibStatut(4).'</td></tr>';
  215. $calcproductsunique=$entrepot->nb_different_products();
  216. $calcproducts=$entrepot->nb_products();
  217. // Total nb of different products
  218. print '<tr><td valign="top">'.$langs->trans("NumberOfDifferentProducts").'</td><td colspan="3">';
  219. print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb'];
  220. print "</td></tr>";
  221. // Nb of products
  222. print '<tr><td valign="top">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
  223. print empty($calcproducts['nb'])?'0':$calcproducts['nb'];
  224. print "</td></tr>";
  225. // Value
  226. print '<tr><td valign="top">'.$langs->trans("EstimatedStockValueShort").'</td><td colspan="3">';
  227. print empty($calcproducts['value'])?'0':$calcproducts['value'];
  228. print "</td></tr>";
  229. // Last movement
  230. $sql = "SELECT MAX(m.datem) as datem";
  231. $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
  232. $sql .= " WHERE m.fk_entrepot = '".$entrepot->id."'";
  233. $resqlbis = $db->query($sql);
  234. if ($resqlbis)
  235. {
  236. $obj = $db->fetch_object($resqlbis);
  237. $lastmovementdate=$db->jdate($obj->datem);
  238. }
  239. else
  240. {
  241. dol_print_error($db);
  242. }
  243. print '<tr><td valign="top">'.$langs->trans("LastMovement").'</td><td colspan="3">';
  244. if ($lastmovementdate)
  245. {
  246. print dol_print_date($lastmovementdate,'dayhour');
  247. }
  248. else
  249. {
  250. print $langs->trans("None");
  251. }
  252. print "</td></tr>";
  253. print "</table>";
  254. print '</div>';
  255. }
  256. /*
  257. * Correct stock
  258. */
  259. if ($action == "correction")
  260. {
  261. print_titre($langs->trans("StockCorrection"));
  262. print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
  263. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  264. print '<input type="hidden" name="action" value="correct_stock">';
  265. print '<table class="border" width="100%">';
  266. // Warehouse
  267. print '<tr>';
  268. print '<td width="20%">'.$langs->trans("Product").'</td>';
  269. print '<td width="20%">';
  270. print $form->select_produits(GETPOST('productid'),'product_id',(empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''));
  271. print '</td>';
  272. print '<td width="20%">';
  273. print '<select name="mouvement" class="flat">';
  274. print '<option value="0">'.$langs->trans("Add").'</option>';
  275. print '<option value="1">'.$langs->trans("Delete").'</option>';
  276. print '</select></td>';
  277. print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input class="flat" name="nbpiece" size="10" value=""></td>';
  278. print '</tr>';
  279. // Label
  280. print '<tr>';
  281. print '<td width="20%">'.$langs->trans("Label").'</td>';
  282. print '<td colspan="4">';
  283. print '<input type="text" name="label" size="40" value="">';
  284. print '</td>';
  285. print '</tr>';
  286. print '</table>';
  287. print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
  288. print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
  289. print '</form>';
  290. }
  291. /*
  292. * Transfer of units
  293. */
  294. /*
  295. if ($action == "transfert")
  296. {
  297. print_titre($langs->trans("Transfer"));
  298. print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
  299. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  300. print '<input type="hidden" name="action" value="transfert_stock">';
  301. print '<table class="border" width="100%">';
  302. print '<tr>';
  303. print '<td width="20%">'.$langs->trans("Product").'</td>';
  304. print '<td width="20%">';
  305. print $form->select_produits(GETPOST('productid'),'product_id');
  306. print '</td>';
  307. print '<td width="20%">'.$langs->trans("WarehouseTarget").'</td><td width="20%">';
  308. print $formproduct->selectWarehouses('','id_entrepot_destination','',1);
  309. print '</td>';
  310. print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value=""></td>';
  311. print '</tr>';
  312. // Label
  313. print '<tr>';
  314. print '<td width="20%">'.$langs->trans("Label").'</td>';
  315. print '<td colspan="5">';
  316. print '<input type="text" name="label" size="40" value="">';
  317. print '</td>';
  318. print '</tr>';
  319. print '</table>';
  320. print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
  321. print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
  322. print '</form>';
  323. }
  324. */
  325. /* ************************************************************************** */
  326. /* */
  327. /* Barre d'action */
  328. /* */
  329. /* ************************************************************************** */
  330. if (empty($action) && $id)
  331. {
  332. print "<div class=\"tabsAction\">\n";
  333. if ($user->rights->stock->creer)
  334. {
  335. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=correction">'.$langs->trans("StockCorrection").'</a>';
  336. }
  337. /*if ($user->rights->stock->mouvement->creer)
  338. {
  339. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=transfert">'.$langs->trans("StockMovement").'</a>';
  340. }*/
  341. print '</div><br>';
  342. }
  343. $param='';
  344. if ($id) $param.='&id='.$id;
  345. if ($search_movement) $param.='&search_movement='.urlencode($search_movement);
  346. if ($search_product_ref) $param.='&search_product_ref='.urlencode($search_product_ref);
  347. if ($search_product) $param.='&search_product='.urlencode($search_product);
  348. if ($search_warehouse) $param.='&search_warehouse='.urlencode($search_warehouse);
  349. if ($sref) $param.='&sref='.urlencode($sref);
  350. if ($snom) $param.='&snom='.urlencode($snom);
  351. if ($search_user) $param.='&search_user='.urlencode($search_user);
  352. if ($idproduct > 0) $param.='&idproduct='.$idproduct;
  353. if ($id) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num,0,'');
  354. else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num);
  355. print '<table class="noborder" width="100%">';
  356. print "<tr class=\"liste_titre\">";
  357. //print_liste_field_titre($langs->trans("Id"),$_SERVER["PHP_SELF"], "m.rowid","",$param,"",$sortfield,$sortorder);
  358. print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"], "m.datem","",$param,"",$sortfield,$sortorder);
  359. print_liste_field_titre($langs->trans("LabelMovement"),$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder);
  360. print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder);
  361. print_liste_field_titre($langs->trans("ProductRef"),$_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder);
  362. print_liste_field_titre($langs->trans("ProductLabel"),$_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder);
  363. print_liste_field_titre($langs->trans("Warehouse"),$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible
  364. print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder);
  365. print_liste_field_titre($langs->trans("Units"),$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder);
  366. print "</tr>\n";
  367. // Lignes des champs de filtre
  368. print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
  369. if ($id) print '<input type="hidden" name="id" value="'.$id.'">';
  370. print '<tr class="liste_titre">';
  371. print '<td class="liste_titre" valign="right">';
  372. print $langs->trans('Month').': <input class="flat" type="text" size="2" maxlength="2" name="month" value="'.$month.'">';
  373. print '&nbsp;'.$langs->trans('Year').': ';
  374. $syear = GETPOST('year')?GETPOST('year'):-1;
  375. $formother->select_year($syear,'year',1, 20, 5);
  376. print '</td>';
  377. // Label of movement
  378. print '<td class="liste_titre" align="left">';
  379. print '<input class="flat" type="text" size="10" name="search_movement" value="'.$search_movement.'">';
  380. print '</td>';
  381. // Origin of movement
  382. print '<td class="liste_titre" align="left">';
  383. print '&nbsp; ';
  384. print '</td>';
  385. // Product Ref
  386. print '<td class="liste_titre" align="left">';
  387. print '<input class="flat" type="text" size="6" name="search_product_ref" value="'.($idproduct?$product->ref:$search_product_ref).'">';
  388. print '</td>';
  389. // Product label
  390. print '<td class="liste_titre" align="left">';
  391. print '<input class="flat" type="text" size="10" name="search_product" value="'.($idproduct?$product->libelle:$search_product).'">';
  392. print '</td>';
  393. print '<td class="liste_titre" align="left">';
  394. if (empty($idproduct) || $idproduct < 0) print '<input class="flat" type="text" size="10" name="search_warehouse" value="'.($search_warehouse).'">'; // We are on a specific warehouse card, no filter on other should be possible
  395. print '</td>';
  396. print '<td class="liste_titre" align="left">';
  397. print '<input class="flat" type="text" size="6" name="search_user" value="'.($search_user).'">';
  398. print '</td>';
  399. print '<td class="liste_titre" align="right">';
  400. print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
  401. print '&nbsp; ';
  402. print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
  403. print '</td>';
  404. print "</tr>\n";
  405. print '</form>';
  406. $arrayofuniqueproduct=array();
  407. $var=True;
  408. while ($i < min($num,$conf->liste_limit))
  409. {
  410. $objp = $db->fetch_object($resql);
  411. $arrayofuniqueproduct[$objp->rowid]=$objp->produit;
  412. if(!empty($objp->fk_origin)) {
  413. $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
  414. } else {
  415. $origin = '';
  416. }
  417. $var=!$var;
  418. print "<tr ".$bc[$var].">";
  419. // Id movement
  420. //print '<td>'.$objp->mid.'</td>'; // This is primary not movement id
  421. // Date
  422. print '<td>'.dol_print_date($db->jdate($objp->datem),'dayhour').'</td>';
  423. // Label of movement
  424. print '<td>'.$objp->label.'</td>';
  425. // Origin of movement
  426. print '<td>'.$origin.'</td>';
  427. // Product ref
  428. print '<td>';
  429. $productstatic->id=$objp->rowid;
  430. $productstatic->ref=$objp->product_ref;
  431. $productstatic->type=$objp->type;
  432. print $productstatic->getNomUrl(1,'',16);
  433. print "</td>\n";
  434. // Product label
  435. print '<td>';
  436. $productstatic->id=$objp->rowid;
  437. $productstatic->ref=$objp->produit;
  438. $productstatic->type=$objp->type;
  439. print $productstatic->getNomUrl(1,'',16);
  440. print "</td>\n";
  441. // Warehouse
  442. print '<td>';
  443. $warehousestatic->id=$objp->entrepot_id;
  444. $warehousestatic->libelle=$objp->stock;
  445. print $warehousestatic->getNomUrl(1);
  446. print "</td>\n";
  447. // Author
  448. print '<td>';
  449. $userstatic->id=$objp->fk_user_author;
  450. $userstatic->lastname=$objp->login;
  451. print $userstatic->getNomUrl(1);
  452. print "</td>\n";
  453. // Value
  454. print '<td align="right">';
  455. if ($objp->value > 0) print '+';
  456. print $objp->value.'</td>';
  457. print "</tr>\n";
  458. $i++;
  459. }
  460. $db->free($resql);
  461. print "</table><br>";
  462. // Add number of product when there is a filter on period
  463. if (count($arrayofuniqueproduct) == 1 && is_numeric($year))
  464. {
  465. $productidselected=0;
  466. foreach ($arrayofuniqueproduct as $key => $val)
  467. {
  468. $productidselected=$key;
  469. $productlabelselected=$val;
  470. }
  471. $datebefore=dol_get_first_day($year?$year:strftime("%Y",time()), $month?$month:1, true);
  472. $dateafter=dol_get_last_day($year?$year:strftime("%Y",time()), $month?$month:12, true);
  473. $balancebefore=$movement->calculateBalanceForProductBefore($productidselected, $datebefore);
  474. $balanceafter=$movement->calculateBalanceForProductBefore($productidselected, $dateafter);
  475. //print '<tr class="total"><td class="liste_total">';
  476. print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore,'day','gmt'));
  477. //print '</td>';
  478. //print '<td class="liste_total" colspan="6" align="right">';
  479. print ': '.$balancebefore;
  480. print "<br>\n";
  481. //print '</td></tr>';
  482. //print '<tr class="total"><td class="liste_total">';
  483. print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter,'day','gmt'));
  484. //print '</td>';
  485. //print '<td class="liste_total" colspan="6" align="right">';
  486. print ': '.$balanceafter;
  487. print "<br>\n";
  488. //print '</td></tr>';
  489. }
  490. }
  491. else
  492. {
  493. dol_print_error($db);
  494. }
  495. llxFooter();
  496. $db->close();