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 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
285 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
286 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
290 $sql .=
" WHERE f.type <> 2";
291 $sql .=
" AND f.fk_statut = 1";
292 if (isset($user->socid) && $user->socid > 0) {
293 $sql .=
" AND f.fk_soc = ".((int) $user->socid);
296 $resql = $db->query($sql);
298 $num = $db->num_rows(
$resql);
301 $dataseries = array();
304 $obj = $db->fetch_object(
$resql);
313 $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);
316 if (!empty($dataseries[0])) {
317 foreach ($dataseries[0] as $key => $value) {
318 if (is_numeric($value)) {
324 $langs->trans(
'InvoiceLate30Days'),
325 $langs->trans(
'InvoiceLate15Days'),
326 $langs->trans(
'InvoiceLateMinus15Days'),
327 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate') : $langs->trans(
"InvoiceToPay"),
328 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate15Days') : $langs->trans(
"InvoiceToPay15Days"),
329 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate30Days') : $langs->trans(
"InvoiceToPay30Days"),
332 $colorseries = array($badgeStatus8, $badgeStatus1, $badgeStatus3, $badgeStatus4, $badgeStatus11,
'-'.$badgeStatus11);
334 $result =
'<div class="div-table-responsive-no-min">';
335 $result .=
'<table class="noborder nohover centpercent">';
336 $result .=
'<tr class="liste_titre">';
337 $result .=
'<td>'.$langs->trans(
"NbOfOpenInvoices").
' - ';
338 if ($mode ==
'customers') {
339 $result .= $langs->trans(
"CustomerInvoice");
340 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
341 $result .= $langs->trans(
"SupplierInvoice");
348 if ($conf->use_javascript_ajax) {
351 $dolgraph->SetData($dataseries);
353 $dolgraph->setLegend($legend);
355 $dolgraph->SetDataColor(array_values($colorseries));
356 $dolgraph->setShowLegend(2);
357 $dolgraph->setShowPercent(1);
358 $dolgraph->SetType(array(
'bars',
'bars',
'bars',
'bars',
'bars',
'bars'));
360 $dolgraph->setHeight(
'160');
361 $dolgraph->setWidth(
'450');
362 $dolgraph->setHideXValues(
true);
363 if ($mode ==
'customers') {
364 $dolgraph->draw(
'idgraphcustomerinvoices');
365 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
366 $dolgraph->draw(
'idgraphfourninvoices');
370 $result .=
'<tr maxwidth="255">';
371 $result .=
'<td class="center">'.$dolgraph->show($total ? 0 : $langs->trans(
"NoOpenInvoice")).
'</td>';
377 $result .=
'</table>';
395 global $conf, $db, $langs, $user, $hookmanager;
397 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
400 $tmpinvoice =
new Facture($db);
402 $sql =
"SELECT f.rowid, f.ref, f.datef as date, f.total_ht, f.total_tva, f.total_ttc, f.ref_client";
403 $sql .=
", f.type, f.fk_statut as status, f.paye";
404 $sql .=
", s.nom as name";
405 $sql .=
", s.rowid as socid, s.email";
406 $sql .=
", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
407 $sql .=
", cc.rowid as country_id, cc.code as country_code";
408 if (empty($user->rights->societe->client->voir) && !$socid) {
409 $sql .=
", sc.fk_soc, sc.fk_user ";
411 $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";
412 if (empty($user->rights->societe->client->voir) && !$socid) {
413 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
415 $sql .=
" WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT;
416 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
417 if (empty($user->rights->societe->client->voir) && !$socid) {
418 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
422 $sql .=
" AND f.fk_soc = ".((int) $socid);
425 $parameters = array();
426 $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerDraft', $parameters);
427 $sql .= $hookmanager->resPrint;
429 $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,";
430 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,";
431 $sql .=
" cc.rowid, cc.code";
432 if (empty($user->rights->societe->client->voir) && !$socid) {
433 $sql .=
", sc.fk_soc, sc.fk_user";
437 $parameters = array();
438 $reshook = $hookmanager->executeHooks(
'printFieldListGroupByCustomerDraft', $parameters);
439 $sql .= $hookmanager->resPrint;
441 $resql = $db->query($sql);
444 $num = $db->num_rows(
$resql);
445 $nbofloop = min($num, $maxofloop);
447 $result .=
'<div class="div-table-responsive-no-min">';
448 $result .=
'<table class="noborder centpercent">';
450 $result .=
'<tr class="liste_titre">';
451 $result .=
'<th colspan="3">';
452 $result .= $langs->trans(
"CustomersDraftInvoices").
' ';
453 $result .=
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?search_status='.
Facture::STATUS_DRAFT.
'">';
454 $result .=
'<span class="badge marginleftonlyshort">'.$num.
'</span>';
460 $companystatic =
new Societe($db);
465 while ($i < $nbofloop) {
466 $obj = $db->fetch_object(
$resql);
468 if ($i >= $maxCount) {
471 $tot_ttc += $obj->total_ttc;
475 $tmpinvoice->id = $obj->rowid;
476 $tmpinvoice->ref = $obj->ref;
477 $tmpinvoice->date = $db->jdate($obj->date);
478 $tmpinvoice->type = $obj->type;
479 $tmpinvoice->total_ht = $obj->total_ht;
480 $tmpinvoice->total_tva = $obj->total_tva;
481 $tmpinvoice->total_ttc = $obj->total_ttc;
482 $tmpinvoice->ref_client = $obj->ref_client;
483 $tmpinvoice->statut = $obj->status;
484 $tmpinvoice->paye = $obj->paye;
486 $companystatic->id = $obj->socid;
487 $companystatic->name = $obj->name;
488 $companystatic->email = $obj->email;
489 $companystatic->country_id = $obj->country_id;
490 $companystatic->country_code = $obj->country_code;
491 $companystatic->client = 1;
492 $companystatic->code_client = $obj->code_client;
493 $companystatic->code_fournisseur = $obj->code_fournisseur;
494 $companystatic->code_compta = $obj->code_compta;
495 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
497 $result .=
'<tr class="oddeven">';
498 $result .=
'<td class="nowrap tdoverflowmax100">';
499 $result .= $tmpinvoice->getNomUrl(1,
'');
501 $result .=
'<td class="nowrap tdoverflowmax100">';
502 $result .= $companystatic->getNomUrl(1,
'customer');
504 $result .=
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
506 $tot_ttc += $obj->total_ttc;
511 $result .=
'<tr class="oddeven">';
512 $result .=
'<td class="nowrap" colspan="3">';
513 $result .=
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
515 $result .=
"</tr>\n";
518 $result .=
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
519 $result .=
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
522 $result .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
524 $result .=
"</table></div>";
542 global $conf, $db, $langs, $user, $hookmanager;
544 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
549 $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";
550 $sql .=
", s.nom as name";
551 $sql .=
", s.rowid as socid, s.email";
552 $sql .=
", s.code_client, s.code_compta";
553 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
554 $sql .=
", cc.rowid as country_id, cc.code as country_code";
555 $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";
556 if (empty($user->rights->societe->client->voir) && !$socid) {
557 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
559 $sql .=
" WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT;
560 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
')';
561 if (empty($user->rights->societe->client->voir) && !$socid) {
562 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
565 $sql .=
" AND f.fk_soc = ".((int) $socid);
568 $parameters = array();
569 $reshook = $hookmanager->executeHooks(
'printFieldListWhereSupplierDraft', $parameters);
570 $sql .= $hookmanager->resPrint;
571 $resql = $db->query($sql);
574 $num = $db->num_rows(
$resql);
575 $nbofloop = min($num, $maxofloop);
577 $result .=
'<div class="div-table-responsive-no-min">';
578 $result .=
'<table class="noborder centpercent">';
580 $result .=
'<tr class="liste_titre">';
581 $result .=
'<th colspan="3">';
582 $result .= $langs->trans(
"SuppliersDraftInvoices").
' ';
584 $result .=
'<span class="badge marginleftonlyshort">'.$num.
'</span>';
590 $companystatic =
new Societe($db);
595 while ($i < $nbofloop) {
596 $obj = $db->fetch_object(
$resql);
598 if ($i >= $maxCount) {
601 $tot_ttc += $obj->total_ttc;
605 $facturesupplierstatic->ref = $obj->ref;
606 $facturesupplierstatic->id = $obj->rowid;
607 $facturesupplierstatic->total_ht = $obj->total_ht;
608 $facturesupplierstatic->total_tva = $obj->total_tva;
609 $facturesupplierstatic->total_ttc = $obj->total_ttc;
610 $facturesupplierstatic->ref_supplier = $obj->ref_supplier;
611 $facturesupplierstatic->type = $obj->type;
612 $facturesupplierstatic->statut = $obj->status;
613 $facturesupplierstatic->paye = $obj->paye;
615 $companystatic->id = $obj->socid;
616 $companystatic->name = $obj->name;
617 $companystatic->email = $obj->email;
618 $companystatic->country_id = $obj->country_id;
619 $companystatic->country_code = $obj->country_code;
620 $companystatic->fournisseur = 1;
621 $companystatic->code_client = $obj->code_client;
622 $companystatic->code_fournisseur = $obj->code_fournisseur;
623 $companystatic->code_compta = $obj->code_compta;
624 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
626 $result .=
'<tr class="oddeven">';
627 $result .=
'<td class="nowrap tdoverflowmax100">';
628 $result .= $facturesupplierstatic->getNomUrl(1,
'');
630 $result .=
'<td class="nowrap tdoverflowmax100">';
631 $result .= $companystatic->getNomUrl(1,
'supplier');
633 $result .=
'<td class="right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
635 $tot_ttc += $obj->total_ttc;
640 $result .=
'<tr class="oddeven">';
641 $result .=
'<td class="nowrap" colspan="3">';
642 $result .=
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
644 $result .=
"</tr>\n";
647 $result .=
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
648 $result .=
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
651 $result .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
653 $result .=
"</table></div>";
672 global $conf, $db, $langs, $user;
674 $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,";
675 $sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client";
676 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
677 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
678 if (empty($user->rights->societe->client->voir) && !$socid) {
679 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
681 $sql .=
" WHERE f.fk_soc = s.rowid";
682 $sql .=
" AND f.entity IN (".getEntity(
'facture').
")";
684 $sql .=
" AND f.fk_soc = ".((int) $socid);
686 if (empty($user->rights->societe->client->voir) && !$socid) {
687 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
689 $sql .=
" ORDER BY f.tms DESC";
690 $sql .= $db->plimit($maxCount, 0);
692 $resql = $db->query($sql);
697 $num = $db->num_rows(
$resql);
699 $result =
'<div class="div-table-responsive-no-min">';
700 $result .=
'<table class="noborder centpercent">';
702 $result .=
'<tr class="liste_titre">';
703 $result .=
'<th colspan="3">'.$langs->trans(
"LastCustomersBills", $maxCount).
'</th>';
704 $result .=
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
705 $result .=
'<th class="right"></th>';
709 $result .=
'</table>';
715 $objectstatic =
new Facture($db);
716 $companystatic =
new Societe($db);
720 $obj = $db->fetch_object(
$resql);
722 $objectstatic->id = $obj->rowid;
723 $objectstatic->ref = $obj->ref;
724 $objectstatic->paye = $obj->paye;
725 $objectstatic->statut = $obj->status;
726 $objectstatic->total_ht = $obj->total_ht;
727 $objectstatic->total_tva = $obj->total_tva;
728 $objectstatic->total_ttc = $obj->total_ttc;
729 $objectstatic->type = $obj->type;
731 $companystatic->id = $obj->socid;
732 $companystatic->name = $obj->socname;
733 $companystatic->client = $obj->client;
734 $companystatic->canvas = $obj->canvas;
737 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
739 $result .=
'<tr class="nowrap">';
741 $result .=
'<td class="oddeven">';
742 $result .=
'<table class="nobordernopadding">';
743 $result .=
'<tr class="nocellnopadd">';
745 $result .=
'<td width="96" class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
746 $result .=
'<td width="16" class="nobordernopadding nowrap"> </td>';
747 $result .=
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
750 $result .=
'</table>';
753 $result .=
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
754 $result .=
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
755 $result .=
'<td class="right amount">'.price($obj->total_ttc).
'</td>';
758 $payment = $objectstatic->getSommePaiement();
759 $result .=
'<td class="right">'.$objectstatic->getLibStatut(5, $payment).
'</td>';
766 $result .=
'</table>';
780 global $conf, $db, $langs, $user;
782 $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,";
783 $sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client";
784 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
785 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
786 if (empty($user->rights->societe->client->voir) && !$socid) {
787 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
789 $sql .=
" WHERE f.fk_soc = s.rowid";
790 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
792 $sql .=
" AND f.fk_soc = ".((int) $socid);
794 if (empty($user->rights->societe->client->voir) && !$socid) {
795 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
797 $sql .=
" ORDER BY f.tms DESC";
798 $sql .= $db->plimit($maxCount, 0);
800 $resql = $db->query($sql);
806 $num = $db->num_rows(
$resql);
808 $result =
'<div class="div-table-responsive-no-min">';
809 $result .=
'<table class="noborder centpercent">';
810 $result .=
'<tr class="liste_titre">';
811 $result .=
'<th colspan="3">'.$langs->trans(
"BoxTitleLastSupplierBills", $maxCount).
'</th>';
812 $result .=
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
813 $result .=
'<th class="right"></th>';
817 $result .=
'</table>';
823 $companystatic =
new Societe($db);
828 $obj = $db->fetch_object(
$resql);
830 $objectstatic->id = $obj->rowid;
831 $objectstatic->ref = $obj->ref;
832 $objectstatic->paye = $obj->paye;
833 $objectstatic->statut = $obj->status;
834 $objectstatic->total_ht = $obj->total_ht;
835 $objectstatic->total_tva = $obj->total_tva;
836 $objectstatic->total_ttc = $obj->total_ttc;
837 $objectstatic->type = $obj->type;
839 $companystatic->id = $obj->socid;
840 $companystatic->name = $obj->socname;
841 $companystatic->client = $obj->client;
842 $companystatic->canvas = $obj->canvas;
845 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
847 $result .=
'<tr class="nowrap">';
849 $result .=
'<td class="oddeven">';
850 $result .=
'<table class="nobordernopadding">';
851 $result .=
'<tr class="nocellnopadd">';
853 $result .=
'<td width="96" class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
854 $result .=
'<td width="16" class="nobordernopadding nowrap"> </td>';
855 $result .=
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
858 $result .=
'</table>';
861 $result .=
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
863 $result .=
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
865 $result .=
'<td class="amount right">'.price($obj->total_ttc).
'</td>';
867 $result .=
'<td class="right">'.$objectstatic->getLibStatut(5).
'</td>';
874 $result .=
'</table>';
888 global $conf, $db, $langs, $user, $hookmanager;
892 if (
isModEnabled(
'facture') && !empty($user->rights->facture->lire)) {
893 $tmpinvoice =
new Facture($db);
895 $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";
896 $sql .=
", f.date_lim_reglement as datelimite";
897 $sql .=
", s.nom as name";
898 $sql .=
", s.rowid as socid, s.email";
899 $sql .=
", s.code_client, s.code_compta";
900 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
901 $sql .=
", cc.rowid as country_id, cc.code as country_code";
902 $sql .=
", sum(pf.amount) as am";
903 $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";
904 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf on f.rowid=pf.fk_facture";
905 if (empty($user->rights->societe->client->voir) && !$socid) {
906 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
908 $sql .=
" WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = ".Facture::STATUS_VALIDATED;
909 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
')';
910 if (empty($user->rights->societe->client->voir) && !$socid) {
911 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
914 $sql .=
" AND f.fk_soc = ".((int) $socid);
917 $parameters = array();
918 $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerUnpaid', $parameters);
919 $sql .= $hookmanager->resPrint;
921 $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,";
922 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code";
923 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
924 $sql .=
" ORDER BY f.datef ASC, f.ref ASC";
926 $resql = $db->query($sql);
928 $num = $db->num_rows(
$resql);
934 print
'<div class="div-table-responsive-no-min">';
935 print
'<table class="noborder centpercent">';
937 print
'<tr class="liste_titre">';
938 print
'<th colspan="2">';
939 print $langs->trans(
"BillsCustomersUnpaid", $num).
' ';
941 print
'<span class="badge">'.$num.
'</span>';
945 print
'<th class="right">'.$langs->trans(
"DateDue").
'</th>';
946 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
947 print
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
949 print
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
950 print
'<th class="right">'.$langs->trans(
"Received").
'</th>';
951 print
'<th width="16"> </th>';
954 $societestatic =
new Societe($db);
955 $total_ttc = $totalam = $total = 0;
957 $obj = $db->fetch_object(
$resql);
959 if ($i >= $maxCount) {
962 $total += $obj->total_ht;
963 $total_ttc += $obj->total_ttc;
964 $totalam += $obj->am;
968 $tmpinvoice->ref = $obj->ref;
969 $tmpinvoice->id = $obj->rowid;
970 $tmpinvoice->total_ht = $obj->total_ht;
971 $tmpinvoice->total_tva = $obj->total_tva;
972 $tmpinvoice->total_ttc = $obj->total_ttc;
973 $tmpinvoice->type = $obj->type;
974 $tmpinvoice->statut = $obj->status;
975 $tmpinvoice->paye = $obj->paye;
976 $tmpinvoice->date_lim_reglement = $db->jdate($obj->datelimite);
978 $societestatic->id = $obj->socid;
979 $societestatic->name = $obj->name;
980 $societestatic->email = $obj->email;
981 $societestatic->country_id = $obj->country_id;
982 $societestatic->country_code = $obj->country_code;
983 $societestatic->client = 1;
984 $societestatic->code_client = $obj->code_client;
985 $societestatic->code_fournisseur = $obj->code_fournisseur;
986 $societestatic->code_compta = $obj->code_compta;
987 $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
989 print
'<tr class="oddeven">';
990 print
'<td class="nowrap">';
992 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
993 print
'<td class="nobordernopadding nowrap">';
994 print $tmpinvoice->getNomUrl(1,
'');
996 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
999 $urlsource = $_SERVER[
'PHP_SELF'].
'?facid='.$obj->rowid;
1000 print $formfile->getDocumentsLink($tmpinvoice->element, $filename, $filedir);
1001 print
'</td></tr></table>';
1004 print
'<td class="nowrap tdoverflowmax100">';
1005 print $societestatic->getNomUrl(1,
'customer');
1007 print
'<td class="right">';
1009 if ($tmpinvoice->hasDelay()) {
1013 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1014 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
1016 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
1017 print
'<td class="nowrap right"><span class="amount">'.price($obj->am).
'</span></td>';
1018 print
'<td>'.$tmpinvoice->getLibStatut(3, $obj->am).
'</td>';
1021 $total_ttc += $obj->total_ttc;
1022 $total += $obj->total_ht;
1023 $totalam += $obj->am;
1030 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1033 print
'<tr class="oddeven">';
1034 print
'<td class="nowrap" colspan="'.$colspan.
'">';
1035 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1040 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>';
1041 print
'<td> </td>';
1042 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1043 print
'<td class="right"><span class="amount">'.price($total).
'</span></td>';
1045 print
'<td class="nowrap right"><span class="amount">'.price($total_ttc).
'</span></td>';
1046 print
'<td class="nowrap right"><span class="amount">'.price($totalam).
'</span></td>';
1047 print
'<td> </td>';
1051 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1054 print
'<tr class="oddeven"><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
1056 print
'</table></div><br>';
1076 global $conf, $db, $langs, $user, $hookmanager;
1080 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)) {
1083 $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";
1084 $sql .=
", ff.date_lim_reglement";
1085 $sql .=
", s.nom as name";
1086 $sql .=
", s.rowid as socid, s.email";
1087 $sql .=
", s.code_client, s.code_compta";
1088 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
1089 $sql .=
", sum(pf.amount) as am";
1090 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"facture_fourn as ff";
1091 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
1092 if (empty($user->rights->societe->client->voir) && !$socid) {
1093 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1095 $sql .=
" WHERE s.rowid = ff.fk_soc";
1096 $sql .=
" AND ff.entity = ".$conf->entity;
1097 $sql .=
" AND ff.paye = 0";
1098 $sql .=
" AND ff.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
1099 if (empty($user->rights->societe->client->voir) && !$socid) {
1100 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1103 $sql .=
" AND ff.fk_soc = ".((int) $socid);
1106 $parameters = array();
1107 $reshook = $hookmanager->executeHooks(
'printFieldListWhereSupplierUnpaid', $parameters);
1108 $sql .= $hookmanager->resPrint;
1110 $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,";
1111 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
1112 $sql .=
" ORDER BY ff.date_lim_reglement ASC";
1114 $resql = $db->query($sql);
1116 $num = $db->num_rows(
$resql);
1121 print
'<div class="div-table-responsive-no-min">';
1122 print
'<table class="noborder centpercent">';
1124 print
'<tr class="liste_titre">';
1125 print
'<th colspan="2">';
1126 print $langs->trans(
"BillsSuppliersUnpaid", $num).
' ';
1128 print
'<span class="badge">'.$num.
'</span>';
1132 print
'<th class="right">'.$langs->trans(
"DateDue").
'</th>';
1133 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1134 print
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
1136 print
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
1137 print
'<th class="right">'.$langs->trans(
"Paid").
'</th>';
1138 print
'<th width="16"> </th>';
1140 $societestatic =
new Societe($db);
1143 $total = $total_ttc = $totalam = 0;
1145 $obj = $db->fetch_object(
$resql);
1147 if ($i >= $maxCount) {
1150 $total += $obj->total_ht;
1151 $total_ttc += $obj->total_ttc;
1155 $facstatic->ref = $obj->ref;
1156 $facstatic->id = $obj->rowid;
1157 $facstatic->type = $obj->type;
1158 $facstatic->total_ht = $obj->total_ht;
1159 $facstatic->total_tva = $obj->total_tva;
1160 $facstatic->total_ttc = $obj->total_ttc;
1161 $facstatic->statut = $obj->status;
1162 $facstatic->paye = $obj->paye;
1164 $societestatic->id = $obj->socid;
1165 $societestatic->name = $obj->name;
1166 $societestatic->email = $obj->email;
1167 $societestatic->client = 0;
1168 $societestatic->fournisseur = 1;
1169 $societestatic->code_client = $obj->code_client;
1170 $societestatic->code_fournisseur = $obj->code_fournisseur;
1171 $societestatic->code_compta = $obj->code_compta;
1172 $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1174 print
'<tr class="oddeven">';
1175 print
'<td class="nowrap tdoverflowmax100">';
1176 print $facstatic->getNomUrl(1,
'');
1178 print
'<td class="nowrap tdoverflowmax100">'.$societestatic->getNomUrl(1,
'supplier').
'</td>';
1179 print
'<td class="right">'.dol_print_date($db->jdate($obj->date_lim_reglement),
'day').
'</td>';
1180 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1181 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
1183 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
1184 print
'<td class="nowrap right"><span class="amount">'.price($obj->am).
'</span></td>';
1185 print
'<td>'.$facstatic->getLibStatut(3, $obj->am).
'</td>';
1187 $total += $obj->total_ht;
1188 $total_ttc += $obj->total_ttc;
1189 $totalam += $obj->am;
1195 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1198 print
'<tr class="oddeven">';
1199 print
'<td class="nowrap" colspan="'.$colspan.
'">';
1200 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1205 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>';
1206 print
'<td> </td>';
1207 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1208 print
'<td class="right">'.price($total).
'</td>';
1210 print
'<td class="nowrap right">'.price($total_ttc).
'</td>';
1211 print
'<td class="nowrap right">'.price($totalam).
'</td>';
1212 print
'<td> </td>';
1216 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1219 print
'<tr class="oddeven"><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
1221 print
'</table></div><br>';
getPurchaseInvoiceUnpaidOpenTable($maxCount=500, $socid=0)
Return a HTML table that contains of unpaid purchase invoices.
dol_now($mode= 'auto')
Return date for now.
getNumberInvoicesPieChart($mode)
Return an HTML table that contains a pie chart of the number of customers or supplier invoices...
const STATUS_VALIDATED
Validated (need to be paid)
Class to manage suppliers invoices.
invoice_admin_prepare_head()
Return array head with list of tabs to view object informations.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
Class to manage third parties objects (customers, suppliers, prospects...)
const STATUS_VALIDATED
Validated (need to be paid)
getCustomerInvoiceUnpaidOpenTable($maxCount=500, $socid=0)
Return a HTML table that contains of unpaid customers invoices.
const STATUS_DRAFT
Draft status.
static count($dbs, $objecttype, $objectid)
Return nb of links.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
supplier_invoice_rec_prepare_head($object)
Return array head with list of tabs to view object informations.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDraftSupplierTable($maxCount=500, $socid=0)
Return a HTML table that contains a list with customer invoice drafts.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage invoices.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).
getPurchaseInvoiceLatestEditTable($maxCount=5, $socid=0)
Return a HTML table that contains a list with latest edited supplier invoices.
getCustomerInvoiceDraftTable($maxCount=500, $socid=0)
Return a HTML table that contains a list with customer invoice drafts.
invoice_rec_prepare_head($object)
Return array head with list of tabs to view object informations.
getCustomerInvoiceLatestEditTable($maxCount=5, $socid=0)
Return a HTML table that contains a list with latest edited customer invoices.
facture_prepare_head($object)
Initialize the array of tabs for customer invoice.