index.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <?php
  2. /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2014-2016 Charlie BENKE <charlie@patas-monkey.com>
  6. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  7. * Copyright (C) 2019 Pierre Ardoin <mapiolca@me.com>
  8. * Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.fr>
  9. * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/product/index.php
  26. * \ingroup product
  27. * \brief Homepage products and services
  28. */
  29. require '../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
  33. $type = GETPOST("type", 'int');
  34. if ($type == '' && empty($user->rights->produit->lire)) {
  35. $type = '1'; // Force global page on service page only
  36. }
  37. if ($type == '' && empty($user->rights->service->lire)) {
  38. $type = '0'; // Force global page on product page only
  39. }
  40. // Load translation files required by the page
  41. $langs->loadLangs(array('products', 'stocks'));
  42. // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
  43. $hookmanager->initHooks(array('productindex'));
  44. $product_static = new Product($db);
  45. // Security check
  46. if ($type == '0') {
  47. $result = restrictedArea($user, 'produit');
  48. } elseif ($type == '1') {
  49. $result = restrictedArea($user, 'service');
  50. } else {
  51. $result = restrictedArea($user, 'produit|service|expedition');
  52. }
  53. /*
  54. * View
  55. */
  56. $transAreaType = $langs->trans("ProductsAndServicesArea");
  57. $helpurl = '';
  58. if (!isset($_GET["type"])) {
  59. $transAreaType = $langs->trans("ProductsAndServicesArea");
  60. $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
  61. }
  62. if ((isset($_GET["type"]) && $_GET["type"] == 0) || empty($conf->service->enabled)) {
  63. $transAreaType = $langs->trans("ProductsArea");
  64. $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
  65. }
  66. if ((isset($_GET["type"]) && $_GET["type"] == 1) || empty($conf->product->enabled)) {
  67. $transAreaType = $langs->trans("ServicesArea");
  68. $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
  69. }
  70. llxHeader("", $langs->trans("ProductsAndServices"), $helpurl);
  71. $linkback = "";
  72. print load_fiche_titre($transAreaType, $linkback, 'product');
  73. print '<div class="fichecenter"><div class="fichethirdleft">';
  74. if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This may be useless due to the global search combo
  75. // Search contract
  76. if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) {
  77. $listofsearchfields['search_product'] = array('text'=>'ProductOrService');
  78. }
  79. if (count($listofsearchfields)) {
  80. print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
  81. print '<input type="hidden" name="token" value="'.newToken().'">';
  82. print '<div class="div-table-responsive-no-min">';
  83. print '<table class="noborder nohover centpercent">';
  84. $i = 0;
  85. foreach ($listofsearchfields as $key => $value) {
  86. if ($i == 0) {
  87. print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
  88. }
  89. print '<tr class="oddeven">';
  90. print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td>';
  91. print '<td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
  92. if ($i == 0) {
  93. print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
  94. }
  95. print '</tr>';
  96. $i++;
  97. }
  98. print '</table>';
  99. print '</div>';
  100. print '</form>';
  101. print '<br>';
  102. }
  103. }
  104. /*
  105. * Number of products and/or services
  106. */
  107. if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) {
  108. $prodser = array();
  109. $prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0;
  110. $prodser[0]['sell'] = 0;
  111. $prodser[0]['buy'] = 0;
  112. $prodser[0]['none'] = 0;
  113. $prodser[1][0] = $prodser[1][1] = $prodser[1][2] = $prodser[1][3] = 0;
  114. $prodser[1]['sell'] = 0;
  115. $prodser[1]['buy'] = 0;
  116. $prodser[1]['none'] = 0;
  117. $sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy";
  118. $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
  119. $sql .= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')';
  120. // Add where from hooks
  121. $parameters = array();
  122. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $product_static); // Note that $action and $object may have been modified by hook
  123. $sql .= $hookmanager->resPrint;
  124. $sql .= " GROUP BY p.fk_product_type, p.tosell, p.tobuy";
  125. $result = $db->query($sql);
  126. while ($objp = $db->fetch_object($result)) {
  127. $status = 3; // On sale + On purchase
  128. if (!$objp->tosell && !$objp->tobuy) {
  129. $status = 0; // Not on sale, not on purchase
  130. }
  131. if ($objp->tosell && !$objp->tobuy) {
  132. $status = 1; // On sale only
  133. }
  134. if (!$objp->tosell && $objp->tobuy) {
  135. $status = 2; // On purchase only
  136. }
  137. $prodser[$objp->fk_product_type][$status] = $objp->total;
  138. if ($objp->tosell) {
  139. $prodser[$objp->fk_product_type]['sell'] += $objp->total;
  140. }
  141. if ($objp->tobuy) {
  142. $prodser[$objp->fk_product_type]['buy'] += $objp->total;
  143. }
  144. if (!$objp->tosell && !$objp->tobuy) {
  145. $prodser[$objp->fk_product_type]['none'] += $objp->total;
  146. }
  147. }
  148. if ($conf->use_javascript_ajax) {
  149. print '<div class="div-table-responsive-no-min">';
  150. print '<table class="noborder centpercent">';
  151. print '<tr class="liste_titre"><th>'.$langs->trans("Statistics").'</th></tr>';
  152. print '<tr><td class="center nopaddingleftimp nopaddingrightimp">';
  153. $SommeA = $prodser[0]['sell'];
  154. $SommeB = $prodser[0]['buy'];
  155. $SommeC = $prodser[0]['none'];
  156. $SommeD = $prodser[1]['sell'];
  157. $SommeE = $prodser[1]['buy'];
  158. $SommeF = $prodser[1]['none'];
  159. $total = 0;
  160. $dataval = array();
  161. $datalabels = array();
  162. $i = 0;
  163. $total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF;
  164. $dataseries = array();
  165. if (!empty($conf->product->enabled)) {
  166. $dataseries[] = array($langs->transnoentitiesnoconv("ProductsOnSale"), round($SommeA));
  167. $dataseries[] = array($langs->transnoentitiesnoconv("ProductsOnPurchase"), round($SommeB));
  168. $dataseries[] = array($langs->transnoentitiesnoconv("ProductsNotOnSell"), round($SommeC));
  169. }
  170. if (!empty($conf->service->enabled)) {
  171. $dataseries[] = array($langs->transnoentitiesnoconv("ServicesOnSale"), round($SommeD));
  172. $dataseries[] = array($langs->transnoentitiesnoconv("ServicesOnPurchase"), round($SommeE));
  173. $dataseries[] = array($langs->transnoentitiesnoconv("ServicesNotOnSell"), round($SommeF));
  174. }
  175. include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
  176. $dolgraph = new DolGraph();
  177. $dolgraph->SetData($dataseries);
  178. $dolgraph->setShowLegend(2);
  179. $dolgraph->setShowPercent(0);
  180. $dolgraph->SetType(array('pie'));
  181. $dolgraph->setHeight('200');
  182. $dolgraph->draw('idgraphstatus');
  183. print $dolgraph->show($total ? 0 : 1);
  184. print '</td></tr>';
  185. print '</table>';
  186. print '</div>';
  187. }
  188. }
  189. if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_PRODUCTS)) {
  190. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  191. print '<br>';
  192. print '<div class="div-table-responsive-no-min">';
  193. print '<table class="noborder centpercent">';
  194. print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
  195. print '<tr><td class="center" colspan="2">';
  196. $sql = "SELECT c.label, count(*) as nb";
  197. $sql .= " FROM ".MAIN_DB_PREFIX."categorie_product as cs";
  198. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
  199. $sql .= " WHERE c.type = 0";
  200. $sql .= " AND c.entity IN (".getEntity('category').")";
  201. $sql .= " GROUP BY c.label";
  202. $sql .= " ORDER BY nb desc";
  203. $total = 0;
  204. $result = $db->query($sql);
  205. if ($result) {
  206. $num = $db->num_rows($result);
  207. $i = 0;
  208. if (!empty($conf->use_javascript_ajax)) {
  209. $dataseries = array();
  210. $rest = 0;
  211. $nbmax = 10;
  212. while ($i < $num) {
  213. $obj = $db->fetch_object($result);
  214. if ($i < $nbmax) {
  215. $dataseries[] = array($obj->label, round($obj->nb));
  216. } else {
  217. $rest += $obj->nb;
  218. }
  219. $total += $obj->nb;
  220. $i++;
  221. }
  222. if ($i > $nbmax) {
  223. $dataseries[] = array($langs->trans("Other"), round($rest));
  224. }
  225. include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
  226. $dolgraph = new DolGraph();
  227. $dolgraph->SetData($dataseries);
  228. $dolgraph->setShowLegend(2);
  229. $dolgraph->setShowPercent(1);
  230. $dolgraph->SetType(array('pie'));
  231. $dolgraph->setHeight('200');
  232. $dolgraph->draw('idstatscategproduct');
  233. print $dolgraph->show($total ? 0 : 1);
  234. } else {
  235. while ($i < $num) {
  236. $obj = $db->fetch_object($result);
  237. print '<tr><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
  238. $total += $obj->nb;
  239. $i++;
  240. }
  241. }
  242. }
  243. print '</td></tr>';
  244. print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
  245. print $total;
  246. print '</td></tr>';
  247. print '</table>';
  248. print '</div>';
  249. }
  250. print '</div><div class="fichetwothirdright">';
  251. /*
  252. * Latest modified products
  253. */
  254. if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) {
  255. $max = 15;
  256. $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,";
  257. $sql .= " p.entity,";
  258. $sql .= " p.tms as datem";
  259. $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
  260. $sql .= " WHERE p.entity IN (".getEntity($product_static->element, 1).")";
  261. if ($type != '') {
  262. $sql .= " AND p.fk_product_type = ".((int) $type);
  263. }
  264. // Add where from hooks
  265. $parameters = array();
  266. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $product_static); // Note that $action and $object may have been modified by hook
  267. $sql .= $hookmanager->resPrint;
  268. $sql .= $db->order("p.tms", "DESC");
  269. $sql .= $db->plimit($max, 0);
  270. //print $sql;
  271. $result = $db->query($sql);
  272. if ($result) {
  273. $num = $db->num_rows($result);
  274. $i = 0;
  275. if ($num > 0) {
  276. $transRecordedType = $langs->trans("LastModifiedProductsAndServices", $max);
  277. if (isset($_GET["type"]) && $_GET["type"] == 0) {
  278. $transRecordedType = $langs->trans("LastRecordedProducts", $max);
  279. }
  280. if (isset($_GET["type"]) && $_GET["type"] == 1) {
  281. $transRecordedType = $langs->trans("LastRecordedServices", $max);
  282. }
  283. print '<div class="div-table-responsive-no-min">';
  284. print '<table class="noborder centpercent">';
  285. $colnb = 2;
  286. if (empty($conf->global->PRODUIT_MULTIPRICES)) {
  287. $colnb++;
  288. }
  289. print '<tr class="liste_titre"><th colspan="'.$colnb.'">'.$transRecordedType.'</th>';
  290. print '<th class="right" colspan="3"><a href="'.DOL_URL_ROOT.'/product/list.php?sortfield=p.tms&sortorder=DESC">'.$langs->trans("FullList").'</td>';
  291. print '</tr>';
  292. while ($i < $num) {
  293. $objp = $db->fetch_object($result);
  294. $product_static->id = $objp->rowid;
  295. $product_static->ref = $objp->ref;
  296. $product_static->label = $objp->label;
  297. $product_static->type = $objp->fk_product_type;
  298. $product_static->entity = $objp->entity;
  299. $product_static->status = $objp->tosell;
  300. $product_static->status_buy = $objp->tobuy;
  301. $product_static->status_batch = $objp->tobatch;
  302. // Multilangs
  303. if (!empty($conf->global->MAIN_MULTILANGS)) {
  304. $sql = "SELECT label";
  305. $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
  306. $sql .= " WHERE fk_product = ".((int) $objp->rowid);
  307. $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'";
  308. $resultd = $db->query($sql);
  309. if ($resultd) {
  310. $objtp = $db->fetch_object($resultd);
  311. if ($objtp && $objtp->label != '') {
  312. $objp->label = $objtp->label;
  313. }
  314. }
  315. }
  316. print '<tr class="oddeven">';
  317. print '<td class="nowraponall tdoverflowmax100">';
  318. print $product_static->getNomUrl(1, '', 16);
  319. print "</td>\n";
  320. print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->label).'">'.dol_escape_htmltag($objp->label).'</td>';
  321. print '<td title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($db->jdate($objp->datem), 'dayhour', 'tzuserrel')).'">';
  322. print dol_print_date($db->jdate($objp->datem), 'day', 'tzuserrel');
  323. print "</td>";
  324. // Sell price
  325. if (empty($conf->global->PRODUIT_MULTIPRICES)) {
  326. if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) {
  327. $product = new Product($db);
  328. $product->fetch($objp->rowid);
  329. $priceparser = new PriceParser($db);
  330. $price_result = $priceparser->parseProduct($product);
  331. if ($price_result >= 0) {
  332. $objp->price = $price_result;
  333. }
  334. }
  335. print '<td class="nowraponall amount right">';
  336. if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') {
  337. print price($objp->price_ttc).' '.$langs->trans("TTC");
  338. } else {
  339. print price($objp->price).' '.$langs->trans("HT");
  340. }
  341. print '</td>';
  342. }
  343. print '<td class="right nowrap width25"><span class="statusrefsell">';
  344. print $product_static->LibStatut($objp->tosell, 3, 0);
  345. print "</span></td>";
  346. print '<td class="right nowrap width25"><span class="statusrefbuy">';
  347. print $product_static->LibStatut($objp->tobuy, 3, 1);
  348. print "</span></td>";
  349. print "</tr>\n";
  350. $i++;
  351. }
  352. $db->free($result);
  353. print "</table>";
  354. print '</div>';
  355. print '<br>';
  356. }
  357. } else {
  358. dol_print_error($db);
  359. }
  360. }
  361. // TODO Move this into a page that should be available into menu "accountancy - report - turnover - per quarter"
  362. // Also method used for counting must provide the 2 possible methods like done by all other reports into menu "accountancy - report - turnover":
  363. // "commitment engagment" method and "cash accounting" method
  364. if (!empty($conf->global->MAIN_SHOW_PRODUCT_ACTIVITY_TRIM)) {
  365. if (!empty($conf->product->enabled)) {
  366. activitytrim(0);
  367. }
  368. if (!empty($conf->service->enabled)) {
  369. activitytrim(1);
  370. }
  371. }
  372. print '</div></div>';
  373. $parameters = array('type' => $type, 'user' => $user);
  374. $reshook = $hookmanager->executeHooks('dashboardProductsServices', $parameters, $product_static); // Note that $action and $object may have been modified by hook
  375. // End of page
  376. llxFooter();
  377. $db->close();
  378. /**
  379. * Print html activity for product type
  380. *
  381. * @param int $product_type Type of product
  382. * @return void
  383. */
  384. function activitytrim($product_type)
  385. {
  386. global $conf, $langs, $db;
  387. // We display the last 3 years
  388. $yearofbegindate = date('Y', dol_time_plus_duree(time(), -3, "y"));
  389. // breakdown by quarter
  390. $sql = "SELECT DATE_FORMAT(p.datep,'%Y') as annee, DATE_FORMAT(p.datep,'%m') as mois, SUM(fd.total_ht) as Mnttot";
  391. $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd";
  392. $sql .= " , ".MAIN_DB_PREFIX."paiement as p,".MAIN_DB_PREFIX."paiement_facture as pf";
  393. $sql .= " WHERE f.entity IN (".getEntity('invoice').")";
  394. $sql .= " AND f.rowid = fd.fk_facture";
  395. $sql .= " AND pf.fk_facture = f.rowid";
  396. $sql .= " AND pf.fk_paiement = p.rowid";
  397. $sql .= " AND fd.product_type = ".((int) $product_type);
  398. $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($yearofbegindate), 1)."'";
  399. $sql .= " GROUP BY annee, mois ";
  400. $sql .= " ORDER BY annee, mois ";
  401. $result = $db->query($sql);
  402. if ($result) {
  403. $tmpyear = 0;
  404. $trim1 = 0;
  405. $trim2 = 0;
  406. $trim3 = 0;
  407. $trim4 = 0;
  408. $lgn = 0;
  409. $num = $db->num_rows($result);
  410. if ($num > 0) {
  411. print '<div class="div-table-responsive-no-min">';
  412. print '<table class="noborder" width="75%">';
  413. if ($product_type == 0) {
  414. print '<tr class="liste_titre"><td class=left>'.$langs->trans("ProductSellByQuarterHT").'</td>';
  415. } else {
  416. print '<tr class="liste_titre"><td class=left>'.$langs->trans("ServiceSellByQuarterHT").'</td>';
  417. }
  418. print '<td class=right>'.$langs->trans("Quarter1").'</td>';
  419. print '<td class=right>'.$langs->trans("Quarter2").'</td>';
  420. print '<td class=right>'.$langs->trans("Quarter3").'</td>';
  421. print '<td class=right>'.$langs->trans("Quarter4").'</td>';
  422. print '<td class=right>'.$langs->trans("Total").'</td>';
  423. print '</tr>';
  424. }
  425. $i = 0;
  426. while ($i < $num) {
  427. $objp = $db->fetch_object($result);
  428. if ($tmpyear != $objp->annee) {
  429. if ($trim1 + $trim2 + $trim3 + $trim4 > 0) {
  430. print '<tr class="oddeven"><td class=left>'.$tmpyear.'</td>';
  431. print '<td class="nowrap right">'.price($trim1).'</td>';
  432. print '<td class="nowrap right">'.price($trim2).'</td>';
  433. print '<td class="nowrap right">'.price($trim3).'</td>';
  434. print '<td class="nowrap right">'.price($trim4).'</td>';
  435. print '<td class="nowrap right">'.price($trim1 + $trim2 + $trim3 + $trim4).'</td>';
  436. print '</tr>';
  437. $lgn++;
  438. }
  439. // We go to the following year
  440. $tmpyear = $objp->annee;
  441. $trim1 = 0;
  442. $trim2 = 0;
  443. $trim3 = 0;
  444. $trim4 = 0;
  445. }
  446. if ($objp->mois == "01" || $objp->mois == "02" || $objp->mois == "03") {
  447. $trim1 += $objp->Mnttot;
  448. }
  449. if ($objp->mois == "04" || $objp->mois == "05" || $objp->mois == "06") {
  450. $trim2 += $objp->Mnttot;
  451. }
  452. if ($objp->mois == "07" || $objp->mois == "08" || $objp->mois == "09") {
  453. $trim3 += $objp->Mnttot;
  454. }
  455. if ($objp->mois == "10" || $objp->mois == "11" || $objp->mois == "12") {
  456. $trim4 += $objp->Mnttot;
  457. }
  458. $i++;
  459. }
  460. if ($trim1 + $trim2 + $trim3 + $trim4 > 0) {
  461. print '<tr class="oddeven"><td class=left>'.$tmpyear.'</td>';
  462. print '<td class="nowrap right">'.price($trim1).'</td>';
  463. print '<td class="nowrap right">'.price($trim2).'</td>';
  464. print '<td class="nowrap right">'.price($trim3).'</td>';
  465. print '<td class="nowrap right">'.price($trim4).'</td>';
  466. print '<td class="nowrap right">'.price($trim1 + $trim2 + $trim3 + $trim4).'</td>';
  467. print '</tr>';
  468. }
  469. if ($num > 0) {
  470. print '</table></div>';
  471. }
  472. }
  473. }