31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/propal.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
43if (isModEnabled(
'ficheinter')) {
44 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
49$hookmanager->initHooks(array(
'commercialindex'));
52$langs->loadLangs(array(
"boxes",
"commercial",
"contracts",
"orders",
"propal",
"supplier_proposal"));
54$action =
GETPOST(
'action',
'aZ09');
58$socid =
GETPOST(
'socid',
'int');
59if (isset($user->socid) && $user->socid > 0) {
61 $socid = $user->socid;
65$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
66$maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
70if (!$user->hasRight(
'propal',
'read') && !$user->hasRight(
'supplier_proposal',
'read') && !$user->hasRight(
'commande',
'read') && !$user->hasRight(
'fournisseur',
'commande',
'read')
71 && !$user->hasRight(
'supplier_order',
'read') && !$user->hasRight(
'fichinter',
'read')) {
90$companystatic =
new Societe($db);
91if (isModEnabled(
"propal")) {
92 $propalstatic =
new Propal($db);
94if (isModEnabled(
'supplier_proposal')) {
97if (isModEnabled(
'commande')) {
100if (isModEnabled(
"supplier_order")) {
104if (isModEnabled(
'ficheinter')) {
108llxHeader(
"", $langs->trans(
"CommercialArea"));
112print
'<div class="fichecenter"><div class="fichethirdleft">';
129if (isModEnabled(
"propal") && $user->hasRight(
"propal",
"lire")) {
130 $sql =
"SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
131 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
132 $sql .=
", s.code_client, s.code_compta, s.client";
133 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
134 $sql .=
", s.logo, s.email, s.entity";
135 $sql .=
", s.canvas";
136 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p,";
137 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
138 if (empty($user->rights->societe->client->voir) && !$socid) {
139 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
141 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
142 $sql .=
" AND p.fk_soc = s.rowid";
143 $sql .=
" AND p.fk_statut = ".Propal::STATUS_DRAFT;
144 if (empty($user->rights->societe->client->voir) && !$socid) {
145 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
148 $sql .=
" AND s.rowid = ".((int) $socid);
151 $resql = $db->query($sql);
154 $num = $db->num_rows($resql);
155 $nbofloop = min($num, $maxofloop);
162 while ($i < $nbofloop) {
163 $obj = $db->fetch_object($resql);
168 $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
172 $propalstatic->id = $obj->rowid;
173 $propalstatic->ref = $obj->ref;
174 $propalstatic->ref_client = $obj->ref_client;
175 $propalstatic->total_ht = $obj->total_ht;
176 $propalstatic->total_tva = $obj->total_tva;
177 $propalstatic->total_ttc = $obj->total_ttc;
178 $propalstatic->statut = $obj->status;
180 $companystatic->id = $obj->socid;
181 $companystatic->name = $obj->name;
182 $companystatic->name_alias = $obj->name_alias;
183 $companystatic->code_client = $obj->code_client;
184 $companystatic->code_compta = $obj->code_compta;
185 $companystatic->client = $obj->client;
186 $companystatic->code_fournisseur = $obj->code_fournisseur;
187 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
188 $companystatic->fournisseur = $obj->fournisseur;
189 $companystatic->logo = $obj->logo;
190 $companystatic->email = $obj->email;
191 $companystatic->entity = $obj->entity;
192 $companystatic->canvas = $obj->canvas;
194 print
'<tr class="oddeven">';
195 print
'<td class="nowraponall tdoverflowmax100">'.$propalstatic->getNomUrl(1).
'</td>';
196 print
'<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
197 print
'<td class="nowrap right tdamount amount">'.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).
'</td>';
201 $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
205 print
'<tr class="oddeven">';
206 print
'<td class="nowrap" colspan="5">';
207 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
227if (isModEnabled(
'supplier_proposal') && $user->hasRight(
"supplier_proposal",
"lire")) {
228 $sql =
"SELECT p.rowid, p.ref, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
229 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
230 $sql .=
", s.code_client, s.code_compta, s.client";
231 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
232 $sql .=
", s.logo, s.email, s.entity";
233 $sql .=
", s.canvas";
234 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p,";
235 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
236 if (empty($user->rights->societe->client->voir) && !$socid) {
237 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
239 $sql .=
" WHERE p.entity IN (".getEntity($supplierproposalstatic->element).
")";
240 $sql .=
" AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT;
241 $sql .=
" AND p.fk_soc = s.rowid";
242 if (empty($user->rights->societe->client->voir) && !$socid) {
243 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
246 $sql .=
" AND s.rowid = ".((int) $socid);
249 $resql = $db->query($sql);
252 $num = $db->num_rows($resql);
253 $nbofloop = min($num, $maxofloop);
260 while ($i < $nbofloop) {
261 $obj = $db->fetch_object($resql);
266 $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
270 $supplierproposalstatic->id = $obj->rowid;
271 $supplierproposalstatic->ref = $obj->ref;
272 $supplierproposalstatic->total_ht = $obj->total_ht;
273 $supplierproposalstatic->total_tva = $obj->total_tva;
274 $supplierproposalstatic->total_ttc = $obj->total_ttc;
275 $supplierproposalstatic->statut = $obj->status;
277 $companystatic->id = $obj->socid;
278 $companystatic->name = $obj->name;
279 $companystatic->name_alias = $obj->name_alias;
280 $companystatic->code_client = $obj->code_client;
281 $companystatic->code_compta = $obj->code_compta;
282 $companystatic->client = $obj->client;
283 $companystatic->code_fournisseur = $obj->code_fournisseur;
284 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
285 $companystatic->fournisseur = $obj->fournisseur;
286 $companystatic->logo = $obj->logo;
287 $companystatic->email = $obj->email;
288 $companystatic->entity = $obj->entity;
289 $companystatic->canvas = $obj->canvas;
291 print
'<tr class="oddeven">';
292 print
'<td class="nowraponall tdoverflowmax100">'.$supplierproposalstatic->getNomUrl(1).
'</td>';
293 print
'<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
294 print
'<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).
'</td>';
298 $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
302 print
'<tr class="oddeven">';
303 print
'<td class="nowrap" colspan="5">';
304 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
324if (isModEnabled(
'commande') && $user->hasRight(
'commande',
'lire')) {
325 $sql =
"SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, c.fk_statut as status";
326 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
327 $sql .=
", s.code_client, s.code_compta, s.client";
328 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
329 $sql .=
", s.logo, s.email, s.entity";
330 $sql .=
", s.canvas";
331 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c,";
332 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
333 if (empty($user->rights->societe->client->voir) && !$socid) {
334 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
336 $sql .=
" WHERE c.entity IN (".getEntity($orderstatic->element).
")";
337 $sql .=
" AND c.fk_statut = ".Commande::STATUS_DRAFT;
338 $sql .=
" AND c.fk_soc = s.rowid";
339 if (empty($user->rights->societe->client->voir) && !$socid) {
340 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
343 $sql .=
" AND c.fk_soc = ".((int) $socid);
346 $resql = $db->query($sql);
349 $num = $db->num_rows($resql);
350 $nbofloop = min($num, $maxofloop);
357 while ($i < $nbofloop) {
358 $obj = $db->fetch_object($resql);
363 $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
367 $orderstatic->id = $obj->rowid;
368 $orderstatic->ref = $obj->ref;
369 $orderstatic->ref_client = $obj->ref_client;
370 $orderstatic->total_ht = $obj->total_ht;
371 $orderstatic->total_tva = $obj->total_tva;
372 $orderstatic->total_ttc = $obj->total_ttc;
373 $orderstatic->statut = $obj->status;
375 $companystatic->id = $obj->socid;
376 $companystatic->name = $obj->name;
377 $companystatic->name_alias = $obj->name_alias;
378 $companystatic->code_client = $obj->code_client;
379 $companystatic->code_compta = $obj->code_compta;
380 $companystatic->client = $obj->client;
381 $companystatic->code_fournisseur = $obj->code_fournisseur;
382 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
383 $companystatic->fournisseur = $obj->fournisseur;
384 $companystatic->logo = $obj->logo;
385 $companystatic->email = $obj->email;
386 $companystatic->entity = $obj->entity;
387 $companystatic->canvas = $obj->canvas;
389 print
'<tr class="oddeven">';
390 print
'<td class="nowraponall tdoverflowmax100">'.$orderstatic->getNomUrl(1).
'</td>';
391 print
'<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
392 print
'<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).
'</td>';
396 $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
400 print
'<tr class="oddeven">';
401 print
'<td class="nowrap" colspan="5">';
402 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
422if ((isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight(
"fournisseur",
"commande",
"lire")) || (isModEnabled(
"supplier_order") && $user->hasRight(
"supplier_order",
"lire"))) {
423 $sql =
"SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_statut as status";
424 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
425 $sql .=
", s.code_client, s.code_compta, s.client";
426 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
427 $sql .=
", s.logo, s.email, s.entity";
428 $sql .=
", s.canvas";
429 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf,";
430 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
431 if (empty($user->rights->societe->client->voir) && !$socid) {
432 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
434 $sql .=
" WHERE cf.entity IN (".getEntity($supplierorderstatic->element).
")";
435 $sql .=
" AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT;
436 $sql .=
" AND cf.fk_soc = s.rowid";
437 if (empty($user->rights->societe->client->voir) && !$socid) {
438 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
441 $sql .=
" AND cf.fk_soc = ".((int) $socid);
444 $resql = $db->query($sql);
447 $num = $db->num_rows($resql);
448 $nbofloop = min($num, $maxofloop);
455 while ($i < $nbofloop) {
456 $obj = $db->fetch_object($resql);
461 $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
465 $supplierorderstatic->id = $obj->rowid;
466 $supplierorderstatic->ref = $obj->ref;
467 $supplierorderstatic->ref_supplier = $obj->ref_supplier;
468 $supplierorderstatic->total_ht = $obj->total_ht;
469 $supplierorderstatic->total_tva = $obj->total_tva;
470 $supplierorderstatic->total_ttc = $obj->total_ttc;
471 $supplierorderstatic->statut = $obj->status;
473 $companystatic->id = $obj->socid;
474 $companystatic->name = $obj->name;
475 $companystatic->name_alias = $obj->name_alias;
476 $companystatic->code_client = $obj->code_client;
477 $companystatic->code_compta = $obj->code_compta;
478 $companystatic->client = $obj->client;
479 $companystatic->code_fournisseur = $obj->code_fournisseur;
480 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
481 $companystatic->fournisseur = $obj->fournisseur;
482 $companystatic->logo = $obj->logo;
483 $companystatic->email = $obj->email;
484 $companystatic->entity = $obj->entity;
485 $companystatic->canvas = $obj->canvas;
487 print
'<tr class="oddeven">';
488 print
'<td class="nowraponall tdoverflowmax100">'.$supplierorderstatic->getNomUrl(1).
'</td>';
489 print
'<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
490 print
'<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).
'</td>';
494 $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
498 print
'<tr class="oddeven">';
499 print
'<td class="nowrap" colspan="5">';
500 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
519if (isModEnabled(
'ficheinter')) {
520 $sql =
"SELECT f.rowid, f.ref, s.nom as name, f.fk_statut, f.duree as duration";
521 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
522 $sql .=
", s.code_client, s.code_compta, s.client";
523 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
524 $sql .=
", s.logo, s.email, s.entity";
525 $sql .=
", s.canvas";
526 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinter as f";
527 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
528 if (empty($user->rights->societe->client->voir) && !$socid) {
529 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
531 $sql .=
" WHERE f.entity IN (".getEntity(
'intervention').
")";
532 $sql .=
" AND f.fk_soc = s.rowid";
533 $sql .=
" AND f.fk_statut = 0";
535 $sql .=
" AND f.fk_soc = ".((int) $socid);
537 if (empty($user->rights->societe->client->voir) && !$socid) {
538 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
542 $resql = $db->query($sql);
544 $num = $db->num_rows($resql);
545 $nbofloop = min($num, $maxofloop);
553 while ($i < $nbofloop) {
554 $obj = $db->fetch_object($resql);
556 $fichinterstatic->id=$obj->rowid;
557 $fichinterstatic->ref=$obj->ref;
558 $fichinterstatic->statut=$obj->fk_statut;
560 $companystatic->id = $obj->socid;
561 $companystatic->name = $obj->name;
562 $companystatic->name_alias = $obj->name_alias;
563 $companystatic->code_client = $obj->code_client;
564 $companystatic->code_compta = $obj->code_compta;
565 $companystatic->client = $obj->client;
566 $companystatic->code_fournisseur = $obj->code_fournisseur;
567 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
568 $companystatic->fournisseur = $obj->fournisseur;
569 $companystatic->logo = $obj->logo;
570 $companystatic->email = $obj->email;
571 $companystatic->entity = $obj->entity;
572 $companystatic->canvas = $obj->canvas;
574 print
'<tr class="oddeven">';
575 print
'<td class="tdoverflowmax100">';
576 print $fichinterstatic->getNomUrl(1);
578 print
'<td class="tdoverflowmax100">';
579 print $companystatic->getNomUrl(1,
'customer');
581 print
'<td class="nowraponall tdoverflowmax100 right">';
592 print
"</table></div>";
596print
'</div><div class="fichetwothirdright">';
601if (isModEnabled(
"societe") && $user->hasRight(
'societe',
'lire')) {
602 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
603 $sql .=
", s.code_client, s.code_compta, s.client";
604 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
605 $sql .=
", s.logo, s.email, s.entity";
606 $sql .=
", s.canvas";
607 $sql .=
", s.datec, s.tms";
608 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
609 if (empty($user->rights->societe->client->voir) && !$socid) {
610 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
612 $sql .=
" WHERE s.entity IN (".getEntity($companystatic->element).
")";
614 if (empty($user->rights->societe->client->voir) && !$socid) {
615 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
618 $parameters = array(
'socid' => $socid);
619 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $companystatic);
620 if (empty($reshook)) {
622 $sql .=
" AND s.rowid = ".((int) $socid);
625 $sql .= $hookmanager->resPrint;
626 $sql .=
" ORDER BY s.tms DESC";
627 $sql .= $db->plimit($max, 0);
629 $resql = $db->query($sql);
631 if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
632 $header =
"BoxTitleLastCustomersOrProspects";
633 } elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
634 $header =
"BoxTitleLastModifiedProspects";
636 $header =
"BoxTitleLastModifiedCustomers";
639 $num = $db->num_rows($resql);
640 startSimpleTable($langs->trans($header, min($max, $num)),
"societe/list.php",
"type=p,c", 1);
645 while ($i < $num && $i < $max) {
646 $objp = $db->fetch_object($resql);
648 $companystatic->id = $objp->socid;
649 $companystatic->name = $objp->name;
650 $companystatic->name_alias = $objp->name_alias;
651 $companystatic->code_client = $objp->code_client;
652 $companystatic->code_compta = $objp->code_compta;
653 $companystatic->client = $objp->client;
654 $companystatic->code_fournisseur = $objp->code_fournisseur;
655 $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
656 $companystatic->fournisseur = $objp->fournisseur;
657 $companystatic->logo = $objp->logo;
658 $companystatic->email = $objp->email;
659 $companystatic->entity = $objp->entity;
660 $companystatic->canvas = $objp->canvas;
662 print
'<tr class="oddeven">';
663 print
'<td class="nowraponall tdoverflowmax100">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
664 print
'<td class="nowrap">';
667 $obj = $companystatic;
669 if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
670 $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>';
672 if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
673 $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>';
684 $datem = $db->jdate($objp->tms);
685 print
'<td class="right nowrap tddate" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
707if ((isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) && $user->hasRight(
'societe',
'lire')) {
708 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
709 $sql .=
", s.code_client, s.code_compta, s.client";
710 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
711 $sql .=
", s.logo, s.email, s.entity";
712 $sql .=
", s.canvas";
713 $sql .=
", s.datec as dc, s.tms as dm";
714 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
715 if (empty($user->rights->societe->client->voir) && !$user->socid) {
716 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
718 $sql .=
" WHERE s.entity IN (".getEntity($companystatic->element).
")";
719 $sql .=
" AND s.fournisseur = ".Societe::SUPPLIER;
720 if (empty($user->rights->societe->client->voir) && !$user->socid) {
721 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
724 $parameters = array(
'socid' => $socid);
725 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $companystatic);
726 if (empty($reshook)) {
728 $sql .=
" AND s.rowid = ".((int) $socid);
731 $sql .= $hookmanager->resPrint;
732 $sql .=
" ORDER BY s.datec DESC";
733 $sql .= $db->plimit($max, 0);
735 $resql = $db->query($sql);
737 $num = $db->num_rows($resql);
738 startSimpleTable($langs->trans(
"BoxTitleLastModifiedSuppliers", min($max, $num)),
"societe/list.php",
"type=f", 1);
742 while ($i < $num && $i < $max) {
743 $objp = $db->fetch_object($resql);
745 $companystatic->id = $objp->socid;
746 $companystatic->name = $objp->name;
747 $companystatic->name_alias = $objp->name_alias;
748 $companystatic->code_client = $objp->code_client;
749 $companystatic->code_compta = $objp->code_compta;
750 $companystatic->client = $objp->client;
751 $companystatic->code_fournisseur = $objp->code_fournisseur;
752 $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
753 $companystatic->fournisseur = $objp->fournisseur;
754 $companystatic->logo = $objp->logo;
755 $companystatic->email = $objp->email;
756 $companystatic->entity = $objp->entity;
757 $companystatic->canvas = $objp->canvas;
759 print
'<tr class="oddeven">';
760 print
'<td class="nowraponall tdoverflowmax100">'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
763 $obj = $companystatic;
772 if ((isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) && $obj->fournisseur) {
773 $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>';
779 $datem = $db->jdate($objp->dm);
780 print
'<td class="right tddate" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
818if (isModEnabled(
'contrat') && $user->hasRight(
"contrat",
"lire") && 0) {
819 $staticcontrat =
new Contrat($db);
821 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
822 $sql .=
", s.code_client, s.code_compta, s.client";
823 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
824 $sql .=
", s.logo, s.email, s.entity";
825 $sql .=
", s.canvas";
826 $sql .=
", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo";
827 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
828 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as c";
829 $sql .=
", ".MAIN_DB_PREFIX.
"product as p";
830 if (empty($user->rights->societe->client->voir) && !$socid) {
831 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
833 $sql .=
" WHERE c.entity IN (".getEntity($staticcontrat->element).
")";
834 $sql .=
" AND c.fk_soc = s.rowid";
835 $sql .=
" AND c.fk_product = p.rowid";
836 if (empty($user->rights->societe->client->voir) && !$socid) {
837 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
840 $sql .=
" AND s.rowid = ".((int) $socid);
842 $sql .=
" ORDER BY c.tms DESC";
843 $sql .= $db->plimit($max + 1, 0);
845 $resql = $db->query($sql);
847 $num = $db->num_rows($resql);
854 $obj = $db->fetch_object($resql);
856 $companystatic->id = $obj->socid;
857 $companystatic->name = $obj->name;
858 $companystatic->name_alias = $obj->name_alias;
859 $companystatic->code_client = $obj->code_client;
860 $companystatic->code_compta = $obj->code_compta;
861 $companystatic->client = $obj->client;
862 $companystatic->code_fournisseur = $obj->code_fournisseur;
863 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
864 $companystatic->fournisseur = $obj->fournisseur;
865 $companystatic->logo = $obj->logo;
866 $companystatic->email = $obj->email;
867 $companystatic->entity = $obj->entity;
868 $companystatic->canvas = $obj->canvas;
870 $staticcontrat->id = $obj->contratid;
871 $staticcontrat->ref = $obj->ref;
873 print
'<tr class="oddeven">';
874 print
'<td class="nowraponall">'.$staticcontrat->getNomUrl(1).
'</td>';
875 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
876 print
'<td class="right">'.$staticcontrat->LibStatut($obj->statut, 3).
'</td>';
896if (isModEnabled(
"propal") && $user->hasRight(
"propal",
"lire")) {
897 $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";
898 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
899 $sql .=
", s.code_client, s.code_compta, s.client";
900 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
901 $sql .=
", s.logo, s.email, s.entity";
902 $sql .=
", s.canvas";
903 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p";
904 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
905 if (empty($user->rights->societe->client->voir) && !$socid) {
906 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
908 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
909 $sql .=
" AND p.fk_soc = s.rowid";
910 $sql .=
" AND p.fk_statut = ".Propal::STATUS_VALIDATED;
911 if (empty($user->rights->societe->client->voir) && !$socid) {
912 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
915 $sql .=
" AND s.rowid = ".((int) $socid);
917 $sql .=
" ORDER BY p.rowid DESC";
919 $resql = $db->query($sql);
921 $total = $total_ttc = 0;
922 $num = $db->num_rows($resql);
923 $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
924 startSimpleTable(
"ProposalsOpened",
"comm/propal/list.php",
"search_status=1", 4, $num);
930 while ($i < $nbofloop) {
931 $obj = $db->fetch_object($resql);
936 $total += $obj->total_ht;
937 $total_ttc += $obj->total_ttc;
941 $propalstatic->id = $obj->propalid;
942 $propalstatic->ref = $obj->ref;
943 $propalstatic->ref_client = $obj->ref_client;
944 $propalstatic->total_ht = $obj->total_ht;
945 $propalstatic->total_tva = $obj->total_tva;
946 $propalstatic->total_ttc = $obj->total_ttc;
948 $companystatic->id = $obj->socid;
949 $companystatic->name = $obj->name;
950 $companystatic->name_alias = $obj->name_alias;
951 $companystatic->code_client = $obj->code_client;
952 $companystatic->code_compta = $obj->code_compta;
953 $companystatic->client = $obj->client;
954 $companystatic->code_fournisseur = $obj->code_fournisseur;
955 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
956 $companystatic->fournisseur = $obj->fournisseur;
957 $companystatic->logo = $obj->logo;
958 $companystatic->email = $obj->email;
959 $companystatic->entity = $obj->entity;
960 $companystatic->canvas = $obj->canvas;
965 $warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ?
img_warning($langs->trans(
"Late")) :
'';
967 print
'<tr class="oddeven">';
969 print
'<td class="nowrap" width="140">';
970 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
971 print
'<td class="nobordernopadding nowraponall">'.$propalstatic->getNomUrl(1).
'</td>';
972 print
'<td width="18" class="nobordernopadding nowrap">'.$warning.
'</td>';
973 print
'<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
978 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
979 $datem = $db->jdate($obj->dp);
980 print
'<td class="center tddate" title="'.dol_escape_htmltag($langs->trans(
"Date").
': '.
dol_print_date($datem,
'day',
'tzserver')).
'">';
983 print
'<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).
'</td>';
984 print
'<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
989 $total += $obj->total_ht;
990 $total_ttc += $obj->total_ttc;
994 print
'<tr class="oddeven">';
995 print
'<td class="nowrap" colspan="5">';
996 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1002 addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total,
"NoProposal", true);
1015if (isModEnabled(
'commande') && $user->hasRight(
'commande',
'lire')) {
1016 $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";
1017 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
1018 $sql .=
", s.code_client, s.code_compta, s.client";
1019 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
1020 $sql .=
", s.logo, s.email, s.entity";
1021 $sql .=
", s.canvas";
1022 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
1023 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
1024 if (empty($user->rights->societe->client->voir) && !$socid) {
1025 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1027 $sql .=
" WHERE c.entity IN (".getEntity($orderstatic->element).
")";
1028 $sql .=
" AND c.fk_soc = s.rowid";
1030 if (empty($user->rights->societe->client->voir) && !$socid) {
1031 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1034 $sql .=
" AND s.rowid = ".((int) $socid);
1036 $sql .=
" ORDER BY c.rowid DESC";
1038 $resql = $db->query($sql);
1040 $total = $total_ttc = 0;
1041 $num = $db->num_rows($resql);
1042 $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
1049 while ($i < $nbofloop) {
1050 $obj = $db->fetch_object($resql);
1055 $total += $obj->total_ht;
1056 $total_ttc += $obj->total_ttc;
1060 $orderstatic->id = $obj->commandeid;
1061 $orderstatic->ref = $obj->ref;
1062 $orderstatic->ref_client = $obj->ref_client;
1063 $orderstatic->statut = $obj->fk_statut;
1064 $orderstatic->total_ht = $obj->total_ht;
1065 $orderstatic->total_tva = $obj->total_tva;
1066 $orderstatic->total_ttc = $obj->total_ttc;
1068 $companystatic->id = $obj->socid;
1069 $companystatic->name = $obj->name;
1070 $companystatic->name_alias = $obj->name_alias;
1071 $companystatic->code_client = $obj->code_client;
1072 $companystatic->code_compta = $obj->code_compta;
1073 $companystatic->client = $obj->client;
1074 $companystatic->code_fournisseur = $obj->code_fournisseur;
1075 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1076 $companystatic->fournisseur = $obj->fournisseur;
1077 $companystatic->logo = $obj->logo;
1078 $companystatic->email = $obj->email;
1079 $companystatic->entity = $obj->entity;
1080 $companystatic->canvas = $obj->canvas;
1087 print
'<tr class="oddeven">';
1089 print
'<td class="nowrap" width="140">';
1090 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1091 print
'<td class="nobordernopadding nowraponall">'.$orderstatic->getNomUrl(1).
'</td>';
1092 print
'<td width="18" class="nobordernopadding nowrap"></td>';
1093 print
'<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($orderstatic->element, $filename, $filedir).
'</td>';
1098 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
1099 $datem = $db->jdate($obj->dv);
1100 print
'<td class="center tddate" title="'.dol_escape_htmltag($langs->trans(
"DateValue").
': '.
dol_print_date($datem,
'day',
'tzserver')).
'">';
1104 print
'<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).
'</td>';
1105 print
'<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).
'</td>';
1110 $total += $obj->total_ht;
1111 $total_ttc += $obj->total_ttc;
1115 print
'<tr class="oddeven">';
1116 print
'<td class="nowrap" colspan="5">';
1117 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1123 addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total,
"None", true);
1135$parameters = array(
'user' => $user);
1136$reshook = $hookmanager->executeHooks(
'dashboardCommercials', $parameters, $object);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage predefined suppliers products.
const STATUS_DRAFT
Draft status.
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage contracts.
Class to manage interventions.
const STATUS_DRAFT
Draft status.
Class to manage proposals.
const STATUS_DRAFT
Draft status.
Class to manage third parties objects (customers, suppliers, prospects...)
const PROSPECT
Third party type is a prospect.
const CUSTOMER_AND_PROSPECT
Third party type is a customer and a prospect.
Class to manage price ask supplier.
const STATUS_DRAFT
Draft status.
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line)
startSimpleTable($header, $link="", $arguments="", $emptyRows=0, $number=-1)
Start a table with headers and a optinal clickable number (don't forget to use "finishSimpleTable()" ...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
addSummaryTableLine($tableColumnCount, $num, $nbofloop=0, $total=0, $noneWord="None", $extraRightColumn=false)
Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx")
getCustomerOrderPieChart($socid=0)
Return a HTML table that contains a pie chart of sales orders.
getCustomerProposalPieChart($socid=0)
Return a HTML table that contains a pie chart of customer proposals.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.