33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/propal.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
45 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
61$hookmanager->initHooks(array(
'commercialindex'));
64$langs->loadLangs(array(
"boxes",
"commercial",
"contracts",
"orders",
"propal",
"supplier_proposal"));
66$action =
GETPOST(
'action',
'aZ09');
71if (!empty($user->socid) && $user->socid > 0) {
73 $socid = $user->socid;
83if (!$user->hasRight(
'propal',
'read') && !$user->hasRight(
'supplier_proposal',
'read') && !$user->hasRight(
'commande',
'read') && !$user->hasRight(
'fournisseur',
'commande',
'read')
84 && !$user->hasRight(
'supplier_order',
'read') && !$user->hasRight(
'fichinter',
'read') && !$user->hasRight(
'contrat',
'read')) {
101$form =
new Form($db);
103$companystatic =
new Societe($db);
105$supplierproposalstatic =
null;
107$supplierorderstatic =
null;
108$fichinterstatic =
null;
110 $propalstatic =
new Propal($db);
126llxHeader(
"", $langs->trans(
"CommercialArea"));
130print
'<div class="fichecenter">';
132print
'<div class="twocolumns">';
134print
'<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
150if (
isModEnabled(
"propal") && $user->hasRight(
"propal",
"lire") && is_object($propalstatic)) {
151 $sql =
"SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
152 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
153 $sql .=
", s.code_client, s.code_compta as code_compta_client, s.client";
154 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
155 $sql .=
", s.logo, s.email, s.entity";
156 $sql .=
", s.canvas";
157 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p,";
158 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
159 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
160 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
162 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
163 $sql .=
" AND p.fk_soc = s.rowid";
164 $sql .=
" AND p.fk_statut = ".Propal::STATUS_DRAFT;
165 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
166 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
169 $sql .=
" AND s.rowid = ".((int) $socid);
172 $parameters = array(
'socid' => $user->socid);
173 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
174 $sql .= $hookmanager->resPrint;
176 $resql = $db->query($sql);
179 $num = $db->num_rows($resql);
180 $nbofloop = min($num, $maxofloop);
187 while ($i < $nbofloop) {
188 $obj = $db->fetch_object($resql);
193 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
197 $propalstatic->id = $obj->rowid;
198 $propalstatic->ref = $obj->ref;
199 $propalstatic->ref_client = $obj->ref_client;
200 $propalstatic->ref_customer = $obj->ref_client;
201 $propalstatic->total_ht = $obj->total_ht;
202 $propalstatic->total_tva = $obj->total_tva;
203 $propalstatic->total_ttc = $obj->total_ttc;
204 $propalstatic->statut = $obj->status;
205 $propalstatic->status = $obj->status;
207 $companystatic->id = $obj->socid;
208 $companystatic->name = $obj->name;
209 $companystatic->name_alias = $obj->name_alias;
210 $companystatic->code_client = $obj->code_client;
211 $companystatic->code_compta = $obj->code_compta_client;
212 $companystatic->code_compta_client = $obj->code_compta_client;
213 $companystatic->client = $obj->client;
214 $companystatic->code_fournisseur = $obj->code_fournisseur;
215 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
216 $companystatic->fournisseur = $obj->fournisseur;
217 $companystatic->logo = $obj->logo;
218 $companystatic->email = $obj->email;
219 $companystatic->entity = $obj->entity;
220 $companystatic->canvas = $obj->canvas;
222 print
'<tr class="oddeven">';
223 print
'<td class="nowraponall tdoverflowmax125 minwidth75">'.$propalstatic->getNomUrl(1).
'</td>';
224 print
'<td class="nowrap tdoverflowmax250">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
225 print
'<td class="nowrap right tdamount amount">'.price((
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc)).
'</td>';
229 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
233 print
'<tr class="oddeven">';
234 print
'<td class="nowrap" colspan="5">';
235 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
255if (
isModEnabled(
'supplier_proposal') && $user->hasRight(
"supplier_proposal",
"lire") && is_object($supplierproposalstatic)) {
256 $sql =
"SELECT p.rowid, p.ref, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
257 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
258 $sql .=
", s.code_client, s.code_compta as code_compta_client, s.client";
259 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
260 $sql .=
", s.logo, s.email, s.entity";
261 $sql .=
", s.canvas";
262 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p,";
263 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
264 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
265 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
267 $sql .=
" WHERE p.entity IN (".getEntity($supplierproposalstatic->element).
")";
268 $sql .=
" AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT;
269 $sql .=
" AND p.fk_soc = s.rowid";
270 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
271 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
274 $sql .=
" AND s.rowid = ".((int) $socid);
277 $parameters = array(
'socid' => $user->socid);
278 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $supplierproposalstatic);
279 $sql .= $hookmanager->resPrint;
280 $resql = $db->query($sql);
283 $num = $db->num_rows($resql);
284 $nbofloop = min($num, $maxofloop);
291 while ($i < $nbofloop) {
292 $obj = $db->fetch_object($resql);
297 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
301 $supplierproposalstatic->id = $obj->rowid;
302 $supplierproposalstatic->ref = $obj->ref;
303 $supplierproposalstatic->total_ht = $obj->total_ht;
304 $supplierproposalstatic->total_tva = $obj->total_tva;
305 $supplierproposalstatic->total_ttc = $obj->total_ttc;
306 $supplierproposalstatic->statut = $obj->status;
307 $supplierproposalstatic->status = $obj->status;
309 $companystatic->id = $obj->socid;
310 $companystatic->name = $obj->name;
311 $companystatic->name_alias = $obj->name_alias;
312 $companystatic->code_client = $obj->code_client;
313 $companystatic->code_compta_client = $obj->code_compta_client;
314 $companystatic->client = $obj->client;
315 $companystatic->code_fournisseur = $obj->code_fournisseur;
316 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
317 $companystatic->fournisseur = $obj->fournisseur;
318 $companystatic->logo = $obj->logo;
319 $companystatic->email = $obj->email;
320 $companystatic->entity = $obj->entity;
321 $companystatic->canvas = $obj->canvas;
323 print
'<tr class="oddeven">';
324 print
'<td class="nowraponall tdoverflowmax125 minwidth75">'.$supplierproposalstatic->getNomUrl(1).
'</td>';
325 print
'<td class="nowrap tdoverflowmax250">'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
326 print
'<td class="nowrap right tdamount amount">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
330 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
334 print
'<tr class="oddeven">';
335 print
'<td class="nowrap" colspan="5">';
336 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
356if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire') && is_object($orderstatic)) {
357 $sql =
"SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, c.fk_statut as status";
358 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
359 $sql .=
", s.code_client, s.code_compta as code_compta_client, s.client";
360 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
361 $sql .=
", s.logo, s.email, s.entity";
362 $sql .=
", s.canvas";
363 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c,";
364 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
365 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
366 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
368 $sql .=
" WHERE c.entity IN (".getEntity($orderstatic->element).
")";
369 $sql .=
" AND c.fk_statut = ".Commande::STATUS_DRAFT;
370 $sql .=
" AND c.fk_soc = s.rowid";
371 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
372 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
375 $sql .=
" AND c.fk_soc = ".((int) $socid);
378 $parameters = array(
'socid' => $user->socid);
379 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $orderstatic);
380 $sql .= $hookmanager->resPrint;
381 $resql = $db->query($sql);
384 $num = $db->num_rows($resql);
385 $nbofloop = min($num, $maxofloop);
392 while ($i < $nbofloop) {
393 $obj = $db->fetch_object($resql);
398 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
402 $orderstatic->id = $obj->rowid;
403 $orderstatic->ref = $obj->ref;
404 $orderstatic->ref_client = $obj->ref_client;
405 $orderstatic->total_ht = $obj->total_ht;
406 $orderstatic->total_tva = $obj->total_tva;
407 $orderstatic->total_ttc = $obj->total_ttc;
408 $orderstatic->statut = $obj->status;
409 $orderstatic->status = $obj->status;
411 $companystatic->id = $obj->socid;
412 $companystatic->name = $obj->name;
413 $companystatic->name_alias = $obj->name_alias;
414 $companystatic->code_client = $obj->code_client;
415 $companystatic->code_compta = $obj->code_compta_client;
416 $companystatic->code_compta_client = $obj->code_compta_client;
417 $companystatic->client = $obj->client;
418 $companystatic->code_fournisseur = $obj->code_fournisseur;
419 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
420 $companystatic->fournisseur = $obj->fournisseur;
421 $companystatic->logo = $obj->logo;
422 $companystatic->email = $obj->email;
423 $companystatic->entity = $obj->entity;
424 $companystatic->canvas = $obj->canvas;
426 print
'<tr class="oddeven">';
427 print
'<td class="nowraponall tdoverflowmax125 minwidth75">'.$orderstatic->getNomUrl(1).
'</td>';
428 print
'<td class="nowrap tdoverflowmax250">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
429 print
'<td class="nowrap right tdamount amount">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
433 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
437 print
'<tr class="oddeven">';
438 print
'<td class="nowrap" colspan="5">';
439 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
459if ((
isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight(
"fournisseur",
"commande",
"lire")) || (
isModEnabled(
"supplier_order") && $user->hasRight(
"supplier_order",
"lire"))) {
462 $sql =
"SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_statut as status";
463 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
464 $sql .=
", s.code_client, s.code_compta, s.client";
465 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
466 $sql .=
", s.logo, s.email, s.entity";
467 $sql .=
", s.canvas";
468 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf,";
469 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
470 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
471 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
473 $sql .=
" WHERE cf.entity IN (".getEntity($supplierorderstatic->element).
")";
474 $sql .=
" AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT;
475 $sql .=
" AND cf.fk_soc = s.rowid";
476 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
477 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
480 $sql .=
" AND cf.fk_soc = ".((int) $socid);
483 $parameters = array(
'socid' => $user->socid);
484 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $supplierorderstatic);
485 $sql .= $hookmanager->resPrint;
486 $resql = $db->query($sql);
489 $num = $db->num_rows($resql);
490 $nbofloop = min($num, $maxofloop);
497 while ($i < $nbofloop) {
498 $obj = $db->fetch_object($resql);
503 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
507 $supplierorderstatic->id = $obj->rowid;
508 $supplierorderstatic->ref = $obj->ref;
509 $supplierorderstatic->ref_supplier = $obj->ref_supplier;
510 $supplierorderstatic->total_ht = $obj->total_ht;
511 $supplierorderstatic->total_tva = $obj->total_tva;
512 $supplierorderstatic->total_ttc = $obj->total_ttc;
513 $supplierorderstatic->statut = $obj->status;
514 $supplierorderstatic->status = $obj->status;
516 $companystatic->id = $obj->socid;
517 $companystatic->name = $obj->name;
518 $companystatic->name_alias = $obj->name_alias;
519 $companystatic->code_client = $obj->code_client;
520 $companystatic->code_compta = $obj->code_compta;
521 $companystatic->code_compta_client = $obj->code_compta;
522 $companystatic->client = $obj->client;
523 $companystatic->code_fournisseur = $obj->code_fournisseur;
524 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
525 $companystatic->fournisseur = $obj->fournisseur;
526 $companystatic->logo = $obj->logo;
527 $companystatic->email = $obj->email;
528 $companystatic->entity = $obj->entity;
529 $companystatic->canvas = $obj->canvas;
531 print
'<tr class="oddeven">';
532 print
'<td class="nowraponall tdoverflowmax125 minwidth75">'.$supplierorderstatic->getNomUrl(1).
'</td>';
533 print
'<td class="nowrap tdoverflowmax250">'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
534 print
'<td class="nowrap right tdamount amount">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
538 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
542 print
'<tr class="oddeven">';
543 print
'<td class="nowrap" colspan="5">';
544 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
563if (
isModEnabled(
'intervention') && is_object($fichinterstatic)) {
564 $sql =
"SELECT f.rowid, f.ref, s.nom as name, f.fk_statut, f.duree as duration";
565 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
566 $sql .=
", s.code_client, s.code_compta as code_compta_client, s.client";
567 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
568 $sql .=
", s.logo, s.email, s.entity";
569 $sql .=
", s.canvas";
570 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinter as f";
571 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
572 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
573 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
575 $sql .=
" WHERE f.entity IN (".getEntity(
'intervention').
")";
576 $sql .=
" AND f.fk_soc = s.rowid";
577 $sql .=
" AND f.fk_statut = 0";
579 $sql .=
" AND f.fk_soc = ".((int) $socid);
581 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
582 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
586 $parameters = array(
'socid' => $user->socid);
587 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $fichinterstatic);
588 $sql .= $hookmanager->resPrint;
589 $resql = $db->query($sql);
591 $num = $db->num_rows($resql);
592 $nbofloop = min($num, $maxofloop);
600 while ($i < $nbofloop) {
601 $obj = $db->fetch_object($resql);
603 $fichinterstatic->id = $obj->rowid;
604 $fichinterstatic->ref = $obj->ref;
605 $fichinterstatic->statut = $obj->fk_statut;
606 $fichinterstatic->status = $obj->fk_statut;
608 $companystatic->id = $obj->socid;
609 $companystatic->name = $obj->name;
610 $companystatic->name_alias = $obj->name_alias;
611 $companystatic->code_client = $obj->code_client;
612 $companystatic->code_compta = $obj->code_compta_client;
613 $companystatic->code_compta_client = $obj->code_compta_client;
614 $companystatic->client = $obj->client;
615 $companystatic->code_fournisseur = $obj->code_fournisseur;
616 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
617 $companystatic->fournisseur = $obj->fournisseur;
618 $companystatic->logo = $obj->logo;
619 $companystatic->email = $obj->email;
620 $companystatic->entity = $obj->entity;
621 $companystatic->canvas = $obj->canvas;
623 print
'<tr class="oddeven">';
624 print
'<td class="tdoverflowmax125 minwidth75">';
625 print $fichinterstatic->getNomUrl(1);
627 print
'<td class="tdoverflowmax250 minwidth100">';
628 print $companystatic->getNomUrl(1,
'customer');
630 print
'<td class="nowraponall tdoverflowmax100 right">';
646print
'</div><div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
757if (
isModEnabled(
'propal') && is_object($propalstatic)) {
758 $sql =
"SELECT p.rowid, p.entity, p.ref, p.fk_statut as status, p.tms as datem,";
759 $sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client";
760 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p,";
761 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
762 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
763 $sql .=
" AND p.fk_soc = s.rowid";
766 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
767 $search_sale = $user->id;
770 if ($search_sale && $search_sale !=
'-1') {
771 if ($search_sale == -2) {
772 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
773 } elseif ($search_sale > 0) {
774 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
779 $sql .=
" AND p.fk_soc = ".((int) $socid);
782 $parameters = array(
'socid' => $user->socid);
783 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
784 $sql .= $hookmanager->resPrint;
785 $sql .=
" ORDER BY p.tms DESC";
787 $sql .= $db->plimit($max, 0);
789 $resql = $db->query($sql);
791 $num = $db->num_rows($resql);
793 startSimpleTable($langs->trans(
"LastModifiedProposals", $max),
"comm/propal/list.php",
"sortfield=p.tms&sortorder=DESC", 2, -1,
'propal');
798 $obj = $db->fetch_object($resql);
800 $propalstatic->id = $obj->rowid;
801 $propalstatic->ref = $obj->ref;
802 $propalstatic->status = $obj->status;
804 $companystatic->id = $obj->socid;
805 $companystatic->name = $obj->socname;
806 $companystatic->client = $obj->client;
807 $companystatic->canvas = $obj->canvas;
808 $companystatic->email = $obj->email;
809 $companystatic->code_compta = $obj->code_compta_client;
810 $companystatic->code_compta_client = $obj->code_compta_client;
814 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
816 print
'<tr class="oddeven">';
818 print
'<td class="nowrap">';
819 print
'<table class="nobordernopadding">';
820 print
'<tr class="nocellnopadd">';
821 print
'<td width="96" class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
822 print
'<td width="16" class="nobordernopadding nowrap"></td>';
823 print
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
828 print
'<td class="tdoverflowmax100">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
830 $datem = $db->jdate($obj->datem);
831 print
'<td class="center" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
835 print
'<td class="right">'.$propalstatic->LibStatut($obj->status, 3).
'</td>';
856 $commandestatic =
new Commande($db);
858 $sql =
"SELECT c.rowid, c.entity, c.ref, c.fk_statut as status, c.facture, c.date_cloture as datec, c.tms as datem,";
859 $sql .=
" s.nom as name, s.rowid as socid";
860 $sql .=
", s.client";
861 $sql .=
", s.code_client";
862 $sql .=
", s.canvas";
863 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c,";
864 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
865 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
866 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
868 $sql .=
" WHERE c.fk_soc = s.rowid";
869 $sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
872 $sql .=
" AND c.fk_soc = ".((int) $socid);
874 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
875 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
878 $parameters = array(
'socid' => $user->socid);
879 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $orderstatic);
880 $sql .= $hookmanager->resPrint;
881 $sql .=
" ORDER BY c.tms DESC";
882 $sql .= $db->plimit($max, 0);
884 $resql = $db->query($sql);
886 $num = $db->num_rows($resql);
888 startSimpleTable($langs->trans(
"LastModifiedOrders", $max),
"commande/list.php",
"sortfield=c.tms&sortorder=DESC", 2, -1,
'order');
893 $obj = $db->fetch_object($resql);
895 print
'<tr class="oddeven">';
896 print
'<td width="20%" class="nowrap">';
898 $commandestatic->id = $obj->rowid;
899 $commandestatic->ref = $obj->ref;
901 $companystatic->id = $obj->socid;
902 $companystatic->name = $obj->name;
903 $companystatic->client = $obj->client;
904 $companystatic->code_client = $obj->code_client;
905 $companystatic->canvas = $obj->canvas;
907 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
908 print
'<td width="96" class="nobordernopadding nowrap">';
909 print $commandestatic->getNomUrl(1);
912 print
'<td width="16" class="nobordernopadding nowrap">';
916 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
919 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
920 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
921 print
'</td></tr></table>';
925 print
'<td class="nowrap">';
926 print $companystatic->getNomUrl(1,
'company', 16);
929 $datem = $db->jdate($obj->datem);
930 print
'<td class="center" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
934 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, $obj->facture, 3).
'</td>';
1040if (
isModEnabled(
'contract') && $user->hasRight(
"contrat",
"lire") && 0) {
1041 $staticcontrat =
new Contrat($db);
1043 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
1044 $sql .=
", s.code_client, s.code_compta as code_compta_client, s.client";
1045 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
1046 $sql .=
", s.logo, s.email, s.entity";
1047 $sql .=
", s.canvas";
1048 $sql .=
", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo";
1049 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
1050 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as c";
1051 $sql .=
", ".MAIN_DB_PREFIX.
"product as p";
1052 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
1053 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1055 $sql .=
" WHERE c.entity IN (".getEntity($staticcontrat->element).
")";
1056 $sql .=
" AND c.fk_soc = s.rowid";
1057 $sql .=
" AND c.fk_product = p.rowid";
1058 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
1059 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1062 $sql .=
" AND s.rowid = ".((int) $socid);
1065 $parameters = array(
'socid' => $user->socid);
1066 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $staticcontrat);
1067 $sql .= $hookmanager->resPrint;
1068 $sql .=
" ORDER BY c.tms DESC";
1069 $sql .= $db->plimit($max + 1, 0);
1071 $resql = $db->query($sql);
1073 $num = $db->num_rows($resql);
1080 $obj = $db->fetch_object($resql);
1082 $companystatic->id = $obj->socid;
1083 $companystatic->name = $obj->name;
1084 $companystatic->name_alias = $obj->name_alias;
1085 $companystatic->code_client = $obj->code_client;
1086 $companystatic->code_compta = $obj->code_compta_client;
1087 $companystatic->code_compta_client = $obj->code_compta_client;
1088 $companystatic->client = $obj->client;
1089 $companystatic->code_fournisseur = $obj->code_fournisseur;
1090 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1091 $companystatic->fournisseur = $obj->fournisseur;
1092 $companystatic->logo = $obj->logo;
1093 $companystatic->email = $obj->email;
1094 $companystatic->entity = $obj->entity;
1095 $companystatic->canvas = $obj->canvas;
1097 $staticcontrat->id = $obj->contratid;
1098 $staticcontrat->ref = $obj->ref;
1100 print
'<tr class="oddeven">';
1101 print
'<td class="nowraponall">'.$staticcontrat->getNomUrl(1).
'</td>';
1102 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
1103 print
'<td class="right">'.$staticcontrat->LibStatut($obj->statut, 3).
'</td>';
1123if (
isModEnabled(
"propal") && $user->hasRight(
"propal",
"lire")) {
1124 $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";
1125 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
1126 $sql .=
", s.code_client, s.code_compta as code_compta_client, s.client";
1127 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
1128 $sql .=
", s.logo, s.email, s.entity";
1129 $sql .=
", s.canvas";
1130 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p";
1131 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
1132 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
1133 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1135 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
1136 $sql .=
" AND p.fk_soc = s.rowid";
1137 $sql .=
" AND p.fk_statut = ".Propal::STATUS_VALIDATED;
1138 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
1139 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1142 $sql .=
" AND s.rowid = ".((int) $socid);
1145 $parameters = array(
'socid' => $user->socid);
1146 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
1147 $sql .= $hookmanager->resPrint;
1148 $sql .=
" ORDER BY p.rowid DESC";
1150 $resql = $db->query($sql);
1152 $total = $total_ttc = 0;
1153 $num = $db->num_rows($resql);
1155 startSimpleTable(
"ProposalsOpened",
"comm/propal/list.php",
"search_status=1", 4, $num);
1161 while ($i < $nbofloop) {
1162 $obj = $db->fetch_object($resql);
1167 $total += $obj->total_ht;
1168 $total_ttc += $obj->total_ttc;
1172 $propalstatic->id = $obj->propalid;
1173 $propalstatic->ref = $obj->ref;
1174 $propalstatic->ref_client = $obj->ref_client;
1175 $propalstatic->ref_customer = $obj->ref_client;
1176 $propalstatic->total_ht = $obj->total_ht;
1177 $propalstatic->total_tva = $obj->total_tva;
1178 $propalstatic->total_ttc = $obj->total_ttc;
1180 $companystatic->id = $obj->socid;
1181 $companystatic->name = $obj->name;
1182 $companystatic->name_alias = $obj->name_alias;
1183 $companystatic->code_client = $obj->code_client;
1184 $companystatic->code_compta = $obj->code_compta_client;
1185 $companystatic->code_compta_client = $obj->code_compta_client;
1186 $companystatic->client = $obj->client;
1187 $companystatic->code_fournisseur = $obj->code_fournisseur;
1188 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1189 $companystatic->fournisseur = $obj->fournisseur;
1190 $companystatic->logo = $obj->logo;
1191 $companystatic->email = $obj->email;
1192 $companystatic->entity = $obj->entity;
1193 $companystatic->canvas = $obj->canvas;
1198 $warning = ($db->jdate($obj->dfv) < ($now -
getWarningDelay(
'propal',
'cloture'))) ?
img_warning($langs->trans(
"Late")) :
'';
1200 print
'<tr class="oddeven">';
1202 print
'<td class="nowrap" width="140">';
1203 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1204 print
'<td class="nobordernopadding nowraponall">'.$propalstatic->getNomUrl(1).
'</td>';
1205 print
'<td width="18" class="nobordernopadding nowrap">'.$warning.
'</td>';
1206 print
'<td width="16" class="nobordernopadding center">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
1211 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
1212 $datem = $db->jdate($obj->dp);
1213 print
'<td class="center tddate" title="'.dol_escape_htmltag($langs->trans(
"Date").
': '.
dol_print_date($datem,
'day',
'tzserver')).
'">';
1216 print
'<td class="right tdamount amount">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
1217 print
'<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
1222 $total += $obj->total_ht;
1223 $total_ttc += $obj->total_ttc;
1227 print
'<tr class="oddeven">';
1228 print
'<td class="nowrap" colspan="5">';
1229 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1248if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire') && is_object($orderstatic)) {
1249 $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";
1250 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
1251 $sql .=
", s.code_client, s.code_compta as code_compta_client, s.client";
1252 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
1253 $sql .=
", s.logo, s.email, s.entity";
1254 $sql .=
", s.canvas";
1255 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
1256 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
1257 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
1258 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1260 $sql .=
" WHERE c.entity IN (".getEntity($orderstatic->element).
")";
1261 $sql .=
" AND c.fk_soc = s.rowid";
1263 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
1264 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1267 $sql .=
" AND s.rowid = ".((int) $socid);
1270 $parameters = array(
'socid' => $user->socid);
1271 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $orderstatic);
1272 $sql .= $hookmanager->resPrint;
1273 $sql .=
" ORDER BY c.rowid DESC";
1275 $resql = $db->query($sql);
1277 $total = $total_ttc = 0;
1278 $num = $db->num_rows($resql);
1286 while ($i < $nbofloop) {
1287 $obj = $db->fetch_object($resql);
1292 $total += $obj->total_ht;
1293 $total_ttc += $obj->total_ttc;
1297 $orderstatic->id = $obj->commandeid;
1298 $orderstatic->ref = $obj->ref;
1299 $orderstatic->ref_client = $obj->ref_client;
1300 $orderstatic->statut = $obj->fk_statut;
1301 $orderstatic->status = $obj->fk_statut;
1302 $orderstatic->total_ht = $obj->total_ht;
1303 $orderstatic->total_tva = $obj->total_tva;
1304 $orderstatic->total_ttc = $obj->total_ttc;
1306 $companystatic->id = $obj->socid;
1307 $companystatic->name = $obj->name;
1308 $companystatic->name_alias = $obj->name_alias;
1309 $companystatic->code_client = $obj->code_client;
1310 $companystatic->code_compta = $obj->code_compta_client;
1311 $companystatic->code_compta_client = $obj->code_compta_client;
1312 $companystatic->client = $obj->client;
1313 $companystatic->code_fournisseur = $obj->code_fournisseur;
1314 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1315 $companystatic->fournisseur = $obj->fournisseur;
1316 $companystatic->logo = $obj->logo;
1317 $companystatic->email = $obj->email;
1318 $companystatic->entity = $obj->entity;
1319 $companystatic->canvas = $obj->canvas;
1326 print
'<tr class="oddeven">';
1328 print
'<td class="nowrap" width="140">';
1329 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1330 print
'<td class="nobordernopadding nowraponall">'.$orderstatic->getNomUrl(1).
'</td>';
1331 print
'<td width="18" class="nobordernopadding nowrap"></td>';
1332 print
'<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($orderstatic->element, $filename, $filedir).
'</td>';
1337 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
1338 $datem = $db->jdate($obj->dv);
1339 print
'<td class="center tddate" title="'.dol_escape_htmltag($langs->trans(
"DateValue").
': '.
dol_print_date($datem,
'day',
'tzserver')).
'">';
1343 print
'<td class="right tdamount amount">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
1344 print
'<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).
'</td>';
1349 $total += $obj->total_ht;
1350 $total_ttc += $obj->total_ttc;
1354 print
'<tr class="oddeven">';
1355 print
'<td class="nowrap" colspan="5">';
1356 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1375$parameters = array(
'user' => $user);
1376$reshook = $hookmanager->executeHooks(
'dashboardCommercials', $parameters, $object);
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.
const STATUS_DRAFT
Draft status.
Class to manage proposals.
const STATUS_DRAFT
Draft status.
Class to manage third parties objects (customers, suppliers, prospects...)
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.
dol_now($mode='gmt')
Return date for now.
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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")
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getWarningDelay($module, $parmlevel1, $parmlevel2='')
Return a warning delay You can use it like this: if (getWarningDelay('module', 'paramlevel1')) It rep...
startSimpleTable($header, $link="", $arguments="", $emptyColumns=0, $number=-1, $pictofulllist='')
Start a table with headers and a optional clickable number (don't forget to use "finishSimpleTable()"...
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.