38 global $db, $langs, $conf;
43 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$object->id;
44 $head[$h][1] = $langs->trans(
'CustomerInvoice');
45 $head[$h][2] =
'compta';
48 if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
49 $nbContact = count($object->liste_contact(-1,
'internal')) + count($object->liste_contact(-1,
'external'));
50 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/contact.php?facid='.urlencode($object->id);
51 $head[$h][1] = $langs->trans(
'ContactsAddresses');
53 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
55 $head[$h][2] =
'contact';
59 if (!empty($conf->prelevement->enabled)) {
60 $nbStandingOrders = 0;
61 $sql =
"SELECT COUNT(pfd.rowid) as nb";
62 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
63 $sql .=
" WHERE pfd.fk_facture = ".((int) $object->id);
64 $sql .=
" AND pfd.ext_payment_id IS NULL";
67 $obj = $db->fetch_object(
$resql);
69 $nbStandingOrders = $obj->nb;
74 $langs->load(
"banks");
76 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/prelevement.php?facid='.urlencode($object->id);
77 $head[$h][1] = $langs->trans(
'StandingOrders');
78 if ($nbStandingOrders > 0) {
79 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbStandingOrders.
'</span>';
81 $head[$h][2] =
'standingorders';
91 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
93 if (!empty($object->note_private)) {
96 if (!empty($object->note_public)) {
99 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/note.php?facid='.$object->id;
100 $head[$h][1] = $langs->trans(
'Notes');
102 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
104 $head[$h][2] =
'note';
108 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
109 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
111 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
112 $nbLinks =
Link::count($db, $object->element, $object->id);
113 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/document.php?facid='.$object->id;
114 $head[$h][1] = $langs->trans(
'Documents');
115 if (($nbFiles + $nbLinks) > 0) {
116 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
118 $head[$h][2] =
'documents';
121 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/info.php?facid='.$object->id;
122 $head[$h][1] = $langs->trans(
'Info');
123 $head[$h][2] =
'info';
138 global $langs, $conf, $user;
143 $head[$h][0] = DOL_URL_ROOT.
'/admin/facture.php';
144 $head[$h][1] = $langs->trans(
"Miscellaneous");
145 $head[$h][2] =
'general';
148 $head[$h][0] = DOL_URL_ROOT.
'/admin/payment.php';
149 $head[$h][1] = $langs->trans(
"Payments");
150 $head[$h][2] =
'payment';
159 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facture_cust_extrafields.php';
160 $head[$h][1] = $langs->trans(
"ExtraFieldsCustomerInvoices");
161 $head[$h][2] =
'attributes';
164 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facturedet_cust_extrafields.php';
165 $head[$h][1] = $langs->trans(
"ExtraFieldsLines");
166 $head[$h][2] =
'attributeslines';
169 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facture_rec_cust_extrafields.php';
170 $head[$h][1] = $langs->trans(
"ExtraFieldsCustomerInvoicesRec");
171 $head[$h][2] =
'attributesrec';
174 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facturedet_rec_cust_extrafields.php';
175 $head[$h][1] = $langs->trans(
"ExtraFieldsLinesRec");
176 $head[$h][2] =
'attributeslinesrec';
179 if ($conf->global->INVOICE_USE_SITUATION) {
180 $head[$h][0] = DOL_URL_ROOT.
'/admin/facture_situation.php';
181 $head[$h][1] = $langs->trans(
"InvoiceSituation");
182 $head[$h][2] =
'situation';
200 global $db, $langs, $conf;
205 $head[$h][0] = DOL_URL_ROOT .
'/compta/facture/card-rec.php?id=' . $object->id;
206 $head[$h][1] = $langs->trans(
"RepeatableInvoice");
207 $head[$h][2] =
'card';
229 global $db, $langs, $conf;
234 $head[$h][0] = DOL_URL_ROOT .
'/fourn/facture/card-rec.php?id=' . $object->id;
235 $head[$h][1] = $langs->trans(
"RepeatableSupplierInvoice");
236 $head[$h][2] =
'card';
258 global $conf, $db, $langs, $user;
259 if (($mode ==
'customers' &&
isModEnabled(
'facture') && !empty($user->rights->facture->lire))
260 || ($mode =
'suppliers') && (
isModEnabled(
'fournisseur') ||
isModEnabled(
'supplier_invoice')) && !empty($user->rights->facture->lire)
262 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
264 $now = date_create(date(
'Y-m-d',
dol_now()));
265 $datenowsub30 = date_create(date(
'Y-m-d',
dol_now()));
266 $datenowsub15 = date_create(date(
'Y-m-d',
dol_now()));
267 $datenowadd30 = date_create(date(
'Y-m-d',
dol_now()));
268 $datenowadd15 = date_create(date(
'Y-m-d',
dol_now()));
269 $interval30days = date_interval_create_from_date_string(
'30 days');
270 $interval15days = date_interval_create_from_date_string(
'15 days');
271 date_sub($datenowsub30, $interval30days);
272 date_sub($datenowsub15, $interval15days);
273 date_add($datenowadd30, $interval30days);
274 date_add($datenowadd15, $interval15days);
277 $sql .=
" sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($datenowsub30,
'Y-m-d').
"'", 1, 0).
") as nblate30";
278 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($datenowsub15,
'Y-m-d').
"'", 1, 0).
") as nblate15";
279 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($now,
'Y-m-d').
"'", 1, 0).
") as nblatenow";
280 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement >= '".date_format($now,
'Y-m-d').
"' OR f.date_lim_reglement IS NULL", 1, 0).
") as nbnotlatenow";
281 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement > '".date_format($datenowadd15,
'Y-m-d').
"'", 1, 0).
") as nbnotlate15";
282 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement > '".date_format($datenowadd30,
'Y-m-d').
"'", 1, 0).
") as nbnotlate30";
283 if ($mode ==
'customers') {
284 $element =
'invoice';
285 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
286 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
287 $element =
'supplier_invoice';
288 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
292 $sql .=
" WHERE f.entity IN (".getEntity($element).
")";
293 $sql .=
" AND f.type <> 2";
294 $sql .=
" AND f.fk_statut = 1";
295 if (isset($user->socid) && $user->socid > 0) {
296 $sql .=
" AND f.fk_soc = ".((int) $user->socid);
299 $resql = $db->query($sql);
301 $num = $db->num_rows(
$resql);
304 $dataseries = array();
307 $obj = $db->fetch_object(
$resql);
316 $dataseries[$i]=array($langs->transnoentitiesnoconv(
'NbOfOpenInvoices'), $obj->nblate30, $obj->nblate15 - $obj->nblate30, $obj->nblatenow - $obj->nblate15, $obj->nbnotlatenow - $obj->nbnotlate15, $obj->nbnotlate15 - $obj->nbnotlate30, $obj->nbnotlate30);
319 if (!empty($dataseries[0])) {
320 foreach ($dataseries[0] as $key => $value) {
321 if (is_numeric($value)) {
327 $langs->trans(
'InvoiceLate30Days'),
328 $langs->trans(
'InvoiceLate15Days'),
329 $langs->trans(
'InvoiceLateMinus15Days'),
330 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate') : $langs->trans(
"InvoiceToPay"),
331 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate15Days') : $langs->trans(
"InvoiceToPay15Days"),
332 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate30Days') : $langs->trans(
"InvoiceToPay30Days"),
335 $colorseries = array($badgeStatus8, $badgeStatus1, $badgeStatus3, $badgeStatus4, $badgeStatus11,
'-'.$badgeStatus11);
337 $result =
'<div class="div-table-responsive-no-min">';
338 $result .=
'<table class="noborder nohover centpercent">';
339 $result .=
'<tr class="liste_titre">';
340 $result .=
'<td>'.$langs->trans(
"NbOfOpenInvoices").
' - ';
341 if ($mode ==
'customers') {
342 $result .= $langs->trans(
"CustomerInvoice");
343 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
344 $result .= $langs->trans(
"SupplierInvoice");
351 if ($conf->use_javascript_ajax) {
354 $dolgraph->SetData($dataseries);
356 $dolgraph->setLegend($legend);
358 $dolgraph->SetDataColor(array_values($colorseries));
359 $dolgraph->setShowLegend(2);
360 $dolgraph->setShowPercent(1);
361 $dolgraph->SetType(array(
'bars',
'bars',
'bars',
'bars',
'bars',
'bars'));
363 $dolgraph->setHeight(
'160');
364 $dolgraph->setWidth(
'450');
365 $dolgraph->setHideXValues(
true);
366 if ($mode ==
'customers') {
367 $dolgraph->draw(
'idgraphcustomerinvoices');
368 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
369 $dolgraph->draw(
'idgraphfourninvoices');
373 $result .=
'<tr maxwidth="255">';
374 $result .=
'<td class="center">'.$dolgraph->show($total ? 0 : $langs->trans(
"NoOpenInvoice")).
'</td>';
380 $result .=
'</table>';
398 global $conf, $db, $langs, $user, $hookmanager;
400 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
403 $tmpinvoice =
new Facture($db);
405 $sql =
"SELECT f.rowid, f.ref, f.datef as date, f.total_ht, f.total_tva, f.total_ttc, f.ref_client";
406 $sql .=
", f.type, f.fk_statut as status, f.paye";
407 $sql .=
", s.nom as name";
408 $sql .=
", s.rowid as socid, s.email";
409 $sql .=
", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
410 $sql .=
", cc.rowid as country_id, cc.code as country_code";
411 if (empty($user->rights->societe->client->voir) && !$socid) {
412 $sql .=
", sc.fk_soc, sc.fk_user ";
414 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f, ".MAIN_DB_PREFIX.
"societe as s LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as cc ON cc.rowid = s.fk_pays";
415 if (empty($user->rights->societe->client->voir) && !$socid) {
416 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
418 $sql .=
" WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT;
419 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
420 if (empty($user->rights->societe->client->voir) && !$socid) {
421 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
425 $sql .=
" AND f.fk_soc = ".((int) $socid);
428 $parameters = array();
429 $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerDraft', $parameters);
430 $sql .= $hookmanager->resPrint;
432 $sql .=
" GROUP BY f.rowid, f.ref, f.datef, f.total_ht, f.total_tva, f.total_ttc, f.ref_client, f.type, f.fk_statut, f.paye,";
433 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,";
434 $sql .=
" cc.rowid, cc.code";
435 if (empty($user->rights->societe->client->voir) && !$socid) {
436 $sql .=
", sc.fk_soc, sc.fk_user";
440 $parameters = array();
441 $reshook = $hookmanager->executeHooks(
'printFieldListGroupByCustomerDraft', $parameters);
442 $sql .= $hookmanager->resPrint;
444 $resql = $db->query($sql);
447 $num = $db->num_rows(
$resql);
448 $nbofloop = min($num, $maxofloop);
450 $result .=
'<div class="div-table-responsive-no-min">';
451 $result .=
'<table class="noborder centpercent">';
453 $result .=
'<tr class="liste_titre">';
454 $result .=
'<th colspan="3">';
455 $result .= $langs->trans(
"CustomersDraftInvoices").
' ';
456 $result .=
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?search_status='.
Facture::STATUS_DRAFT.
'">';
457 $result .=
'<span class="badge marginleftonlyshort">'.$num.
'</span>';
463 $companystatic =
new Societe($db);
468 while ($i < $nbofloop) {
469 $obj = $db->fetch_object(
$resql);
471 if ($i >= $maxCount) {
474 $tot_ttc += $obj->total_ttc;
478 $tmpinvoice->id = $obj->rowid;
479 $tmpinvoice->ref = $obj->ref;
480 $tmpinvoice->date = $db->jdate($obj->date);
481 $tmpinvoice->type = $obj->type;
482 $tmpinvoice->total_ht = $obj->total_ht;
483 $tmpinvoice->total_tva = $obj->total_tva;
484 $tmpinvoice->total_ttc = $obj->total_ttc;
485 $tmpinvoice->ref_client = $obj->ref_client;
486 $tmpinvoice->statut = $obj->status;
487 $tmpinvoice->paye = $obj->paye;
489 $companystatic->id = $obj->socid;
490 $companystatic->name = $obj->name;
491 $companystatic->email = $obj->email;
492 $companystatic->country_id = $obj->country_id;
493 $companystatic->country_code = $obj->country_code;
494 $companystatic->client = 1;
495 $companystatic->code_client = $obj->code_client;
496 $companystatic->code_fournisseur = $obj->code_fournisseur;
497 $companystatic->code_compta = $obj->code_compta;
498 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
500 $result .=
'<tr class="oddeven">';
501 $result .=
'<td class="nowrap tdoverflowmax100">';
502 $result .= $tmpinvoice->getNomUrl(1,
'');
504 $result .=
'<td class="nowrap tdoverflowmax100">';
505 $result .= $companystatic->getNomUrl(1,
'customer');
507 $result .=
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
509 $tot_ttc += $obj->total_ttc;
514 $result .=
'<tr class="oddeven">';
515 $result .=
'<td class="nowrap" colspan="3">';
516 $result .=
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
518 $result .=
"</tr>\n";
521 $result .=
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
522 $result .=
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
525 $result .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
527 $result .=
"</table></div>";
545 global $conf, $db, $langs, $user, $hookmanager;
547 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
552 $sql =
"SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier, f.fk_statut as status, f.paye";
553 $sql .=
", s.nom as name";
554 $sql .=
", s.rowid as socid, s.email";
555 $sql .=
", s.code_client, s.code_compta";
556 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
557 $sql .=
", cc.rowid as country_id, cc.code as country_code";
558 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f, ".MAIN_DB_PREFIX.
"societe as s LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as cc ON cc.rowid = s.fk_pays";
559 if (empty($user->rights->societe->client->voir) && !$socid) {
560 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
562 $sql .=
" WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT;
563 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
')';
564 if (empty($user->rights->societe->client->voir) && !$socid) {
565 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
568 $sql .=
" AND f.fk_soc = ".((int) $socid);
571 $parameters = array();
572 $reshook = $hookmanager->executeHooks(
'printFieldListWhereSupplierDraft', $parameters);
573 $sql .= $hookmanager->resPrint;
574 $resql = $db->query($sql);
577 $num = $db->num_rows(
$resql);
578 $nbofloop = min($num, $maxofloop);
580 $result .=
'<div class="div-table-responsive-no-min">';
581 $result .=
'<table class="noborder centpercent">';
583 $result .=
'<tr class="liste_titre">';
584 $result .=
'<th colspan="3">';
585 $result .= $langs->trans(
"SuppliersDraftInvoices").
' ';
587 $result .=
'<span class="badge marginleftonlyshort">'.$num.
'</span>';
593 $companystatic =
new Societe($db);
598 while ($i < $nbofloop) {
599 $obj = $db->fetch_object(
$resql);
601 if ($i >= $maxCount) {
604 $tot_ttc += $obj->total_ttc;
608 $facturesupplierstatic->ref = $obj->ref;
609 $facturesupplierstatic->id = $obj->rowid;
610 $facturesupplierstatic->total_ht = $obj->total_ht;
611 $facturesupplierstatic->total_tva = $obj->total_tva;
612 $facturesupplierstatic->total_ttc = $obj->total_ttc;
613 $facturesupplierstatic->ref_supplier = $obj->ref_supplier;
614 $facturesupplierstatic->type = $obj->type;
615 $facturesupplierstatic->statut = $obj->status;
616 $facturesupplierstatic->paye = $obj->paye;
618 $companystatic->id = $obj->socid;
619 $companystatic->name = $obj->name;
620 $companystatic->email = $obj->email;
621 $companystatic->country_id = $obj->country_id;
622 $companystatic->country_code = $obj->country_code;
623 $companystatic->fournisseur = 1;
624 $companystatic->code_client = $obj->code_client;
625 $companystatic->code_fournisseur = $obj->code_fournisseur;
626 $companystatic->code_compta = $obj->code_compta;
627 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
629 $result .=
'<tr class="oddeven">';
630 $result .=
'<td class="nowrap tdoverflowmax100">';
631 $result .= $facturesupplierstatic->getNomUrl(1,
'');
633 $result .=
'<td class="nowrap tdoverflowmax100">';
634 $result .= $companystatic->getNomUrl(1,
'supplier');
636 $result .=
'<td class="right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
638 $tot_ttc += $obj->total_ttc;
643 $result .=
'<tr class="oddeven">';
644 $result .=
'<td class="nowrap" colspan="3">';
645 $result .=
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
647 $result .=
"</tr>\n";
650 $result .=
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
651 $result .=
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
654 $result .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
656 $result .=
"</table></div>";
675 global $conf, $db, $langs, $user;
677 $sql =
"SELECT f.rowid, f.entity, f.ref, f.fk_statut as status, f.paye, f.type, f.total_ht, f.total_tva, f.total_ttc, f.datec,";
678 $sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client";
679 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
680 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
681 if (empty($user->rights->societe->client->voir) && !$socid) {
682 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
684 $sql .=
" WHERE f.fk_soc = s.rowid";
685 $sql .=
" AND f.entity IN (".getEntity(
'facture').
")";
687 $sql .=
" AND f.fk_soc = ".((int) $socid);
689 if (empty($user->rights->societe->client->voir) && !$socid) {
690 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
692 $sql .=
" ORDER BY f.tms DESC";
693 $sql .= $db->plimit($maxCount, 0);
695 $resql = $db->query($sql);
700 $num = $db->num_rows(
$resql);
702 $result =
'<div class="div-table-responsive-no-min">';
703 $result .=
'<table class="noborder centpercent">';
705 $result .=
'<tr class="liste_titre">';
706 $result .=
'<th colspan="3">'.$langs->trans(
"LastCustomersBills", $maxCount).
'</th>';
707 $result .=
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
708 $result .=
'<th class="right"></th>';
712 $result .=
'</table>';
718 $objectstatic =
new Facture($db);
719 $companystatic =
new Societe($db);
723 $obj = $db->fetch_object(
$resql);
725 $objectstatic->id = $obj->rowid;
726 $objectstatic->ref = $obj->ref;
727 $objectstatic->paye = $obj->paye;
728 $objectstatic->statut = $obj->status;
729 $objectstatic->total_ht = $obj->total_ht;
730 $objectstatic->total_tva = $obj->total_tva;
731 $objectstatic->total_ttc = $obj->total_ttc;
732 $objectstatic->type = $obj->type;
734 $companystatic->id = $obj->socid;
735 $companystatic->name = $obj->socname;
736 $companystatic->client = $obj->client;
737 $companystatic->canvas = $obj->canvas;
740 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
742 $result .=
'<tr class="nowrap">';
744 $result .=
'<td class="oddeven">';
745 $result .=
'<table class="nobordernopadding">';
746 $result .=
'<tr class="nocellnopadd">';
748 $result .=
'<td width="96" class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
749 $result .=
'<td width="16" class="nobordernopadding nowrap"> </td>';
750 $result .=
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
753 $result .=
'</table>';
756 $result .=
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
757 $result .=
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
758 $result .=
'<td class="right amount">'.price($obj->total_ttc).
'</td>';
761 $payment = $objectstatic->getSommePaiement();
762 $result .=
'<td class="right">'.$objectstatic->getLibStatut(5, $payment).
'</td>';
769 $result .=
'</table>';
783 global $conf, $db, $langs, $user;
785 $sql =
"SELECT f.rowid, f.entity, f.ref, f.fk_statut as status, f.paye, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier, f.datec,";
786 $sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client";
787 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
788 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
789 if (empty($user->rights->societe->client->voir) && !$socid) {
790 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
792 $sql .=
" WHERE f.fk_soc = s.rowid";
793 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
795 $sql .=
" AND f.fk_soc = ".((int) $socid);
797 if (empty($user->rights->societe->client->voir) && !$socid) {
798 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
800 $sql .=
" ORDER BY f.tms DESC";
801 $sql .= $db->plimit($maxCount, 0);
803 $resql = $db->query($sql);
809 $num = $db->num_rows(
$resql);
811 $result =
'<div class="div-table-responsive-no-min">';
812 $result .=
'<table class="noborder centpercent">';
813 $result .=
'<tr class="liste_titre">';
814 $result .=
'<th colspan="3">'.$langs->trans(
"BoxTitleLastSupplierBills", $maxCount).
'</th>';
815 $result .=
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
816 $result .=
'<th class="right"></th>';
820 $result .=
'</table>';
826 $companystatic =
new Societe($db);
831 $obj = $db->fetch_object(
$resql);
833 $objectstatic->id = $obj->rowid;
834 $objectstatic->ref = $obj->ref;
835 $objectstatic->paye = $obj->paye;
836 $objectstatic->statut = $obj->status;
837 $objectstatic->total_ht = $obj->total_ht;
838 $objectstatic->total_tva = $obj->total_tva;
839 $objectstatic->total_ttc = $obj->total_ttc;
840 $objectstatic->type = $obj->type;
842 $companystatic->id = $obj->socid;
843 $companystatic->name = $obj->socname;
844 $companystatic->client = $obj->client;
845 $companystatic->canvas = $obj->canvas;
848 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
850 $result .=
'<tr class="nowrap">';
852 $result .=
'<td class="oddeven">';
853 $result .=
'<table class="nobordernopadding">';
854 $result .=
'<tr class="nocellnopadd">';
856 $result .=
'<td width="96" class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
857 $result .=
'<td width="16" class="nobordernopadding nowrap"> </td>';
858 $result .=
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
861 $result .=
'</table>';
864 $result .=
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
866 $result .=
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
868 $result .=
'<td class="amount right">'.price($obj->total_ttc).
'</td>';
870 $result .=
'<td class="right">'.$objectstatic->getLibStatut(5).
'</td>';
877 $result .=
'</table>';
891 global $conf, $db, $langs, $user, $hookmanager;
895 if (
isModEnabled(
'facture') && !empty($user->rights->facture->lire)) {
896 $tmpinvoice =
new Facture($db);
898 $sql =
"SELECT f.rowid, f.ref, f.fk_statut as status, f.datef, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms";
899 $sql .=
", f.date_lim_reglement as datelimite";
900 $sql .=
", s.nom as name";
901 $sql .=
", s.rowid as socid, s.email";
902 $sql .=
", s.code_client, s.code_compta";
903 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
904 $sql .=
", cc.rowid as country_id, cc.code as country_code";
905 $sql .=
", sum(pf.amount) as am";
906 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX.
"facture as f";
907 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf on f.rowid=pf.fk_facture";
908 if (empty($user->rights->societe->client->voir) && !$socid) {
909 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
911 $sql .=
" WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = ".Facture::STATUS_VALIDATED;
912 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
')';
913 if (empty($user->rights->societe->client->voir) && !$socid) {
914 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
917 $sql .=
" AND f.fk_soc = ".((int) $socid);
920 $parameters = array();
921 $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerUnpaid', $parameters);
922 $sql .= $hookmanager->resPrint;
924 $sql .=
" GROUP BY f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,";
925 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code";
926 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
927 $sql .=
" ORDER BY f.datef ASC, f.ref ASC";
929 $resql = $db->query($sql);
931 $num = $db->num_rows(
$resql);
937 print
'<div class="div-table-responsive-no-min">';
938 print
'<table class="noborder centpercent">';
940 print
'<tr class="liste_titre">';
941 print
'<th colspan="2">';
942 print $langs->trans(
"BillsCustomersUnpaid", $num).
' ';
944 print
'<span class="badge">'.$num.
'</span>';
948 print
'<th class="right">'.$langs->trans(
"DateDue").
'</th>';
949 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
950 print
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
952 print
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
953 print
'<th class="right">'.$langs->trans(
"Received").
'</th>';
954 print
'<th width="16"> </th>';
957 $societestatic =
new Societe($db);
958 $total_ttc = $totalam = $total = 0;
960 $obj = $db->fetch_object(
$resql);
962 if ($i >= $maxCount) {
965 $total += $obj->total_ht;
966 $total_ttc += $obj->total_ttc;
967 $totalam += $obj->am;
971 $tmpinvoice->ref = $obj->ref;
972 $tmpinvoice->id = $obj->rowid;
973 $tmpinvoice->total_ht = $obj->total_ht;
974 $tmpinvoice->total_tva = $obj->total_tva;
975 $tmpinvoice->total_ttc = $obj->total_ttc;
976 $tmpinvoice->type = $obj->type;
977 $tmpinvoice->statut = $obj->status;
978 $tmpinvoice->paye = $obj->paye;
979 $tmpinvoice->date_lim_reglement = $db->jdate($obj->datelimite);
981 $societestatic->id = $obj->socid;
982 $societestatic->name = $obj->name;
983 $societestatic->email = $obj->email;
984 $societestatic->country_id = $obj->country_id;
985 $societestatic->country_code = $obj->country_code;
986 $societestatic->client = 1;
987 $societestatic->code_client = $obj->code_client;
988 $societestatic->code_fournisseur = $obj->code_fournisseur;
989 $societestatic->code_compta = $obj->code_compta;
990 $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
992 print
'<tr class="oddeven">';
993 print
'<td class="nowrap">';
995 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
996 print
'<td class="nobordernopadding nowrap">';
997 print $tmpinvoice->getNomUrl(1,
'');
999 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
1002 $urlsource = $_SERVER[
'PHP_SELF'].
'?facid='.$obj->rowid;
1003 print $formfile->getDocumentsLink($tmpinvoice->element, $filename, $filedir);
1004 print
'</td></tr></table>';
1007 print
'<td class="nowrap tdoverflowmax100">';
1008 print $societestatic->getNomUrl(1,
'customer');
1010 print
'<td class="right">';
1012 if ($tmpinvoice->hasDelay()) {
1016 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1017 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
1019 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
1020 print
'<td class="nowrap right"><span class="amount">'.price($obj->am).
'</span></td>';
1021 print
'<td>'.$tmpinvoice->getLibStatut(3, $obj->am).
'</td>';
1024 $total_ttc += $obj->total_ttc;
1025 $total += $obj->total_ht;
1026 $totalam += $obj->am;
1033 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1036 print
'<tr class="oddeven">';
1037 print
'<td class="nowrap" colspan="'.$colspan.
'">';
1038 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1043 print
'<tr class="liste_total"><td colspan="2">'.$langs->trans(
"Total").
' <span style="font-weight: normal">('.$langs->trans(
"RemainderToTake").
': '.
price($total_ttc - $totalam).
')</span> </td>';
1044 print
'<td> </td>';
1045 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1046 print
'<td class="right"><span class="amount">'.price($total).
'</span></td>';
1048 print
'<td class="nowrap right"><span class="amount">'.price($total_ttc).
'</span></td>';
1049 print
'<td class="nowrap right"><span class="amount">'.price($totalam).
'</span></td>';
1050 print
'<td> </td>';
1054 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1057 print
'<tr class="oddeven"><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
1059 print
'</table></div><br>';
1079 global $conf, $db, $langs, $user, $hookmanager;
1083 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) {
1086 $sql =
"SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye";
1087 $sql .=
", ff.date_lim_reglement";
1088 $sql .=
", s.nom as name";
1089 $sql .=
", s.rowid as socid, s.email";
1090 $sql .=
", s.code_client, s.code_compta";
1091 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
1092 $sql .=
", sum(pf.amount) as am";
1093 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"facture_fourn as ff";
1094 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
1095 if (empty($user->rights->societe->client->voir) && !$socid) {
1096 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1098 $sql .=
" WHERE s.rowid = ff.fk_soc";
1099 $sql .=
" AND ff.entity = ".$conf->entity;
1100 $sql .=
" AND ff.paye = 0";
1101 $sql .=
" AND ff.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
1102 if (empty($user->rights->societe->client->voir) && !$socid) {
1103 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1106 $sql .=
" AND ff.fk_soc = ".((int) $socid);
1109 $parameters = array();
1110 $reshook = $hookmanager->executeHooks(
'printFieldListWhereSupplierUnpaid', $parameters);
1111 $sql .= $hookmanager->resPrint;
1113 $sql .=
" GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.type, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye, ff.date_lim_reglement,";
1114 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
1115 $sql .=
" ORDER BY ff.date_lim_reglement ASC";
1117 $resql = $db->query($sql);
1119 $num = $db->num_rows(
$resql);
1124 print
'<div class="div-table-responsive-no-min">';
1125 print
'<table class="noborder centpercent">';
1127 print
'<tr class="liste_titre">';
1128 print
'<th colspan="2">';
1129 print $langs->trans(
"BillsSuppliersUnpaid", $num).
' ';
1131 print
'<span class="badge">'.$num.
'</span>';
1135 print
'<th class="right">'.$langs->trans(
"DateDue").
'</th>';
1136 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1137 print
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
1139 print
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
1140 print
'<th class="right">'.$langs->trans(
"Paid").
'</th>';
1141 print
'<th width="16"> </th>';
1143 $societestatic =
new Societe($db);
1146 $total = $total_ttc = $totalam = 0;
1148 $obj = $db->fetch_object(
$resql);
1150 if ($i >= $maxCount) {
1153 $total += $obj->total_ht;
1154 $total_ttc += $obj->total_ttc;
1158 $facstatic->ref = $obj->ref;
1159 $facstatic->id = $obj->rowid;
1160 $facstatic->type = $obj->type;
1161 $facstatic->total_ht = $obj->total_ht;
1162 $facstatic->total_tva = $obj->total_tva;
1163 $facstatic->total_ttc = $obj->total_ttc;
1164 $facstatic->statut = $obj->status;
1165 $facstatic->paye = $obj->paye;
1167 $societestatic->id = $obj->socid;
1168 $societestatic->name = $obj->name;
1169 $societestatic->email = $obj->email;
1170 $societestatic->client = 0;
1171 $societestatic->fournisseur = 1;
1172 $societestatic->code_client = $obj->code_client;
1173 $societestatic->code_fournisseur = $obj->code_fournisseur;
1174 $societestatic->code_compta = $obj->code_compta;
1175 $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1177 print
'<tr class="oddeven">';
1178 print
'<td class="nowrap tdoverflowmax100">';
1179 print $facstatic->getNomUrl(1,
'');
1181 print
'<td class="nowrap tdoverflowmax100">'.$societestatic->getNomUrl(1,
'supplier').
'</td>';
1182 print
'<td class="right">'.dol_print_date($db->jdate($obj->date_lim_reglement),
'day').
'</td>';
1183 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1184 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
1186 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
1187 print
'<td class="nowrap right"><span class="amount">'.price($obj->am).
'</span></td>';
1188 print
'<td>'.$facstatic->getLibStatut(3, $obj->am).
'</td>';
1190 $total += $obj->total_ht;
1191 $total_ttc += $obj->total_ttc;
1192 $totalam += $obj->am;
1198 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1201 print
'<tr class="oddeven">';
1202 print
'<td class="nowrap" colspan="'.$colspan.
'">';
1203 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1208 print
'<tr class="liste_total"><td colspan="2">'.$langs->trans(
"Total").
' <span style="font-weight: normal">('.$langs->trans(
"RemainderToPay").
': '.
price($total_ttc - $totalam).
')</span> </td>';
1209 print
'<td> </td>';
1210 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1211 print
'<td class="right">'.price($total).
'</td>';
1213 print
'<td class="nowrap right">'.price($total_ttc).
'</td>';
1214 print
'<td class="nowrap right">'.price($totalam).
'</td>';
1215 print
'<td> </td>';
1219 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1222 print
'<tr class="oddeven"><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
1224 print
'</table></div><br>';