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';
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;
284 if (($mode ==
'customers' &&
isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire'))
285 || ($mode ==
'suppliers' && (
isModEnabled(
'fournisseur') ||
isModEnabled(
'supplier_invoice')) && $user->hasRight(
'fournisseur',
'facture',
'lire'))
287 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
289 $now = date_create(date(
'Y-m-d',
dol_now()));
290 $datenowsub30 = date_create(date(
'Y-m-d',
dol_now()));
291 $datenowsub15 = date_create(date(
'Y-m-d',
dol_now()));
292 $datenowadd30 = date_create(date(
'Y-m-d',
dol_now()));
293 $datenowadd15 = date_create(date(
'Y-m-d',
dol_now()));
294 $interval30days = date_interval_create_from_date_string(
'30 days');
295 $interval15days = date_interval_create_from_date_string(
'15 days');
296 date_sub($datenowsub30, $interval30days);
297 date_sub($datenowsub15, $interval15days);
298 date_add($datenowadd30, $interval30days);
299 date_add($datenowadd15, $interval15days);
302 $sql .=
" sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($datenowsub30,
'Y-m-d').
"'", 1, 0).
") as nblate30";
303 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($datenowsub15,
'Y-m-d').
"'", 1, 0).
") as nblate15";
304 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($now,
'Y-m-d').
"'", 1, 0).
") as nblatenow";
305 $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";
306 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement > '".date_format($datenowadd15,
'Y-m-d').
"'", 1, 0).
") as nbnotlate15";
307 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement > '".date_format($datenowadd30,
'Y-m-d').
"'", 1, 0).
") as nbnotlate30";
308 if ($mode ==
'customers') {
309 $element =
'invoice';
310 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
311 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
312 $element =
'supplier_invoice';
313 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
317 $sql .=
" WHERE f.entity IN (".getEntity($element).
")";
318 $sql .=
" AND f.type <> 2";
319 $sql .=
" AND f.fk_statut = 1";
320 if (isset($user->socid) && $user->socid > 0) {
321 $sql .=
" AND f.fk_soc = ".((int) $user->socid);
324 $resql = $db->query($sql);
326 $num = $db->num_rows(
$resql);
329 $dataseries = array();
332 $obj = $db->fetch_object(
$resql);
341 $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);
344 if (!empty($dataseries[0])) {
345 foreach ($dataseries[0] as $key => $value) {
346 if (is_numeric($value)) {
352 $langs->trans(
'InvoiceLate30Days'),
353 $langs->trans(
'InvoiceLate15Days'),
354 $langs->trans(
'InvoiceLateMinus15Days'),
355 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate') : $langs->trans(
"InvoiceToPay"),
356 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate15Days') : $langs->trans(
"InvoiceToPay15Days"),
357 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate30Days') : $langs->trans(
"InvoiceToPay30Days"),
360 $colorseries = array($badgeStatus8, $badgeStatus1, $badgeStatus3, $badgeStatus4, $badgeStatus11,
'-'.$badgeStatus11);
362 $result =
'<div class="div-table-responsive-no-min">';
363 $result .=
'<table class="noborder nohover centpercent">';
364 $result .=
'<tr class="liste_titre">';
365 $result .=
'<td>'.$langs->trans(
"NbOfOpenInvoices").
' - ';
366 if ($mode ==
'customers') {
367 $result .= $langs->trans(
"CustomerInvoice");
368 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
369 $result .= $langs->trans(
"SupplierInvoice");
376 if ($conf->use_javascript_ajax) {
379 $dolgraph->SetData($dataseries);
381 $dolgraph->setLegend($legend);
383 $dolgraph->SetDataColor(array_values($colorseries));
384 $dolgraph->setShowLegend(2);
385 $dolgraph->setShowPercent(1);
386 $dolgraph->SetType(array(
'bars',
'bars',
'bars',
'bars',
'bars',
'bars'));
388 $dolgraph->setHeight(
'160');
389 $dolgraph->setWidth(
'450');
390 $dolgraph->setHideXValues(
true);
391 if ($mode ==
'customers') {
392 $dolgraph->draw(
'idgraphcustomerinvoices');
393 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
394 $dolgraph->draw(
'idgraphfourninvoices');
398 $result .=
'<tr maxwidth="255">';
399 $result .=
'<td class="center">'.$dolgraph->show($total ? 0 : $langs->trans(
"NoOpenInvoice")).
'</td>';
405 $result .=
'</table>';
425 global $conf, $db, $langs, $user, $hookmanager;
429 if (
isModEnabled(
'facture') && !empty($user->rights->facture->lire)) {
430 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
432 $tmpinvoice =
new Facture($db);
434 $sql =
"SELECT f.rowid, f.ref, f.datef as date, f.total_ht, f.total_tva, f.total_ttc, f.ref_client";
435 $sql .=
", f.type, f.fk_statut as status, f.paye";
436 $sql .=
", s.nom as name";
437 $sql .=
", s.rowid as socid, s.email";
438 $sql .=
", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
439 $sql .=
", cc.rowid as country_id, cc.code as country_code";
440 if (empty($user->rights->societe->client->voir) && !$socid) {
441 $sql .=
", sc.fk_soc, sc.fk_user ";
443 $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";
444 if (empty($user->rights->societe->client->voir) && !$socid) {
445 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
447 $sql .=
" WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT;
448 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
449 if (empty($user->rights->societe->client->voir) && !$socid) {
450 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
454 $sql .=
" AND f.fk_soc = ".((int) $socid);
457 $parameters = array();
458 $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerDraft', $parameters);
459 $sql .= $hookmanager->resPrint;
461 $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,";
462 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,";
463 $sql .=
" cc.rowid, cc.code";
464 if (empty($user->rights->societe->client->voir) && !$socid) {
465 $sql .=
", sc.fk_soc, sc.fk_user";
469 $parameters = array();
470 $reshook = $hookmanager->executeHooks(
'printFieldListGroupByCustomerDraft', $parameters);
471 $sql .= $hookmanager->resPrint;
473 $resql = $db->query($sql);
476 $num = $db->num_rows(
$resql);
477 $nbofloop = min($num, $maxofloop);
479 $result .=
'<div class="div-table-responsive-no-min">';
480 $result .=
'<table class="noborder centpercent">';
482 $result .=
'<tr class="liste_titre">';
483 $result .=
'<th colspan="3">';
484 $result .= $langs->trans(
"CustomersDraftInvoices").
' ';
485 $result .=
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?search_status='.
Facture::STATUS_DRAFT.
'">';
486 $result .=
'<span class="badge marginleftonlyshort">'.$num.
'</span>';
492 $companystatic =
new Societe($db);
497 while ($i < $nbofloop) {
498 $obj = $db->fetch_object(
$resql);
500 if ($i >= $maxCount) {
503 $tot_ttc += $obj->total_ttc;
507 $tmpinvoice->id = $obj->rowid;
508 $tmpinvoice->ref = $obj->ref;
509 $tmpinvoice->date = $db->jdate($obj->date);
510 $tmpinvoice->type = $obj->type;
511 $tmpinvoice->total_ht = $obj->total_ht;
512 $tmpinvoice->total_tva = $obj->total_tva;
513 $tmpinvoice->total_ttc = $obj->total_ttc;
514 $tmpinvoice->ref_client = $obj->ref_client;
515 $tmpinvoice->statut = $obj->status;
516 $tmpinvoice->paye = $obj->paye;
518 $companystatic->id = $obj->socid;
519 $companystatic->name = $obj->name;
520 $companystatic->email = $obj->email;
521 $companystatic->country_id = $obj->country_id;
522 $companystatic->country_code = $obj->country_code;
523 $companystatic->client = 1;
524 $companystatic->code_client = $obj->code_client;
525 $companystatic->code_fournisseur = $obj->code_fournisseur;
526 $companystatic->code_compta = $obj->code_compta;
527 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
529 $result .=
'<tr class="oddeven">';
530 $result .=
'<td class="nowrap tdoverflowmax100">';
531 $result .= $tmpinvoice->getNomUrl(1,
'');
533 $result .=
'<td class="nowrap tdoverflowmax100">';
534 $result .= $companystatic->getNomUrl(1,
'customer');
536 $result .=
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
538 $tot_ttc += $obj->total_ttc;
543 $result .=
'<tr class="oddeven">';
544 $result .=
'<td class="nowrap" colspan="3">';
545 $result .=
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
547 $result .=
"</tr>\n";
550 $result .=
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
551 $result .=
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
554 $result .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
556 $result .=
"</table></div>";
575 global $conf, $db, $langs, $user, $hookmanager;
580 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
584 $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";
585 $sql .=
", s.nom as name";
586 $sql .=
", s.rowid as socid, s.email";
587 $sql .=
", s.code_client, s.code_compta";
588 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
589 $sql .=
", cc.rowid as country_id, cc.code as country_code";
590 $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";
591 if (empty($user->rights->societe->client->voir) && !$socid) {
592 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
594 $sql .=
" WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT;
595 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
')';
596 if (empty($user->rights->societe->client->voir) && !$socid) {
597 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
600 $sql .=
" AND f.fk_soc = ".((int) $socid);
603 $parameters = array();
604 $reshook = $hookmanager->executeHooks(
'printFieldListWhereSupplierDraft', $parameters);
605 $sql .= $hookmanager->resPrint;
606 $resql = $db->query($sql);
609 $num = $db->num_rows(
$resql);
610 $nbofloop = min($num, $maxofloop);
612 $result .=
'<div class="div-table-responsive-no-min">';
613 $result .=
'<table class="noborder centpercent">';
615 $result .=
'<tr class="liste_titre">';
616 $result .=
'<th colspan="3">';
617 $result .= $langs->trans(
"SuppliersDraftInvoices").
' ';
619 $result .=
'<span class="badge marginleftonlyshort">'.$num.
'</span>';
625 $companystatic =
new Societe($db);
630 while ($i < $nbofloop) {
631 $obj = $db->fetch_object(
$resql);
633 if ($i >= $maxCount) {
636 $tot_ttc += $obj->total_ttc;
640 $facturesupplierstatic->ref = $obj->ref;
641 $facturesupplierstatic->id = $obj->rowid;
642 $facturesupplierstatic->total_ht = $obj->total_ht;
643 $facturesupplierstatic->total_tva = $obj->total_tva;
644 $facturesupplierstatic->total_ttc = $obj->total_ttc;
645 $facturesupplierstatic->ref_supplier = $obj->ref_supplier;
646 $facturesupplierstatic->type = $obj->type;
647 $facturesupplierstatic->statut = $obj->status;
648 $facturesupplierstatic->paye = $obj->paye;
650 $companystatic->id = $obj->socid;
651 $companystatic->name = $obj->name;
652 $companystatic->email = $obj->email;
653 $companystatic->country_id = $obj->country_id;
654 $companystatic->country_code = $obj->country_code;
655 $companystatic->fournisseur = 1;
656 $companystatic->code_client = $obj->code_client;
657 $companystatic->code_fournisseur = $obj->code_fournisseur;
658 $companystatic->code_compta = $obj->code_compta;
659 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
661 $result .=
'<tr class="oddeven">';
662 $result .=
'<td class="nowrap tdoverflowmax100">';
663 $result .= $facturesupplierstatic->getNomUrl(1,
'');
665 $result .=
'<td class="nowrap tdoverflowmax100">';
666 $result .= $companystatic->getNomUrl(1,
'supplier');
668 $result .=
'<td class="right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
670 $tot_ttc += $obj->total_ttc;
675 $result .=
'<tr class="oddeven">';
676 $result .=
'<td class="nowrap" colspan="3">';
677 $result .=
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
679 $result .=
"</tr>\n";
682 $result .=
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
683 $result .=
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
686 $result .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
688 $result .=
"</table></div>";
708 global $conf, $db, $langs, $user;
710 $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,";
711 $sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client";
712 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
713 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
714 if (empty($user->rights->societe->client->voir) && !$socid) {
715 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
717 $sql .=
" WHERE f.fk_soc = s.rowid";
718 $sql .=
" AND f.entity IN (".getEntity(
'facture').
")";
720 $sql .=
" AND f.fk_soc = ".((int) $socid);
722 if (empty($user->rights->societe->client->voir) && !$socid) {
723 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
725 $sql .=
" ORDER BY f.tms DESC";
726 $sql .= $db->plimit($maxCount, 0);
728 $resql = $db->query($sql);
733 $num = $db->num_rows(
$resql);
735 $result =
'<div class="div-table-responsive-no-min">';
736 $result .=
'<table class="noborder centpercent">';
738 $result .=
'<tr class="liste_titre">';
739 $result .=
'<th colspan="3">'.$langs->trans(
"LastCustomersBills", $maxCount).
'</th>';
740 $result .=
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
741 $result .=
'<th class="right"></th>';
745 $result .=
'</table>';
751 $objectstatic =
new Facture($db);
752 $companystatic =
new Societe($db);
756 $obj = $db->fetch_object(
$resql);
758 $objectstatic->id = $obj->rowid;
759 $objectstatic->ref = $obj->ref;
760 $objectstatic->paye = $obj->paye;
761 $objectstatic->statut = $obj->status;
762 $objectstatic->total_ht = $obj->total_ht;
763 $objectstatic->total_tva = $obj->total_tva;
764 $objectstatic->total_ttc = $obj->total_ttc;
765 $objectstatic->type = $obj->type;
767 $companystatic->id = $obj->socid;
768 $companystatic->name = $obj->socname;
769 $companystatic->client = $obj->client;
770 $companystatic->canvas = $obj->canvas;
773 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
775 $result .=
'<tr class="nowrap">';
777 $result .=
'<td class="oddeven">';
778 $result .=
'<table class="nobordernopadding">';
779 $result .=
'<tr class="nocellnopadd">';
781 $result .=
'<td width="96" class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
782 $result .=
'<td width="16" class="nobordernopadding nowrap"> </td>';
783 $result .=
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
786 $result .=
'</table>';
789 $result .=
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
790 $result .=
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
791 $result .=
'<td class="right amount">'.price($obj->total_ttc).
'</td>';
794 $payment = $objectstatic->getSommePaiement();
795 $result .=
'<td class="right">'.$objectstatic->getLibStatut(5, $payment).
'</td>';
802 $result .=
'</table>';
816 global $conf, $db, $langs, $user;
818 $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,";
819 $sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client";
820 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
821 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
822 if (empty($user->rights->societe->client->voir) && !$socid) {
823 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
825 $sql .=
" WHERE f.fk_soc = s.rowid";
826 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
828 $sql .=
" AND f.fk_soc = ".((int) $socid);
830 if (empty($user->rights->societe->client->voir) && !$socid) {
831 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
833 $sql .=
" ORDER BY f.tms DESC";
834 $sql .= $db->plimit($maxCount, 0);
836 $resql = $db->query($sql);
842 $num = $db->num_rows(
$resql);
844 $result =
'<div class="div-table-responsive-no-min">';
845 $result .=
'<table class="noborder centpercent">';
846 $result .=
'<tr class="liste_titre">';
847 $result .=
'<th colspan="3">'.$langs->trans(
"BoxTitleLastSupplierBills", $maxCount).
'</th>';
848 $result .=
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
849 $result .=
'<th class="right"></th>';
853 $result .=
'</table>';
859 $companystatic =
new Societe($db);
864 $obj = $db->fetch_object(
$resql);
866 $objectstatic->id = $obj->rowid;
867 $objectstatic->ref = $obj->ref;
868 $objectstatic->paye = $obj->paye;
869 $objectstatic->statut = $obj->status;
870 $objectstatic->total_ht = $obj->total_ht;
871 $objectstatic->total_tva = $obj->total_tva;
872 $objectstatic->total_ttc = $obj->total_ttc;
873 $objectstatic->type = $obj->type;
875 $companystatic->id = $obj->socid;
876 $companystatic->name = $obj->socname;
877 $companystatic->client = $obj->client;
878 $companystatic->canvas = $obj->canvas;
881 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
883 $result .=
'<tr class="nowrap">';
885 $result .=
'<td class="oddeven">';
886 $result .=
'<table class="nobordernopadding">';
887 $result .=
'<tr class="nocellnopadd">';
889 $result .=
'<td width="96" class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
890 $result .=
'<td width="16" class="nobordernopadding nowrap"> </td>';
891 $result .=
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
894 $result .=
'</table>';
897 $result .=
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
899 $result .=
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
901 $result .=
'<td class="amount right">'.price($obj->total_ttc).
'</td>';
903 $result .=
'<td class="right">'.$objectstatic->getLibStatut(5).
'</td>';
910 $result .=
'</table>';
924 global $conf, $db, $langs, $user, $hookmanager;
928 if (
isModEnabled(
'facture') && !empty($user->rights->facture->lire)) {
929 $tmpinvoice =
new Facture($db);
931 $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";
932 $sql .=
", f.date_lim_reglement as datelimite";
933 $sql .=
", s.nom as name";
934 $sql .=
", s.rowid as socid, s.email";
935 $sql .=
", s.code_client, s.code_compta";
936 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
937 $sql .=
", cc.rowid as country_id, cc.code as country_code";
938 $sql .=
", sum(pf.amount) as am";
939 $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";
940 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf on f.rowid=pf.fk_facture";
941 if (empty($user->rights->societe->client->voir) && !$socid) {
942 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
944 $sql .=
" WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = ".Facture::STATUS_VALIDATED;
945 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
')';
946 if (empty($user->rights->societe->client->voir) && !$socid) {
947 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
950 $sql .=
" AND f.fk_soc = ".((int) $socid);
953 $parameters = array();
954 $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerUnpaid', $parameters);
955 $sql .= $hookmanager->resPrint;
957 $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,";
958 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code";
959 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
960 $sql .=
" ORDER BY f.datef ASC, f.ref ASC";
962 $resql = $db->query($sql);
964 $num = $db->num_rows(
$resql);
970 print
'<div class="div-table-responsive-no-min">';
971 print
'<table class="noborder centpercent">';
973 print
'<tr class="liste_titre">';
974 print
'<th colspan="2">';
975 print $langs->trans(
"BillsCustomersUnpaid", $num).
' ';
977 print
'<span class="badge">'.$num.
'</span>';
981 print
'<th class="right">'.$langs->trans(
"DateDue").
'</th>';
982 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
983 print
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
985 print
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
986 print
'<th class="right">'.$langs->trans(
"Received").
'</th>';
987 print
'<th width="16"> </th>';
990 $societestatic =
new Societe($db);
991 $total_ttc = $totalam = $total = 0;
993 $obj = $db->fetch_object(
$resql);
995 if ($i >= $maxCount) {
998 $total += $obj->total_ht;
999 $total_ttc += $obj->total_ttc;
1000 $totalam += $obj->am;
1004 $tmpinvoice->ref = $obj->ref;
1005 $tmpinvoice->id = $obj->rowid;
1006 $tmpinvoice->total_ht = $obj->total_ht;
1007 $tmpinvoice->total_tva = $obj->total_tva;
1008 $tmpinvoice->total_ttc = $obj->total_ttc;
1009 $tmpinvoice->type = $obj->type;
1010 $tmpinvoice->statut = $obj->status;
1011 $tmpinvoice->paye = $obj->paye;
1012 $tmpinvoice->date_lim_reglement = $db->jdate($obj->datelimite);
1014 $societestatic->id = $obj->socid;
1015 $societestatic->name = $obj->name;
1016 $societestatic->email = $obj->email;
1017 $societestatic->country_id = $obj->country_id;
1018 $societestatic->country_code = $obj->country_code;
1019 $societestatic->client = 1;
1020 $societestatic->code_client = $obj->code_client;
1021 $societestatic->code_fournisseur = $obj->code_fournisseur;
1022 $societestatic->code_compta = $obj->code_compta;
1023 $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1025 print
'<tr class="oddeven">';
1026 print
'<td class="nowrap">';
1028 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1029 print
'<td class="nobordernopadding nowrap">';
1030 print $tmpinvoice->getNomUrl(1,
'');
1032 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
1035 $urlsource = $_SERVER[
'PHP_SELF'].
'?facid='.$obj->rowid;
1036 print $formfile->getDocumentsLink($tmpinvoice->element, $filename, $filedir);
1037 print
'</td></tr></table>';
1040 print
'<td class="nowrap tdoverflowmax100">';
1041 print $societestatic->getNomUrl(1,
'customer');
1043 print
'<td class="right">';
1045 if ($tmpinvoice->hasDelay()) {
1049 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1050 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
1052 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
1053 print
'<td class="nowrap right"><span class="amount">'.price($obj->am).
'</span></td>';
1054 print
'<td>'.$tmpinvoice->getLibStatut(3, $obj->am).
'</td>';
1057 $total_ttc += $obj->total_ttc;
1058 $total += $obj->total_ht;
1059 $totalam += $obj->am;
1066 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1069 print
'<tr class="oddeven">';
1070 print
'<td class="nowrap" colspan="'.$colspan.
'">';
1071 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1076 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>';
1077 print
'<td> </td>';
1078 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1079 print
'<td class="right"><span class="amount">'.price($total).
'</span></td>';
1081 print
'<td class="nowrap right"><span class="amount">'.price($total_ttc).
'</span></td>';
1082 print
'<td class="nowrap right"><span class="amount">'.price($totalam).
'</span></td>';
1083 print
'<td> </td>';
1087 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1090 print
'<tr class="oddeven"><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
1092 print
'</table></div><br>';
1112 global $conf, $db, $langs, $user, $hookmanager;
1116 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (
isModEnabled(
"supplier_invoice") && $user->rights->supplier_invoice->lire)) {
1119 $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";
1120 $sql .=
", ff.date_lim_reglement";
1121 $sql .=
", s.nom as name";
1122 $sql .=
", s.rowid as socid, s.email";
1123 $sql .=
", s.code_client, s.code_compta";
1124 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
1125 $sql .=
", sum(pf.amount) as am";
1126 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"facture_fourn as ff";
1127 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
1128 if (empty($user->rights->societe->client->voir) && !$socid) {
1129 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1131 $sql .=
" WHERE s.rowid = ff.fk_soc";
1132 $sql .=
" AND ff.entity = ".$conf->entity;
1133 $sql .=
" AND ff.paye = 0";
1134 $sql .=
" AND ff.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
1135 if (empty($user->rights->societe->client->voir) && !$socid) {
1136 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1139 $sql .=
" AND ff.fk_soc = ".((int) $socid);
1142 $parameters = array();
1143 $reshook = $hookmanager->executeHooks(
'printFieldListWhereSupplierUnpaid', $parameters);
1144 $sql .= $hookmanager->resPrint;
1146 $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,";
1147 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
1148 $sql .=
" ORDER BY ff.date_lim_reglement ASC";
1150 $resql = $db->query($sql);
1152 $num = $db->num_rows(
$resql);
1157 print
'<div class="div-table-responsive-no-min">';
1158 print
'<table class="noborder centpercent">';
1160 print
'<tr class="liste_titre">';
1161 print
'<th colspan="2">';
1162 print $langs->trans(
"BillsSuppliersUnpaid", $num).
' ';
1164 print
'<span class="badge">'.$num.
'</span>';
1168 print
'<th class="right">'.$langs->trans(
"DateDue").
'</th>';
1169 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1170 print
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
1172 print
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
1173 print
'<th class="right">'.$langs->trans(
"Paid").
'</th>';
1174 print
'<th width="16"> </th>';
1176 $societestatic =
new Societe($db);
1179 $total = $total_ttc = $totalam = 0;
1181 $obj = $db->fetch_object(
$resql);
1183 if ($i >= $maxCount) {
1186 $total += $obj->total_ht;
1187 $total_ttc += $obj->total_ttc;
1191 $facstatic->ref = $obj->ref;
1192 $facstatic->id = $obj->rowid;
1193 $facstatic->type = $obj->type;
1194 $facstatic->total_ht = $obj->total_ht;
1195 $facstatic->total_tva = $obj->total_tva;
1196 $facstatic->total_ttc = $obj->total_ttc;
1197 $facstatic->statut = $obj->status;
1198 $facstatic->paye = $obj->paye;
1200 $societestatic->id = $obj->socid;
1201 $societestatic->name = $obj->name;
1202 $societestatic->email = $obj->email;
1203 $societestatic->client = 0;
1204 $societestatic->fournisseur = 1;
1205 $societestatic->code_client = $obj->code_client;
1206 $societestatic->code_fournisseur = $obj->code_fournisseur;
1207 $societestatic->code_compta = $obj->code_compta;
1208 $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1210 print
'<tr class="oddeven">';
1211 print
'<td class="nowrap tdoverflowmax100">';
1212 print $facstatic->getNomUrl(1,
'');
1214 print
'<td class="nowrap tdoverflowmax100">'.$societestatic->getNomUrl(1,
'supplier').
'</td>';
1215 print
'<td class="right">'.dol_print_date($db->jdate($obj->date_lim_reglement),
'day').
'</td>';
1216 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1217 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
1219 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
1220 print
'<td class="nowrap right"><span class="amount">'.price($obj->am).
'</span></td>';
1221 print
'<td>'.$facstatic->getLibStatut(3, $obj->am).
'</td>';
1223 $total += $obj->total_ht;
1224 $total_ttc += $obj->total_ttc;
1225 $totalam += $obj->am;
1231 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1234 print
'<tr class="oddeven">';
1235 print
'<td class="nowrap" colspan="'.$colspan.
'">';
1236 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1241 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>';
1242 print
'<td> </td>';
1243 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1244 print
'<td class="right">'.price($total).
'</td>';
1246 print
'<td class="nowrap right">'.price($total_ttc).
'</td>';
1247 print
'<td class="nowrap right">'.price($totalam).
'</td>';
1248 print
'<td> </td>';
1252 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1255 print
'<tr class="oddeven"><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
1257 print
'</table></div><br>';