24 require
'../../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
33 $langs->loadLangs([
'bills',
'boxes']);
36 $socid =
GETPOST(
'socid',
'int');
37 if (isset($user->socid) && $user->socid > 0)
40 $socid = $user->socid;
44 $maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
45 $maxLatestEditCount = 5;
46 $maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
52 llxHeader(
"", $langs->trans(
"SupplierInvoicesArea"),
'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores');
56 print '<div class="fichecenter">';
58 print
'<div class="fichethirdleft">';
61 if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))
63 print getAreaSearchFrom();
67 print getPieChart($socid);
69 print getDraftTable($maxDraftCount, $socid);
73 print
'<div class="fichetwothirdright">';
74 print
'<div class="ficheaddleft">';
76 print getLatestEditTable($maxLatestEditCount, $socid);
78 print getOpenTable($maxOpenCount, $socid);
94 function getAreaSearchFrom()
98 $result =
'<form method="post" action="'.DOL_URL_ROOT.
'/compta/facture/list.php">';
99 $result .=
'<div class="div-table-responsive-no-min">';
100 $result .=
'<input type="hidden" name="token" value="'.newToken().
'">';
101 $result .=
'<table class="noborder nohover centpercent">';
103 $result .=
'<tr class="liste_titre">';
104 $result .=
'<td colspan="3">'.$langs->trans(
"Search").
'</td>';
107 $result .=
'<tr class="oddeven">';
108 $result .=
'<td>'.$langs->trans(
"Invoice").
':</td><td><input type="text" class="flat" name="sall" size=18></td>';
109 $result .=
'<td><input type="submit" value="'.$langs->trans(
"Search").
'" class="button"></td>';
112 $result .=
"</table>";
114 $result .=
"</form>";
125 function getPieChart($socid = 0)
127 global $conf, $db, $langs, $user;
129 $sql =
"SELECT count(f.rowid), f.fk_statut";
130 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
131 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as f";
132 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
133 $sql .=
" WHERE f.fk_soc = s.rowid";
134 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
135 if ($user->socid) $sql .=
' AND f.fk_soc = '.$user->socid;
136 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
137 $sql .=
" GROUP BY f.fk_statut";
139 $resql = $db->query($sql);
146 $num = $db->num_rows(
$resql);
154 $row = $db->fetch_row(
$resql);
157 $vals[$row[1]] = $row[0];
166 $result =
'<div class="div-table-responsive-no-min">';
167 $result .=
'<table class="noborder nohover centpercent">';
169 $result .=
'<tr class="liste_titre">';
170 $result .=
'<td colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"SupplierInvoice").
'</td>';
177 foreach ($array as $status)
179 $objectstatic->statut = $status;
180 $objectstatic->paye = $status == FactureFournisseur::STATUS_CLOSED ? -1 : 0;
182 $dataseries[] = [$objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)];
183 if (!$conf->use_javascript_ajax)
185 $result .=
'<tr class="oddeven">';
186 $result .=
'<td>'.$objectstatic->getLibStatut(0).
'</td>';
187 $result .=
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
192 if ($conf->use_javascript_ajax)
195 $dolgraph->SetData($dataseries);
196 $dolgraph->setShowLegend(2);
197 $dolgraph->setShowPercent(1);
198 $dolgraph->SetType([
'pie']);
199 $dolgraph->setHeight(
'200');
200 $dolgraph->draw(
'idgraphthirdparties');
203 $result .=
'<td align="center" colspan="2">'.$dolgraph->show($total ? 0 : 1).
'</td>';
207 $result .=
'<tr class="liste_total">';
208 $result .=
'<td>'.$langs->trans(
"Total").
'</td>';
209 $result .=
'<td class="right">'.$total.
'</td>';
212 $result .=
'</table>';
225 function getDraftTable($maxCount = 500, $socid = 0)
227 global $db, $langs, $user;
229 $sql =
"SELECT f.rowid, f.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client, f.total_ttc";
230 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
231 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
232 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
233 $sql .=
" WHERE f.fk_soc = s.rowid";
234 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
235 $sql .=
" AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT;
236 if ($socid) $sql .=
" AND f.fk_soc = ".$socid;
237 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
238 $sql .= $db->plimit($maxCount, 0);
240 $resql = $db->query($sql);
247 $num = $db->num_rows(
$resql);
249 $result =
'<div class="div-table-responsive-no-min">';
250 $result .=
'<table class="noborder centpercent">';
252 $result .=
'<tr class="liste_titre">';
253 $result .=
'<td colspan="3">';
254 $result .= $langs->trans(
"SuppliersDraftInvoices");
255 $result .=
' <a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?search_status=0">';
256 $result .=
'<span class="badge">'.$num.
'</span>';
263 $result .=
'</table>';
269 $companystatic =
new Societe($db);
270 $nbofloop = min($num, $maxCount);
274 while ($i < $nbofloop)
276 $obj = $db->fetch_object(
$resql);
278 $objectstatic->id = $obj->rowid;
279 $objectstatic->ref = $obj->ref;
281 $companystatic->id = $obj->socid;
282 $companystatic->name = $obj->socname;
283 $companystatic->client = $obj->client;
284 $companystatic->canvas = $obj->canvas;
286 $result .=
'<tr class="oddeven">';
287 $result .=
'<td class="nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
288 $result .=
'<td>'.$companystatic->getNomUrl(1,
'supplier', 24).
'</td>';
289 $result .=
'<td class="right">'.price($obj->total_ttc).
'</td>';
293 $total += $obj->total_ttc;
296 if ($num > $nbofloop)
298 $result .=
'<tr class="liste_total">';
299 $result .=
'<td colspan="3" class="right">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
'</td>';
304 $result .=
'<tr class="liste_total">';
305 $result .=
'<td colspan="2" class="right">'.$langs->trans(
"Total").
'</td>';
306 $result .=
'<td class="right">'.price($total).
'</td>';
310 $result .=
'</table>';
322 function getLatestEditTable($maxCount = 5, $socid = 0)
324 global $conf, $db, $langs, $user;
326 $sql =
"SELECT f.rowid, f.entity, f.ref, f.fk_statut as status, f.paye, s.nom as socname, s.rowid as socid, s.canvas, s.client,";
328 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
329 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
330 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
331 $sql .=
" WHERE f.fk_soc = s.rowid";
332 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
333 if ($socid) $sql .=
" AND f.fk_soc = ".$socid;
334 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
335 $sql .=
" ORDER BY f.tms DESC";
336 $sql .= $db->plimit($maxCount, 0);
338 $resql = $db->query($sql);
345 $num = $db->num_rows(
$resql);
347 $result =
'<div class="div-table-responsive-no-min">';
348 $result .=
'<table class="noborder centpercent">';
349 $result .=
'<tr class="liste_titre">';
350 $result .=
'<td colspan="4">'.$langs->trans(
"BoxTitleLastSupplierBills", $maxCount).
'</td>';
355 $result .=
'</table>';
361 $companystatic =
new Societe($db);
367 $obj = $db->fetch_object(
$resql);
369 $objectstatic->id = $obj->rowid;
370 $objectstatic->ref = $obj->ref;
371 $objectstatic->paye = $obj->paye;
372 $objectstatic->statut = $obj->status;
374 $companystatic->id = $obj->socid;
375 $companystatic->name = $obj->socname;
376 $companystatic->client = $obj->client;
377 $companystatic->canvas = $obj->canvas;
380 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
382 $result .=
'<tr width="20%" class="nowrap">';
384 $result .=
'<td class="oddeven">';
385 $result .=
'<table class="nobordernopadding">';
386 $result .=
'<tr class="nocellnopadd">';
388 $result .=
'<td width="96" class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
389 $result .=
'<td width="16" class="nobordernopadding nowrap"> </td>';
390 $result .=
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
393 $result .=
'</table>';
396 $result .=
'<td>'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
397 $result .=
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
398 $result .=
'<td class="right">'.$objectstatic->getLibStatut(5).
'</td>';
405 $result .=
'</table>';
417 function getOpenTable($maxCount = 500, $socid = 0)
419 global $conf, $db, $langs, $user;
421 $sql =
"SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client";
422 $sql .=
", f.rowid as id, f.entity, f.total_ttc, f.total_ht, f.ref, f.fk_statut";
423 $sql .=
", f.datef as df, f.date_lim_reglement as datelimite";
424 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
425 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as f";
426 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
427 $sql .=
" WHERE f.fk_soc = s.rowid";
428 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
429 $sql .=
" AND f.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
430 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
431 if ($socid) $sql .=
" AND s.rowid = ".$socid;
432 $sql .=
" ORDER BY f.rowid DESC";
433 $sql .= $db->plimit($maxCount, 0);
435 $resql = $db->query($sql);
442 $num = $db->num_rows(
$resql);
444 $result =
'<div class="div-table-responsive-no-min">';
445 $result .=
'<table class="noborder centpercent">';
446 $result .=
'<tr class="liste_titre">';
447 $result .=
'<td colspan="4">';
448 $result .= $langs->trans(
"BillsCustomersUnpaid");
449 $result .=
' <a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?search_status=1">';
450 $result .=
'<span class="badge">'.$num.
'</span>';
457 $result .=
'</table>';
463 $companystatic =
new Societe($db);
465 $nbofloop = min($num, $maxCount);
470 while ($i < $nbofloop)
472 $obj = $db->fetch_object(
$resql);
474 $objectstatic->id = $obj->id;
475 $objectstatic->ref = $obj->ref;
477 $companystatic->id = $obj->socid;
478 $companystatic->name = $obj->socname;
479 $companystatic->client = $obj->client;
480 $companystatic->canvas = $obj->canvas;
483 $filedir = $conf->propal->multidir_output[$obj->entity].
'/'.$filename;
485 $result .=
'<tr class="oddeven">';
487 $result .=
'<td class="nowrap" width="140">';
488 $result .=
'<table class="nobordernopadding">';
489 $result .=
'<tr class="nocellnopadd">';
491 $result .=
'<td class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).
'</td>';
492 $result .=
'<td width="18" class="nobordernopadding nowrap">';
494 if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay))
501 $result .=
'<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).
'</td>';
504 $result .=
'</table>';
507 $result .=
'<td class="left">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>';
508 $result .=
'<td class="right">'.dol_print_date($db->jdate($obj->df),
'day').
'</td>';
509 $result .=
'<td class="right">'.price($obj->total_ttc).
'</td>';
514 $total += $obj->total_ttc;
517 if ($num > $nbofloop)
519 $result .=
'<tr class="liste_total">';
520 $result .=
'<td colspan="4" class="right">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
'</td>';
525 $result .=
'<tr class="liste_total">';
526 $result .=
'<td colspan="2" class="right">'.$langs->trans(
"Total").
'</td>';
527 $result .=
'<td align="right">'.price($total).
'</td>';
528 $result .=
'<td> </td>';
532 $result .=
'</table>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_now($mode= 'auto')
Return date for now.
const STATUS_VALIDATED
Validated (need to be paid)
Class to manage suppliers invoices.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
const STATUS_CLOSED
Classified paid.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
const STATUS_ABANDONED
Classified abandoned and no payment done.