38require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
47require_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');
64if ($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');
117if ($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');
126$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
127if (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',
163if (empty($user->socid)) {
164 $fieldstosearchall[
"f.note_private"] =
"NotePrivate";
167$checkedtypetiers = 0;
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,
'position'=>41),
177 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'checked'=>0,
'position'=>42),
178 's.town'=>array(
'label'=>
"Town",
'checked'=>-1,
'position'=>43),
179 's.zip'=>array(
'label'=>
"Zip",
'checked'=>1,
'position'=>44),
180 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0,
'position'=>45),
181 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0,
'position'=>46),
182 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers,
'position'=>49),
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,
'position'=>205,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
193 'f.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'position'=>206,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
194 'f.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'position'=>207,
'checked'=>0,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
195 'f.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'position'=>208,
'checked'=>0,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
196 'f.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'position'=>209,
'checked'=>0,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
197 'multicurrency_dynamount_payed'=>array(
'label'=>
'MulticurrencyAlreadyPaid',
'position'=>210,
'checked'=>0,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
198 'multicurrency_rtp'=>array(
'label'=>
'MulticurrencyRemainderToPay',
'checked'=>0,
'position'=>211,
'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),
205include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
210if (!isModEnabled(
'supplier_invoice')) {
213if ((!$user->hasRight(
"fournisseur",
"facture",
"lire") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
214 || (!$user->hasRight(
"supplier_invoice",
"lire") && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
218$permissiontoread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
219$permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
220$permissiontodelete = ($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer"));
227if (
GETPOST(
'cancel',
'alpha')) {
231if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
235$parameters = array(
'socid'=>$socid);
236$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
241if (empty($reshook)) {
243 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
246 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha')) {
250 $search_product_category =
'';
252 $search_refsupplier =
"";
255 $search_project =
'';
256 $search_company =
"";
257 $search_company_alias =
"";
258 $search_amount_no_tax =
"";
259 $search_amount_all_tax =
"";
260 $search_montant_ht =
'';
261 $search_montant_vat =
'';
262 $search_montant_localtax1 =
'';
263 $search_montant_localtax2 =
'';
264 $search_montant_ttc =
'';
266 $search_multicurrency_code =
'';
267 $search_multicurrency_tx =
'';
268 $search_multicurrency_montant_ht =
'';
269 $search_multicurrency_montant_vat =
'';
270 $search_multicurrency_montant_ttc =
'';
272 $search_paymentmode =
'';
273 $search_paymentcond =
'';
278 $search_country =
'';
279 $search_type_thirdparty =
'';
280 $search_date_start =
'';
281 $search_date_end =
'';
282 $search_datelimit_startday =
'';
283 $search_datelimit_startmonth =
'';
284 $search_datelimit_startyear =
'';
285 $search_datelimit_endday =
'';
286 $search_datelimit_endmonth =
'';
287 $search_datelimit_endyear =
'';
288 $search_datelimit_start =
'';
289 $search_datelimit_end =
'';
291 $search_array_options = array();
292 $search_categ_sup = 0;
299 $objectclass =
'FactureFournisseur';
300 $objectlabel =
'SupplierInvoices';
301 $uploaddir = $conf->fournisseur->facture->dir_output;
302 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
304 if ($massaction ==
'banktransfertrequest') {
305 $langs->load(
"withdrawals");
307 if (!$user->hasRight(
"paymentbybanktransfer",
"create")) {
314 $arrayofselected = is_array($toselect) ? $toselect : array();
315 $listofbills = array();
316 foreach ($arrayofselected as $toselectid) {
318 $result = $objecttmp->fetch($toselectid);
320 $totalpaid = $objecttmp->getSommePaiement();
321 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
322 $totaldeposits = $objecttmp->getSumDepositsUsed();
323 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
326 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
327 } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
329 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
330 } elseif ($objecttmp->resteapayer < 0) {
332 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
335 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
336 $rsql .=
" , pfd.date_traite as date_traite";
337 $rsql .=
" , pfd.amount";
338 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
339 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
340 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
341 $rsql .=
" WHERE fk_facture_fourn = ".((int) $objecttmp->id);
342 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
343 $rsql .=
" AND pfd.traite = 0";
344 $rsql .=
" ORDER BY pfd.date_demande DESC";
346 $result_sql = $db->query($rsql);
348 $numprlv = $db->num_rows($result_sql);
353 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
354 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'VIR') {
356 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"BadPaymentMethod"), $objecttmp->errors,
'errors');
358 $listofbills[] = $objecttmp;
364 if (!empty($listofbills)) {
365 $nbwithdrawrequestok = 0;
366 foreach ($listofbills as $aBill) {
368 $result = $aBill->demande_prelevement($user, $aBill->resteapayer,
'bank-transfer',
'supplier_invoice');
371 $nbwithdrawrequestok++;
377 if ($nbwithdrawrequestok > 0) {
378 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
390$form =
new Form($db);
393$bankaccountstatic =
new Account($db);
400$title = $langs->trans(
"BillsSuppliers").($socid ?
' '.$soc->name :
'');
401$help_url =
'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores';
407 $sql =
'SELECT DISTINCT';
409$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,";
410$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,";
411$sql .=
" f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,";
412$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,';
413$sql .=
" f.note_public, f.note_private,";
414$sql .=
" f.fk_user_author,";
415$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,";
416$sql .=
" typent.code as typent_code,";
417$sql .=
" state.code_departement as state_code, state.nom as state_name,";
418$sql .=
" country.code as country_code,";
419$sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
420$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';
424 $sql .=
', SUM(pf.amount) as dynamount_payed';
427if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
428 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
429 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
433$parameters = array();
434$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
435$sql .= $hookmanager->resPrint;
436$sql = preg_replace(
'/,\s*$/',
'', $sql);
440$sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
441$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
442$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
443$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
444$sql .=
', '.MAIN_DB_PREFIX.
'facture_fourn as f';
445if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
446 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
449 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
452 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn';
454$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
455$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
457if ($search_sale > 0 || (!$user->hasRight(
"societe",
"client",
"voir") && !$socid)) {
458 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
460if ($search_user > 0) {
461 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
462 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
465$parameters = array();
466$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
467$sql .= $hookmanager->resPrint;
468$sql .=
' WHERE f.fk_soc = s.rowid';
469$sql .=
' AND f.entity IN ('.getEntity(
'facture_fourn').
')';
470if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
471 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
474 $sql .=
' AND s.rowid = '.((int) $socid);
477 if (is_numeric($search_ref)) {
486if ($search_refsupplier) {
489if ($search_type !=
'' && $search_type >= 0) {
490 if ($search_type ==
'0') {
491 $sql .=
" AND f.type = 0";
493 if ($search_type ==
'1') {
494 $sql .=
" AND f.type = 1";
496 if ($search_type ==
'2') {
497 $sql .=
" AND f.type = 2";
499 if ($search_type ==
'3') {
500 $sql .=
" AND f.type = 3";
505if ($search_project) {
508if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
509 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
511 if ($search_company) {
514 if ($search_company_alias) {
527if ($search_country) {
528 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
530if ($search_type_thirdparty !=
'' && $search_type_thirdparty >= 0) {
531 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
533if ($search_montant_ht !=
'') {
536if ($search_montant_vat !=
'') {
539if ($search_montant_localtax1 !=
'') {
540 $sql .=
natural_search(
'f.localtax1', $search_montant_localtax1, 1);
542if ($search_montant_localtax2 !=
'') {
543 $sql .=
natural_search(
'f.localtax2', $search_montant_localtax2, 1);
545if ($search_montant_ttc !=
'') {
548if ($search_multicurrency_code !=
'') {
549 $sql .=
" AND f.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
551if ($search_multicurrency_tx !=
'') {
552 $sql .=
natural_search(
'f.multicurrency_tx', $search_multicurrency_tx, 1);
554if ($search_multicurrency_montant_ht !=
'') {
555 $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
557if ($search_multicurrency_montant_vat !=
'') {
558 $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
560if ($search_multicurrency_montant_ttc !=
'') {
561 $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
564 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_login);
566if ($search_status !=
'' && $search_status >= 0) {
567 $sql .=
" AND f.fk_statut = ".((int) $search_status);
569if ($search_paymentmode > 0) {
570 $sql .=
" AND f.fk_mode_reglement = ".((int) $search_paymentmode);
572if ($search_paymentcond > 0) {
573 $sql .=
" AND f.fk_cond_reglement = ".((int) $search_paymentcond);
575if ($search_date_start) {
576 $sql .=
" AND f.datef >= '" . $db->idate($search_date_start) .
"'";
578if ($search_date_end) {
579 $sql .=
" AND f.datef <= '" . $db->idate($search_date_end) .
"'";
581if ($search_datelimit_start) {
582 $sql .=
" AND f.date_lim_reglement >= '" . $db->idate($search_datelimit_start) .
"'";
584if ($search_datelimit_end) {
585 $sql .=
" AND f.date_lim_reglement <= '" . $db->idate($search_datelimit_end) .
"'";
587if ($option ==
'late') {
588 $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() - $conf->facture->fournisseur->warning_delay).
"'";
593$searchCategorySupplierList = $search_categ_sup ? array($search_categ_sup) : array();
594$searchCategorySupplierOperator = 0;
596if (!empty($searchCategorySupplierList)) {
597 $searchCategorySupplierSqlList = array();
598 $listofcategoryid =
'';
599 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
600 if (intval($searchCategorySupplier) == -2) {
601 $searchCategorySupplierSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
602 } elseif (intval($searchCategorySupplier) > 0) {
603 if ($searchCategorySupplierOperator == 0) {
604 $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).
")";
606 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategorySupplier);
610 if ($listofcategoryid) {
611 $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).
"))";
613 if ($searchCategorySupplierOperator == 1) {
614 if (!empty($searchCategorySupplierSqlList)) {
615 $sql .=
" AND (".implode(
' OR ', $searchCategorySupplierSqlList).
")";
618 if (!empty($searchCategorySupplierSqlList)) {
619 $sql .=
" AND (".implode(
' AND ', $searchCategorySupplierSqlList).
")";
624$searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
625$searchCategoryProductOperator = 0;
626if (!empty($searchCategoryProductList)) {
627 $searchCategoryProductSqlList = array();
628 $listofcategoryid =
'';
629 foreach ($searchCategoryProductList as $searchCategoryProduct) {
630 if (intval($searchCategoryProduct) == -2) {
631 $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 fd.fk_product = ck.fk_product)";
632 } elseif (intval($searchCategoryProduct) > 0) {
633 if ($searchCategoryProductOperator == 0) {
634 $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 fd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
636 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
640 if ($listofcategoryid) {
641 $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 fd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
643 if ($searchCategoryProductOperator == 1) {
644 if (!empty($searchCategoryProductSqlList)) {
645 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
648 if (!empty($searchCategoryProductSqlList)) {
649 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
653if ($search_status !=
'' && $search_status >= 0) {
654 $sql .=
" AND f.fk_statut = ".((int) $search_status);
656if ($filter && $filter != -1) {
657 $aFilter = explode(
',', $filter);
658 foreach ($aFilter as $fil) {
659 $filt = explode(
':', $fil);
660 $sql .=
" AND ".$db->escape(trim($filt[0])).
" = '".$db->escape(trim($filt[1])).
"'";
663if ($search_sale > 0) {
664 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
666if ($search_user > 0) {
667 $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);
670include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
672$parameters = array();
673$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
674$sql .= $hookmanager->resPrint;
677 $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,";
678 $sql .=
" f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,";
679 $sql .=
" f.localtax1, f.localtax2,";
680 $sql .=
' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
681 $sql .=
" f.note_public, f.note_private,";
682 $sql .=
" f.fk_user_author,";
683 $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,';
684 $sql .=
" typent.code,";
685 $sql .=
" state.code_departement, state.nom,";
686 $sql .=
' country.code,';
687 $sql .=
" p.rowid, p.ref, p.title,";
688 $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";
689 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
690 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
692 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
",ef.".$key :
'');
696 $parameters = array(
'all' => $search_all,
'fieldstosearchall' => $fieldstosearchall);
697 $reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object, $action);
698 $sql .= $hookmanager->resPrint;
700 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
704$parameters = array();
705$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
706$sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
709$nbtotalofrecords =
'';
712 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
713 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
714 $resql = $db->query($sqlforcount);
716 $objforcount = $db->fetch_object($resql);
717 $nbtotalofrecords = $objforcount->nbtotalofrecords;
722 if (($page * $limit) > $nbtotalofrecords) {
730$sql .= $db->order($sortfield, $sortorder);
732 $sql .= $db->plimit($limit + 1, $offset);
736$resql = $db->query($sql);
742$num = $db->num_rows($resql);
744if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
745 $obj = $db->fetch_object($resql);
748 header(
"Location: ".DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$id);
760 if (empty($search_company)) {
761 $search_company = $soc->name;
762 $search_company_alias = $soc->name_alias;
766$arrayofselected = is_array($toselect) ? $toselect : array();
768$param =
'&socid='.$socid;
770 $param .=
'&mode='.urlencode($mode);
772if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
773 $param .=
'&contextpage='.urlencode($contextpage);
775if ($limit > 0 && $limit != $conf->liste_limit) {
776 $param .=
'&limit='.((int) $limit);
778if ($optioncss !=
'') {
779 $param .=
'&optioncss='.urlencode($optioncss);
782 $param .=
'&search_all='.urlencode($search_all);
784if ($search_date_start) {
785 $param .=
buildParamDate(
'search_date_start',
null,
'',
'tzserver');
787if ($search_date_end) {
788 $param .=
buildParamDate(
'search_date_end',
null,
'',
'tzserver');
790if ($search_datelimit_startday) {
791 $param .=
'&search_datelimit_startday='.urlencode($search_datelimit_startday);
793if ($search_datelimit_startmonth) {
794 $param .=
'&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth);
796if ($search_datelimit_startyear) {
797 $param .=
'&search_datelimit_startyear='.urlencode($search_datelimit_startyear);
799if ($search_datelimit_endday) {
800 $param .=
'&search_datelimit_endday='.urlencode($search_datelimit_endday);
802if ($search_datelimit_endmonth) {
803 $param .=
'&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth);
805if ($search_datelimit_endyear) {
806 $param .=
'&search_datelimit_endyear='.urlencode($search_datelimit_endyear);
809 $param .=
'&search_ref='.urlencode($search_ref);
811if ($search_refsupplier) {
812 $param .=
'&search_refsupplier='.urlencode($search_refsupplier);
814if ($search_type !=
'') {
815 $param .=
'&search_type='.urlencode($search_type);
818 $param .=
'&search_label='.urlencode($search_label);
820if ($search_company) {
821 $param .=
'&search_company='.urlencode($search_company);
823if ($search_company_alias) {
824 $param .=
'&search_company_alias='.urlencode($search_company_alias);
827 $param .=
'&search_login='.urlencode($search_login);
829if ($search_montant_ht !=
'') {
830 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
832if ($search_montant_vat !=
'') {
833 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
835if ($search_montant_localtax1 !=
'') {
836 $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
838if ($search_montant_localtax2 !=
'') {
839 $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
841if ($search_montant_ttc !=
'') {
842 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
844if ($search_multicurrency_code !=
'') {
845 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
847if ($search_multicurrency_tx !=
'') {
848 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
850if ($search_multicurrency_montant_ht !=
'') {
851 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
853if ($search_multicurrency_montant_vat !=
'') {
854 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
856if ($search_multicurrency_montant_ttc !=
'') {
857 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
859if ($search_amount_no_tax) {
860 $param .=
'&search_amount_no_tax='.urlencode($search_amount_no_tax);
862if ($search_amount_all_tax) {
863 $param .=
'&search_amount_all_tax='.urlencode($search_amount_all_tax);
865if ($search_status >= 0) {
866 $param .=
"&search_status=".urlencode($search_status);
868if ($search_paymentmode) {
869 $param .=
'&search_paymentmode='.urlencode($search_paymentmode);
871if ($search_paymentcond) {
872 $param .=
'&search_paymentcond='.urlencode($search_paymentcond);
875 $param .=
'&show_files='.urlencode($show_files);
878 $param .=
"&search_option=".urlencode($option);
880if ($search_categ_sup > 0) {
881 $param .=
'&search_categ_sup='.urlencode($search_categ_sup);
883if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
884 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
888include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
890$parameters = array();
891$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
892$param .= $hookmanager->resPrint;
895$arrayofmassactions = array(
896 'validate'=>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
897 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
902if (isModEnabled(
'paymentbybanktransfer') && $user->hasRight(
"paymentbybanktransfer",
"create")) {
903 $langs->load(
'withdrawals');
904 $arrayofmassactions[
'banktransfertrequest'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeBankTransferOrder");
906if (!empty($permissiontodelete)) {
907 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
909if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
910 $arrayofmassactions = array();
912$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
914$url = DOL_URL_ROOT.
'/fourn/facture/card.php?action=create';
916 $url .=
'&socid='.urlencode($socid);
920print
'<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
921if ($optioncss !=
'') {
922 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
924print
'<input type="hidden" name="token" value="'.newToken().
'">';
925print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
926print
'<input type="hidden" name="action" value="list">';
927print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
928print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
929print
'<input type="hidden" name="socid" value="'.$socid.
'">';
930print
'<input type="hidden" name="page" value="'.$page.
'">';
931print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
932print
'<input type="hidden" name="page_y" value="">';
933print
'<input type="hidden" name="mode" value="'.$mode.
'">';
936$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'));
937$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'));
939$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer")));
941print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'supplier_invoice', 0, $newcardbutton,
'', $limit, 0, 0, 1);
943$topicmail =
"SendBillRef";
944$modelmail =
"invoice_supplier_send";
946$trackid =
'sinv'.$object->id;
947include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
951 foreach ($fieldstosearchall as $key => $val) {
952 $fieldstosearchall[$key] = $langs->trans($val);
953 $setupstring .= $key.
"=".$val.
";";
955 print
'<!-- Search done like if SUPPLIER_INVOICE_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
956 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
961if ($user->hasRight(
"user",
"user",
"lire")) {
962 $langs->load(
"commercial");
963 $moreforfilter .=
'<div class="divsearchfield">';
964 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
965 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth200');
966 $moreforfilter .=
'</div>';
969if ($user->hasRight(
"user",
"user",
"lire")) {
970 $moreforfilter .=
'<div class="divsearchfield">';
971 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
972 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
973 $moreforfilter .=
'</div>';
976if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
977 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
978 $moreforfilter .=
'<div class="divsearchfield">';
979 $tmptitle = $langs->trans(
'IncludingProductWithTag');
980 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
981 $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);
982 $moreforfilter .=
'</div>';
985if (isModEnabled(
'categorie')) {
986 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
987 $moreforfilter .=
'<div class="divsearchfield">';
988 $tmptitle = $langs->trans(
'SuppliersCategoriesShort');
989 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'supplier', $search_categ_sup,
'search_categ_sup', 1, $tmptitle);
990 $moreforfilter .=
'</div>';
992$parameters = array();
993$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
994if (empty($reshook)) {
995 $moreforfilter .= $hookmanager->resPrint;
997 $moreforfilter = $hookmanager->resPrint;
1000if (!empty($moreforfilter)) {
1001 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1002 print $moreforfilter;
1006$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1007$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1008$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1010print
'<div class="div-table-responsive">';
1011print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1015print
'<tr class="liste_titre_filter">';
1018 print
'<td class="liste_titre center maxwidthsearch">';
1019 $searchpicto = $form->showFilterButtons(
'left');
1024if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1025 print
'<td class="liste_titre left">';
1026 print
'<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1030if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1031 print
'<td class="liste_titre">';
1032 print
'<input class="flat maxwidth75" type="text" name="search_refsupplier" value="'.dol_escape_htmltag($search_refsupplier).
'">';
1036if (!empty($arrayfields[
'f.type'][
'checked'])) {
1037 print
'<td class="liste_titre maxwidthonsmartphone">';
1051 print $form->selectarray(
'search_type', $listtype, $search_type, 1, 0, 0,
'', 0, 0, 0,
'ASC',
'maxwidth100');
1055if (!empty($arrayfields[
'f.label'][
'checked'])) {
1056 print
'<td class="liste_titre">';
1057 print
'<input class="flat maxwidth75" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).
'">';
1061if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1062 print
'<td class="liste_titre center">';
1063 print
'<div class="nowrap">';
1064 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1066 print
'<div class="nowrap">';
1067 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1072if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1073 print
'<td class="liste_titre center">';
1074 print
'<div class="nowrap">';
1081 print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"Before"));
1082 print
'<br><input type="checkbox" name="search_option" value="late"'.($option ==
'late' ?
' checked' :
'').
'> '.$langs->trans(
"Alert");
1087if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1088 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1091if (!empty($arrayfields[
's.nom'][
'checked'])) {
1092 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'"'.($socid > 0 ?
" disabled" :
"").
'></td>';
1095if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1096 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1099if (!empty($arrayfields[
's.town'][
'checked'])) {
1100 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1103if (!empty($arrayfields[
's.zip'][
'checked'])) {
1104 print
'<td class="liste_titre center"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1107if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1108 print
'<td class="liste_titre">';
1109 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1113if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1114 print
'<td class="liste_titre center">';
1115 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1119if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1120 print
'<td class="liste_titre maxwidthonsmartphone center">';
1121 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);
1125if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1126 print
'<td class="liste_titre left">';
1127 print $form->getSelectConditionsPaiements($search_paymentcond,
'search_paymentcond', -1, 1, 1,
'maxwidth100');
1131if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1132 print
'<td class="liste_titre left">';
1133 print $form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 20, 1,
'maxwidth100', 1);
1136if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1138 print
'<td class="liste_titre right">';
1139 print
'<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
1142if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1144 print
'<td class="liste_titre right">';
1145 print
'<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
1148if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1150 print
'<td class="liste_titre right">';
1151 print
'<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).
'">';
1154if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1156 print
'<td class="liste_titre right">';
1157 print
'<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).
'">';
1160if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1162 print
'<td class="liste_titre right">';
1163 print
'<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
1166if (!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).
'">';
1172if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1173 print
'<td class="liste_titre right">';
1176if (!empty($arrayfields[
'rtp'][
'checked'])) {
1177 print
'<td class="liste_titre">';
1180if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1182 print
'<td class="liste_titre">';
1183 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1186if (!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).
'">';
1192if (!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).
'">';
1198if (!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).
'">';
1204if (!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).
'">';
1210if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1211 print
'<td class="liste_titre">';
1214if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1215 print
'<td class="liste_titre right">';
1219include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1222$parameters = array(
'arrayfields'=>$arrayfields);
1223$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1224print $hookmanager->resPrint;
1226if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1227 print
'<td class="liste_titre">';
1231if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1232 print
'<td class="liste_titre">';
1236if (!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;
1257print
'<tr class="liste_titre">';
1259 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1260 $totalarray[
'nbfield']++;
1262if (!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']++;
1266if (!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']++;
1270if (!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']++;
1274if (!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']++;
1278if (!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']++;
1282if (!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']++;
1286if (!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']++;
1290if (!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']++;
1294if (!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']++;
1298if (!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']++;
1302if (!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']++;
1306if (!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']++;
1310if (!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']++;
1314if (!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']++;
1318if (!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']++;
1322if (!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']++;
1326if (!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']++;
1330if (!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']++;
1334if (!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']++;
1338if (!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']++;
1342if (!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']++;
1346if (!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']++;
1350if (!empty($arrayfields[
'u.login'][
'checked'])) {
1351 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1352 $totalarray[
'nbfield']++;
1354if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1355 print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1356 $totalarray[
'nbfield']++;
1358if (!empty($arrayfields[
'rtp'][
'checked'])) {
1359 print_liste_field_titre($arrayfields[
'rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1360 $totalarray[
'nbfield']++;
1362if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1363 print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1364 $totalarray[
'nbfield']++;
1366if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1367 print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1368 $totalarray[
'nbfield']++;
1370if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1371 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1372 $totalarray[
'nbfield']++;
1374if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1375 print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1376 $totalarray[
'nbfield']++;
1378if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1379 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1380 $totalarray[
'nbfield']++;
1382if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1383 print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1384 $totalarray[
'nbfield']++;
1386if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1387 print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1388 $totalarray[
'nbfield']++;
1391include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1393$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
1394$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1395print $hookmanager->resPrint;
1396if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1397 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1398 $totalarray[
'nbfield']++;
1400if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1401 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1402 $totalarray[
'nbfield']++;
1404if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1405 print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"fk_statut,paye,type",
"", $param,
'', $sortfield, $sortorder,
'right ');
1406 $totalarray[
'nbfield']++;
1409 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1410 $totalarray[
'nbfield']++;
1416$projectstatic =
new Project($db);
1417$userstatic =
new User($db);
1422$savnbfield = $totalarray[
'nbfield'];
1423$totalarray = array();
1424$totalarray[
'nbfield'] = 0;
1425$totalarray[
'val'] = array();
1426$totalarray[
'val'][
'f.total_ht']=0;
1427$totalarray[
'val'][
'f.total_vat']=0;
1428$totalarray[
'val'][
'f.total_localtax1']=0;
1429$totalarray[
'val'][
'f.total_localtax1']=0;
1430$totalarray[
'val'][
'f.total_ttc']=0;
1431$imaxinloop = ($limit ? min($num, $limit) : $num);
1432while ($i < $imaxinloop) {
1433 $obj = $db->fetch_object($resql);
1438 $datelimit = $db->jdate($obj->datelimite);
1440 $userstatic->id = $obj->fk_user_author;
1441 $userstatic->login = $obj->login;
1442 $userstatic->lastname = $obj->lastname;
1443 $userstatic->firstname = $obj->firstname;
1444 $userstatic->email = $obj->user_email;
1445 $userstatic->statut = $obj->user_statut;
1446 $userstatic->entity = $obj->entity;
1447 $userstatic->photo = $obj->photo;
1448 $userstatic->office_phone = $obj->office_phone;
1449 $userstatic->office_fax = $obj->office_fax;
1450 $userstatic->user_mobile = $obj->user_mobile;
1451 $userstatic->job = $obj->job;
1452 $userstatic->gender = $obj->gender;
1454 $facturestatic->id = $obj->facid;
1455 $facturestatic->ref = $obj->ref;
1456 $facturestatic->type = $obj->type;
1457 $facturestatic->ref_supplier = $obj->ref_supplier;
1458 $facturestatic->date_echeance = $db->jdate($obj->datelimite);
1459 $facturestatic->statut = $obj->fk_statut;
1460 $facturestatic->note_public = $obj->note_public;
1461 $facturestatic->note_private = $obj->note_private;
1462 $facturestatic->multicurrency_code = $obj->multicurrency_code;
1463 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1464 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1465 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1466 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1468 $thirdparty->id = $obj->socid;
1469 $thirdparty->name = $obj->name;
1470 $thirdparty->name_alias = $obj->alias;
1471 $thirdparty->client = $obj->client;
1472 $thirdparty->fournisseur = $obj->fournisseur;
1473 $thirdparty->code_client = $obj->code_client;
1474 $thirdparty->code_compta_client = $obj->code_compta_client;
1475 $thirdparty->code_fournisseur = $obj->code_fournisseur;
1476 $thirdparty->code_compta_fournisseur = $obj->code_compta_fournisseur;
1477 $thirdparty->email = $obj->email;
1478 $thirdparty->country_code = $obj->country_code;
1480 $paiement = $facturestatic->getSommePaiement();
1481 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1482 $totaldeposits = $facturestatic->getSumDepositsUsed();
1483 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1484 $remaintopay = $obj->total_ttc - $totalpay;
1485 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1486 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1487 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1488 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1489 $multicurrency_remaintopay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1491 $facturestatic->alreadypaid = ($paiement ? $paiement : 0);
1492 $facturestatic->paye = $obj->paye;
1493 $facturestatic->statut = $obj->fk_statut;
1494 $facturestatic->type = $obj->type;
1495 $facturestatic->socid = $thirdparty->getNomUrl(1,
'supplier', 3);
1496 $facturestatic->total_ht = $obj->total_ht;
1497 $facturestatic->date = $db->jdate($obj->datef);
1499 $object = $facturestatic;
1503 if ($facturestatic->isCreditNoteUsed()) {
1504 $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed();
1508 if ($mode ==
'kanban') {
1510 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1511 print
'<div class="box-flex-container kanban">';
1514 if ($massactionbutton || $massaction) {
1516 if (in_array($object->id, $arrayofselected)) {
1521 $arraydata = array(
'alreadypaid' => $paiement,
'thirdparty' => $thirdparty->getNomUrl(1,
'', 12));
1522 print $facturestatic->getKanbanView(
'', $arraydata);
1523 if ($i == ($imaxinloop - 1)) {
1530 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
1534 print
'<td class="nowrap center">';
1535 if ($massactionbutton || $massaction) {
1537 if (in_array($obj->facid, $arrayofselected)) {
1540 print
'<input id="cb'.$obj->facid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1544 $totalarray[
'nbfield']++;
1547 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1548 print
'<td class="nowraponall">';
1550 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1552 print
'<td class="nobordernopadding nowraponall">';
1553 print $facturestatic->getNomUrl(1,
'', 0, 0,
'', 0, -1, 1);
1556 $filedir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir($obj->facid, 2, 0, 0, $facturestatic,
'invoice_supplier').dol_sanitizeFileName($obj->ref);
1557 $subdir =
get_exdir($obj->facid, 2, 0, 0, $facturestatic,
'invoice_supplier').dol_sanitizeFileName($obj->ref);
1558 print $formfile->getDocumentsLink(
'facture_fournisseur', $subdir, $filedir);
1559 print
'</td></tr></table>';
1563 $totalarray[
'nbfield']++;
1568 if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1569 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).
'">';
1570 print $obj->ref_supplier;
1573 $totalarray[
'nbfield']++;
1578 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1579 print
'<td class="nowrap">';
1580 print $facturestatic->getLibType();
1583 $totalarray[
'nbfield']++;
1588 if (!empty($arrayfields[
'f.label'][
'checked'])) {
1589 print
'<td class="nowrap">';
1593 $totalarray[
'nbfield']++;
1598 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1599 print
'<td class="center nowrap">';
1603 $totalarray[
'nbfield']++;
1608 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1609 print
'<td class="center nowraponall">'.dol_print_date($datelimit,
'day');
1610 if ($facturestatic->hasDelay()) {
1611 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
1615 $totalarray[
'nbfield']++;
1620 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1621 print
'<td class="nowrap">';
1622 if ($obj->project_id > 0) {
1623 $projectstatic->id = $obj->project_id;
1624 $projectstatic->ref = $obj->project_ref;
1625 $projectstatic->title = $obj->project_label;
1626 print $projectstatic->getNomUrl(1);
1630 $totalarray[
'nbfield']++;
1635 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1636 print
'<td class="tdoverflowmax150">';
1637 print $thirdparty->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1640 $totalarray[
'nbfield']++;
1644 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1645 print
'<td class="tdoverflowmax150">';
1649 $totalarray[
'nbfield']++;
1653 if (!empty($arrayfields[
's.town'][
'checked'])) {
1654 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
1658 $totalarray[
'nbfield']++;
1662 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1663 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).
'">';
1667 $totalarray[
'nbfield']++;
1671 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1672 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).
'">';
1676 $totalarray[
'nbfield']++;
1680 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1681 print
'<td class="center">';
1682 $tmparray =
getCountry($obj->fk_pays,
'all');
1683 print $tmparray[
'label'];
1686 $totalarray[
'nbfield']++;
1690 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1691 print
'<td class="center">';
1692 if (empty($typenArray)) {
1693 $typenArray = $formcompany->typent_array(1);
1695 print $typenArray[$obj->typent_code];
1698 $totalarray[
'nbfield']++;
1703 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1704 $s = $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 1,
'', -1, -1, 1);
1705 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1709 $totalarray[
'nbfield']++;
1713 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1714 $s = $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1, 0,
'', 1);
1715 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1719 $totalarray[
'nbfield']++;
1724 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1725 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1727 $totalarray[
'nbfield']++;
1730 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
1732 $totalarray[
'val'][
'f.total_ht'] += $obj->total_ht;
1735 if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1736 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_vat).
"</span></td>\n";
1738 $totalarray[
'nbfield']++;
1741 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_vat';
1743 $totalarray[
'val'][
'f.total_vat'] += $obj->total_vat;
1746 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1747 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_localtax1).
"</span></td>\n";
1749 $totalarray[
'nbfield']++;
1752 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax1';
1754 $totalarray[
'val'][
'f.total_localtax1'] += $obj->total_localtax1;
1757 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1758 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_localtax2).
"</span></td>\n";
1760 $totalarray[
'nbfield']++;
1763 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax2';
1765 $totalarray[
'val'][
'f.total_localtax2'] += $obj->total_localtax2;
1768 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1769 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1771 $totalarray[
'nbfield']++;
1774 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
1776 $totalarray[
'val'][
'f.total_ttc'] += $obj->total_ttc;
1780 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1781 print
'<td class="tdoverflowmax150">';
1782 if ($userstatic->id) {
1783 print $userstatic->getNomUrl(-1);
1789 $totalarray[
'nbfield']++;
1793 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1794 print
'<td class="right nowrap"><span class="amount">'.(!empty($totalpay) ?
price($totalpay, 0, $langs) :
'').
'</span></td>';
1796 $totalarray[
'nbfield']++;
1799 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalam';
1801 $totalarray[
'val'][
'totalam'] += $totalpay;
1804 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1805 print
'<td class="right nowrap">'.(!empty($remaintopay) ?
price($remaintopay, 0, $langs) :
' ').
'</td>';
1807 $totalarray[
'nbfield']++;
1810 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'rtp';
1812 $totalarray[
'val'][
'rtp'] += $remaintopay;
1816 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1817 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1819 $totalarray[
'nbfield']++;
1824 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1825 print
'<td class="nowrap">';
1826 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1829 $totalarray[
'nbfield']++;
1833 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1834 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
1836 $totalarray[
'nbfield']++;
1840 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1841 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
1843 $totalarray[
'nbfield']++;
1847 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1848 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
1850 $totalarray[
'nbfield']++;
1853 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1854 print
'<td class="right nowrap"><span class="amount">'.(!empty($multicurrency_totalpay) ?
price($multicurrency_totalpay, 0, $langs) :
'').
'</span></td>';
1856 $totalarray[
'nbfield']++;
1861 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1862 print
'<td class="right nowrap"><span class="amount">';
1863 print (!empty($multicurrency_remaintopay) ?
price($multicurrency_remaintopay, 0, $langs) :
'');
1864 print
'</span></td>';
1866 $totalarray[
'nbfield']++;
1872 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1874 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1875 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1876 print $hookmanager->resPrint;
1879 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1880 print
'<td class="center nowrap">';
1881 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1884 $totalarray[
'nbfield']++;
1888 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1889 print
'<td class="center nowrap">';
1890 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1893 $totalarray[
'nbfield']++;
1897 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1898 print
'<td class="right nowrap">';
1899 print $facturestatic->getLibStatut(5, $paiement);
1902 $totalarray[
'nbfield']++;
1908 print
'<td class="nowrap center">';
1909 if ($massactionbutton || $massaction) {
1911 if (in_array($obj->facid, $arrayofselected)) {
1914 print
'<input id="cb'.$obj->facid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1918 $totalarray[
'nbfield']++;
1929include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1934 foreach ($arrayfields as $key => $val) {
1935 if (!empty($val[
'checked'])) {
1939 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1944$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1945$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1946print $hookmanager->resPrint;
1948print
'</table>'.
"\n";
1951print
'</form>'.
"\n";
1953$hidegeneratedfilelistifempty = 1;
1954if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1955 $hidegeneratedfilelistifempty = 0;
1959$urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1960$urlsource .= str_replace(
'&',
'&', $param);
1962$filedir = $diroutputmassaction;
1963$genallowed = $user->hasRight(
'facture',
'lire');
1964$delallowed = $user->hasRight(
'facture',
'creer');
1967print $formfile->showdocuments(
'massfilesarea_supplier_invoice',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
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.
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.
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,...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.