38 require
'../../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
47 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
50 $langs->loadLangs(array(
'products',
'bills',
'companies',
'projects'));
52 $action =
GETPOST(
'action',
'aZ09');
53 $massaction =
GETPOST(
'massaction',
'alpha');
54 $show_files =
GETPOST(
'show_files',
'int');
55 $confirm =
GETPOST(
'confirm',
'alpha');
56 $toselect =
GETPOST(
'toselect',
'array');
57 $optioncss =
GETPOST(
'optioncss',
'alpha');
58 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierinvoicelist';
61 $socid =
GETPOST(
'socid',
'int');
64 if ($user->socid > 0) {
67 $socid = $user->socid;
70 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
71 $search_label =
GETPOST(
"search_label",
"alpha");
72 $search_amount_no_tax =
GETPOST(
"search_amount_no_tax",
"alpha");
73 $search_amount_all_tax =
GETPOST(
"search_amount_all_tax",
"alpha");
75 $search_refsupplier =
GETPOST(
'search_refsupplier',
'alpha');
76 $search_type =
GETPOST(
'search_type',
'int');
77 $search_project =
GETPOST(
'search_project',
'alpha');
78 $search_company =
GETPOST(
'search_company',
'alpha');
79 $search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
80 $search_montant_ht =
GETPOST(
'search_montant_ht',
'alpha');
81 $search_montant_vat =
GETPOST(
'search_montant_vat',
'alpha');
82 $search_montant_localtax1 =
GETPOST(
'search_montant_localtax1',
'alpha');
83 $search_montant_localtax2 =
GETPOST(
'search_montant_localtax2',
'alpha');
84 $search_montant_ttc =
GETPOST(
'search_montant_ttc',
'alpha');
85 $search_login =
GETPOST(
'search_login',
'alpha');
86 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
87 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
88 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
89 $search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
90 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
91 $search_status =
GETPOST(
'search_status',
'int');
92 $search_paymentmode =
GETPOST(
'search_paymentmode',
'int');
93 $search_paymentcond =
GETPOST(
'search_paymentcond',
'int');
94 $search_town =
GETPOST(
'search_town',
'alpha');
95 $search_zip =
GETPOST(
'search_zip',
'alpha');
96 $search_state =
GETPOST(
"search_state");
97 $search_country =
GETPOST(
"search_country",
'int');
98 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
99 $search_user =
GETPOST(
'search_user',
'int');
100 $search_sale =
GETPOST(
'search_sale',
'int');
101 $search_date_start =
GETPOSTDATE(
'search_date_start',
'',
'tzserver');
102 $search_date_end =
GETPOSTDATE(
'search_date_end',
'23:59:59',
'tzserver');
103 $search_datelimit_startday =
GETPOST(
'search_datelimit_startday',
'int');
104 $search_datelimit_startmonth =
GETPOST(
'search_datelimit_startmonth',
'int');
105 $search_datelimit_startyear =
GETPOST(
'search_datelimit_startyear',
'int');
106 $search_datelimit_endday =
GETPOST(
'search_datelimit_endday',
'int');
107 $search_datelimit_endmonth =
GETPOST(
'search_datelimit_endmonth',
'int');
108 $search_datelimit_endyear =
GETPOST(
'search_datelimit_endyear',
'int');
109 $search_datelimit_start =
dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
110 $search_datelimit_end =
dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
111 $search_btn =
GETPOST(
'button_search',
'alpha');
112 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
113 $search_categ_sup = trim(
GETPOST(
"search_categ_sup",
'int'));
114 $search_product_category =
GETPOST(
'search_product_category',
'int');
116 $option =
GETPOST(
'search_option');
117 if ($option ==
'late') {
118 $search_status =
'1';
120 $filter =
GETPOST(
'filtre',
'alpha');
123 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
124 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
125 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
127 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
131 $offset = $limit * $page;
132 $pageprev = $page - 1;
133 $pagenext = $page + 1;
138 $sortfield =
"f.datef,f.rowid";
141 $diroutputmassaction = $conf->fournisseur->facture->dir_output.
'/temp/massgeneration/'.$user->id;
147 $hookmanager->initHooks(array(
'supplierinvoicelist'));
151 $extrafields->fetch_name_optionals_label($object->table_element);
153 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
156 $fieldstosearchall = array(
158 'f.ref_supplier'=>
'RefSupplier',
159 'f.note_public'=>
'NotePublic',
160 's.nom'=>
"ThirdParty",
161 'pd.description'=>
'Description',
163 if (empty($user->socid)) {
164 $fieldstosearchall[
"f.note_private"] =
"NotePrivate";
167 $checkedtypetiers = 0;
168 $arrayfields = array(
169 'f.ref'=>array(
'label'=>
"Ref",
'checked'=>1),
170 'f.ref_supplier'=>array(
'label'=>
"RefSupplier",
'checked'=>1),
171 'f.type'=>array(
'label'=>
"Type",
'checked'=>0),
172 'f.label'=>array(
'label'=>
"Label",
'checked'=>0),
173 'f.datef'=>array(
'label'=>
"DateInvoice",
'checked'=>1),
174 'f.date_lim_reglement'=>array(
'label'=>
"DateDue",
'checked'=>1),
175 'p.ref'=>array(
'label'=>
"ProjectRef",
'checked'=>0),
176 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1),
177 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'checked'=>0),
178 's.town'=>array(
'label'=>
"Town",
'checked'=>-1),
179 's.zip'=>array(
'label'=>
"Zip",
'checked'=>1),
180 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0),
181 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0),
182 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers),
183 'f.fk_cond_reglement'=>array(
'label'=>
"PaymentTerm",
'checked'=>1,
'position'=>50),
184 'f.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>1,
'position'=>52),
185 'f.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1,
'position'=>105),
186 'f.total_vat'=>array(
'label'=>
"AmountVAT",
'checked'=>0,
'position'=>110),
187 'f.total_localtax1'=>array(
'label'=>$langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked'=>0,
'enabled'=>$mysoc->localtax1_assuj ==
"1",
'position'=>95),
188 'f.total_localtax2'=>array(
'label'=>$langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked'=>0,
'enabled'=>$mysoc->localtax2_assuj ==
"1",
'position'=>100),
189 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0,
'position'=>115),
190 'dynamount_payed'=>array(
'label'=>
"Paid",
'checked'=>0,
'position'=>116),
191 'rtp'=>array(
'label'=>
"Rest",
'checked'=>0,
'position'=>117),
192 'f.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
193 'f.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
194 'f.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
195 'f.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
196 'f.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
197 'multicurrency_dynamount_payed'=>array(
'label'=>
'MulticurrencyAlreadyPaid',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
198 'multicurrency_rtp'=>array(
'label'=>
'MulticurrencyRemainderToPay',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
199 'u.login'=>array(
'label'=>
"Author",
'checked'=>1,
'position'=>500),
200 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>501),
201 'f.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>502),
202 'f.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000),
203 'f.nb_docs'=>array(
'label'=>
"Documents",
'checked'=>1,
'position'=>510),
206 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
214 if ((!$user->hasRight(
"fournisseur",
"facture",
"lire") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
215 || (!$user->hasRight(
"supplier_invoice",
"lire") && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
219 $permissiontoread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
220 $permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
221 $permissiontodelete = ($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer"));
228 if (
GETPOST(
'cancel',
'alpha')) {
232 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
236 $parameters = array(
'socid'=>$socid);
237 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
242 if (empty($reshook)) {
244 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
247 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha')) {
251 $search_product_category =
'';
253 $search_refsupplier =
"";
256 $search_project =
'';
257 $search_company =
"";
258 $search_company_alias =
"";
259 $search_amount_no_tax =
"";
260 $search_amount_all_tax =
"";
261 $search_montant_ht =
'';
262 $search_montant_vat =
'';
263 $search_montant_localtax1 =
'';
264 $search_montant_localtax2 =
'';
265 $search_montant_ttc =
'';
267 $search_multicurrency_code =
'';
268 $search_multicurrency_tx =
'';
269 $search_multicurrency_montant_ht =
'';
270 $search_multicurrency_montant_vat =
'';
271 $search_multicurrency_montant_ttc =
'';
273 $search_paymentmode =
'';
274 $search_paymentcond =
'';
279 $search_country =
'';
280 $search_type_thirdparty =
'';
281 $search_date_start =
'';
282 $search_date_end =
'';
283 $search_datelimit_startday =
'';
284 $search_datelimit_startmonth =
'';
285 $search_datelimit_startyear =
'';
286 $search_datelimit_endday =
'';
287 $search_datelimit_endmonth =
'';
288 $search_datelimit_endyear =
'';
289 $search_datelimit_start =
'';
290 $search_datelimit_end =
'';
292 $search_array_options = array();
293 $search_categ_sup = 0;
300 $objectclass =
'FactureFournisseur';
301 $objectlabel =
'SupplierInvoices';
302 $uploaddir = $conf->fournisseur->facture->dir_output;
303 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
305 if ($massaction ==
'banktransfertrequest') {
306 $langs->load(
"withdrawals");
308 if (!$user->hasRight(
"paymentbybanktransfer",
"create")) {
315 $arrayofselected = is_array($toselect) ? $toselect : array();
316 $listofbills = array();
317 foreach ($arrayofselected as $toselectid) {
319 $result = $objecttmp->fetch($toselectid);
321 $totalpaid = $objecttmp->getSommePaiement();
322 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
323 $totaldeposits = $objecttmp->getSumDepositsUsed();
324 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
327 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
328 } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
330 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
331 } elseif ($objecttmp->resteapayer < 0) {
333 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
336 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
337 $rsql .=
" , pfd.date_traite as date_traite";
338 $rsql .=
" , pfd.amount";
339 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
340 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
341 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
342 $rsql .=
" WHERE fk_facture_fourn = ".((int) $objecttmp->id);
343 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
344 $rsql .=
" AND pfd.traite = 0";
345 $rsql .=
" ORDER BY pfd.date_demande DESC";
347 $result_sql = $db->query($rsql);
349 $numprlv = $db->num_rows($result_sql);
354 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
355 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'VIR') {
357 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"BadPaymentMethod"), $objecttmp->errors,
'errors');
359 $listofbills[] = $objecttmp;
365 if (!empty($listofbills)) {
366 $nbwithdrawrequestok = 0;
367 foreach ($listofbills as $aBill) {
369 $result = $aBill->demande_prelevement($user, $aBill->resteapayer,
'bank-transfer',
'supplier_invoice');
372 $nbwithdrawrequestok++;
378 if ($nbwithdrawrequestok > 0) {
379 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
394 $bankaccountstatic =
new Account($db);
397 $thirdparty =
new Societe($db);
401 $title = $langs->trans(
"BillsSuppliers").($socid ?
' '.$soc->name :
'');
402 $help_url =
'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores';
408 $sql =
'SELECT DISTINCT';
410 $sql .=
" f.rowid as facid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement, f.fk_cond_reglement,";
411 $sql .=
" f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,";
412 $sql .=
" f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,";
413 $sql .=
' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva as multicurrency_total_vat, f.multicurrency_total_ttc,';
414 $sql .=
" f.note_public, f.note_private,";
415 $sql .=
" f.fk_user_author,";
416 $sql .=
" s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,";
417 $sql .=
" typent.code as typent_code,";
418 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
419 $sql .=
" country.code as country_code,";
420 $sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
421 $sql .=
' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
425 $sql .=
', SUM(pf.amount) as dynamount_payed';
428 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
429 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
430 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
434 $parameters = array();
435 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
436 $sql .= $hookmanager->resPrint;
437 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
441 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
442 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
443 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
444 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
445 $sql .=
', '.MAIN_DB_PREFIX.
'facture_fourn as f';
446 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
447 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
450 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
453 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn';
455 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
456 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
458 if ($search_sale > 0 || (!$user->hasRight(
"societe",
"client",
"voir") && !$socid)) {
459 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
461 if ($search_user > 0) {
462 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
463 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
466 $parameters = array();
467 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
468 $sql .= $hookmanager->resPrint;
469 $sql .=
' WHERE f.fk_soc = s.rowid';
470 $sql .=
' AND f.entity IN ('.getEntity(
'facture_fourn').
')';
471 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
472 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
475 $sql .=
' AND s.rowid = '.((int) $socid);
478 if (is_numeric($search_ref)) {
487 if ($search_refsupplier) {
490 if ($search_type !=
'' && $search_type >= 0) {
491 if ($search_type ==
'0') {
492 $sql .=
" AND f.type = 0";
494 if ($search_type ==
'1') {
495 $sql .=
" AND f.type = 1";
497 if ($search_type ==
'2') {
498 $sql .=
" AND f.type = 2";
500 if ($search_type ==
'3') {
501 $sql .=
" AND f.type = 3";
506 if ($search_project) {
509 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
512 if ($search_company) {
515 if ($search_company_alias) {
528 if ($search_country) {
529 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
531 if ($search_type_thirdparty !=
'' && $search_type_thirdparty >= 0) {
532 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
534 if ($search_montant_ht !=
'') {
537 if ($search_montant_vat !=
'') {
540 if ($search_montant_localtax1 !=
'') {
543 if ($search_montant_localtax2 !=
'') {
546 if ($search_montant_ttc !=
'') {
549 if ($search_multicurrency_code !=
'') {
550 $sql .=
" AND f.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
552 if ($search_multicurrency_tx !=
'') {
555 if ($search_multicurrency_montant_ht !=
'') {
556 $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
558 if ($search_multicurrency_montant_vat !=
'') {
559 $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
561 if ($search_multicurrency_montant_ttc !=
'') {
562 $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
567 if ($search_status !=
'' && $search_status >= 0) {
568 $sql .=
" AND f.fk_statut = ".((int) $search_status);
570 if ($search_paymentmode > 0) {
571 $sql .=
" AND f.fk_mode_reglement = ".((int) $search_paymentmode);
573 if ($search_paymentcond > 0) {
574 $sql .=
" AND f.fk_cond_reglement = ".((int) $search_paymentcond);
576 if ($search_date_start) {
577 $sql .=
" AND f.datef >= '" . $db->idate($search_date_start) .
"'";
579 if ($search_date_end) {
580 $sql .=
" AND f.datef <= '" . $db->idate($search_date_end) .
"'";
582 if ($search_datelimit_start) {
583 $sql .=
" AND f.date_lim_reglement >= '" . $db->idate($search_datelimit_start) .
"'";
585 if ($search_datelimit_end) {
586 $sql .=
" AND f.date_lim_reglement <= '" . $db->idate($search_datelimit_end) .
"'";
588 if ($option ==
'late') {
589 $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() - $conf->facture->fournisseur->warning_delay).
"'";
594 $searchCategorySupplierList = $search_categ_sup ? array($search_categ_sup) : array();
595 $searchCategorySupplierOperator = 0;
597 if (!empty($searchCategorySupplierList)) {
598 $searchCategorySupplierSqlList = array();
599 $listofcategoryid =
'';
600 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
601 if (intval($searchCategorySupplier) == -2) {
602 $searchCategorySupplierSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
603 } elseif (intval($searchCategorySupplier) > 0) {
604 if ($searchCategorySupplierOperator == 0) {
605 $searchCategorySupplierSqlList[] =
" EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).
")";
607 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategorySupplier);
611 if ($listofcategoryid) {
612 $searchCategorySupplierSqlList[] =
" EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
614 if ($searchCategorySupplierOperator == 1) {
615 if (!empty($searchCategorySupplierSqlList)) {
616 $sql .=
" AND (".implode(
' OR ', $searchCategorySupplierSqlList).
")";
619 if (!empty($searchCategorySupplierSqlList)) {
620 $sql .=
" AND (".implode(
' AND ', $searchCategorySupplierSqlList).
")";
625 $searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
626 $searchCategoryProductOperator = 0;
627 if (!empty($searchCategoryProductList)) {
628 $searchCategoryProductSqlList = array();
629 $listofcategoryid =
'';
630 foreach ($searchCategoryProductList as $searchCategoryProduct) {
631 if (intval($searchCategoryProduct) == -2) {
632 $searchCategoryProductSqlList[] =
"NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product)";
633 } elseif (intval($searchCategoryProduct) > 0) {
634 if ($searchCategoryProductOperator == 0) {
635 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
637 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
641 if ($listofcategoryid) {
642 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
644 if ($searchCategoryProductOperator == 1) {
645 if (!empty($searchCategoryProductSqlList)) {
646 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
649 if (!empty($searchCategoryProductSqlList)) {
650 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
654 if ($search_status !=
'' && $search_status >= 0) {
655 $sql .=
" AND f.fk_statut = ".((int) $search_status);
657 if ($filter && $filter != -1) {
658 $aFilter = explode(
',', $filter);
659 foreach ($aFilter as $fil) {
660 $filt = explode(
':', $fil);
661 $sql .=
" AND ".$db->escape(trim($filt[0])).
" = '".$db->escape(trim($filt[1])).
"'";
664 if ($search_sale > 0) {
665 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
667 if ($search_user > 0) {
668 $sql .=
" AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".((int) $search_user);
671 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
673 $parameters = array();
674 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
675 $sql .= $hookmanager->resPrint;
678 $sql .=
" GROUP BY f.rowid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement, f.fk_mode_reglement, f.fk_cond_reglement,";
679 $sql .=
" f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,";
680 $sql .=
" f.localtax1, f.localtax2,";
681 $sql .=
' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
682 $sql .=
" f.note_public, f.note_private,";
683 $sql .=
" f.fk_user_author,";
684 $sql .=
' s.rowid, s.nom, s.name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
685 $sql .=
" typent.code,";
686 $sql .=
" state.code_departement, state.nom,";
687 $sql .=
' country.code,';
688 $sql .=
" p.rowid, p.ref, p.title,";
689 $sql .=
" u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender";
690 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
691 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
693 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
",ef.".$key :
'');
697 $parameters = array(
'all' => $search_all,
'fieldstosearchall' => $fieldstosearchall);
698 $reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object, $action);
699 $sql .= $hookmanager->resPrint;
705 $parameters = array();
706 $reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
707 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
710 $nbtotalofrecords =
'';
713 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
714 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
715 $resql = $db->query($sqlforcount);
717 $objforcount = $db->fetch_object($resql);
718 $nbtotalofrecords = $objforcount->nbtotalofrecords;
723 if (($page * $limit) > $nbtotalofrecords) {
731 $sql .= $db->order($sortfield, $sortorder);
733 $sql .= $db->plimit($limit + 1, $offset);
737 $resql = $db->query(
$sql);
743 $num = $db->num_rows($resql);
745 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
746 $obj = $db->fetch_object($resql);
749 header(
"Location: ".DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$id);
761 if (empty($search_company)) {
762 $search_company = $soc->name;
763 $search_company_alias = $soc->name_alias;
767 $arrayofselected = is_array($toselect) ? $toselect : array();
769 $param =
'&socid='.$socid;
771 $param .=
'&mode='.urlencode($mode);
773 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
774 $param .=
'&contextpage='.urlencode($contextpage);
776 if ($limit > 0 && $limit != $conf->liste_limit) {
777 $param .=
'&limit='.((int) $limit);
779 if ($optioncss !=
'') {
780 $param .=
'&optioncss='.urlencode($optioncss);
783 $param .=
'&search_all='.urlencode($search_all);
785 if ($search_date_start) {
786 $param .=
buildParamDate(
'search_date_start',
null,
'',
'tzserver');
788 if ($search_date_end) {
789 $param .=
buildParamDate(
'search_date_end',
null,
'',
'tzserver');
791 if ($search_datelimit_startday) {
792 $param .=
'&search_datelimit_startday='.urlencode($search_datelimit_startday);
794 if ($search_datelimit_startmonth) {
795 $param .=
'&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth);
797 if ($search_datelimit_startyear) {
798 $param .=
'&search_datelimit_startyear='.urlencode($search_datelimit_startyear);
800 if ($search_datelimit_endday) {
801 $param .=
'&search_datelimit_endday='.urlencode($search_datelimit_endday);
803 if ($search_datelimit_endmonth) {
804 $param .=
'&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth);
806 if ($search_datelimit_endyear) {
807 $param .=
'&search_datelimit_endyear='.urlencode($search_datelimit_endyear);
810 $param .=
'&search_ref='.urlencode($search_ref);
812 if ($search_refsupplier) {
813 $param .=
'&search_refsupplier='.urlencode($search_refsupplier);
815 if ($search_type !=
'') {
816 $param .=
'&search_type='.urlencode($search_type);
819 $param .=
'&search_label='.urlencode($search_label);
821 if ($search_company) {
822 $param .=
'&search_company='.urlencode($search_company);
824 if ($search_company_alias) {
825 $param .=
'&search_company_alias='.urlencode($search_company_alias);
828 $param .=
'&search_login='.urlencode($search_login);
830 if ($search_montant_ht !=
'') {
831 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
833 if ($search_montant_vat !=
'') {
834 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
836 if ($search_montant_localtax1 !=
'') {
837 $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
839 if ($search_montant_localtax2 !=
'') {
840 $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
842 if ($search_montant_ttc !=
'') {
843 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
845 if ($search_multicurrency_code !=
'') {
846 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
848 if ($search_multicurrency_tx !=
'') {
849 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
851 if ($search_multicurrency_montant_ht !=
'') {
852 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
854 if ($search_multicurrency_montant_vat !=
'') {
855 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
857 if ($search_multicurrency_montant_ttc !=
'') {
858 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
860 if ($search_amount_no_tax) {
861 $param .=
'&search_amount_no_tax='.urlencode($search_amount_no_tax);
863 if ($search_amount_all_tax) {
864 $param .=
'&search_amount_all_tax='.urlencode($search_amount_all_tax);
866 if ($search_status >= 0) {
867 $param .=
"&search_status=".urlencode($search_status);
870 $param .=
'&show_files='.urlencode($show_files);
873 $param .=
"&search_option=".urlencode($option);
875 if ($search_categ_sup > 0) {
876 $param .=
'&search_categ_sup='.urlencode($search_categ_sup);
878 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
879 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
883 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
885 $parameters = array();
886 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
887 $param .= $hookmanager->resPrint;
890 $arrayofmassactions = array(
891 'validate'=>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
892 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
897 if (
isModEnabled(
'paymentbybanktransfer') && $user->hasRight(
"paymentbybanktransfer",
"create")) {
898 $langs->load(
'withdrawals');
899 $arrayofmassactions[
'banktransfertrequest'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeBankTransferOrder");
901 if (!empty($permissiontodelete)) {
902 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
904 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
905 $arrayofmassactions = array();
907 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
909 $url = DOL_URL_ROOT.
'/fourn/facture/card.php?action=create';
910 if (!empty($socid)) {
911 $url .=
'&socid='.urlencode($socid);
915 print
'<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
916 if ($optioncss !=
'') {
917 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
919 print
'<input type="hidden" name="token" value="'.newToken().
'">';
920 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
921 print
'<input type="hidden" name="action" value="list">';
922 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
923 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
924 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
925 print
'<input type="hidden" name="page" value="'.$page.
'">';
926 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
927 print
'<input type="hidden" name="page_y" value="">';
928 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
931 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss'=>
'reposition'));
932 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss'=>
'reposition'));
934 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer")));
936 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'supplier_invoice', 0, $newcardbutton,
'', $limit, 0, 0, 1);
938 $topicmail =
"SendBillRef";
939 $modelmail =
"invoice_supplier_send";
941 $trackid =
'sinv'.$object->id;
942 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
946 foreach ($fieldstosearchall as $key => $val) {
947 $fieldstosearchall[$key] = $langs->trans($val);
948 $setupstring .= $key.
"=".$val.
";";
950 print
'<!-- Search done like if SUPPLIER_INVOICE_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
951 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
956 if ($user->hasRight(
"user",
"user",
"lire")) {
957 $langs->load(
"commercial");
958 $moreforfilter .=
'<div class="divsearchfield">';
959 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
960 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth200');
961 $moreforfilter .=
'</div>';
964 if ($user->hasRight(
"user",
"user",
"lire")) {
965 $moreforfilter .=
'<div class="divsearchfield">';
966 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
967 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
968 $moreforfilter .=
'</div>';
971 if (
isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
972 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
973 $moreforfilter .=
'<div class="divsearchfield">';
974 $tmptitle = $langs->trans(
'IncludingProductWithTag');
975 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
976 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0, 0,
'maxwidth300 widthcentpercentminusx', 1);
977 $moreforfilter .=
'</div>';
981 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
982 $moreforfilter .=
'<div class="divsearchfield">';
983 $tmptitle = $langs->trans(
'SuppliersCategoriesShort');
984 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'supplier', $search_categ_sup,
'search_categ_sup', 1, $tmptitle);
985 $moreforfilter .=
'</div>';
987 $parameters = array();
988 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
989 if (empty($reshook)) {
990 $moreforfilter .= $hookmanager->resPrint;
992 $moreforfilter = $hookmanager->resPrint;
995 if (!empty($moreforfilter)) {
996 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
997 print $moreforfilter;
1001 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1002 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1003 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
1005 print
'<div class="div-table-responsive">';
1006 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1010 print
'<tr class="liste_titre_filter">';
1013 print
'<td class="liste_titre center maxwidthsearch">';
1014 $searchpicto =
$form->showFilterButtons(
'left');
1019 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1020 print
'<td class="liste_titre left">';
1021 print
'<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1025 if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1026 print
'<td class="liste_titre">';
1027 print
'<input class="flat maxwidth75" type="text" name="search_refsupplier" value="'.dol_escape_htmltag($search_refsupplier).
'">';
1031 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1032 print
'<td class="liste_titre maxwidthonsmartphone">';
1046 print
$form->selectarray(
'search_type', $listtype, $search_type, 1, 0, 0,
'', 0, 0, 0,
'ASC',
'maxwidth100');
1050 if (!empty($arrayfields[
'f.label'][
'checked'])) {
1051 print
'<td class="liste_titre">';
1052 print
'<input class="flat maxwidth75" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).
'">';
1056 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1057 print
'<td class="liste_titre center">';
1058 print
'<div class="nowrap">';
1059 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1061 print
'<div class="nowrap">';
1062 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1067 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1068 print
'<td class="liste_titre center">';
1069 print
'<div class="nowrap">';
1076 print
$form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"Before"));
1077 print
'<br><input type="checkbox" name="search_option" value="late"'.($option ==
'late' ?
' checked' :
'').
'> '.$langs->trans(
"Alert");
1082 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1083 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1086 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1087 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'"'.($socid > 0 ?
" disabled" :
"").
'></td>';
1090 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1091 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1094 if (!empty($arrayfields[
's.town'][
'checked'])) {
1095 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1098 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1099 print
'<td class="liste_titre center"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1102 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1103 print
'<td class="liste_titre">';
1104 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1108 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1109 print
'<td class="liste_titre center">';
1110 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1114 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1115 print
'<td class="liste_titre maxwidthonsmartphone center">';
1116 print
$form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
1120 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1121 print
'<td class="liste_titre left">';
1122 print
$form->getSelectConditionsPaiements($search_paymentcond,
'search_paymentcond', -1, 1, 1,
'maxwidth100');
1126 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1127 print
'<td class="liste_titre left">';
1128 print
$form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 20, 1,
'maxwidth100', 1);
1131 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1133 print
'<td class="liste_titre right">';
1134 print
'<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
1137 if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1139 print
'<td class="liste_titre right">';
1140 print
'<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
1143 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1145 print
'<td class="liste_titre right">';
1146 print
'<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).
'">';
1149 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1151 print
'<td class="liste_titre right">';
1152 print
'<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).
'">';
1155 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1157 print
'<td class="liste_titre right">';
1158 print
'<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
1161 if (!empty($arrayfields[
'f.nb_docs'][
'checked'])) {
1163 print
'<td class="liste_titre" align="center">';
1166 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1168 print
'<td class="liste_titre" align="center">';
1169 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1172 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1173 print
'<td class="liste_titre right">';
1176 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1177 print
'<td class="liste_titre">';
1180 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1182 print
'<td class="liste_titre">';
1183 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1186 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1188 print
'<td class="liste_titre">';
1189 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1192 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1194 print
'<td class="liste_titre right">';
1195 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1198 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1200 print
'<td class="liste_titre right">';
1201 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1204 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1206 print
'<td class="liste_titre right">';
1207 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1210 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1211 print
'<td class="liste_titre">';
1214 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1215 print
'<td class="liste_titre right">';
1219 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1222 $parameters = array(
'arrayfields'=>$arrayfields);
1223 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1224 print $hookmanager->resPrint;
1226 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1227 print
'<td class="liste_titre">';
1231 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1232 print
'<td class="liste_titre">';
1236 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1237 print
'<td class="liste_titre right parentonrightofpage">';
1238 $liststatus = array(
'0'=>$langs->trans(
"Draft"),
'1'=>$langs->trans(
"Unpaid"),
'2'=>$langs->trans(
"Paid"));
1239 print
$form->selectarray(
'search_status', $liststatus, $search_status, 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage', 1);
1244 print
'<td class="liste_titre center maxwidthsearch">';
1245 $searchpicto =
$form->showFilterButtons();
1252 $totalarray = array();
1253 $totalarray[
'nbfield'] = 0;
1257 print
'<tr class="liste_titre">';
1259 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1260 $totalarray[
'nbfield']++;
1262 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1263 print_liste_field_titre($arrayfields[
'f.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'f.ref,f.rowid',
'', $param,
'', $sortfield, $sortorder);
1264 $totalarray[
'nbfield']++;
1266 if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1267 print_liste_field_titre($arrayfields[
'f.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
'f.ref_supplier',
'', $param,
'', $sortfield, $sortorder);
1268 $totalarray[
'nbfield']++;
1270 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1271 print_liste_field_titre($arrayfields[
'f.type'][
'label'], $_SERVER[
"PHP_SELF"],
'f.type',
'', $param,
'', $sortfield, $sortorder);
1272 $totalarray[
'nbfield']++;
1274 if (!empty($arrayfields[
'f.label'][
'checked'])) {
1275 print_liste_field_titre($arrayfields[
'f.label'][
'label'], $_SERVER[
'PHP_SELF'],
"f.libelle,f.rowid",
'', $param,
'', $sortfield, $sortorder);
1276 $totalarray[
'nbfield']++;
1278 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1279 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
'PHP_SELF'],
'f.datef,f.rowid',
'', $param,
'', $sortfield, $sortorder,
'center ');
1280 $totalarray[
'nbfield']++;
1282 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1283 print_liste_field_titre($arrayfields[
'f.date_lim_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_lim_reglement",
'', $param,
'', $sortfield, $sortorder,
'center ');
1284 $totalarray[
'nbfield']++;
1286 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1287 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
'PHP_SELF'],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
1288 $totalarray[
'nbfield']++;
1290 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1291 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1292 $totalarray[
'nbfield']++;
1294 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1295 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1296 $totalarray[
'nbfield']++;
1298 if (!empty($arrayfields[
's.town'][
'checked'])) {
1299 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1300 $totalarray[
'nbfield']++;
1302 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1303 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder,
'center ');
1304 $totalarray[
'nbfield']++;
1306 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1307 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.name_alias",
"", $param,
'', $sortfield, $sortorder);
1308 $totalarray[
'nbfield']++;
1310 if (!empty($arrayfields[
'state.name_alias'][
'checked'])) {
1311 print_liste_field_titre($arrayfields[
'state.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1312 $totalarray[
'nbfield']++;
1314 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1315 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1316 $totalarray[
'nbfield']++;
1318 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1319 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1320 $totalarray[
'nbfield']++;
1322 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1323 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_cond_reglement",
"", $param,
"", $sortfield, $sortorder);
1324 $totalarray[
'nbfield']++;
1326 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1327 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_mode_reglement",
"", $param,
"", $sortfield, $sortorder);
1328 $totalarray[
'nbfield']++;
1330 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1331 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1332 $totalarray[
'nbfield']++;
1334 if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1335 print_liste_field_titre($arrayfields[
'f.total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1336 $totalarray[
'nbfield']++;
1338 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1339 print_liste_field_titre($arrayfields[
'f.total_localtax1'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax1',
'', $param,
'', $sortfield, $sortorder,
'right ');
1340 $totalarray[
'nbfield']++;
1342 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1343 print_liste_field_titre($arrayfields[
'f.total_localtax2'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax2',
'', $param,
'', $sortfield, $sortorder,
'right ');
1344 $totalarray[
'nbfield']++;
1346 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1347 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1348 $totalarray[
'nbfield']++;
1350 if (!empty($arrayfields[
'f.nb_docs'][
'checked'])) {
1351 print_liste_field_titre($arrayfields[
'f.nb_docs'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1353 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1354 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1355 $totalarray[
'nbfield']++;
1357 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1358 print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1359 $totalarray[
'nbfield']++;
1361 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1362 print_liste_field_titre($arrayfields[
'rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1363 $totalarray[
'nbfield']++;
1365 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1366 print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1367 $totalarray[
'nbfield']++;
1369 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1370 print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1371 $totalarray[
'nbfield']++;
1373 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1374 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1375 $totalarray[
'nbfield']++;
1377 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1378 print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1379 $totalarray[
'nbfield']++;
1381 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1382 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1383 $totalarray[
'nbfield']++;
1385 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1386 print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1387 $totalarray[
'nbfield']++;
1389 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1390 print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1391 $totalarray[
'nbfield']++;
1394 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1396 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
1397 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1398 print $hookmanager->resPrint;
1399 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1400 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1401 $totalarray[
'nbfield']++;
1403 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1404 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1405 $totalarray[
'nbfield']++;
1407 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1408 print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"fk_statut,paye,type",
"", $param,
'', $sortfield, $sortorder,
'right ');
1409 $totalarray[
'nbfield']++;
1412 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1413 $totalarray[
'nbfield']++;
1419 $projectstatic =
new Project($db);
1420 $userstatic =
new User($db);
1425 $savnbfield = $totalarray[
'nbfield'];
1426 $totalarray = array();
1427 $totalarray[
'nbfield'] = 0;
1428 $totalarray[
'val'] = array();
1429 $totalarray[
'val'][
'f.total_ht']=0;
1430 $totalarray[
'val'][
'f.total_vat']=0;
1431 $totalarray[
'val'][
'f.total_localtax1']=0;
1432 $totalarray[
'val'][
'f.total_localtax1']=0;
1433 $totalarray[
'val'][
'f.total_ttc']=0;
1434 $imaxinloop = ($limit ? min($num, $limit) : $num);
1435 while ($i < $imaxinloop) {
1436 $obj = $db->fetch_object($resql);
1441 $datelimit = $db->jdate($obj->datelimite);
1443 $userstatic->id = $obj->fk_user_author;
1444 $userstatic->login = $obj->login;
1445 $userstatic->lastname = $obj->lastname;
1446 $userstatic->firstname = $obj->firstname;
1447 $userstatic->email = $obj->user_email;
1448 $userstatic->statut = $obj->user_statut;
1449 $userstatic->entity = $obj->entity;
1450 $userstatic->photo = $obj->photo;
1451 $userstatic->office_phone = $obj->office_phone;
1452 $userstatic->office_fax = $obj->office_fax;
1453 $userstatic->user_mobile = $obj->user_mobile;
1454 $userstatic->job = $obj->job;
1455 $userstatic->gender = $obj->gender;
1457 $facturestatic->id = $obj->facid;
1458 $facturestatic->ref = $obj->ref;
1459 $facturestatic->type = $obj->type;
1460 $facturestatic->ref_supplier = $obj->ref_supplier;
1461 $facturestatic->date_echeance = $db->jdate($obj->datelimite);
1462 $facturestatic->statut = $obj->fk_statut;
1463 $facturestatic->note_public = $obj->note_public;
1464 $facturestatic->note_private = $obj->note_private;
1465 $facturestatic->multicurrency_code = $obj->multicurrency_code;
1466 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1467 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1468 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1469 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1471 $thirdparty->id = $obj->socid;
1472 $thirdparty->name = $obj->name;
1473 $thirdparty->name_alias = $obj->alias;
1474 $thirdparty->client = $obj->client;
1475 $thirdparty->fournisseur = $obj->fournisseur;
1476 $thirdparty->code_client = $obj->code_client;
1477 $thirdparty->code_compta_client = $obj->code_compta_client;
1478 $thirdparty->code_fournisseur = $obj->code_fournisseur;
1479 $thirdparty->code_compta_fournisseur = $obj->code_compta_fournisseur;
1480 $thirdparty->email = $obj->email;
1481 $thirdparty->country_code = $obj->country_code;
1483 $paiement = $facturestatic->getSommePaiement();
1484 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1485 $totaldeposits = $facturestatic->getSumDepositsUsed();
1486 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1487 $remaintopay = $obj->total_ttc - $totalpay;
1488 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1489 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1490 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1491 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1492 $multicurrency_remaintopay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1494 $facturestatic->alreadypaid = ($paiement ? $paiement : 0);
1495 $facturestatic->paye = $obj->paye;
1496 $facturestatic->statut = $obj->fk_statut;
1497 $facturestatic->type = $obj->type;
1498 $facturestatic->socid = $thirdparty->getNomUrl(1,
'supplier', 3);
1499 $facturestatic->total_ht = $obj->total_ht;
1500 $facturestatic->date = $db->jdate($obj->datef);
1502 $object = $facturestatic;
1506 if ($facturestatic->isCreditNoteUsed()) {
1507 $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed();
1511 if ($mode ==
'kanban') {
1513 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1514 print
'<div class="box-flex-container kanban">';
1517 if ($massactionbutton || $massaction) {
1519 if (in_array($object->id, $arrayofselected)) {
1524 $arraydata = array(
'alreadypaid' => $paiement,
'thirdparty' => $thirdparty->getNomUrl(1,
'', 12));
1525 print $facturestatic->getKanbanView(
'', $arraydata);
1526 if ($i == ($imaxinloop - 1)) {
1533 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
1537 print
'<td class="nowrap center">';
1538 if ($massactionbutton || $massaction) {
1540 if (in_array($obj->facid, $arrayofselected)) {
1543 print
'<input id="cb'.$obj->facid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1547 $totalarray[
'nbfield']++;
1550 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1551 print
'<td class="nowraponall">';
1553 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1555 print
'<td class="nobordernopadding nowraponall">';
1556 print $facturestatic->getNomUrl(1,
'', 0, 0,
'', 0, -1, 1);
1559 $filedir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir($obj->facid, 2, 0, 0, $facturestatic,
'invoice_supplier').dol_sanitizeFileName($obj->ref);
1560 $subdir =
get_exdir($obj->facid, 2, 0, 0, $facturestatic,
'invoice_supplier').dol_sanitizeFileName($obj->ref);
1561 print $formfile->getDocumentsLink(
'facture_fournisseur', $subdir, $filedir);
1562 print
'</td></tr></table>';
1566 $totalarray[
'nbfield']++;
1571 if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1572 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).
'">';
1573 print $obj->ref_supplier;
1576 $totalarray[
'nbfield']++;
1581 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1582 print
'<td class="nowrap">';
1583 print $facturestatic->getLibType();
1586 $totalarray[
'nbfield']++;
1591 if (!empty($arrayfields[
'f.label'][
'checked'])) {
1592 print
'<td class="nowrap">';
1596 $totalarray[
'nbfield']++;
1601 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1602 print
'<td class="center nowrap">';
1606 $totalarray[
'nbfield']++;
1611 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1612 print
'<td class="center nowraponall">'.dol_print_date($datelimit,
'day');
1613 if ($facturestatic->hasDelay()) {
1614 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
1618 $totalarray[
'nbfield']++;
1623 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1624 print
'<td class="nowrap">';
1625 if ($obj->project_id > 0) {
1626 $projectstatic->id = $obj->project_id;
1627 $projectstatic->ref = $obj->project_ref;
1628 $projectstatic->title = $obj->project_label;
1629 print $projectstatic->getNomUrl(1);
1633 $totalarray[
'nbfield']++;
1638 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1639 print
'<td class="tdoverflowmax150">';
1640 print $thirdparty->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1643 $totalarray[
'nbfield']++;
1647 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1648 print
'<td class="tdoverflowmax150">';
1652 $totalarray[
'nbfield']++;
1656 if (!empty($arrayfields[
's.town'][
'checked'])) {
1657 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
1661 $totalarray[
'nbfield']++;
1665 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1666 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).
'">';
1670 $totalarray[
'nbfield']++;
1674 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1675 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).
'">';
1679 $totalarray[
'nbfield']++;
1683 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1684 print
'<td class="center">';
1685 $tmparray =
getCountry($obj->fk_pays,
'all');
1686 print $tmparray[
'label'];
1689 $totalarray[
'nbfield']++;
1693 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1694 print
'<td class="center">';
1695 if (empty($typenArray)) {
1696 $typenArray = $formcompany->typent_array(1);
1698 print $typenArray[$obj->typent_code];
1701 $totalarray[
'nbfield']++;
1706 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1707 $s =
$form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 1,
'', -1, -1, 1);
1708 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1712 $totalarray[
'nbfield']++;
1716 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1717 $s =
$form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1, 0,
'', 1);
1718 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1722 $totalarray[
'nbfield']++;
1727 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1728 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1730 $totalarray[
'nbfield']++;
1733 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
1735 $totalarray[
'val'][
'f.total_ht'] += $obj->total_ht;
1738 if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1739 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_vat).
"</span></td>\n";
1741 $totalarray[
'nbfield']++;
1744 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_vat';
1746 $totalarray[
'val'][
'f.total_vat'] += $obj->total_vat;
1749 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1750 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_localtax1).
"</span></td>\n";
1752 $totalarray[
'nbfield']++;
1755 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax1';
1757 $totalarray[
'val'][
'f.total_localtax1'] += $obj->total_localtax1;
1760 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1761 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_localtax2).
"</span></td>\n";
1763 $totalarray[
'nbfield']++;
1766 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax2';
1768 $totalarray[
'val'][
'f.total_localtax2'] += $obj->total_localtax2;
1771 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1772 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1774 $totalarray[
'nbfield']++;
1777 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
1779 $totalarray[
'val'][
'f.total_ttc'] += $obj->total_ttc;
1783 if (!empty($arrayfields[
'f.nb_docs'][
'checked'])) {
1784 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1785 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
1786 $upload_dir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir($facturestatic->id, 2, 0, 0, $facturestatic,
'invoice_supplier').$facturestatic->ref;
1787 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
1788 $nbLinks =
Link::count($db, $facturestatic->element, $facturestatic->id);
1789 $nbTotal = $nbFiles + $nbLinks;
1790 echo
'<td class="center">'.(empty($nbTotal)?
'':$nbTotal).
'</td>';
1794 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1795 print
'<td class="tdoverflowmax150">';
1796 if ($userstatic->id) {
1797 print $userstatic->getNomUrl(-1);
1803 $totalarray[
'nbfield']++;
1807 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1808 print
'<td class="right nowrap"><span class="amount">'.(!empty($totalpay) ?
price($totalpay, 0, $langs) :
'').
'</span></td>';
1810 $totalarray[
'nbfield']++;
1813 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalam';
1815 $totalarray[
'val'][
'totalam'] += $totalpay;
1818 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1819 print
'<td class="right nowrap">'.(!empty($remaintopay) ?
price($remaintopay, 0, $langs) :
' ').
'</td>';
1821 $totalarray[
'nbfield']++;
1824 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'rtp';
1826 $totalarray[
'val'][
'rtp'] += $remaintopay;
1830 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1831 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1833 $totalarray[
'nbfield']++;
1838 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1839 print
'<td class="nowrap">';
1840 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1843 $totalarray[
'nbfield']++;
1847 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1848 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
1850 $totalarray[
'nbfield']++;
1854 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1855 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
1857 $totalarray[
'nbfield']++;
1861 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1862 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
1864 $totalarray[
'nbfield']++;
1867 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1868 print
'<td class="right nowrap"><span class="amount">'.(!empty($multicurrency_totalpay) ?
price($multicurrency_totalpay, 0, $langs) :
'').
'</span></td>';
1870 $totalarray[
'nbfield']++;
1875 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1876 print
'<td class="right nowrap"><span class="amount">';
1877 print (!empty($multicurrency_remaintopay) ?
price($multicurrency_remaintopay, 0, $langs) :
'');
1878 print
'</span></td>';
1880 $totalarray[
'nbfield']++;
1886 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1888 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1889 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1890 print $hookmanager->resPrint;
1893 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1894 print
'<td class="center nowrap">';
1895 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1898 $totalarray[
'nbfield']++;
1902 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1903 print
'<td class="center nowrap">';
1904 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1907 $totalarray[
'nbfield']++;
1911 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1912 print
'<td class="right nowrap">';
1913 print $facturestatic->getLibStatut(5, $paiement);
1916 $totalarray[
'nbfield']++;
1922 print
'<td class="nowrap center">';
1923 if ($massactionbutton || $massaction) {
1925 if (in_array($obj->facid, $arrayofselected)) {
1928 print
'<input id="cb'.$obj->facid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1932 $totalarray[
'nbfield']++;
1943 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1948 foreach ($arrayfields as $key => $val) {
1949 if (!empty($val[
'checked'])) {
1953 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1958 $parameters = array(
'arrayfields' => $arrayfields,
'sql' =>
$sql);
1959 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1960 print $hookmanager->resPrint;
1962 print
'</table>'.
"\n";
1963 print
'</div>'.
"\n";
1965 print
'</form>'.
"\n";
1967 $hidegeneratedfilelistifempty = 1;
1968 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1969 $hidegeneratedfilelistifempty = 0;
1973 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1974 $urlsource .= str_replace(
'&',
'&', $param);
1976 $filedir = $diroutputmassaction;
1977 $genallowed = $user->hasRight(
'facture',
'lire');
1978 $delallowed = $user->hasRight(
'facture',
'creer');
1981 print $formfile->showdocuments(
'massfilesarea_supplier_invoice',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage suppliers invoices.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_STANDARD
Standard invoice.
Class to manage suppliers.
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
GETPOSTDATE($prefix, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form::selectDate) for year,...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
buildParamDate($prefix, $timestamp=null, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form::selectDate) for year,...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.