29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
36 $langs->loadLangs(array(
"companies",
"bills"));
38 $socid =
GETPOST(
'socid',
'int');
45 $socid = $user->socid;
48 $sortfield =
GETPOST(
"sortfield",
'alpha');
49 $sortorder =
GETPOST(
"sortorder",
'alpha');
51 $search_ref =
GETPOST(
'search_ref',
'alpha');
52 $search_ref_supplier =
GETPOST(
'search_ref_supplier',
'alpha');
53 $search_company =
GETPOST(
'search_company',
'alpha');
54 $search_amount_no_tax =
GETPOST(
'search_amount_no_tax',
'alpha');
55 $search_amount_all_tax =
GETPOST(
'search_amount_all_tax',
'alpha');
57 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
59 if (empty($page) || $page == -1) { $page = 0; }
60 $offset = $limit * $page;
61 $pageprev = $page - 1;
62 $pagenext = $page + 1;
63 if (!$sortfield) $sortfield =
"f.date_lim_reglement";
64 if (!$sortorder) $sortorder =
"ASC";
66 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
69 $search_ref_supplier =
"";
71 $search_amount_no_tax =
"";
72 $search_amount_all_tax =
"";
81 llxHeader(
'', $langs->trans(
"BillsSuppliersUnpaid"));
83 $title = $langs->trans(
"BillsSuppliersUnpaid");
86 $companystatic =
new Societe($db);
88 if ($user->rights->fournisseur->facture->lire)
90 $sql =
"SELECT s.rowid as socid, s.nom as name,";
91 $sql .=
" f.rowid, f.ref, f.ref_supplier, f.total_ht, f.total_ttc,";
92 $sql .=
" f.datef as df, f.date_lim_reglement as datelimite, ";
93 $sql .=
" f.paye as paye, f.rowid as facid, f.fk_statut";
94 $sql .=
" ,sum(pf.amount) as am";
95 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", sc.fk_soc, sc.fk_user ";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
97 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
98 $sql .=
",".MAIN_DB_PREFIX.
"facture_fourn as f";
99 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn ";
100 $sql .=
" WHERE f.entity = ".$conf->entity;
101 $sql .=
" AND f.fk_soc = s.rowid";
102 $sql .=
" AND f.paye = 0 AND f.fk_statut = 1";
103 if ($option ==
'late') $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() - $conf->facture->fournisseur->warning_delay).
"'";
104 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
105 if ($socid) $sql .=
" AND s.rowid = ".$socid;
109 $filtrearr = explode(
",",
GETPOST(
'filtre'));
110 foreach ($filtrearr as $fil)
112 $filt = explode(
":", $fil);
113 $sql .=
" AND ".$filt[0].
" = ".$filt[1];
119 $sql .=
" AND f.ref LIKE '%".$db->escape($search_ref).
"%'";
121 if ($search_ref_supplier)
123 $sql .=
" AND f.ref_supplier LIKE '%".$db->escape($search_ref_supplier).
"%'";
128 $sql .=
" AND s.nom LIKE '%".$db->escape($search_company).
"%'";
131 if ($search_amount_no_tax)
133 $sql .=
" AND f.total_ht = '".$db->escape($search_amount_no_tax).
"'";
136 if ($search_amount_all_tax)
138 $sql .=
" AND f.total_ttc = '".$db->escape($search_amount_all_tax).
"'";
143 $sql .=
" AND f.ref_supplier LIKE '%".$db->escape(
GETPOST(
'sf_re')).
"%'";
146 $sql .=
" GROUP BY s.rowid, s.nom, f.rowid, f.ref, f.ref_supplier, f.total_ht, f.total_ttc, f.datef, f.date_lim_reglement, f.paye, f.fk_statut";
147 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", sc.fk_soc, sc.fk_user ";
148 $sql .= $db->order($sortfield, $sortorder);
149 if (!in_array(
"f.ref_supplier", explode(
',', $sortfield))) $sql .=
", f.ref_supplier DESC";
151 $resql = $db->query($sql);
154 $num = $db->num_rows(
$resql);
163 if ($socid) $param .=
"&socid=".$socid;
165 if ($search_ref) $param .=
'&search_ref='.urlencode($search_ref);
166 if ($search_ref_supplier) $param .=
'&search_ref_supplier='.urlencode($search_ref_supplier);
167 if ($search_company) $param .=
'&search_company='.urlencode($search_company);
168 if ($search_amount_no_tax) $param .=
'&search_amount_no_tax='.urlencode($search_amount_no_tax);
169 if ($search_amount_all_tax) $param .=
'&search_amount_all_tax='.urlencode($search_amount_all_tax);
171 $param .= ($option ?
"&option=".$option :
"");
172 if (!empty($late)) $param .=
'&late='.urlencode($late);
173 $urlsource = str_replace(
'&',
'&', $param);
175 $titre = ($socid ? $langs->trans(
"BillsSuppliersUnpaidForCompany", $soc->name) : $langs->trans(
"BillsSuppliersUnpaid"));
177 if ($option ==
'late') $titre .=
' ('.$langs->trans(
"Late").
')';
178 else $titre .=
' ('.$langs->trans(
"All").
')';
181 if (empty($option)) $link =
'<a href="'.$_SERVER[
"PHP_SELF"].
'?option=late'.($socid ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"ShowUnpaidLateOnly").
'</a>';
182 elseif ($option ==
'late') $link = '<a href="'.
$_SERVER["PHP_SELF"].'?'.($socid ? '&socid='.$socid : '').'">'.$langs->trans("ShowUnpaidAll").'</a>';
187 print '<form method="get" action="'.
$_SERVER["PHP_SELF"].'">';
189 print '<table class="liste centpercent">';
190 print '<tr class="liste_titre">';
199 print_liste_field_titre("
Status",
$_SERVER["PHP_SELF"], "fk_statut,paye,am", "", $param, '', $sortfield, $sortorder, 'right ');
203 print '<tr class="liste_titre">';
204 print '<td class="liste_titre">';
205 print '<input class="flat" size="8"
type="text"
name="search_ref" value="'.$search_ref.'"></td>';
206 print '<td class="liste_titre">';
207 print '<input class="flat" size="8"
type="text"
name="search_ref_supplier" value="'.$search_ref_supplier.'"></td>';
208 print '<td class="liste_titre"> </td>';
209 print '<td class="liste_titre"> </td>';
210 print '<td class="liste_titre left">';
211 print '<input class="flat"
type="text" size="6"
name="search_company" value="'.$search_company.'">';
212 print '</td><td class="liste_titre right">';
213 print '<input class="flat"
type="text" size="8"
name="search_amount_no_tax" value="'.$search_amount_no_tax.'">';
214 print '</td><td class="liste_titre right">';
215 print '<input class="flat"
type="text" size="8"
name="search_amount_all_tax" value="'.$search_amount_all_tax.'">';
217 print '<td class="liste_titre maxwidthsearch">';
218 $searchpicto = $form->showFilterAndCheckAddButtons(0);
231 $objp = $db->fetch_object(
$resql);
233 $facturestatic->statut = $objp->fk_statut;
234 $facturestatic->date_echeance = $db->jdate($objp->datelimite);
238 print '<tr class="oddeven">';
239 $classname =
"impayee";
241 print '<td class="nowrap">';
242 $facturestatic->id = $objp->facid;
243 $facturestatic->ref = $objp->ref;
244 print $facturestatic->getNomUrl(1);
247 print '<td class="nowrap">'.dol_trunc($objp->ref_supplier, 12).
'</td>';
249 print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->df),
'day').
"</td>\n";
250 print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->datelimite),
'day');
251 if ($facturestatic->hasDelay()) {
257 $companystatic->id = $objp->socid;
258 $companystatic->name = $objp->name;
259 print $companystatic->getNomUrl(1,
'supplier', 32);
262 print "<td class=\"right\">".price($objp->total_ht).
"</td>";
263 print "<td class=\"right\">".price($objp->total_ttc).
"</td>";
264 print "<td class=\"right\">".price($objp->am).
"</td>";
267 print '<td class="right nowrap">';
268 print $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 5, $objp->am);
272 $total_ht += $objp->total_ht;
273 $total_ttc += $objp->total_ttc;
274 $total_paid += $objp->am;
279 print '<tr class="liste_total">';
280 print "<td colspan=\"5\" class=\"left\">".$langs->trans(
"Total").
": </td>";
281 print "<td class=\"right\"><b>".price($total_ht).
"</b></td>";
282 print "<td class=\"right\"><b>".price($total_ttc).
"</b></td>";
283 print "<td class=\"right\"><b>".price($total_paid).
"</b></td>";
284 print '<td class="center"> </td>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
dol_now($mode= 'auto')
Return date for now.
Class to manage suppliers invoices.
$conf db name
Only used if Module[ID]Name translation string is not found.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
if(!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'] s nom
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
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...
print $_SERVER["PHP_SELF"] n
Edit parameters.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type