index.php 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  6. * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
  7. * Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
  8. * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/comm/index.php
  25. * \ingroup commercial
  26. * \brief Home page of commercial area
  27. */
  28. require '../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
  39. require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
  40. // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
  41. $hookmanager = new HookManager($db);
  42. $hookmanager->initHooks(array('commercialindex'));
  43. // Load translation files required by the page
  44. $langs->loadLangs(array("boxes", "commercial", "contracts", "orders", "propal", "supplier_proposal"));
  45. $action = GETPOST('action', 'aZ09');
  46. $bid = GETPOST('bid', 'int');
  47. // Securite acces client
  48. $socid = GETPOST('socid', 'int');
  49. if (isset($user->socid) && $user->socid > 0) {
  50. $action = '';
  51. $socid = $user->socid;
  52. }
  53. $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
  54. $now = dol_now();
  55. // Security check
  56. $socid = GETPOST("socid", 'int');
  57. if ($user->socid > 0) {
  58. $action = '';
  59. $id = $user->socid;
  60. } else {
  61. $id = 0;
  62. }
  63. restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
  64. $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
  65. /*
  66. * Actions
  67. */
  68. // None
  69. /*
  70. * View
  71. */
  72. $form = new Form($db);
  73. $formfile = new FormFile($db);
  74. $companystatic = new Societe($db);
  75. if (!empty($conf->propal->enabled)) {
  76. $propalstatic = new Propal($db);
  77. }
  78. if (!empty($conf->supplier_proposal->enabled)) {
  79. $supplierproposalstatic = new SupplierProposal($db);
  80. }
  81. if (!empty($conf->commande->enabled)) {
  82. $orderstatic = new Commande($db);
  83. }
  84. if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
  85. $supplierorderstatic = new CommandeFournisseur($db);
  86. }
  87. llxHeader("", $langs->trans("CommercialArea"));
  88. print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial');
  89. print '<div class="fichecenter"><div class="fichethirdleft">';
  90. $tmp = getCustomerProposalPieChart($socid);
  91. if ($tmp) {
  92. print $tmp;
  93. print '<br>';
  94. }
  95. $tmp = getCustomerOrderPieChart($socid);
  96. if ($tmp) {
  97. print $tmp;
  98. print '<br>';
  99. }
  100. /*
  101. * Draft customer proposals
  102. */
  103. if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
  104. $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
  105. $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
  106. $sql .= ", s.code_client, s.code_compta, s.client";
  107. $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
  108. $sql .= ", s.logo, s.email, s.entity";
  109. $sql .= ", s.canvas";
  110. $sql .= " FROM ".MAIN_DB_PREFIX."propal as p,";
  111. $sql .= " ".MAIN_DB_PREFIX."societe as s";
  112. if (!$user->rights->societe->client->voir && !$socid) {
  113. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  114. }
  115. $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
  116. $sql .= " AND p.fk_soc = s.rowid";
  117. $sql .= " AND p.fk_statut = ".Propal::STATUS_DRAFT;
  118. if (!$user->rights->societe->client->voir && !$socid) {
  119. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  120. }
  121. if ($socid) {
  122. $sql .= " AND s.rowid = ".((int) $socid);
  123. }
  124. $resql = $db->query($sql);
  125. if ($resql) {
  126. $total = 0;
  127. $num = $db->num_rows($resql);
  128. $nbofloop = min($num, $maxofloop);
  129. startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=".Propal::STATUS_DRAFT, 2, $num);
  130. if ($num > 0) {
  131. $i = 0;
  132. $othernb = 0;
  133. while ($i < $nbofloop) {
  134. $obj = $db->fetch_object($resql);
  135. if ($i >= $max) {
  136. $othernb += 1;
  137. $i++;
  138. $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
  139. continue;
  140. }
  141. $propalstatic->id = $obj->rowid;
  142. $propalstatic->ref = $obj->ref;
  143. $propalstatic->ref_client = $obj->ref_client;
  144. $propalstatic->total_ht = $obj->total_ht;
  145. $propalstatic->total_tva = $obj->total_tva;
  146. $propalstatic->total_ttc = $obj->total_ttc;
  147. $propalstatic->statut = $obj->status;
  148. $companystatic->id = $obj->socid;
  149. $companystatic->name = $obj->name;
  150. $companystatic->name_alias = $obj->name_alias;
  151. $companystatic->code_client = $obj->code_client;
  152. $companystatic->code_compta = $obj->code_compta;
  153. $companystatic->client = $obj->client;
  154. $companystatic->code_fournisseur = $obj->code_fournisseur;
  155. $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
  156. $companystatic->fournisseur = $obj->fournisseur;
  157. $companystatic->logo = $obj->logo;
  158. $companystatic->email = $obj->email;
  159. $companystatic->entity = $obj->entity;
  160. $companystatic->canvas = $obj->canvas;
  161. print '<tr class="oddeven">';
  162. print '<td class="nowrap tdoverflowmax100">'.$propalstatic->getNomUrl(1).'</td>';
  163. print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
  164. print '<td class="nowrap right tdamount amount">'.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).'</td>';
  165. print '</tr>';
  166. $i++;
  167. $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
  168. }
  169. if ($othernb) {
  170. print '<tr class="oddeven">';
  171. print '<td class="nowrap" colspan="5">';
  172. print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
  173. print '</td>';
  174. print "</tr>\n";
  175. }
  176. }
  177. addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
  178. finishSimpleTable(true);
  179. $db->free($resql);
  180. } else {
  181. dol_print_error($db);
  182. }
  183. }
  184. /*
  185. * Draft supplier proposals
  186. */
  187. if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) {
  188. $sql = "SELECT p.rowid, p.ref, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
  189. $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
  190. $sql .= ", s.code_client, s.code_compta, s.client";
  191. $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
  192. $sql .= ", s.logo, s.email, s.entity";
  193. $sql .= ", s.canvas";
  194. $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p,";
  195. $sql .= " ".MAIN_DB_PREFIX."societe as s";
  196. if (!$user->rights->societe->client->voir && !$socid) {
  197. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  198. }
  199. $sql .= " WHERE p.entity IN (".getEntity($supplierproposalstatic->element).")";
  200. $sql .= " AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT;
  201. $sql .= " AND p.fk_soc = s.rowid";
  202. if (!$user->rights->societe->client->voir && !$socid) {
  203. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  204. }
  205. if ($socid) {
  206. $sql .= " AND s.rowid = ".((int) $socid);
  207. }
  208. $resql = $db->query($sql);
  209. if ($resql) {
  210. $total = 0;
  211. $num = $db->num_rows($resql);
  212. $nbofloop = min($num, $maxofloop);
  213. startSimpleTable("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=".SupplierProposal::STATUS_DRAFT, 2, $num);
  214. if ($num > 0) {
  215. $i = 0;
  216. $othernb = 0;
  217. while ($i < $nbofloop) {
  218. $obj = $db->fetch_object($resql);
  219. if ($i >= $max) {
  220. $othernb += 1;
  221. $i++;
  222. $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
  223. continue;
  224. }
  225. $supplierproposalstatic->id = $obj->rowid;
  226. $supplierproposalstatic->ref = $obj->ref;
  227. $supplierproposalstatic->total_ht = $obj->total_ht;
  228. $supplierproposalstatic->total_tva = $obj->total_tva;
  229. $supplierproposalstatic->total_ttc = $obj->total_ttc;
  230. $supplierproposalstatic->statut = $obj->status;
  231. $companystatic->id = $obj->socid;
  232. $companystatic->name = $obj->name;
  233. $companystatic->name_alias = $obj->name_alias;
  234. $companystatic->code_client = $obj->code_client;
  235. $companystatic->code_compta = $obj->code_compta;
  236. $companystatic->client = $obj->client;
  237. $companystatic->code_fournisseur = $obj->code_fournisseur;
  238. $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
  239. $companystatic->fournisseur = $obj->fournisseur;
  240. $companystatic->logo = $obj->logo;
  241. $companystatic->email = $obj->email;
  242. $companystatic->entity = $obj->entity;
  243. $companystatic->canvas = $obj->canvas;
  244. print '<tr class="oddeven">';
  245. print '<td class="nowrap tdoverflowmax100">'.$supplierproposalstatic->getNomUrl(1).'</td>';
  246. print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
  247. print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
  248. print '</tr>';
  249. $i++;
  250. $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
  251. }
  252. if ($othernb) {
  253. print '<tr class="oddeven">';
  254. print '<td class="nowrap" colspan="5">';
  255. print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
  256. print '</td>';
  257. print "</tr>\n";
  258. }
  259. }
  260. addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
  261. finishSimpleTable(true);
  262. $db->free($resql);
  263. } else {
  264. dol_print_error($db);
  265. }
  266. }
  267. /*
  268. * Draft customer orders
  269. */
  270. if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
  271. $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, c.fk_statut as status";
  272. $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
  273. $sql .= ", s.code_client, s.code_compta, s.client";
  274. $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
  275. $sql .= ", s.logo, s.email, s.entity";
  276. $sql .= ", s.canvas";
  277. $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
  278. $sql .= " ".MAIN_DB_PREFIX."societe as s";
  279. if (!$user->rights->societe->client->voir && !$socid) {
  280. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  281. }
  282. $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")";
  283. $sql .= " AND c.fk_statut = ".Commande::STATUS_DRAFT;
  284. $sql .= " AND c.fk_soc = s.rowid";
  285. if (!$user->rights->societe->client->voir && !$socid) {
  286. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  287. }
  288. if ($socid) {
  289. $sql .= " AND c.fk_soc = ".((int) $socid);
  290. }
  291. $resql = $db->query($sql);
  292. if ($resql) {
  293. $total = 0;
  294. $num = $db->num_rows($resql);
  295. $nbofloop = min($num, $maxofloop);
  296. startSimpleTable("DraftOrders", "commande/list.php", "search_status=".Commande::STATUS_DRAFT, 2, $num);
  297. if ($num > 0) {
  298. $i = 0;
  299. $othernb = 0;
  300. while ($i < $nbofloop) {
  301. $obj = $db->fetch_object($resql);
  302. if ($i >= $max) {
  303. $othernb += 1;
  304. $i++;
  305. $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
  306. continue;
  307. }
  308. $orderstatic->id = $obj->rowid;
  309. $orderstatic->ref = $obj->ref;
  310. $orderstatic->ref_client = $obj->ref_client;
  311. $orderstatic->total_ht = $obj->total_ht;
  312. $orderstatic->total_tva = $obj->total_tva;
  313. $orderstatic->total_ttc = $obj->total_ttc;
  314. $orderstatic->statut = $obj->status;
  315. $companystatic->id = $obj->socid;
  316. $companystatic->name = $obj->name;
  317. $companystatic->name_alias = $obj->name_alias;
  318. $companystatic->code_client = $obj->code_client;
  319. $companystatic->code_compta = $obj->code_compta;
  320. $companystatic->client = $obj->client;
  321. $companystatic->code_fournisseur = $obj->code_fournisseur;
  322. $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
  323. $companystatic->fournisseur = $obj->fournisseur;
  324. $companystatic->logo = $obj->logo;
  325. $companystatic->email = $obj->email;
  326. $companystatic->entity = $obj->entity;
  327. $companystatic->canvas = $obj->canvas;
  328. print '<tr class="oddeven">';
  329. print '<td class="nowrap tdoverflowmax100">'.$orderstatic->getNomUrl(1).'</td>';
  330. print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
  331. print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
  332. print '</tr>';
  333. $i++;
  334. $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
  335. }
  336. if ($othernb) {
  337. print '<tr class="oddeven">';
  338. print '<td class="nowrap" colspan="5">';
  339. print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
  340. print '</td>';
  341. print "</tr>\n";
  342. }
  343. }
  344. addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
  345. finishSimpleTable(true);
  346. $db->free($resql);
  347. } else {
  348. dol_print_error($db);
  349. }
  350. }
  351. /*
  352. * Draft purchase orders
  353. */
  354. if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) {
  355. $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_statut as status";
  356. $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
  357. $sql .= ", s.code_client, s.code_compta, s.client";
  358. $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
  359. $sql .= ", s.logo, s.email, s.entity";
  360. $sql .= ", s.canvas";
  361. $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,";
  362. $sql .= " ".MAIN_DB_PREFIX."societe as s";
  363. if (!$user->rights->societe->client->voir && !$socid) {
  364. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  365. }
  366. $sql .= " WHERE cf.entity IN (".getEntity($supplierorderstatic->element).")";
  367. $sql .= " AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT;
  368. $sql .= " AND cf.fk_soc = s.rowid";
  369. if (!$user->rights->societe->client->voir && !$socid) {
  370. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  371. }
  372. if ($socid) {
  373. $sql .= " AND cf.fk_soc = ".((int) $socid);
  374. }
  375. $resql = $db->query($sql);
  376. if ($resql) {
  377. $total = 0;
  378. $num = $db->num_rows($resql);
  379. $nbofloop = min($num, $maxofloop);
  380. startSimpleTable("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=".CommandeFournisseur::STATUS_DRAFT, 2, $num);
  381. if ($num > 0) {
  382. $i = 0;
  383. $othernb = 0;
  384. while ($i < $nbofloop) {
  385. $obj = $db->fetch_object($resql);
  386. if ($i >= $max) {
  387. $othernb += 1;
  388. $i++;
  389. $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
  390. continue;
  391. }
  392. $supplierorderstatic->id = $obj->rowid;
  393. $supplierorderstatic->ref = $obj->ref;
  394. $supplierorderstatic->ref_supplier = $obj->ref_supplier;
  395. $supplierorderstatic->total_ht = $obj->total_ht;
  396. $supplierorderstatic->total_tva = $obj->total_tva;
  397. $supplierorderstatic->total_ttc = $obj->total_ttc;
  398. $supplierorderstatic->statut = $obj->status;
  399. $companystatic->id = $obj->socid;
  400. $companystatic->name = $obj->name;
  401. $companystatic->name_alias = $obj->name_alias;
  402. $companystatic->code_client = $obj->code_client;
  403. $companystatic->code_compta = $obj->code_compta;
  404. $companystatic->client = $obj->client;
  405. $companystatic->code_fournisseur = $obj->code_fournisseur;
  406. $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
  407. $companystatic->fournisseur = $obj->fournisseur;
  408. $companystatic->logo = $obj->logo;
  409. $companystatic->email = $obj->email;
  410. $companystatic->entity = $obj->entity;
  411. $companystatic->canvas = $obj->canvas;
  412. print '<tr class="oddeven">';
  413. print '<td class="nowrap tdoverflowmax100">'.$supplierorderstatic->getNomUrl(1).'</td>';
  414. print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
  415. print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
  416. print '</tr>';
  417. $i++;
  418. $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
  419. }
  420. if ($othernb) {
  421. print '<tr class="oddeven">';
  422. print '<td class="nowrap" colspan="5">';
  423. print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
  424. print '</td>';
  425. print "</tr>\n";
  426. }
  427. }
  428. addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
  429. finishSimpleTable(true);
  430. $db->free($resql);
  431. } else {
  432. dol_print_error($db);
  433. }
  434. }
  435. print '</div><div class="fichetwothirdright">';
  436. print '<div class="ficheaddleft">';
  437. /*
  438. * Last modified customers or prospects
  439. */
  440. if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
  441. $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
  442. $sql .= ", s.code_client, s.code_compta, s.client";
  443. $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
  444. $sql .= ", s.logo, s.email, s.entity";
  445. $sql .= ", s.canvas";
  446. $sql .= ", s.datec, s.tms";
  447. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
  448. if (!$user->rights->societe->client->voir && !$socid) {
  449. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  450. }
  451. $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
  452. $sql .= " AND s.client IN (".Societe::CUSTOMER.", ".Societe::PROSPECT.", ".Societe::CUSTOMER_AND_PROSPECT.")";
  453. if (!$user->rights->societe->client->voir && !$socid) {
  454. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  455. }
  456. if ($socid) {
  457. $sql .= " AND s.rowid = $socid";
  458. }
  459. $sql .= " ORDER BY s.tms DESC";
  460. $sql .= $db->plimit($max, 0);
  461. $resql = $db->query($sql);
  462. if ($resql) {
  463. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
  464. $header = "BoxTitleLastCustomersOrProspects";
  465. } elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
  466. $header = "BoxTitleLastModifiedProspects";
  467. } else {
  468. $header = "BoxTitleLastModifiedCustomers";
  469. }
  470. $num = $db->num_rows($resql);
  471. startSimpleTable($langs->trans($header, min($max, $num)), "societe/list.php", "type=p,c", 1);
  472. if ($num) {
  473. $i = 0;
  474. while ($i < $num && $i < $max) {
  475. $objp = $db->fetch_object($resql);
  476. $companystatic->id = $objp->socid;
  477. $companystatic->name = $objp->name;
  478. $companystatic->name_alias = $objp->name_alias;
  479. $companystatic->code_client = $objp->code_client;
  480. $companystatic->code_compta = $objp->code_compta;
  481. $companystatic->client = $objp->client;
  482. $companystatic->code_fournisseur = $objp->code_fournisseur;
  483. $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
  484. $companystatic->fournisseur = $objp->fournisseur;
  485. $companystatic->logo = $objp->logo;
  486. $companystatic->email = $objp->email;
  487. $companystatic->entity = $objp->entity;
  488. $companystatic->canvas = $objp->canvas;
  489. print '<tr class="oddeven">';
  490. print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
  491. print '<td class="nowrap">';
  492. //print $companystatic->getLibCustProspStatut();
  493. $obj = $companystatic;
  494. $s = '';
  495. if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
  496. $s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
  497. }
  498. if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
  499. $s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
  500. }
  501. /*
  502. if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur)
  503. {
  504. $s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
  505. }*/
  506. print $s;
  507. print '</td>';
  508. print '<td class="right nowrap tddate">'.dol_print_date($db->jdate($objp->tms), 'day').'</td>';
  509. print '</tr>';
  510. $i++;
  511. }
  512. }
  513. addSummaryTableLine(3, $num);
  514. finishSimpleTable(true);
  515. $db->free($resql);
  516. } else {
  517. dol_print_error($db);
  518. }
  519. }
  520. /*
  521. * Last suppliers
  522. */
  523. if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) {
  524. $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
  525. $sql .= ", s.code_client, s.code_compta, s.client";
  526. $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
  527. $sql .= ", s.logo, s.email, s.entity";
  528. $sql .= ", s.canvas";
  529. $sql .= ", s.datec as dc, s.tms as dm";
  530. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
  531. if (!$user->rights->societe->client->voir && !$user->socid) {
  532. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  533. }
  534. $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
  535. $sql .= " AND s.fournisseur = ".Societe::SUPPLIER;
  536. if (!$user->rights->societe->client->voir && !$user->socid) {
  537. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  538. }
  539. if ($socid) {
  540. $sql .= " AND s.rowid = ".((int) $socid);
  541. }
  542. $sql .= " ORDER BY s.datec DESC";
  543. $sql .= $db->plimit($max, 0);
  544. $resql = $db->query($sql);
  545. if ($resql) {
  546. $num = $db->num_rows($resql);
  547. startSimpleTable($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f", 1);
  548. if ($num) {
  549. $i = 0;
  550. while ($i < $num && $i < $max) {
  551. $objp = $db->fetch_object($resql);
  552. $companystatic->id = $objp->socid;
  553. $companystatic->name = $objp->name;
  554. $companystatic->name_alias = $objp->name_alias;
  555. $companystatic->code_client = $objp->code_client;
  556. $companystatic->code_compta = $objp->code_compta;
  557. $companystatic->client = $objp->client;
  558. $companystatic->code_fournisseur = $objp->code_fournisseur;
  559. $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
  560. $companystatic->fournisseur = $objp->fournisseur;
  561. $companystatic->logo = $objp->logo;
  562. $companystatic->email = $objp->email;
  563. $companystatic->entity = $objp->entity;
  564. $companystatic->canvas = $objp->canvas;
  565. print '<tr class="oddeven">';
  566. print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
  567. print '<td>';
  568. $obj = $companystatic;
  569. $s = '';
  570. /*if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
  571. $s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
  572. }
  573. if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
  574. {
  575. $s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
  576. }*/
  577. if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) {
  578. $s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
  579. }
  580. print $s;
  581. print '</td>';
  582. print '<td class="right tddate">'.dol_print_date($db->jdate($objp->dm), 'day').'</td>';
  583. print '</tr>';
  584. $i++;
  585. }
  586. }
  587. addSummaryTableLine(3, $num);
  588. finishSimpleTable(true);
  589. $db->free($resql);
  590. } else {
  591. dol_print_error($db);
  592. }
  593. }
  594. /*
  595. * Last actions
  596. */
  597. /*if ($user->rights->agenda->myactions->read) {
  598. show_array_last_actions_done($max);
  599. }*/
  600. /*
  601. * Actions to do
  602. */
  603. /*if ($user->rights->agenda->myactions->read) {
  604. show_array_actions_to_do($max);
  605. }*/
  606. /*
  607. * Latest contracts
  608. */
  609. if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
  610. $staticcontrat = new Contrat($db);
  611. $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
  612. $sql .= ", s.code_client, s.code_compta, s.client";
  613. $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
  614. $sql .= ", s.logo, s.email, s.entity";
  615. $sql .= ", s.canvas";
  616. $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo";
  617. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
  618. $sql .= ", ".MAIN_DB_PREFIX."contrat as c";
  619. $sql .= ", ".MAIN_DB_PREFIX."product as p";
  620. if (!$user->rights->societe->client->voir && !$socid) {
  621. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  622. }
  623. $sql .= " WHERE c.entity IN (".getEntity($staticcontrat->element).")";
  624. $sql .= " AND c.fk_soc = s.rowid";
  625. $sql .= " AND c.fk_product = p.rowid";
  626. if (!$user->rights->societe->client->voir && !$socid) {
  627. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  628. }
  629. if ($socid) {
  630. $sql .= " AND s.rowid = ".((int) $socid);
  631. }
  632. $sql .= " ORDER BY c.tms DESC";
  633. $sql .= $db->plimit($max + 1, 0);
  634. $resql = $db->query($sql);
  635. if ($resql) {
  636. $num = $db->num_rows($resql);
  637. startSimpleTable($langs->trans("LastContracts", $max), "", "", 2);
  638. if ($num > 0) {
  639. $i = 0;
  640. while ($i < $num) {
  641. $obj = $db->fetch_object($resql);
  642. $companystatic->id = $obj->socid;
  643. $companystatic->name = $obj->name;
  644. $companystatic->name_alias = $obj->name_alias;
  645. $companystatic->code_client = $obj->code_client;
  646. $companystatic->code_compta = $obj->code_compta;
  647. $companystatic->client = $obj->client;
  648. $companystatic->code_fournisseur = $obj->code_fournisseur;
  649. $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
  650. $companystatic->fournisseur = $obj->fournisseur;
  651. $companystatic->logo = $obj->logo;
  652. $companystatic->email = $obj->email;
  653. $companystatic->entity = $obj->entity;
  654. $companystatic->canvas = $obj->canvas;
  655. $staticcontrat->id = $obj->contratid;
  656. $staticcontrat->ref = $obj->ref;
  657. print '<tr class="oddeven">';
  658. print '<td>'.$staticcontrat->getNomUrl(1).'</td>';
  659. print '<td>'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
  660. print '<td class="right">'.$staticcontrat->LibStatut($obj->statut, 3).'</td>';
  661. print '</tr>';
  662. $i++;
  663. }
  664. }
  665. addSummaryTableLine(2, $num);
  666. finishSimpleTable(true);
  667. $db->free($resql);
  668. } else {
  669. dol_print_error($db);
  670. }
  671. }
  672. /*
  673. * Opened (validated) proposals
  674. */
  675. if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
  676. $sql = "SELECT p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
  677. $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
  678. $sql .= ", s.code_client, s.code_compta, s.client";
  679. $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
  680. $sql .= ", s.logo, s.email, s.entity";
  681. $sql .= ", s.canvas";
  682. $sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
  683. $sql .= ", ".MAIN_DB_PREFIX."societe as s";
  684. if (!$user->rights->societe->client->voir && !$socid) {
  685. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  686. }
  687. $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
  688. $sql .= " AND p.fk_soc = s.rowid";
  689. $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED;
  690. if (!$user->rights->societe->client->voir && !$socid) {
  691. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  692. }
  693. if ($socid) {
  694. $sql .= " AND s.rowid = ".((int) $socid);
  695. }
  696. $sql .= " ORDER BY p.rowid DESC";
  697. $resql = $db->query($sql);
  698. if ($resql) {
  699. $total = $total_ttc = 0;
  700. $num = $db->num_rows($resql);
  701. $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
  702. startSimpleTable("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num);
  703. if ($num > 0) {
  704. $i = 0;
  705. $othernb = 0;
  706. while ($i < $nbofloop) {
  707. $obj = $db->fetch_object($resql);
  708. if ($i >= $max) {
  709. $othernb += 1;
  710. $i++;
  711. $total += $obj->total_ht;
  712. $total_ttc += $obj->total_ttc;
  713. continue;
  714. }
  715. $propalstatic->id = $obj->propalid;
  716. $propalstatic->ref = $obj->ref;
  717. $propalstatic->ref_client = $obj->ref_client;
  718. $propalstatic->total_ht = $obj->total_ht;
  719. $propalstatic->total_tva = $obj->total_tva;
  720. $propalstatic->total_ttc = $obj->total_ttc;
  721. $companystatic->id = $obj->socid;
  722. $companystatic->name = $obj->name;
  723. $companystatic->name_alias = $obj->name_alias;
  724. $companystatic->code_client = $obj->code_client;
  725. $companystatic->code_compta = $obj->code_compta;
  726. $companystatic->client = $obj->client;
  727. $companystatic->code_fournisseur = $obj->code_fournisseur;
  728. $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
  729. $companystatic->fournisseur = $obj->fournisseur;
  730. $companystatic->logo = $obj->logo;
  731. $companystatic->email = $obj->email;
  732. $companystatic->entity = $obj->entity;
  733. $companystatic->canvas = $obj->canvas;
  734. $filename = dol_sanitizeFileName($obj->ref);
  735. $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
  736. //$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
  737. $warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
  738. print '<tr class="oddeven">';
  739. print '<td class="nowrap" width="140">';
  740. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  741. print '<td class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).'</td>';
  742. print '<td width="18" class="nobordernopadding nowrap">'.$warning.'</td>';
  743. print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'</td>';
  744. print '</tr>';
  745. print '</table>';
  746. print '</td>';
  747. print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
  748. print '<td class="right tddate">'.dol_print_date($db->jdate($obj->dp), 'day').'</td>';
  749. print '<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
  750. print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).'</td>';
  751. print '</tr>';
  752. $i++;
  753. $total += $obj->total_ht;
  754. $total_ttc += $obj->total_ttc;
  755. }
  756. if ($othernb) {
  757. print '<tr class="oddeven">';
  758. print '<td class="nowrap" colspan="5">';
  759. print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
  760. print '</td>';
  761. print "</tr>\n";
  762. }
  763. }
  764. addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total, "NoProposal", true);
  765. finishSimpleTable(true);
  766. $db->free($resql);
  767. } else {
  768. dol_print_error($db);
  769. }
  770. }
  771. /*
  772. * Opened (validated) order
  773. */
  774. if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
  775. $sql = "SELECT c.rowid as commandeid, c.total_ttc, c.total_ht, c.total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed";
  776. $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
  777. $sql .= ", s.code_client, s.code_compta, s.client";
  778. $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
  779. $sql .= ", s.logo, s.email, s.entity";
  780. $sql .= ", s.canvas";
  781. $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
  782. $sql .= ", ".MAIN_DB_PREFIX."societe as s";
  783. if (!$user->rights->societe->client->voir && !$socid) {
  784. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  785. }
  786. $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")";
  787. $sql .= " AND c.fk_soc = s.rowid";
  788. $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")";
  789. if (!$user->rights->societe->client->voir && !$socid) {
  790. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  791. }
  792. if ($socid) {
  793. $sql .= " AND s.rowid = ".((int) $socid);
  794. }
  795. $sql .= " ORDER BY c.rowid DESC";
  796. $resql = $db->query($sql);
  797. if ($resql) {
  798. $total = $total_ttc = 0;
  799. $num = $db->num_rows($resql);
  800. $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
  801. startSimpleTable("OrdersOpened", "commande/list.php", "search_status=".Commande::STATUS_VALIDATED, 4, $num);
  802. if ($num > 0) {
  803. $i = 0;
  804. $othernb = 0;
  805. while ($i < $nbofloop) {
  806. $obj = $db->fetch_object($resql);
  807. if ($i >= $max) {
  808. $othernb += 1;
  809. $i++;
  810. $total += $obj->total_ht;
  811. $total_ttc += $obj->total_ttc;
  812. continue;
  813. }
  814. $orderstatic->id = $obj->commandeid;
  815. $orderstatic->ref = $obj->ref;
  816. $orderstatic->ref_client = $obj->ref_client;
  817. $orderstatic->statut = $obj->fk_statut;
  818. $orderstatic->total_ht = $obj->total_ht;
  819. $orderstatic->total_tva = $obj->total_tva;
  820. $orderstatic->total_ttc = $obj->total_ttc;
  821. $companystatic->id = $obj->socid;
  822. $companystatic->name = $obj->name;
  823. $companystatic->name_alias = $obj->name_alias;
  824. $companystatic->code_client = $obj->code_client;
  825. $companystatic->code_compta = $obj->code_compta;
  826. $companystatic->client = $obj->client;
  827. $companystatic->code_fournisseur = $obj->code_fournisseur;
  828. $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
  829. $companystatic->fournisseur = $obj->fournisseur;
  830. $companystatic->logo = $obj->logo;
  831. $companystatic->email = $obj->email;
  832. $companystatic->entity = $obj->entity;
  833. $companystatic->canvas = $obj->canvas;
  834. $filename = dol_sanitizeFileName($obj->ref);
  835. $filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
  836. //$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
  837. //$warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
  838. print '<tr class="oddeven">';
  839. print '<td class="nowrap" width="140">';
  840. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  841. print '<td class="nobordernopadding nowrap">'.$orderstatic->getNomUrl(1).'</td>';
  842. print '<td width="18" class="nobordernopadding nowrap"></td>';
  843. print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($orderstatic->element, $filename, $filedir).'</td>';
  844. print '</tr>';
  845. print '</table>';
  846. print '</td>';
  847. print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
  848. print '<td class="right tddate">'.dol_print_date($db->jdate($obj->dv), 'day').'</td>';
  849. print '<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
  850. print '<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).'</td>';
  851. print '</tr>';
  852. $i++;
  853. $total += $obj->total_ht;
  854. $total_ttc += $obj->total_ttc;
  855. }
  856. if ($othernb) {
  857. print '<tr class="oddeven">';
  858. print '<td class="nowrap" colspan="5">';
  859. print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
  860. print '</td>';
  861. print "</tr>\n";
  862. }
  863. }
  864. addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total, "None", true);
  865. finishSimpleTable(true);
  866. $db->free($resql);
  867. } else {
  868. dol_print_error($db);
  869. }
  870. }
  871. print '</div>';
  872. print '</div>';
  873. print '</div>';
  874. $parameters = array('user' => $user);
  875. $reshook = $hookmanager->executeHooks('dashboardCommercials', $parameters, $object); // Note that $action and $object may have been modified by hook
  876. // End of page
  877. llxFooter();
  878. $db->close();