index.php 41 KB

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