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_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';
140 global $langs, $conf, $user, $db;
143 $extrafields->fetch_name_optionals_label(
'facture');
144 $extrafields->fetch_name_optionals_label(
'facturedet');
145 $extrafields->fetch_name_optionals_label(
'facture_rec');
146 $extrafields->fetch_name_optionals_label(
'facturedet_rec');
151 $head[$h][0] = DOL_URL_ROOT.
'/admin/facture.php';
152 $head[$h][1] = $langs->trans(
"Miscellaneous");
153 $head[$h][2] =
'general';
156 $head[$h][0] = DOL_URL_ROOT.
'/admin/payment.php';
157 $head[$h][1] = $langs->trans(
"Payments");
158 $head[$h][2] =
'payment';
167 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facture_cust_extrafields.php';
168 $head[$h][1] = $langs->trans(
"ExtraFieldsCustomerInvoices");
169 $nbExtrafields = $extrafields->attributes[
'facture'][
'count'];
170 if ($nbExtrafields > 0) {
171 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
173 $head[$h][2] =
'attributes';
176 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facturedet_cust_extrafields.php';
177 $head[$h][1] = $langs->trans(
"ExtraFieldsLines");
178 $nbExtrafields = $extrafields->attributes[
'facturedet'][
'count'];
179 if ($nbExtrafields > 0) {
180 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
182 $head[$h][2] =
'attributeslines';
185 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facture_rec_cust_extrafields.php';
186 $head[$h][1] = $langs->trans(
"ExtraFieldsCustomerInvoicesRec");
187 $nbExtrafields = $extrafields->attributes[
'facture_rec'][
'count'];
188 if ($nbExtrafields > 0) {
189 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
191 $head[$h][2] =
'attributesrec';
194 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facturedet_rec_cust_extrafields.php';
195 $head[$h][1] = $langs->trans(
"ExtraFieldsLinesRec");
196 $nbExtrafields = $extrafields->attributes[
'facturedet_rec'][
'count'];
197 if ($nbExtrafields > 0) {
198 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
200 $head[$h][2] =
'attributeslinesrec';
203 if (!empty($conf->global->INVOICE_USE_SITUATION)) {
204 $head[$h][0] = DOL_URL_ROOT.
'/admin/facture_situation.php';
205 $head[$h][1] = $langs->trans(
"InvoiceSituation");
206 $head[$h][2] =
'situation';
224 global $db, $langs, $conf;
229 $head[$h][0] = DOL_URL_ROOT .
'/compta/facture/card-rec.php?id=' . $object->id;
230 $head[$h][1] = $langs->trans(
"RepeatableInvoice");
231 $head[$h][2] =
'card';
253 global $db, $langs, $conf;
258 $head[$h][0] = DOL_URL_ROOT .
'/fourn/facture/card-rec.php?id=' . $object->id;
259 $head[$h][1] = $langs->trans(
"RepeatableSupplierInvoice");
260 $head[$h][2] =
'card';
282 global $conf, $db, $langs, $user;
283 if (($mode ==
'customers' &&
isModEnabled(
'facture') && !empty($user->rights->facture->lire))
284 || ($mode =
'suppliers') && (
isModEnabled(
'fournisseur') ||
isModEnabled(
'supplier_invoice')) && !empty($user->rights->facture->lire)
286 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
288 $now = date_create(date(
'Y-m-d',
dol_now()));
289 $datenowsub30 = date_create(date(
'Y-m-d',
dol_now()));
290 $datenowsub15 = date_create(date(
'Y-m-d',
dol_now()));
291 $datenowadd30 = date_create(date(
'Y-m-d',
dol_now()));
292 $datenowadd15 = date_create(date(
'Y-m-d',
dol_now()));
293 $interval30days = date_interval_create_from_date_string(
'30 days');
294 $interval15days = date_interval_create_from_date_string(
'15 days');
295 date_sub($datenowsub30, $interval30days);
296 date_sub($datenowsub15, $interval15days);
297 date_add($datenowadd30, $interval30days);
298 date_add($datenowadd15, $interval15days);
301 $sql .=
" sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($datenowsub30,
'Y-m-d').
"'", 1, 0).
") as nblate30";
302 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($datenowsub15,
'Y-m-d').
"'", 1, 0).
") as nblate15";
303 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($now,
'Y-m-d').
"'", 1, 0).
") as nblatenow";
304 $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";
305 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement > '".date_format($datenowadd15,
'Y-m-d').
"'", 1, 0).
") as nbnotlate15";
306 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement > '".date_format($datenowadd30,
'Y-m-d').
"'", 1, 0).
") as nbnotlate30";
307 if ($mode ==
'customers') {
308 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
309 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
310 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
314 $sql .=
" WHERE f.type <> 2";
315 $sql .=
" AND f.fk_statut = 1";
316 if (isset($user->socid) && $user->socid > 0) {
317 $sql .=
" AND f.fk_soc = ".((int) $user->socid);
320 $resql = $db->query($sql);
322 $num = $db->num_rows(
$resql);
325 $dataseries = array();
328 $obj = $db->fetch_object(
$resql);
337 $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);
340 if (!empty($dataseries[0])) {
341 foreach ($dataseries[0] as $key => $value) {
342 if (is_numeric($value)) {
348 $langs->trans(
'InvoiceLate30Days'),
349 $langs->trans(
'InvoiceLate15Days'),
350 $langs->trans(
'InvoiceLateMinus15Days'),
351 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate') : $langs->trans(
"InvoiceToPay"),
352 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate15Days') : $langs->trans(
"InvoiceToPay15Days"),
353 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate30Days') : $langs->trans(
"InvoiceToPay30Days"),
356 $colorseries = array($badgeStatus8, $badgeStatus1, $badgeStatus3, $badgeStatus4, $badgeStatus11,
'-'.$badgeStatus11);
358 $result =
'<div class="div-table-responsive-no-min">';
359 $result .=
'<table class="noborder nohover centpercent">';
360 $result .=
'<tr class="liste_titre">';
361 $result .=
'<td>'.$langs->trans(
"NbOfOpenInvoices").
' - ';
362 if ($mode ==
'customers') {
363 $result .= $langs->trans(
"CustomerInvoice");
364 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
365 $result .= $langs->trans(
"SupplierInvoice");
372 if ($conf->use_javascript_ajax) {
375 $dolgraph->SetData($dataseries);
377 $dolgraph->setLegend($legend);
379 $dolgraph->SetDataColor(array_values($colorseries));
380 $dolgraph->setShowLegend(2);
381 $dolgraph->setShowPercent(1);
382 $dolgraph->SetType(array(
'bars',
'bars',
'bars',
'bars',
'bars',
'bars'));
384 $dolgraph->setHeight(
'160');
385 $dolgraph->setWidth(
'450');
386 $dolgraph->setHideXValues(
true);
387 if ($mode ==
'customers') {
388 $dolgraph->draw(
'idgraphcustomerinvoices');
389 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
390 $dolgraph->draw(
'idgraphfourninvoices');
394 $result .=
'<tr maxwidth="255">';
395 $result .=
'<td class="center">'.$dolgraph->show($total ? 0 : $langs->trans(
"NoOpenInvoice")).
'</td>';
401 $result .=
'</table>';
419 global $conf, $db, $langs, $user, $hookmanager;
421 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
424 $tmpinvoice =
new Facture($db);
426 $sql =
"SELECT f.rowid, f.ref, f.datef as date, f.total_ht, f.total_tva, f.total_ttc, f.ref_client";
427 $sql .=
", f.type, f.fk_statut as status, f.paye";
428 $sql .=
", s.nom as name";
429 $sql .=
", s.rowid as socid, s.email";
430 $sql .=
", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
431 $sql .=
", cc.rowid as country_id, cc.code as country_code";
432 if (empty($user->rights->societe->client->voir) && !$socid) {
433 $sql .=
", sc.fk_soc, sc.fk_user ";
435 $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";
436 if (empty($user->rights->societe->client->voir) && !$socid) {
437 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
439 $sql .=
" WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT;
440 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
441 if (empty($user->rights->societe->client->voir) && !$socid) {
442 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
446 $sql .=
" AND f.fk_soc = ".((int) $socid);
449 $parameters = array();
450 $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerDraft', $parameters);
451 $sql .= $hookmanager->resPrint;
453 $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,";
454 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,";
455 $sql .=
" cc.rowid, cc.code";
456 if (empty($user->rights->societe->client->voir) && !$socid) {
457 $sql .=
", sc.fk_soc, sc.fk_user";
461 $parameters = array();
462 $reshook = $hookmanager->executeHooks(
'printFieldListGroupByCustomerDraft', $parameters);
463 $sql .= $hookmanager->resPrint;
465 $resql = $db->query($sql);
468 $num = $db->num_rows(
$resql);
469 $nbofloop = min($num, $maxofloop);
471 $result .=
'<div class="div-table-responsive-no-min">';
472 $result .=
'<table class="noborder centpercent">';
474 $result .=
'<tr class="liste_titre">';
475 $result .=
'<th colspan="3">';
476 $result .= $langs->trans(
"CustomersDraftInvoices").
' ';
477 $result .=
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?search_status='.
Facture::STATUS_DRAFT.
'">';
478 $result .=
'<span class="badge marginleftonlyshort">'.$num.
'</span>';
484 $companystatic =
new Societe($db);
489 while ($i < $nbofloop) {
490 $obj = $db->fetch_object(
$resql);
492 if ($i >= $maxCount) {
495 $tot_ttc += $obj->total_ttc;
499 $tmpinvoice->id = $obj->rowid;
500 $tmpinvoice->ref = $obj->ref;
501 $tmpinvoice->date = $db->jdate($obj->date);
502 $tmpinvoice->type = $obj->type;
503 $tmpinvoice->total_ht = $obj->total_ht;
504 $tmpinvoice->total_tva = $obj->total_tva;
505 $tmpinvoice->total_ttc = $obj->total_ttc;
506 $tmpinvoice->ref_client = $obj->ref_client;
507 $tmpinvoice->statut = $obj->status;
508 $tmpinvoice->paye = $obj->paye;
510 $companystatic->id = $obj->socid;
511 $companystatic->name = $obj->name;
512 $companystatic->email = $obj->email;
513 $companystatic->country_id = $obj->country_id;
514 $companystatic->country_code = $obj->country_code;
515 $companystatic->client = 1;
516 $companystatic->code_client = $obj->code_client;
517 $companystatic->code_fournisseur = $obj->code_fournisseur;
518 $companystatic->code_compta = $obj->code_compta;
519 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
521 $result .=
'<tr class="oddeven">';
522 $result .=
'<td class="nowrap tdoverflowmax100">';
523 $result .= $tmpinvoice->getNomUrl(1,
'');
525 $result .=
'<td class="nowrap tdoverflowmax100">';
526 $result .= $companystatic->getNomUrl(1,
'customer');
528 $result .=
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
530 $tot_ttc += $obj->total_ttc;
535 $result .=
'<tr class="oddeven">';
536 $result .=
'<td class="nowrap" colspan="3">';
537 $result .=
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
539 $result .=
"</tr>\n";
542 $result .=
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
543 $result .=
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
546 $result .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
548 $result .=
"</table></div>";
566 global $conf, $db, $langs, $user, $hookmanager;
568 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
573 $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";
574 $sql .=
", s.nom as name";
575 $sql .=
", s.rowid as socid, s.email";
576 $sql .=
", s.code_client, s.code_compta";
577 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
578 $sql .=
", cc.rowid as country_id, cc.code as country_code";
579 $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";
580 if (empty($user->rights->societe->client->voir) && !$socid) {
581 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
583 $sql .=
" WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT;
584 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
')';
585 if (empty($user->rights->societe->client->voir) && !$socid) {
586 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
589 $sql .=
" AND f.fk_soc = ".((int) $socid);
592 $parameters = array();
593 $reshook = $hookmanager->executeHooks(
'printFieldListWhereSupplierDraft', $parameters);
594 $sql .= $hookmanager->resPrint;
595 $resql = $db->query($sql);
598 $num = $db->num_rows(
$resql);
599 $nbofloop = min($num, $maxofloop);
601 $result .=
'<div class="div-table-responsive-no-min">';
602 $result .=
'<table class="noborder centpercent">';
604 $result .=
'<tr class="liste_titre">';
605 $result .=
'<th colspan="3">';
606 $result .= $langs->trans(
"SuppliersDraftInvoices").
' ';
608 $result .=
'<span class="badge marginleftonlyshort">'.$num.
'</span>';
614 $companystatic =
new Societe($db);
619 while ($i < $nbofloop) {
620 $obj = $db->fetch_object(
$resql);
622 if ($i >= $maxCount) {
625 $tot_ttc += $obj->total_ttc;
629 $facturesupplierstatic->ref = $obj->ref;
630 $facturesupplierstatic->id = $obj->rowid;
631 $facturesupplierstatic->total_ht = $obj->total_ht;
632 $facturesupplierstatic->total_tva = $obj->total_tva;
633 $facturesupplierstatic->total_ttc = $obj->total_ttc;
634 $facturesupplierstatic->ref_supplier = $obj->ref_supplier;
635 $facturesupplierstatic->type = $obj->type;
636 $facturesupplierstatic->statut = $obj->status;
637 $facturesupplierstatic->paye = $obj->paye;
639 $companystatic->id = $obj->socid;
640 $companystatic->name = $obj->name;
641 $companystatic->email = $obj->email;
642 $companystatic->country_id = $obj->country_id;
643 $companystatic->country_code = $obj->country_code;
644 $companystatic->fournisseur = 1;
645 $companystatic->code_client = $obj->code_client;
646 $companystatic->code_fournisseur = $obj->code_fournisseur;
647 $companystatic->code_compta = $obj->code_compta;
648 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
650 $result .=
'<tr class="oddeven">';
651 $result .=
'<td class="nowrap tdoverflowmax100">';
652 $result .= $facturesupplierstatic->getNomUrl(1,
'');
654 $result .=
'<td class="nowrap tdoverflowmax100">';
655 $result .= $companystatic->getNomUrl(1,
'supplier');
657 $result .=
'<td class="right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
659 $tot_ttc += $obj->total_ttc;
664 $result .=
'<tr class="oddeven">';
665 $result .=
'<td class="nowrap" colspan="3">';
666 $result .=
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
668 $result .=
"</tr>\n";
671 $result .=
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
672 $result .=
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
675 $result .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
677 $result .=
"</table></div>";
696 global $conf, $db, $langs, $user;
698 $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,";
699 $sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client";
700 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
701 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
702 if (empty($user->rights->societe->client->voir) && !$socid) {
703 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
705 $sql .=
" WHERE f.fk_soc = s.rowid";
706 $sql .=
" AND f.entity IN (".getEntity(
'facture').
")";
708 $sql .=
" AND f.fk_soc = ".((int) $socid);
710 if (empty($user->rights->societe->client->voir) && !$socid) {
711 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
713 $sql .=
" ORDER BY f.tms DESC";
714 $sql .= $db->plimit($maxCount, 0);
716 $resql = $db->query($sql);
721 $num = $db->num_rows(
$resql);
723 $result =
'<div class="div-table-responsive-no-min">';
724 $result .=
'<table class="noborder centpercent">';
726 $result .=
'<tr class="liste_titre">';
727 $result .=
'<th colspan="3">'.$langs->trans(
"LastCustomersBills", $maxCount).
'</th>';
728 $result .=
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
729 $result .=
'<th class="right"></th>';
733 $result .=
'</table>';
739 $objectstatic =
new Facture($db);
740 $companystatic =
new Societe($db);
744 $obj = $db->fetch_object(
$resql);
746 $objectstatic->id = $obj->rowid;
747 $objectstatic->ref = $obj->ref;
748 $objectstatic->paye = $obj->paye;
749 $objectstatic->statut = $obj->status;
750 $objectstatic->total_ht = $obj->total_ht;
751 $objectstatic->total_tva = $obj->total_tva;
752 $objectstatic->total_ttc = $obj->total_ttc;
753 $objectstatic->type = $obj->type;
755 $companystatic->id = $obj->socid;
756 $companystatic->name = $obj->socname;
757 $companystatic->client = $obj->client;
758 $companystatic->canvas = $obj->canvas;
761 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
763 $result .=
'<tr class="nowrap">';
765 $result .=
'<td class="oddeven">';
766 $result .=
'<table class="nobordernopadding">';
767 $result .=
'<tr class="nocellnopadd">';
769 $result .=
'<td width="96" class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
770 $result .=
'<td width="16" class="nobordernopadding nowrap"> </td>';
771 $result .=
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
774 $result .=
'</table>';
777 $result .=
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
778 $result .=
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
779 $result .=
'<td class="right amount">'.price($obj->total_ttc).
'</td>';
782 $payment = $objectstatic->getSommePaiement();
783 $result .=
'<td class="right">'.$objectstatic->getLibStatut(5, $payment).
'</td>';
790 $result .=
'</table>';
804 global $conf, $db, $langs, $user;
806 $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,";
807 $sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client";
808 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
809 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
810 if (empty($user->rights->societe->client->voir) && !$socid) {
811 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
813 $sql .=
" WHERE f.fk_soc = s.rowid";
814 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
816 $sql .=
" AND f.fk_soc = ".((int) $socid);
818 if (empty($user->rights->societe->client->voir) && !$socid) {
819 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
821 $sql .=
" ORDER BY f.tms DESC";
822 $sql .= $db->plimit($maxCount, 0);
824 $resql = $db->query($sql);
830 $num = $db->num_rows(
$resql);
832 $result =
'<div class="div-table-responsive-no-min">';
833 $result .=
'<table class="noborder centpercent">';
834 $result .=
'<tr class="liste_titre">';
835 $result .=
'<th colspan="3">'.$langs->trans(
"BoxTitleLastSupplierBills", $maxCount).
'</th>';
836 $result .=
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
837 $result .=
'<th class="right"></th>';
841 $result .=
'</table>';
847 $companystatic =
new Societe($db);
852 $obj = $db->fetch_object(
$resql);
854 $objectstatic->id = $obj->rowid;
855 $objectstatic->ref = $obj->ref;
856 $objectstatic->paye = $obj->paye;
857 $objectstatic->statut = $obj->status;
858 $objectstatic->total_ht = $obj->total_ht;
859 $objectstatic->total_tva = $obj->total_tva;
860 $objectstatic->total_ttc = $obj->total_ttc;
861 $objectstatic->type = $obj->type;
863 $companystatic->id = $obj->socid;
864 $companystatic->name = $obj->socname;
865 $companystatic->client = $obj->client;
866 $companystatic->canvas = $obj->canvas;
869 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
871 $result .=
'<tr class="nowrap">';
873 $result .=
'<td class="oddeven">';
874 $result .=
'<table class="nobordernopadding">';
875 $result .=
'<tr class="nocellnopadd">';
877 $result .=
'<td width="96" class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
878 $result .=
'<td width="16" class="nobordernopadding nowrap"> </td>';
879 $result .=
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
882 $result .=
'</table>';
885 $result .=
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
887 $result .=
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
889 $result .=
'<td class="amount right">'.price($obj->total_ttc).
'</td>';
891 $result .=
'<td class="right">'.$objectstatic->getLibStatut(5).
'</td>';
898 $result .=
'</table>';
912 global $conf, $db, $langs, $user, $hookmanager;
916 if (
isModEnabled(
'facture') && !empty($user->rights->facture->lire)) {
917 $tmpinvoice =
new Facture($db);
919 $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";
920 $sql .=
", f.date_lim_reglement as datelimite";
921 $sql .=
", s.nom as name";
922 $sql .=
", s.rowid as socid, s.email";
923 $sql .=
", s.code_client, s.code_compta";
924 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
925 $sql .=
", cc.rowid as country_id, cc.code as country_code";
926 $sql .=
", sum(pf.amount) as am";
927 $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";
928 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf on f.rowid=pf.fk_facture";
929 if (empty($user->rights->societe->client->voir) && !$socid) {
930 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
932 $sql .=
" WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = ".Facture::STATUS_VALIDATED;
933 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
')';
934 if (empty($user->rights->societe->client->voir) && !$socid) {
935 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
938 $sql .=
" AND f.fk_soc = ".((int) $socid);
941 $parameters = array();
942 $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerUnpaid', $parameters);
943 $sql .= $hookmanager->resPrint;
945 $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,";
946 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code";
947 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
948 $sql .=
" ORDER BY f.datef ASC, f.ref ASC";
950 $resql = $db->query($sql);
952 $num = $db->num_rows(
$resql);
958 print
'<div class="div-table-responsive-no-min">';
959 print
'<table class="noborder centpercent">';
961 print
'<tr class="liste_titre">';
962 print
'<th colspan="2">';
963 print $langs->trans(
"BillsCustomersUnpaid", $num).
' ';
965 print
'<span class="badge">'.$num.
'</span>';
969 print
'<th class="right">'.$langs->trans(
"DateDue").
'</th>';
970 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
971 print
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
973 print
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
974 print
'<th class="right">'.$langs->trans(
"Received").
'</th>';
975 print
'<th width="16"> </th>';
978 $societestatic =
new Societe($db);
979 $total_ttc = $totalam = $total = 0;
981 $obj = $db->fetch_object(
$resql);
983 if ($i >= $maxCount) {
986 $total += $obj->total_ht;
987 $total_ttc += $obj->total_ttc;
988 $totalam += $obj->am;
992 $tmpinvoice->ref = $obj->ref;
993 $tmpinvoice->id = $obj->rowid;
994 $tmpinvoice->total_ht = $obj->total_ht;
995 $tmpinvoice->total_tva = $obj->total_tva;
996 $tmpinvoice->total_ttc = $obj->total_ttc;
997 $tmpinvoice->type = $obj->type;
998 $tmpinvoice->statut = $obj->status;
999 $tmpinvoice->paye = $obj->paye;
1000 $tmpinvoice->date_lim_reglement = $db->jdate($obj->datelimite);
1002 $societestatic->id = $obj->socid;
1003 $societestatic->name = $obj->name;
1004 $societestatic->email = $obj->email;
1005 $societestatic->country_id = $obj->country_id;
1006 $societestatic->country_code = $obj->country_code;
1007 $societestatic->client = 1;
1008 $societestatic->code_client = $obj->code_client;
1009 $societestatic->code_fournisseur = $obj->code_fournisseur;
1010 $societestatic->code_compta = $obj->code_compta;
1011 $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1013 print
'<tr class="oddeven">';
1014 print
'<td class="nowrap">';
1016 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1017 print
'<td class="nobordernopadding nowrap">';
1018 print $tmpinvoice->getNomUrl(1,
'');
1020 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
1023 $urlsource = $_SERVER[
'PHP_SELF'].
'?facid='.$obj->rowid;
1024 print $formfile->getDocumentsLink($tmpinvoice->element, $filename, $filedir);
1025 print
'</td></tr></table>';
1028 print
'<td class="nowrap tdoverflowmax100">';
1029 print $societestatic->getNomUrl(1,
'customer');
1031 print
'<td class="right">';
1033 if ($tmpinvoice->hasDelay()) {
1037 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1038 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
1040 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
1041 print
'<td class="nowrap right"><span class="amount">'.price($obj->am).
'</span></td>';
1042 print
'<td>'.$tmpinvoice->getLibStatut(3, $obj->am).
'</td>';
1045 $total_ttc += $obj->total_ttc;
1046 $total += $obj->total_ht;
1047 $totalam += $obj->am;
1054 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1057 print
'<tr class="oddeven">';
1058 print
'<td class="nowrap" colspan="'.$colspan.
'">';
1059 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1064 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>';
1065 print
'<td> </td>';
1066 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1067 print
'<td class="right"><span class="amount">'.price($total).
'</span></td>';
1069 print
'<td class="nowrap right"><span class="amount">'.price($total_ttc).
'</span></td>';
1070 print
'<td class="nowrap right"><span class="amount">'.price($totalam).
'</span></td>';
1071 print
'<td> </td>';
1075 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1078 print
'<tr class="oddeven"><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
1080 print
'</table></div><br>';
1100 global $conf, $db, $langs, $user, $hookmanager;
1104 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (
isModEnabled(
"supplier_invoice") && $user->rights->supplier_invoice->lire)) {
1107 $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";
1108 $sql .=
", ff.date_lim_reglement";
1109 $sql .=
", s.nom as name";
1110 $sql .=
", s.rowid as socid, s.email";
1111 $sql .=
", s.code_client, s.code_compta";
1112 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
1113 $sql .=
", sum(pf.amount) as am";
1114 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"facture_fourn as ff";
1115 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
1116 if (empty($user->rights->societe->client->voir) && !$socid) {
1117 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1119 $sql .=
" WHERE s.rowid = ff.fk_soc";
1120 $sql .=
" AND ff.entity = ".$conf->entity;
1121 $sql .=
" AND ff.paye = 0";
1122 $sql .=
" AND ff.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
1123 if (empty($user->rights->societe->client->voir) && !$socid) {
1124 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1127 $sql .=
" AND ff.fk_soc = ".((int) $socid);
1130 $parameters = array();
1131 $reshook = $hookmanager->executeHooks(
'printFieldListWhereSupplierUnpaid', $parameters);
1132 $sql .= $hookmanager->resPrint;
1134 $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,";
1135 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
1136 $sql .=
" ORDER BY ff.date_lim_reglement ASC";
1138 $resql = $db->query($sql);
1140 $num = $db->num_rows(
$resql);
1145 print
'<div class="div-table-responsive-no-min">';
1146 print
'<table class="noborder centpercent">';
1148 print
'<tr class="liste_titre">';
1149 print
'<th colspan="2">';
1150 print $langs->trans(
"BillsSuppliersUnpaid", $num).
' ';
1152 print
'<span class="badge">'.$num.
'</span>';
1156 print
'<th class="right">'.$langs->trans(
"DateDue").
'</th>';
1157 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1158 print
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
1160 print
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
1161 print
'<th class="right">'.$langs->trans(
"Paid").
'</th>';
1162 print
'<th width="16"> </th>';
1164 $societestatic =
new Societe($db);
1167 $total = $total_ttc = $totalam = 0;
1169 $obj = $db->fetch_object(
$resql);
1171 if ($i >= $maxCount) {
1174 $total += $obj->total_ht;
1175 $total_ttc += $obj->total_ttc;
1179 $facstatic->ref = $obj->ref;
1180 $facstatic->id = $obj->rowid;
1181 $facstatic->type = $obj->type;
1182 $facstatic->total_ht = $obj->total_ht;
1183 $facstatic->total_tva = $obj->total_tva;
1184 $facstatic->total_ttc = $obj->total_ttc;
1185 $facstatic->statut = $obj->status;
1186 $facstatic->paye = $obj->paye;
1188 $societestatic->id = $obj->socid;
1189 $societestatic->name = $obj->name;
1190 $societestatic->email = $obj->email;
1191 $societestatic->client = 0;
1192 $societestatic->fournisseur = 1;
1193 $societestatic->code_client = $obj->code_client;
1194 $societestatic->code_fournisseur = $obj->code_fournisseur;
1195 $societestatic->code_compta = $obj->code_compta;
1196 $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1198 print
'<tr class="oddeven">';
1199 print
'<td class="nowrap tdoverflowmax100">';
1200 print $facstatic->getNomUrl(1,
'');
1202 print
'<td class="nowrap tdoverflowmax100">'.$societestatic->getNomUrl(1,
'supplier').
'</td>';
1203 print
'<td class="right">'.dol_print_date($db->jdate($obj->date_lim_reglement),
'day').
'</td>';
1204 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1205 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
1207 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
1208 print
'<td class="nowrap right"><span class="amount">'.price($obj->am).
'</span></td>';
1209 print
'<td>'.$facstatic->getLibStatut(3, $obj->am).
'</td>';
1211 $total += $obj->total_ht;
1212 $total_ttc += $obj->total_ttc;
1213 $totalam += $obj->am;
1219 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1222 print
'<tr class="oddeven">';
1223 print
'<td class="nowrap" colspan="'.$colspan.
'">';
1224 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1229 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>';
1230 print
'<td> </td>';
1231 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1232 print
'<td class="right">'.price($total).
'</td>';
1234 print
'<td class="nowrap right">'.price($total_ttc).
'</td>';
1235 print
'<td class="nowrap right">'.price($totalam).
'</td>';
1236 print
'<td> </td>';
1240 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1243 print
'<tr class="oddeven"><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
1245 print
'</table></div><br>';
Class to manage suppliers invoices.
const STATUS_VALIDATED
Validated (need to be paid)
Class to manage invoices.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated (need to be paid)
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
isModEnabled($module)
Is Dolibarr module enabled.
getNumberInvoicesPieChart($mode)
Return an HTML table that contains a pie chart of the number of customers or supplier invoices.
invoice_admin_prepare_head()
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.
invoice_rec_prepare_head($object)
Return array head with list of tabs to view object informations.
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.
supplier_invoice_rec_prepare_head($object)
Return array head with list of tabs to view object informations.
getDraftSupplierTable($maxCount=500, $socid=0)
Return a HTML table that contains a list with customer invoice drafts.
getCustomerInvoiceUnpaidOpenTable($maxCount=500, $socid=0)
Return a HTML table that contains of unpaid customers invoices.
facture_prepare_head($object)
Initialize the array of tabs for customer invoice.
getPurchaseInvoiceUnpaidOpenTable($maxCount=500, $socid=0)
Return a HTML table that contains of unpaid purchase invoices.