38 global $db, $langs, $conf, $user;
43 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/card.php?id='.$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?id='.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';
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";
65 $resql = $db->query(
$sql);
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?id='.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?id='.$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?id='.$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/agenda.php?id='.$object->id;
122 $head[$h][1] = $langs->trans(
"Events");
123 if (
isModEnabled(
'agenda')&& ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
126 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
127 $cachekey =
'count_events_facture_'.$object->id;
129 if (!is_null($dataretrieved)) {
130 $nbEvent = $dataretrieved;
132 $sql =
"SELECT COUNT(id) as nb";
133 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
134 $sql .=
" WHERE fk_element = ".((int) $object->id);
135 $sql .=
" AND elementtype = 'invoice'";
136 $resql = $db->query(
$sql);
138 $obj = $db->fetch_object($resql);
141 dol_syslog(
'Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
147 $head[$h][1] .= $langs->trans(
"Agenda");
149 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbEvent.
'</span>';
152 $head[$h][2] =
'agenda';
169 global $langs, $conf, $user, $db;
172 $extrafields->fetch_name_optionals_label(
'facture');
173 $extrafields->fetch_name_optionals_label(
'facturedet');
174 $extrafields->fetch_name_optionals_label(
'facture_rec');
175 $extrafields->fetch_name_optionals_label(
'facturedet_rec');
180 $head[$h][0] = DOL_URL_ROOT.
'/admin/facture.php';
181 $head[$h][1] = $langs->trans(
"Miscellaneous");
182 $head[$h][2] =
'general';
185 $head[$h][0] = DOL_URL_ROOT.
'/admin/payment.php';
186 $head[$h][1] = $langs->trans(
"Payments");
187 $head[$h][2] =
'payment';
196 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facture_cust_extrafields.php';
197 $head[$h][1] = $langs->trans(
"ExtraFieldsCustomerInvoices");
198 $nbExtrafields = $extrafields->attributes[
'facture'][
'count'];
199 if ($nbExtrafields > 0) {
200 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
202 $head[$h][2] =
'attributes';
205 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facturedet_cust_extrafields.php';
206 $head[$h][1] = $langs->trans(
"ExtraFieldsLines");
207 $nbExtrafields = $extrafields->attributes[
'facturedet'][
'count'];
208 if ($nbExtrafields > 0) {
209 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
211 $head[$h][2] =
'attributeslines';
214 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facture_rec_cust_extrafields.php';
215 $head[$h][1] = $langs->trans(
"ExtraFieldsCustomerInvoicesRec");
216 $nbExtrafields = $extrafields->attributes[
'facture_rec'][
'count'];
217 if ($nbExtrafields > 0) {
218 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
220 $head[$h][2] =
'attributesrec';
223 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/admin/facturedet_rec_cust_extrafields.php';
224 $head[$h][1] = $langs->trans(
"ExtraFieldsLinesRec");
225 $nbExtrafields = $extrafields->attributes[
'facturedet_rec'][
'count'];
226 if ($nbExtrafields > 0) {
227 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
229 $head[$h][2] =
'attributeslinesrec';
232 if (!empty($conf->global->INVOICE_USE_SITUATION)) {
233 $head[$h][0] = DOL_URL_ROOT.
'/admin/facture_situation.php';
234 $head[$h][1] = $langs->trans(
"InvoiceSituation");
235 $head[$h][2] =
'situation';
253 global $db, $langs, $conf, $user;
258 $head[$h][0] = DOL_URL_ROOT .
'/compta/facture/card-rec.php?id=' . $object->id;
259 $head[$h][1] = $langs->trans(
"RepeatableInvoice");
260 $head[$h][2] =
'card';
263 $head[$h][0] = DOL_URL_ROOT.
'/compta/facture/agenda-rec.php?id='.$object->id;
264 $head[$h][1] = $langs->trans(
"Events");
265 if (
isModEnabled(
'agenda')&& ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
268 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
269 $cachekey =
'count_events_facturerec_'.$object->id;
271 if (!is_null($dataretrieved)) {
272 $nbEvent = $dataretrieved;
274 $sql =
"SELECT COUNT(id) as nb";
275 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
276 $sql .=
" WHERE fk_element = ".((int) $object->id);
277 $sql .=
" AND elementtype = 'invoicerec'";
278 $resql = $db->query(
$sql);
280 $obj = $db->fetch_object($resql);
283 dol_syslog(
'Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
289 $head[$h][1] .= $langs->trans(
"Agenda");
291 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbEvent.
'</span>';
294 $head[$h][2] =
'agenda';
316 global $db, $langs, $conf;
321 $head[$h][0] = DOL_URL_ROOT .
'/fourn/facture/card-rec.php?id=' . $object->id;
322 $head[$h][1] = $langs->trans(
"RepeatableSupplierInvoice");
323 $head[$h][2] =
'card';
345 global $conf, $db, $langs, $user;
347 if (($mode ==
'customers' &&
isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire'))
348 || ($mode ==
'suppliers' && (
isModEnabled(
'fournisseur') ||
isModEnabled(
'supplier_invoice')) && $user->hasRight(
'fournisseur',
'facture',
'lire'))
350 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
352 $now = date_create(date(
'Y-m-d',
dol_now()));
353 $datenowsub30 = date_create(date(
'Y-m-d',
dol_now()));
354 $datenowsub15 = date_create(date(
'Y-m-d',
dol_now()));
355 $datenowadd30 = date_create(date(
'Y-m-d',
dol_now()));
356 $datenowadd15 = date_create(date(
'Y-m-d',
dol_now()));
357 $interval30days = date_interval_create_from_date_string(
'30 days');
358 $interval15days = date_interval_create_from_date_string(
'15 days');
359 date_sub($datenowsub30, $interval30days);
360 date_sub($datenowsub15, $interval15days);
361 date_add($datenowadd30, $interval30days);
362 date_add($datenowadd15, $interval15days);
365 $sql .=
" sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($datenowsub30,
'Y-m-d').
"'", 1, 0).
") as nblate30";
366 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($datenowsub15,
'Y-m-d').
"'", 1, 0).
") as nblate15";
367 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement < '".date_format($now,
'Y-m-d').
"'", 1, 0).
") as nblatenow";
368 $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";
369 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement > '".date_format($datenowadd15,
'Y-m-d').
"'", 1, 0).
") as nbnotlate15";
370 $sql .=
", sum(".$db->ifsql(
"f.date_lim_reglement > '".date_format($datenowadd30,
'Y-m-d').
"'", 1, 0).
") as nbnotlate30";
371 if ($mode ==
'customers') {
372 $element =
'invoice';
373 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
374 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
375 $element =
'supplier_invoice';
376 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
380 $sql .=
" WHERE f.entity IN (".getEntity($element).
")";
381 $sql .=
" AND f.type <> 2";
382 $sql .=
" AND f.fk_statut = 1";
383 if (isset($user->socid) && $user->socid > 0) {
384 $sql .=
" AND f.fk_soc = ".((int) $user->socid);
387 $resql = $db->query(
$sql);
389 $num = $db->num_rows($resql);
392 $dataseries = array();
395 $obj = $db->fetch_object($resql);
404 $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);
407 if (!empty($dataseries[0])) {
408 foreach ($dataseries[0] as $key => $value) {
409 if (is_numeric($value)) {
415 $langs->trans(
'InvoiceLate30Days'),
416 $langs->trans(
'InvoiceLate15Days'),
417 $langs->trans(
'InvoiceLateMinus15Days'),
418 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate') : $langs->trans(
"InvoiceToPay"),
419 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate15Days') : $langs->trans(
"InvoiceToPay15Days"),
420 $mode ==
'customers' ? $langs->trans(
'InvoiceNotLate30Days') : $langs->trans(
"InvoiceToPay30Days"),
423 $colorseries = array($badgeStatus8, $badgeStatus1, $badgeStatus3, $badgeStatus4, $badgeStatus11,
'-'.$badgeStatus11);
425 $result =
'<div class="div-table-responsive-no-min">';
426 $result .=
'<table class="noborder nohover centpercent">';
427 $result .=
'<tr class="liste_titre">';
428 $result .=
'<td>'.$langs->trans(
"NbOfOpenInvoices").
' - ';
429 if ($mode ==
'customers') {
430 $result .= $langs->trans(
"CustomerInvoice");
431 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
432 $result .= $langs->trans(
"SupplierInvoice");
439 if ($conf->use_javascript_ajax) {
442 $dolgraph->SetData($dataseries);
444 $dolgraph->setLegend($legend);
446 $dolgraph->SetDataColor(array_values($colorseries));
447 $dolgraph->setShowLegend(2);
448 $dolgraph->setShowPercent(1);
449 $dolgraph->SetType(array(
'bars',
'bars',
'bars',
'bars',
'bars',
'bars'));
451 $dolgraph->setHeight(
'160');
452 $dolgraph->setWidth(
'450');
453 $dolgraph->setHideXValues(
true);
454 if ($mode ==
'customers') {
455 $dolgraph->draw(
'idgraphcustomerinvoices');
456 } elseif ($mode ==
'fourn' || $mode ==
'suppliers') {
457 $dolgraph->draw(
'idgraphfourninvoices');
461 $result .=
'<tr maxwidth="255">';
462 $result .=
'<td class="center">'.$dolgraph->show($total ? 0 : $langs->trans(
"NoOpenInvoice")).
'</td>';
468 $result .=
'</table>';
488 global $conf, $db, $langs, $user, $hookmanager;
492 if (
isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')) {
493 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
495 $tmpinvoice =
new Facture($db);
497 $sql =
"SELECT f.rowid, f.ref, f.datef as date, f.total_ht, f.total_tva, f.total_ttc, f.ref_client";
498 $sql .=
", f.type, f.fk_statut as status, f.paye";
499 $sql .=
", s.nom as name";
500 $sql .=
", s.rowid as socid, s.email";
501 $sql .=
", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
502 $sql .=
", cc.rowid as country_id, cc.code as country_code";
503 if (empty($user->rights->societe->client->voir) && !$socid) {
504 $sql .=
", sc.fk_soc, sc.fk_user ";
506 $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";
507 if (empty($user->rights->societe->client->voir) && !$socid) {
508 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
510 $sql .=
" WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT;
511 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
512 if (empty($user->rights->societe->client->voir) && !$socid) {
513 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
517 $sql .=
" AND f.fk_soc = ".((int) $socid);
520 $parameters = array();
521 $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerDraft', $parameters);
522 $sql .= $hookmanager->resPrint;
524 $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,";
525 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,";
526 $sql .=
" cc.rowid, cc.code";
527 if (empty($user->rights->societe->client->voir) && !$socid) {
528 $sql .=
", sc.fk_soc, sc.fk_user";
532 $parameters = array();
533 $reshook = $hookmanager->executeHooks(
'printFieldListGroupByCustomerDraft', $parameters);
534 $sql .= $hookmanager->resPrint;
536 $resql = $db->query(
$sql);
539 $num = $db->num_rows($resql);
540 $nbofloop = min($num, $maxofloop);
542 $result .=
'<div class="div-table-responsive-no-min">';
543 $result .=
'<table class="noborder centpercent">';
545 $result .=
'<tr class="liste_titre">';
546 $result .=
'<th colspan="3">';
547 $result .= $langs->trans(
"CustomersDraftInvoices").
' ';
548 $result .=
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?search_status='.
Facture::STATUS_DRAFT.
'">';
549 $result .=
'<span class="badge marginleftonlyshort">'.$num.
'</span>';
555 $companystatic =
new Societe($db);
560 while ($i < $nbofloop) {
561 $obj = $db->fetch_object($resql);
563 if ($i >= $maxCount) {
566 $tot_ttc += $obj->total_ttc;
570 $tmpinvoice->id = $obj->rowid;
571 $tmpinvoice->ref = $obj->ref;
572 $tmpinvoice->date = $db->jdate($obj->date);
573 $tmpinvoice->type = $obj->type;
574 $tmpinvoice->total_ht = $obj->total_ht;
575 $tmpinvoice->total_tva = $obj->total_tva;
576 $tmpinvoice->total_ttc = $obj->total_ttc;
577 $tmpinvoice->ref_client = $obj->ref_client;
578 $tmpinvoice->statut = $obj->status;
579 $tmpinvoice->paye = $obj->paye;
581 $companystatic->id = $obj->socid;
582 $companystatic->name = $obj->name;
583 $companystatic->email = $obj->email;
584 $companystatic->country_id = $obj->country_id;
585 $companystatic->country_code = $obj->country_code;
586 $companystatic->client = 1;
587 $companystatic->code_client = $obj->code_client;
588 $companystatic->code_fournisseur = $obj->code_fournisseur;
589 $companystatic->code_compta = $obj->code_compta;
590 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
592 $result .=
'<tr class="oddeven">';
593 $result .=
'<td class="nowrap tdoverflowmax100">';
594 $result .= $tmpinvoice->getNomUrl(1,
'');
596 $result .=
'<td class="nowrap tdoverflowmax100">';
597 $result .= $companystatic->getNomUrl(1,
'customer');
599 $result .=
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
601 $tot_ttc += $obj->total_ttc;
606 $result .=
'<tr class="oddeven">';
607 $result .=
'<td class="nowrap" colspan="3">';
608 $result .=
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
610 $result .=
"</tr>\n";
613 $result .=
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
614 $result .=
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
617 $result .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
619 $result .=
"</table></div>";
638 global $conf, $db, $langs, $user, $hookmanager;
643 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
647 $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";
648 $sql .=
", s.nom as name";
649 $sql .=
", s.rowid as socid, s.email";
650 $sql .=
", s.code_client, s.code_compta";
651 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
652 $sql .=
", cc.rowid as country_id, cc.code as country_code";
653 $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";
654 if (empty($user->rights->societe->client->voir) && !$socid) {
655 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
657 $sql .=
" WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT;
658 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
')';
659 if (empty($user->rights->societe->client->voir) && !$socid) {
660 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
663 $sql .=
" AND f.fk_soc = ".((int) $socid);
666 $parameters = array();
667 $reshook = $hookmanager->executeHooks(
'printFieldListWhereSupplierDraft', $parameters);
668 $sql .= $hookmanager->resPrint;
669 $resql = $db->query(
$sql);
672 $num = $db->num_rows($resql);
673 $nbofloop = min($num, $maxofloop);
675 $result .=
'<div class="div-table-responsive-no-min">';
676 $result .=
'<table class="noborder centpercent">';
678 $result .=
'<tr class="liste_titre">';
679 $result .=
'<th colspan="3">';
680 $result .= $langs->trans(
"SuppliersDraftInvoices").
' ';
682 $result .=
'<span class="badge marginleftonlyshort">'.$num.
'</span>';
688 $companystatic =
new Societe($db);
693 while ($i < $nbofloop) {
694 $obj = $db->fetch_object($resql);
696 if ($i >= $maxCount) {
699 $tot_ttc += $obj->total_ttc;
703 $facturesupplierstatic->ref = $obj->ref;
704 $facturesupplierstatic->id = $obj->rowid;
705 $facturesupplierstatic->total_ht = $obj->total_ht;
706 $facturesupplierstatic->total_tva = $obj->total_tva;
707 $facturesupplierstatic->total_ttc = $obj->total_ttc;
708 $facturesupplierstatic->ref_supplier = $obj->ref_supplier;
709 $facturesupplierstatic->type = $obj->type;
710 $facturesupplierstatic->statut = $obj->status;
711 $facturesupplierstatic->paye = $obj->paye;
713 $companystatic->id = $obj->socid;
714 $companystatic->name = $obj->name;
715 $companystatic->email = $obj->email;
716 $companystatic->country_id = $obj->country_id;
717 $companystatic->country_code = $obj->country_code;
718 $companystatic->fournisseur = 1;
719 $companystatic->code_client = $obj->code_client;
720 $companystatic->code_fournisseur = $obj->code_fournisseur;
721 $companystatic->code_compta = $obj->code_compta;
722 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
724 $result .=
'<tr class="oddeven">';
725 $result .=
'<td class="nowrap tdoverflowmax100">';
726 $result .= $facturesupplierstatic->getNomUrl(1,
'');
728 $result .=
'<td class="nowrap tdoverflowmax100">';
729 $result .= $companystatic->getNomUrl(1,
'supplier');
731 $result .=
'<td class="right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
733 $tot_ttc += $obj->total_ttc;
738 $result .=
'<tr class="oddeven">';
739 $result .=
'<td class="nowrap" colspan="3">';
740 $result .=
'<span class="opacitymedium">'.$langs->trans(
"More").
'...'.($othernb < $maxofloop ?
' ('.$othernb.
')' :
'').
'</span>';
742 $result .=
"</tr>\n";
745 $result .=
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
746 $result .=
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
749 $result .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
751 $result .=
"</table></div>";
771 global $conf, $db, $langs, $user;
773 $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,";
774 $sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client";
775 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
776 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
777 if (empty($user->rights->societe->client->voir) && !$socid) {
778 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
780 $sql .=
" WHERE f.fk_soc = s.rowid";
781 $sql .=
" AND f.entity IN (".getEntity(
'facture').
")";
783 $sql .=
" AND f.fk_soc = ".((int) $socid);
785 if (empty($user->rights->societe->client->voir) && !$socid) {
786 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
788 $sql .=
" ORDER BY f.tms DESC";
789 $sql .= $db->plimit($maxCount, 0);
791 $resql = $db->query(
$sql);
796 $num = $db->num_rows($resql);
798 $result =
'<div class="div-table-responsive-no-min">';
799 $result .=
'<table class="noborder centpercent">';
801 $result .=
'<tr class="liste_titre">';
802 $result .=
'<th colspan="3">'.$langs->trans(
"LastCustomersBills", $maxCount).
'</th>';
803 $result .=
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
804 $result .=
'<th class="right"></th>';
808 $result .=
'</table>';
814 $objectstatic =
new Facture($db);
815 $companystatic =
new Societe($db);
819 $obj = $db->fetch_object($resql);
821 $objectstatic->id = $obj->rowid;
822 $objectstatic->ref = $obj->ref;
823 $objectstatic->paye = $obj->paye;
824 $objectstatic->statut = $obj->status;
825 $objectstatic->total_ht = $obj->total_ht;
826 $objectstatic->total_tva = $obj->total_tva;
827 $objectstatic->total_ttc = $obj->total_ttc;
828 $objectstatic->type = $obj->type;
830 $companystatic->id = $obj->socid;
831 $companystatic->name = $obj->socname;
832 $companystatic->client = $obj->client;
833 $companystatic->canvas = $obj->canvas;
836 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
838 $result .=
'<tr class="nowrap">';
840 $result .=
'<td class="oddeven">';
841 $result .=
'<table class="nobordernopadding">';
842 $result .=
'<tr class="nocellnopadd">';
844 $result .=
'<td width="96" class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
845 $result .=
'<td width="16" class="nobordernopadding nowrap"> </td>';
846 $result .=
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
849 $result .=
'</table>';
852 $result .=
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
853 $result .=
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
854 $result .=
'<td class="right amount">'.price($obj->total_ttc).
'</td>';
857 $payment = $objectstatic->getSommePaiement();
858 $result .=
'<td class="right">'.$objectstatic->getLibStatut(5, $payment).
'</td>';
865 $result .=
'</table>';
879 global $conf, $db, $langs, $user;
881 $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,";
882 $sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client";
883 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
884 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
885 if (empty($user->rights->societe->client->voir) && !$socid) {
886 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
888 $sql .=
" WHERE f.fk_soc = s.rowid";
889 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
891 $sql .=
" AND f.fk_soc = ".((int) $socid);
893 if (empty($user->rights->societe->client->voir) && !$socid) {
894 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
896 $sql .=
" ORDER BY f.tms DESC";
897 $sql .= $db->plimit($maxCount, 0);
899 $resql = $db->query(
$sql);
905 $num = $db->num_rows($resql);
907 $result =
'<div class="div-table-responsive-no-min">';
908 $result .=
'<table class="noborder centpercent">';
909 $result .=
'<tr class="liste_titre">';
910 $result .=
'<th colspan="3">'.$langs->trans(
"BoxTitleLastSupplierBills", $maxCount).
'</th>';
911 $result .=
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
912 $result .=
'<th class="right"></th>';
916 $result .=
'</table>';
922 $companystatic =
new Societe($db);
927 $obj = $db->fetch_object($resql);
929 $objectstatic->id = $obj->rowid;
930 $objectstatic->ref = $obj->ref;
931 $objectstatic->paye = $obj->paye;
932 $objectstatic->statut = $obj->status;
933 $objectstatic->total_ht = $obj->total_ht;
934 $objectstatic->total_tva = $obj->total_tva;
935 $objectstatic->total_ttc = $obj->total_ttc;
936 $objectstatic->type = $obj->type;
938 $companystatic->id = $obj->socid;
939 $companystatic->name = $obj->socname;
940 $companystatic->client = $obj->client;
941 $companystatic->canvas = $obj->canvas;
944 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
946 $result .=
'<tr class="nowrap">';
948 $result .=
'<td class="oddeven">';
949 $result .=
'<table class="nobordernopadding">';
950 $result .=
'<tr class="nocellnopadd">';
952 $result .=
'<td width="96" class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
953 $result .=
'<td width="16" class="nobordernopadding nowrap"> </td>';
954 $result .=
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
957 $result .=
'</table>';
960 $result .=
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
962 $result .=
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
964 $result .=
'<td class="amount right">'.price($obj->total_ttc).
'</td>';
966 $result .=
'<td class="right">'.$objectstatic->getLibStatut(5).
'</td>';
973 $result .=
'</table>';
987 global $conf, $db, $langs, $user, $hookmanager;
991 if (
isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')) {
992 $tmpinvoice =
new Facture($db);
994 $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";
995 $sql .=
", f.date_lim_reglement as datelimite";
996 $sql .=
", s.nom as name";
997 $sql .=
", s.rowid as socid, s.email";
998 $sql .=
", s.code_client, s.code_compta";
999 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
1000 $sql .=
", cc.rowid as country_id, cc.code as country_code";
1001 $sql .=
", sum(pf.amount) as am";
1002 $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";
1003 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf on f.rowid=pf.fk_facture";
1004 if (empty($user->rights->societe->client->voir) && !$socid) {
1005 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1007 $sql .=
" WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = ".Facture::STATUS_VALIDATED;
1008 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
')';
1009 if (empty($user->rights->societe->client->voir) && !$socid) {
1010 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1013 $sql .=
" AND f.fk_soc = ".((int) $socid);
1016 $parameters = array();
1017 $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerUnpaid', $parameters);
1018 $sql .= $hookmanager->resPrint;
1020 $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,";
1021 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code";
1022 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
1023 $sql .=
" ORDER BY f.datef ASC, f.ref ASC";
1025 $resql = $db->query(
$sql);
1027 $num = $db->num_rows($resql);
1033 print
'<div class="div-table-responsive-no-min">';
1034 print
'<table class="noborder centpercent">';
1036 print
'<tr class="liste_titre">';
1037 print
'<th colspan="2">';
1038 print $langs->trans(
"BillsCustomersUnpaid", $num).
' ';
1040 print
'<span class="badge">'.$num.
'</span>';
1044 print
'<th class="right">'.$langs->trans(
"DateDue").
'</th>';
1045 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1046 print
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
1048 print
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
1049 print
'<th class="right">'.$langs->trans(
"Received").
'</th>';
1050 print
'<th width="16"> </th>';
1053 $societestatic =
new Societe($db);
1054 $total_ttc = $totalam = $total = 0;
1056 $obj = $db->fetch_object($resql);
1058 if ($i >= $maxCount) {
1061 $total += $obj->total_ht;
1062 $total_ttc += $obj->total_ttc;
1063 $totalam += $obj->am;
1067 $tmpinvoice->ref = $obj->ref;
1068 $tmpinvoice->id = $obj->rowid;
1069 $tmpinvoice->total_ht = $obj->total_ht;
1070 $tmpinvoice->total_tva = $obj->total_tva;
1071 $tmpinvoice->total_ttc = $obj->total_ttc;
1072 $tmpinvoice->type = $obj->type;
1073 $tmpinvoice->statut = $obj->status;
1074 $tmpinvoice->paye = $obj->paye;
1075 $tmpinvoice->date_lim_reglement = $db->jdate($obj->datelimite);
1077 $societestatic->id = $obj->socid;
1078 $societestatic->name = $obj->name;
1079 $societestatic->email = $obj->email;
1080 $societestatic->country_id = $obj->country_id;
1081 $societestatic->country_code = $obj->country_code;
1082 $societestatic->client = 1;
1083 $societestatic->code_client = $obj->code_client;
1084 $societestatic->code_fournisseur = $obj->code_fournisseur;
1085 $societestatic->code_compta = $obj->code_compta;
1086 $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1088 print
'<tr class="oddeven">';
1089 print
'<td class="nowrap">';
1091 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1092 print
'<td class="nobordernopadding nowrap">';
1093 print $tmpinvoice->getNomUrl(1,
'');
1095 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
1098 $urlsource = $_SERVER[
'PHP_SELF'].
'?facid='.$obj->rowid;
1099 print $formfile->getDocumentsLink($tmpinvoice->element, $filename, $filedir);
1100 print
'</td></tr></table>';
1103 print
'<td class="nowrap tdoverflowmax100">';
1104 print $societestatic->getNomUrl(1,
'customer');
1106 print
'<td class="right">';
1108 if ($tmpinvoice->hasDelay()) {
1112 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1113 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
1115 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
1116 print
'<td class="nowrap right"><span class="amount">'.price($obj->am).
'</span></td>';
1117 print
'<td>'.$tmpinvoice->getLibStatut(3, $obj->am).
'</td>';
1120 $total_ttc += $obj->total_ttc;
1121 $total += $obj->total_ht;
1122 $totalam += $obj->am;
1129 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1132 print
'<tr class="oddeven">';
1133 print
'<td class="nowrap" colspan="'.$colspan.
'">';
1134 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1139 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>';
1140 print
'<td> </td>';
1141 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1142 print
'<td class="right"><span class="amount">'.price($total).
'</span></td>';
1144 print
'<td class="nowrap right"><span class="amount">'.price($total_ttc).
'</span></td>';
1145 print
'<td class="nowrap right"><span class="amount">'.price($totalam).
'</span></td>';
1146 print
'<td> </td>';
1150 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1153 print
'<tr class="oddeven"><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
1155 print
'</table></div><br>';
1175 global $conf, $db, $langs, $user, $hookmanager;
1179 if (
isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
1182 $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";
1183 $sql .=
", ff.date_lim_reglement";
1184 $sql .=
", s.nom as name";
1185 $sql .=
", s.rowid as socid, s.email";
1186 $sql .=
", s.code_client, s.code_compta";
1187 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur";
1188 $sql .=
", sum(pf.amount) as am";
1189 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"facture_fourn as ff";
1190 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
1191 if (empty($user->rights->societe->client->voir) && !$socid) {
1192 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1194 $sql .=
" WHERE s.rowid = ff.fk_soc";
1195 $sql .=
" AND ff.entity = ".$conf->entity;
1196 $sql .=
" AND ff.paye = 0";
1197 $sql .=
" AND ff.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
1198 if (empty($user->rights->societe->client->voir) && !$socid) {
1199 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1202 $sql .=
" AND ff.fk_soc = ".((int) $socid);
1205 $parameters = array();
1206 $reshook = $hookmanager->executeHooks(
'printFieldListWhereSupplierUnpaid', $parameters);
1207 $sql .= $hookmanager->resPrint;
1209 $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,";
1210 $sql .=
" s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
1211 $sql .=
" ORDER BY ff.date_lim_reglement ASC";
1213 $resql = $db->query(
$sql);
1215 $num = $db->num_rows($resql);
1220 print
'<div class="div-table-responsive-no-min">';
1221 print
'<table class="noborder centpercent">';
1223 print
'<tr class="liste_titre">';
1224 print
'<th colspan="2">';
1225 print $langs->trans(
"BillsSuppliersUnpaid", $num).
' ';
1227 print
'<span class="badge">'.$num.
'</span>';
1231 print
'<th class="right">'.$langs->trans(
"DateDue").
'</th>';
1232 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1233 print
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
1235 print
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
1236 print
'<th class="right">'.$langs->trans(
"Paid").
'</th>';
1237 print
'<th width="16"> </th>';
1239 $societestatic =
new Societe($db);
1242 $total = $total_ttc = $totalam = 0;
1244 $obj = $db->fetch_object($resql);
1246 if ($i >= $maxCount) {
1249 $total += $obj->total_ht;
1250 $total_ttc += $obj->total_ttc;
1254 $facstatic->ref = $obj->ref;
1255 $facstatic->id = $obj->rowid;
1256 $facstatic->type = $obj->type;
1257 $facstatic->total_ht = $obj->total_ht;
1258 $facstatic->total_tva = $obj->total_tva;
1259 $facstatic->total_ttc = $obj->total_ttc;
1260 $facstatic->statut = $obj->status;
1261 $facstatic->paye = $obj->paye;
1263 $societestatic->id = $obj->socid;
1264 $societestatic->name = $obj->name;
1265 $societestatic->email = $obj->email;
1266 $societestatic->client = 0;
1267 $societestatic->fournisseur = 1;
1268 $societestatic->code_client = $obj->code_client;
1269 $societestatic->code_fournisseur = $obj->code_fournisseur;
1270 $societestatic->code_compta = $obj->code_compta;
1271 $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1273 print
'<tr class="oddeven">';
1274 print
'<td class="nowrap tdoverflowmax100">';
1275 print $facstatic->getNomUrl(1,
'');
1277 print
'<td class="nowrap tdoverflowmax100">'.$societestatic->getNomUrl(1,
'supplier').
'</td>';
1278 print
'<td class="right">'.dol_print_date($db->jdate($obj->date_lim_reglement),
'day').
'</td>';
1279 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1280 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
1282 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
1283 print
'<td class="nowrap right"><span class="amount">'.price($obj->am).
'</span></td>';
1284 print
'<td>'.$facstatic->getLibStatut(3, $obj->am).
'</td>';
1286 $total += $obj->total_ht;
1287 $total_ttc += $obj->total_ttc;
1288 $totalam += $obj->am;
1294 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1297 print
'<tr class="oddeven">';
1298 print
'<td class="nowrap" colspan="'.$colspan.
'">';
1299 print
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
1304 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>';
1305 print
'<td> </td>';
1306 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1307 print
'<td class="right">'.price($total).
'</td>';
1309 print
'<td class="nowrap right">'.price($total_ttc).
'</td>';
1310 print
'<td class="nowrap right">'.price($totalam).
'</td>';
1311 print
'<td> </td>';
1315 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
1318 print
'<tr class="oddeven"><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</td></tr>';
1320 print
'</table></div><br>';