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';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
46 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
55 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
61 $langs->loadLangs(array(
'bills',
'companies',
'products',
'categories'));
63 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
64 $projectid = (
GETPOST(
'projectid') ?
GETPOST(
'projectid',
'int') : 0);
68 $socid =
GETPOST(
'socid',
'int');
70 $action =
GETPOST(
'action',
'aZ09');
71 $massaction =
GETPOST(
'massaction',
'alpha');
72 $show_files =
GETPOST(
'show_files',
'int');
73 $confirm =
GETPOST(
'confirm',
'alpha');
74 $toselect =
GETPOST(
'toselect',
'array');
75 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'invoicelist';
77 if ($contextpage ==
'poslist') {
78 $_GET[
'optioncss'] =
'print';
81 $lineid =
GETPOST(
'lineid',
'int');
82 $userid =
GETPOST(
'userid',
'int');
83 $search_product_category =
GETPOST(
'search_product_category',
'int');
85 $search_refcustomer =
GETPOST(
'search_refcustomer',
'alpha');
86 $search_type =
GETPOST(
'search_type',
'int');
87 $search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
88 $search_project =
GETPOST(
'search_project',
'alpha');
89 $search_company =
GETPOST(
'search_company',
'alpha');
90 $search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
91 $search_montant_ht =
GETPOST(
'search_montant_ht',
'alpha');
92 $search_montant_vat =
GETPOST(
'search_montant_vat',
'alpha');
93 $search_montant_localtax1 =
GETPOST(
'search_montant_localtax1',
'alpha');
94 $search_montant_localtax2 =
GETPOST(
'search_montant_localtax2',
'alpha');
95 $search_montant_ttc =
GETPOST(
'search_montant_ttc',
'alpha');
96 $search_login =
GETPOST(
'search_login',
'alpha');
97 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
98 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
99 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
100 $search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
101 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
102 $search_status =
GETPOST(
'search_status',
'intcomma');
103 $search_paymentmode =
GETPOST(
'search_paymentmode',
'int');
104 $search_paymentterms =
GETPOST(
'search_paymentterms',
'int');
105 $search_module_source =
GETPOST(
'search_module_source',
'alpha');
106 $search_pos_source =
GETPOST(
'search_pos_source',
'alpha');
107 $search_town =
GETPOST(
'search_town',
'alpha');
108 $search_zip =
GETPOST(
'search_zip',
'alpha');
109 $search_state =
GETPOST(
"search_state");
110 $search_country =
GETPOST(
"search_country",
'alpha');
111 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
112 $search_user =
GETPOST(
'search_user',
'int');
113 $search_sale =
GETPOST(
'search_sale',
'int');
114 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
115 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
116 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
117 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
118 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
119 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
120 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
121 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
122 $search_date_valid_startday =
GETPOST(
'search_date_valid_startday',
'int');
123 $search_date_valid_startmonth =
GETPOST(
'search_date_valid_startmonth',
'int');
124 $search_date_valid_startyear =
GETPOST(
'search_date_valid_startyear',
'int');
125 $search_date_valid_endday =
GETPOST(
'search_date_valid_endday',
'int');
126 $search_date_valid_endmonth =
GETPOST(
'search_date_valid_endmonth',
'int');
127 $search_date_valid_endyear =
GETPOST(
'search_date_valid_endyear',
'int');
128 $search_date_valid_start =
dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear);
129 $search_date_valid_end =
dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
130 $search_datelimit_startday =
GETPOST(
'search_datelimit_startday',
'int');
131 $search_datelimit_startmonth =
GETPOST(
'search_datelimit_startmonth',
'int');
132 $search_datelimit_startyear =
GETPOST(
'search_datelimit_startyear',
'int');
133 $search_datelimit_endday =
GETPOST(
'search_datelimit_endday',
'int');
134 $search_datelimit_endmonth =
GETPOST(
'search_datelimit_endmonth',
'int');
135 $search_datelimit_endyear =
GETPOST(
'search_datelimit_endyear',
'int');
136 $search_datelimit_start =
dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
137 $search_datelimit_end =
dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
138 $search_categ_cus =
GETPOST(
"search_categ_cus",
'int');
139 $search_fac_rec_source_title =
GETPOST(
"search_fac_rec_source_title",
'alpha');
140 $search_btn =
GETPOST(
'button_search',
'alpha');
141 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
142 $optioncss =
GETPOST(
'optioncss',
'alpha');
144 $option =
GETPOST(
'search_option');
145 if ($option ==
'late') {
146 $search_status =
'1';
148 $filtre =
GETPOST(
'filtre',
'alpha');
150 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
151 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
152 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
154 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
157 $offset = $limit * $page;
158 if (!$sortorder && !empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status ==
'1') {
159 $sortorder = $conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER;
165 $sortfield =
'f.datef';
167 $pageprev = $page - 1;
168 $pagenext = $page + 1;
171 $fieldid = (!empty($ref) ?
'ref' :
'rowid');
172 if (!empty($user->socid)) {
173 $socid = $user->socid;
175 $result =
restrictedArea($user,
'facture', $id,
'',
'',
'fk_soc', $fieldid);
177 $diroutputmassaction = $conf->facture->dir_output.
'/temp/massgeneration/'.$user->id;
186 $hookmanager->initHooks(array(
'invoicelist'));
190 $extrafields->fetch_name_optionals_label($object->table_element);
192 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
195 $fieldstosearchall = array(
197 'f.ref_client'=>
'RefCustomer',
198 'f.note_public'=>
'NotePublic',
199 's.nom'=>
"ThirdParty",
200 's.name_alias'=>
"AliasNameShort",
203 'pd.description'=>
'Description',
205 if (empty($user->socid)) {
206 $fieldstosearchall[
"f.note_private"] =
"NotePrivate";
209 $checkedtypetiers = 0;
210 $arrayfields = array(
211 'f.ref'=>array(
'label'=>
"Ref",
'checked'=>1,
'position'=>5),
212 'f.ref_client'=>array(
'label'=>
"RefCustomer",
'checked'=>-1,
'position'=>10),
213 'f.type'=>array(
'label'=>
"Type",
'checked'=>0,
'position'=>15),
214 'f.datef'=>array(
'label'=>
"DateInvoice",
'checked'=>1,
'position'=>20),
215 'f.date_valid'=>array(
'label'=>
"DateValidation",
'checked'=>0,
'position'=>22),
216 'f.date_lim_reglement'=>array(
'label'=>
"DateDue",
'checked'=>1,
'position'=>25),
217 'f.date_closing'=>array(
'label'=>
"DateClosing",
'checked'=>0,
'position'=>30),
218 'p.ref'=>array(
'label'=>
"ProjectRef",
'checked'=>1,
'enabled'=>(empty($conf->project->enabled) ? 0 : 1),
'position'=>40),
219 'p.title'=>array(
'label'=>
"ProjectLabel",
'checked'=>0,
'enabled'=>(empty($conf->project->enabled) ? 0 : 1),
'position'=>41),
220 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>50),
221 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'checked'=>1,
'position'=>51),
222 's.town'=>array(
'label'=>
"Town",
'checked'=>-1,
'position'=>55),
223 's.zip'=>array(
'label'=>
"Zip",
'checked'=>1,
'position'=>60),
224 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0,
'position'=>65),
225 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0,
'position'=>70),
226 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers,
'position'=>75),
227 'f.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>1,
'position'=>80),
228 'f.fk_cond_reglement'=>array(
'label'=>
"PaymentConditionsShort",
'checked'=>1,
'position'=>85),
229 'f.module_source'=>array(
'label'=>
"POSModule",
'checked'=>($contextpage ==
'poslist' ? 1 : 0),
'enabled'=>((empty($conf->cashdesk->enabled) && empty($conf->takepos->enabled) && empty($conf->global->INVOICE_SHOW_POS)) ? 0 : 1),
'position'=>90),
230 'f.pos_source'=>array(
'label'=>
"POSTerminal",
'checked'=>($contextpage ==
'poslist' ? 1 : 0),
'enabled'=>((empty($conf->cashdesk->enabled) && empty($conf->takepos->enabled) && empty($conf->global->INVOICE_SHOW_POS)) ? 0 : 1),
'position'=>91),
231 'f.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1,
'position'=>95),
232 'f.total_tva'=>array(
'label'=>
"AmountVAT",
'checked'=>0,
'position'=>100),
233 'f.total_localtax1'=>array(
'label'=>$langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked'=>0,
'enabled'=>($mysoc->localtax1_assuj ==
"1"),
'position'=>110),
234 'f.total_localtax2'=>array(
'label'=>$langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked'=>0,
'enabled'=>($mysoc->localtax2_assuj ==
"1"),
'position'=>120),
235 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0,
'position'=>130),
236 'dynamount_payed'=>array(
'label'=>
"Received",
'checked'=>0,
'position'=>140),
237 'rtp'=>array(
'label'=>
"Rest",
'checked'=>0,
'position'=>150),
238 'u.login'=>array(
'label'=>
"Author",
'checked'=>1,
'position'=>165),
239 'sale_representative'=>array(
'label'=>
"SaleRepresentativesOfThirdParty",
'checked'=>0,
'position'=>166),
240 'f.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>280),
241 'f.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>285),
242 'f.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>290),
243 'f.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>291),
244 'f.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>292),
245 'multicurrency_dynamount_payed'=>array(
'label'=>
'MulticurrencyAlreadyPaid',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>295),
246 'multicurrency_rtp'=>array(
'label'=>
'MulticurrencyRemainderToPay',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>296),
247 'total_pa' => array(
'label' => ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE ==
'1') ?
'BuyingPrice' :
'CostPrice'),
'checked' => 0,
'position' => 300,
'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)),
248 'total_margin' => array(
'label' =>
'Margin',
'checked' => 0,
'position' => 301,
'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)),
249 'total_margin_rate' => array(
'label' =>
'MarginRate',
'checked' => 0,
'position' => 302,
'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)),
250 'total_mark_rate' => array(
'label' =>
'MarkRate',
'checked' => 0,
'position' => 303,
'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)),
251 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>500),
252 'f.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>502),
253 'f.note_public'=>array(
'label'=>
'NotePublic',
'checked'=>0,
'position'=>510,
'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))),
254 'f.note_private'=>array(
'label'=>
'NotePrivate',
'checked'=>0,
'position'=>511,
'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))),
255 'f.fk_fac_rec_source'=>array(
'label'=>
'GeneratedFromTemplate',
'checked'=>0,
'position'=>520,
'enabled'=>
'1'),
256 'f.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000),
259 if (
getDolGlobalString(
"INVOICE_USE_SITUATION") && !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) {
260 $arrayfields[
'f.retained_warranty'] = array(
'label'=>$langs->trans(
"RetainedWarranty"),
'checked'=>0,
'position'=>86);
263 foreach ($object->fields as $key => $val) {
265 if (!empty($val[
'visible'])) {
266 $visible = (int)
dol_eval($val[
'visible'], 1, 1,
'1');
268 if (array_key_exists($key, $arrayfields)) { $newkey = $key; } elseif (array_key_exists(
't.'.$key, $arrayfields)) { $newkey =
't.'.$key; } elseif (array_key_exists(
'f.'.$key, $arrayfields)) { $newkey =
'f.'.$key; } elseif (array_key_exists(
's.'.$key, $arrayfields)) { $newkey =
's.'.$key; }
270 $arrayfields[$newkey] = array(
271 'label'=>$val[
'label'],
272 'checked'=>(($visible < 0) ? 0 : 1),
273 'enabled'=>($visible != 3 &&
dol_eval($val[
'enabled'], 1, 1,
'1')),
274 'position'=>$val[
'position'],
275 'help' => empty($val[
'help']) ?
'' : $val[
'help'],
281 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
291 if (
GETPOST(
'cancel',
'alpha')) {
295 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
299 $parameters = array(
'socid'=>$socid,
'arrayfields'=>&$arrayfields);
300 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
305 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
308 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha')) {
311 $search_product_category =
'';
313 $search_refcustomer =
'';
315 $search_project_ref =
'';
316 $search_project =
'';
317 $search_company =
'';
318 $search_company_alias =
'';
319 $search_montant_ht =
'';
320 $search_montant_vat =
'';
321 $search_montant_localtax1 =
'';
322 $search_montant_localtax2 =
'';
323 $search_montant_ttc =
'';
325 $search_multicurrency_code =
'';
326 $search_multicurrency_tx =
'';
327 $search_multicurrency_montant_ht =
'';
328 $search_multicurrency_montant_vat =
'';
329 $search_multicurrency_montant_ttc =
'';
331 $search_paymentmode =
'';
332 $search_paymentterms =
'';
333 $search_module_source =
'';
334 $search_pos_source =
'';
339 $search_country =
'';
340 $search_type_thirdparty =
'';
341 $search_date_startday =
'';
342 $search_date_startmonth =
'';
343 $search_date_startyear =
'';
344 $search_date_endday =
'';
345 $search_date_endmonth =
'';
346 $search_date_endyear =
'';
347 $search_date_start =
'';
348 $search_date_end =
'';
349 $search_date_valid_startday =
'';
350 $search_date_valid_startmonth =
'';
351 $search_date_valid_startyear =
'';
352 $search_date_valid_endday =
'';
353 $search_date_valid_endmonth =
'';
354 $search_date_valid_endyear =
'';
355 $search_date_valid_start =
'';
356 $search_date_valid_end =
'';
357 $search_datelimit_startday =
'';
358 $search_datelimit_startmonth =
'';
359 $search_datelimit_startyear =
'';
360 $search_datelimit_endday =
'';
361 $search_datelimit_endmonth =
'';
362 $search_datelimit_endyear =
'';
363 $search_datelimit_start =
'';
364 $search_datelimit_end =
'';
365 $search_fac_rec_source_title =
'';
367 $search_array_options = array();
368 $search_categ_cus = 0;
373 if (empty($reshook)) {
374 $objectclass =
'Facture';
375 $objectlabel =
'Invoices';
376 $permissiontoread = $user->rights->facture->lire;
377 $permissiontoadd = $user->rights->facture->creer;
378 $permissiontodelete = $user->rights->facture->supprimer;
379 $uploaddir = $conf->facture->dir_output;
380 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
383 if ($action ==
'makepayment_confirm' && !empty($user->rights->facture->paiement)) {
384 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
385 $arrayofselected = is_array($toselect) ? $toselect : array();
386 if (!empty($arrayofselected)) {
387 $bankid =
GETPOST(
'bankid',
'int');
388 $paiementid =
GETPOST(
'paiementid',
'int');
390 if (empty($paiementdate)) {
391 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
393 $action =
'makepayment';
397 foreach ($arrayofselected as $toselectid) {
400 $result = $facture->fetch($toselectid);
409 $paiementAmount = $facture->getSommePaiement();
410 $totalcreditnotes = $facture->getSumCreditNotesUsed();
411 $totaldeposits = $facture->getSumDepositsUsed();
412 $totalpay = $paiementAmount + $totalcreditnotes + $totaldeposits;
413 $remaintopay =
price2num($facture->total_ttc - $totalpay);
414 if ($remaintopay != 0) {
415 $resultBank = $facture->setBankAccount($bankid);
416 if ($resultBank < 0) {
421 $paiement->datepaye = $paiementdate;
422 $paiement->amounts[$facture->id] = $remaintopay;
423 $paiement->multicurrency_amounts[$facture->id] = $remaintopay;
424 $paiement->paiementid = $paiementid;
425 $paiement_id = $paiement->create($user, 1, $facture->thirdparty);
426 if ($paiement_id < 0) {
427 $langs->load(
"errors");
428 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
431 $result = $paiement->addPaymentToBank($user,
'payment',
'', $bankid,
'',
'');
433 $langs->load(
"errors");
434 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
440 setEventMessage($langs->trans(
'NoPaymentAvailable', $facture->ref),
'warnings');
444 setEventMessage($langs->trans(
'BulkPaymentNotPossibleForInvoice', $facture->ref),
'warnings');
449 if (empty($errorpayment)) {
450 setEventMessage($langs->trans(
'PaymentRegisteredAndInvoiceSetToPaid', $facture->ref));
458 } elseif ($massaction ==
'withdrawrequest') {
459 $langs->load(
"withdrawals");
461 if (!$user->rights->prelevement->bons->creer) {
468 $arrayofselected = is_array($toselect) ? $toselect : array();
469 $listofbills = array();
470 foreach ($arrayofselected as $toselectid) {
472 $result = $objecttmp->fetch($toselectid);
474 $totalpaid = $objecttmp->getSommePaiement();
475 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
476 $totaldeposits = $objecttmp->getSumDepositsUsed();
477 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
480 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
481 } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
483 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
484 } elseif ($objecttmp->resteapayer < 0) {
486 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
489 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
490 $rsql .=
" , pfd.date_traite as date_traite";
491 $rsql .=
" , pfd.amount";
492 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
493 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
494 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
495 $rsql .=
" WHERE fk_facture = ".((int) $objecttmp->id);
496 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
497 $rsql .=
" AND pfd.traite = 0";
498 $rsql .=
" ORDER BY pfd.date_demande DESC";
500 $result_sql = $db->query($rsql);
502 $numprlv = $db->num_rows($result_sql);
507 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
508 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'PRE') {
510 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"BadPaymentMethod"), $objecttmp->errors,
'errors');
512 $listofbills[] = $objecttmp;
518 if (!empty($listofbills)) {
519 $nbwithdrawrequestok = 0;
520 foreach ($listofbills as $aBill) {
522 $result = $aBill->demande_prelevement($user, $aBill->resteapayer,
'direct-debit',
'facture');
525 $nbwithdrawrequestok++;
531 if ($nbwithdrawrequestok > 0) {
532 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
551 $bankaccountstatic =
new Account($db);
552 $facturestatic =
new Facture($db);
554 $companystatic =
new Societe($db);
557 if ($sall || $search_product_category > 0 || $search_user > 0) {
558 $sql =
'SELECT DISTINCT';
560 $sql .=
' f.rowid as id, f.ref, f.ref_client, f.fk_soc, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total_ht, f.total_tva, f.total_ttc,';
561 $sql .=
' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
562 $sql .=
' f.fk_user_author,';
563 $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,';
564 $sql .=
' f.datef, f.date_valid, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,';
565 $sql .=
' f.paye as paye, f.fk_statut, f.close_code,';
566 $sql .=
' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,';
567 $sql .=
' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
568 $sql .=
' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, 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,';
569 $sql .=
' typent.code as typent_code,';
570 $sql .=
' state.code_departement as state_code, state.nom as state_name,';
571 $sql .=
' country.code as country_code,';
572 $sql .=
' f.fk_fac_rec_source,';
573 $sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
574 $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';
583 if ($search_categ_cus && $search_categ_cus != -1) {
584 $sql .=
", cc.fk_categorie, cc.fk_soc";
587 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
588 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
589 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
593 $parameters = array();
594 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
595 $sql .= $hookmanager->resPrint;
596 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
597 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
598 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
599 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
600 if (!empty($search_categ_cus) && $search_categ_cus !=
'-1') {
601 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"categorie_societe as cc ON s.rowid = cc.fk_soc";
604 $sql .=
', '.MAIN_DB_PREFIX.
'facture as f';
605 if ($sortfield ==
"f.datef") {
606 $sql .= $db->hintindex(
'idx_facture_datef');
608 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
609 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
618 if ($sall || $search_product_category > 0) {
619 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facturedet as pd ON f.rowid=pd.fk_facture';
621 if ($search_product_category > 0) {
622 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=pd.fk_product';
625 if (!empty($search_fac_rec_source_title)) {
626 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_rec as facrec ON f.fk_fac_rec_source=facrec.rowid';
628 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
629 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
631 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
632 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
634 if ($search_user > 0) {
635 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
636 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
639 $parameters = array();
640 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
641 $sql .= $hookmanager->resPrint;
643 $sql .=
' WHERE f.fk_soc = s.rowid';
644 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
645 if (empty($user->rights->societe->client->voir) && !$socid) {
646 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
648 if ($search_product_category > 0) {
649 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
652 $sql .=
' AND s.rowid = '.((int) $socid);
656 $sql .=
' AND f.fk_user_author IS NULL';
658 $sql .=
' AND f.fk_user_author = '.((int) $userid);
664 if ($search_refcustomer) {
667 if ($search_type !=
'' && $search_type !=
'-1') {
668 $sql .=
" AND f.type IN (".$db->sanitize($db->escape($search_type)).
")";
670 if ($search_project_ref) {
673 if ($search_project) {
676 if ($search_company) {
679 if ($search_company_alias) {
691 if (strlen(trim($search_country))) {
693 $country_code_in_EEC = $country_code_in_EEC_without_me =
'';
694 foreach ($arrayofcode as $key => $value) {
695 $country_code_in_EEC .= ($country_code_in_EEC ?
"," :
"").
"'".$value.
"'";
696 if ($value != $mysoc->country_code) {
697 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ?
"," :
"").
"'".$value.
"'";
700 if ($search_country ==
'special_allnotme') {
701 $sql .=
" AND country.code <> '".$db->escape($mysoc->country_code).
"'";
702 } elseif ($search_country ==
'special_eec') {
703 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC, 1).
")";
704 } elseif ($search_country ==
'special_eecnotme') {
705 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).
")";
706 } elseif ($search_country ==
'special_noteec') {
707 $sql .=
" AND country.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).
")";
712 if ($search_type_thirdparty !=
'' && $search_type_thirdparty !=
'-1') {
713 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
715 if ($search_montant_ht !=
'') {
718 if ($search_montant_vat !=
'') {
721 if ($search_montant_localtax1 !=
'') {
722 $sql .=
natural_search(
'f.localtax1', $search_montant_localtax1, 1);
724 if ($search_montant_localtax2 !=
'') {
725 $sql .=
natural_search(
'f.localtax2', $search_montant_localtax2, 1);
727 if ($search_montant_ttc !=
'') {
730 if ($search_multicurrency_code !=
'') {
731 $sql .=
" AND f.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
733 if ($search_multicurrency_tx !=
'') {
734 $sql .=
natural_search(
'f.multicurrency_tx', $search_multicurrency_tx, 1);
736 if ($search_multicurrency_montant_ht !=
'') {
737 $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
739 if ($search_multicurrency_montant_vat !=
'') {
740 $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
742 if ($search_multicurrency_montant_ttc !=
'') {
743 $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
746 $sql .=
natural_search(array(
'u.login',
'u.firstname',
'u.lastname'), $search_login);
748 if ($search_categ_cus > 0) {
749 $sql .=
" AND cc.fk_categorie = ".((int) $search_categ_cus);
751 if ($search_categ_cus == -2) {
752 $sql .=
" AND cc.fk_categorie IS NULL";
754 if ($search_status !=
'-1' && $search_status !=
'') {
755 if (is_numeric($search_status) && $search_status >= 0) {
756 if ($search_status ==
'0') {
757 $sql .=
" AND f.fk_statut = 0";
759 if ($search_status ==
'1') {
760 $sql .=
" AND f.fk_statut = 1";
762 if ($search_status ==
'2') {
763 $sql .=
" AND f.fk_statut = 2";
765 if ($search_status ==
'3') {
766 $sql .=
" AND f.fk_statut = 3";
769 $sql .=
" AND f.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
773 if ($search_paymentmode > 0) {
774 $sql .=
" AND f.fk_mode_reglement = ".((int) $search_paymentmode);
776 if ($search_paymentterms > 0) {
777 $sql .=
" AND f.fk_cond_reglement = ".((int) $search_paymentterms);
779 if ($search_module_source) {
782 if ($search_pos_source) {
785 if ($search_date_start) {
786 $sql .=
" AND f.datef >= '".$db->idate($search_date_start).
"'";
788 if ($search_date_end) {
789 $sql .=
" AND f.datef <= '".$db->idate($search_date_end).
"'";
791 if ($search_date_valid_start) {
792 $sql .=
" AND f.date_valid >= '".$db->idate($search_date_valid_start).
"'";
794 if ($search_date_valid_end) {
795 $sql .=
" AND f.date_valid <= '".$db->idate($search_date_valid_end).
"'";
797 if ($search_datelimit_start) {
798 $sql .=
" AND f.date_lim_reglement >= '".$db->idate($search_datelimit_start).
"'";
800 if ($search_datelimit_end) {
801 $sql .=
" AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end).
"'";
803 if ($option ==
'late') {
804 $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() - $conf->facture->client->warning_delay).
"'";
806 if ($search_sale > 0) {
807 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
809 if ($search_user > 0) {
810 $sql .=
" AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".((int) $search_user);
812 if (!empty($search_fac_rec_source_title)) {
813 $sql .=
natural_search(
'facrec.titre', $search_fac_rec_source_title);
816 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
818 $parameters = array();
819 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
820 $sql .= $hookmanager->resPrint;
859 $parameters = array();
860 $reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
861 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
863 $nbtotalofrecords =
'';
864 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
870 if ($sall || $search_product_category > 0 || $search_user > 0) {
871 $sqlforcount = preg_replace(
'/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/',
'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords FROM', $sql);
873 $sqlforcount = preg_replace(
'/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/',
'SELECT COUNT(f.rowid) as nbtotalofrecords FROM', $sql);
874 $sqlforcount = preg_replace(
'/LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON pf.fk_facture = f.rowid/',
'', $sqlforcount);
876 $sqlforcount = preg_replace(
'/GROUP BY.*$/',
'', $sqlforcount);
878 $resql = $db->query($sqlforcount);
880 $objforcount = $db->fetch_object(
$resql);
881 $nbtotalofrecords = $objforcount->nbtotalofrecords;
886 if (($page * $limit) > $nbtotalofrecords) {
894 $sql .=
' ORDER BY ';
895 $listfield = explode(
',', $sortfield);
896 $listorder = explode(
',', $sortorder);
897 foreach ($listfield as $key => $value) {
898 $sql .= $listfield[$key].
' '.($listorder[$key] ? $listorder[$key] :
'DESC').
',';
900 $sql .=
' f.rowid DESC ';
902 $sql .= $db->plimit($limit + 1, $offset);
905 $resql = $db->query($sql);
908 $num = $db->num_rows(
$resql);
910 $arrayofselected = is_array($toselect) ? $toselect : array();
912 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
913 $obj = $db->fetch_object(
$resql);
916 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$id);
920 llxHeader(
'', $langs->trans(
'CustomersInvoices'),
'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
925 if (empty($search_company)) {
926 $search_company = $soc->name;
930 $param =
'&socid='.urlencode($socid);
931 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
932 $param .=
'&contextpage='.urlencode($contextpage);
934 if ($limit > 0 && $limit != $conf->liste_limit) {
935 $param .=
'&limit='.urlencode($limit);
938 $param .=
'&sall='.urlencode($sall);
940 if ($search_date_startday) {
941 $param .=
'&search_date_startday='.urlencode($search_date_startday);
943 if ($search_date_startmonth) {
944 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
946 if ($search_date_startyear) {
947 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
949 if ($search_date_endday) {
950 $param .=
'&search_date_endday='.urlencode($search_date_endday);
952 if ($search_date_endmonth) {
953 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
955 if ($search_date_endyear) {
956 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
958 if ($search_date_valid_startday) {
959 $param .=
'&search_date_valid_startday='.urlencode($search_date_valid_startday);
961 if ($search_date_valid_startmonth) {
962 $param .=
'&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
964 if ($search_date_valid_startyear) {
965 $param .=
'&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
967 if ($search_date_valid_endday) {
968 $param .=
'&search_date_valid_endday='.urlencode($search_date_valid_endday);
970 if ($search_date_valid_endmonth) {
971 $param .=
'&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
973 if ($search_date_valid_endyear) {
974 $param .=
'&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
976 if ($search_datelimit_startday) {
977 $param .=
'&search_datelimit_startday='.urlencode($search_datelimit_startday);
979 if ($search_datelimit_startmonth) {
980 $param .=
'&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth);
982 if ($search_datelimit_startyear) {
983 $param .=
'&search_datelimit_startyear='.urlencode($search_datelimit_startyear);
985 if ($search_datelimit_endday) {
986 $param .=
'&search_datelimit_endday='.urlencode($search_datelimit_endday);
988 if ($search_datelimit_endmonth) {
989 $param .=
'&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth);
991 if ($search_datelimit_endyear) {
992 $param .=
'&search_datelimit_endyear='.urlencode($search_datelimit_endyear);
995 $param .=
'&search_ref='.urlencode($search_ref);
997 if ($search_refcustomer) {
998 $param .=
'&search_refcustomer='.urlencode($search_refcustomer);
1000 if ($search_project_ref) {
1001 $param .=
'&search_project_ref='.urlencode($search_project_ref);
1003 if ($search_project) {
1004 $param .=
'&search_project='.urlencode($search_project);
1006 if ($search_type !=
'') {
1007 $param .=
'&search_type='.urlencode($search_type);
1009 if ($search_company) {
1010 $param .=
'&search_societe='.urlencode($search_company);
1012 if ($search_company_alias) {
1013 $param .=
'&search_societe_alias='.urlencode($search_company_alias);
1016 $param .=
'&search_town='.urlencode($search_town);
1019 $param .=
'&search_zip='.urlencode($search_zip);
1021 if ($search_country) {
1022 $param .=
"&search_country=".urlencode($search_country);
1024 if ($search_sale > 0) {
1025 $param .=
'&search_sale='.urlencode($search_sale);
1027 if ($search_user > 0) {
1028 $param .=
'&search_user='.urlencode($search_user);
1030 if ($search_login) {
1031 $param .=
'&search_login='.urlencode($search_login);
1033 if ($search_product_category > 0) {
1034 $param .=
'&search_product_category='.urlencode($search_product_category);
1036 if ($search_montant_ht !=
'') {
1037 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
1039 if ($search_montant_vat !=
'') {
1040 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
1042 if ($search_montant_localtax1 !=
'') {
1043 $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
1045 if ($search_montant_localtax2 !=
'') {
1046 $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
1048 if ($search_montant_ttc !=
'') {
1049 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
1051 if ($search_multicurrency_code !=
'') {
1052 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1054 if ($search_multicurrency_tx !=
'') {
1055 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1057 if ($search_multicurrency_montant_ht !=
'') {
1058 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1060 if ($search_multicurrency_montant_vat !=
'') {
1061 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1063 if ($search_multicurrency_montant_ttc !=
'') {
1064 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1066 if ($search_status !=
'') {
1067 $param .=
'&search_status='.urlencode($search_status);
1069 if ($search_paymentmode > 0) {
1070 $param .=
'&search_paymentmode='.urlencode($search_paymentmode);
1072 if ($search_paymentterms > 0) {
1073 $param .=
'&search_paymentterms='.urlencode($search_paymentterms);
1075 if ($search_module_source) {
1076 $param .=
'&search_module_source='.urlencode($search_module_source);
1078 if ($search_pos_source) {
1079 $param .=
'&search_pos_source='.urlencode($search_pos_source);
1082 $param .=
'&show_files='.urlencode($show_files);
1085 $param .=
"&search_option=".urlencode($option);
1087 if ($optioncss !=
'') {
1088 $param .=
'&optioncss='.urlencode($optioncss);
1090 if ($search_categ_cus > 0) {
1091 $param .=
'&search_categ_cus='.urlencode($search_categ_cus);
1093 if (!empty($search_fac_rec_source_title)) {
1094 $param .=
'&search_fac_rec_source_title='.urlencode($search_fac_rec_source_title);
1098 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1100 $parameters = array();
1101 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1102 $param .= $hookmanager->resPrint;
1104 $arrayofmassactions = array(
1105 'validate'=>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
1106 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1107 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1108 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1111 if (!empty($user->rights->facture->paiement)) {
1112 $arrayofmassactions[
'makepayment'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakePaymentAndClassifyPayed");
1114 if (!empty($conf->prelevement->enabled) && !empty($user->rights->prelevement->bons->creer)) {
1115 $langs->load(
"withdrawals");
1116 $arrayofmassactions[
'withdrawrequest'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeWithdrawRequest");
1118 if (!empty($user->rights->facture->supprimer)) {
1119 if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) {
1120 $arrayofmassactions[
'predeletedraft'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Deletedraft");
1121 } elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) {
1122 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1125 if (in_array($massaction, array(
'presend',
'predelete',
'makepayment'))) {
1126 $arrayofmassactions = array();
1128 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1131 if ($contextpage !=
'poslist') {
1132 $url = DOL_URL_ROOT.
'/compta/facture/card.php?action=create';
1133 if (!empty($socid)) {
1134 $url .=
'&socid='.$socid;
1136 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->facture->creer);
1140 print
'<form method="POST" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
1142 if ($optioncss !=
'') {
1143 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1145 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1146 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1147 if (!in_array($massaction, array(
'makepayment'))) {
1148 print
'<input type="hidden" name="action" value="list">';
1150 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1151 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1152 print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
1153 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1154 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1156 print_barre_liste($langs->trans(
'BillsCustomers').
' '.($socid > 0 ?
' '.$soc->name :
''), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bill', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1158 $topicmail =
"SendBillRef";
1159 $modelmail =
"facture_send";
1160 $objecttmp =
new Facture($db);
1161 $trackid =
'inv'.$object->id;
1162 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1164 if ($massaction ==
'makepayment') {
1166 $formquestion = array(
1170 array(
'type' =>
'date',
'name' =>
'datepaiment',
'label' => $langs->trans(
"Date"),
'datenow' => 1),
1171 array(
'type' =>
'other',
'name' =>
'paiementid',
'label' => $langs->trans(
"PaymentMode"),
'value' =>
$form->select_types_paiements(
GETPOST(
'search_paymentmode'),
'paiementid',
'', 0, 0, 1, 0, 1,
'', 1)),
1172 array(
'type' =>
'other',
'name' =>
'bankid',
'label' => $langs->trans(
"BankAccount"),
'value'=>
$form->select_comptes(
'',
'bankid', 0,
'', 0,
'', 0,
'', 1)),
1175 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
'MakePaymentAndClassifyPayed'), $langs->trans(
'EnterPaymentReceivedFromCustomer'),
'makepayment_confirm', $formquestion, 1, 0, 200, 500, 1);
1180 foreach ($fieldstosearchall as $key => $val) {
1181 $fieldstosearchall[$key] = $langs->trans($val);
1183 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
1187 $moreforfilter =
'';
1188 if ($user->rights->user->user->lire) {
1189 $langs->load(
"commercial");
1190 $moreforfilter .=
'<div class="divsearchfield">';
1191 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1192 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250');
1193 $moreforfilter .=
'</div>';
1196 if ($user->rights->user->user->lire) {
1197 $moreforfilter .=
'<div class="divsearchfield">';
1198 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1199 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250');
1200 $moreforfilter .=
'</div>';
1203 if (
isModEnabled(
'categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
1204 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1205 $moreforfilter .=
'<div class="divsearchfield">';
1206 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1207 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1208 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0, 0,
'maxwidth250', 1);
1209 $moreforfilter .=
'</div>';
1211 if (
isModEnabled(
'categorie') && $user->rights->categorie->lire) {
1212 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1213 $moreforfilter .=
'<div class="divsearchfield">';
1214 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
1215 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle);
1216 $moreforfilter .=
'</div>';
1218 $parameters = array();
1219 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1220 if (empty($reshook)) {
1221 $moreforfilter .= $hookmanager->resPrint;
1223 $moreforfilter = $hookmanager->resPrint;
1226 if ($moreforfilter) {
1227 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1228 print $moreforfilter;
1232 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1233 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
1236 if ($massactionbutton && $contextpage !=
'poslist') {
1237 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1240 print
'<div class="div-table-responsive">';
1241 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1244 print
'<tr class="liste_titre_filter">';
1245 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
1246 print
'<td class="liste_titre">';
1250 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1251 print
'<td class="liste_titre" align="left">';
1252 print
'<input class="flat maxwidth50imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1256 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1257 print
'<td class="liste_titre">';
1258 print
'<input class="flat maxwidth50imp" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).
'">';
1262 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1263 print
'<td class="liste_titre maxwidthonsmartphone">';
1270 if (!empty($conf->global->INVOICE_USE_SITUATION)) {
1274 print
$form->selectarray(
'search_type', $listtype, $search_type, 1, 0, 0,
'', 0, 0, 0,
'ASC',
'maxwidth100');
1278 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1279 print
'<td class="liste_titre center">';
1280 print
'<div class="nowrap">';
1281 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1283 print
'<div class="nowrap">';
1284 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1289 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
1290 print
'<td class="liste_titre center">';
1291 print
'<div class="nowrap">';
1292 print
$form->selectDate($search_date_valid_start ? $search_date_valid_start : -1,
'search_date_valid_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1294 print
'<div class="nowrap">';
1295 print
$form->selectDate($search_date_valid_end ? $search_date_valid_end : -1,
'search_date_valid_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1300 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1301 print
'<td class="liste_titre center">';
1302 print
'<div class="nowrap">';
1309 print
$form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"Before"));
1310 print
'<br><input type="checkbox" name="search_option" value="late"'.($option ==
'late' ?
' checked' :
'').
'> '.$langs->trans(
"Alert");
1315 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1316 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project_ref" value="'.$search_project_ref.
'"></td>';
1319 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1320 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project" value="'.$search_project.
'"></td>';
1323 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1324 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company" value="'.$search_company.
'"'.($socid > 0 ?
" disabled" :
"").
'></td>';
1327 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1328 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company_alias" value="'.$search_company_alias.
'"></td>';
1331 if (!empty($arrayfields[
's.town'][
'checked'])) {
1332 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1335 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1336 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1339 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1340 print
'<td class="liste_titre">';
1341 print
'<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1345 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1346 print
'<td class="liste_titre" align="center">';
1347 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth150imp maxwidth150',
'code2', 1, 0, 1,
null, 1);
1351 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1352 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1353 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),
'maxwidth100', 1);
1357 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1358 print
'<td class="liste_titre">';
1359 $form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 10);
1363 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1364 print
'<td class="liste_titre">';
1365 $form->select_conditions_paiements($search_paymentterms,
'search_paymentterms', -1, 1, 1);
1369 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
1370 print
'<td class="liste_titre">';
1371 print
'<input class="flat maxwidth75" type="text" name="search_module_source" value="'.dol_escape_htmltag($search_module_source).
'">';
1375 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
1376 print
'<td class="liste_titre">';
1377 print
'<input class="flat maxwidth50" type="text" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).
'">';
1380 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1382 print
'<td class="liste_titre right">';
1383 print
'<input class="flat" type="text" size="4" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
1386 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
1388 print
'<td class="liste_titre right">';
1389 print
'<input class="flat" type="text" size="4" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
1392 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1394 print
'<td class="liste_titre right">';
1395 print
'<input class="flat" type="text" size="4" name="search_montant_localtax1" value="'.$search_montant_localtax1.
'">';
1398 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1400 print
'<td class="liste_titre right">';
1401 print
'<input class="flat" type="text" size="4" name="search_montant_localtax2" value="'.$search_montant_localtax2.
'">';
1404 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1406 print
'<td class="liste_titre right">';
1407 print
'<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
1410 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1412 print
'<td class="liste_titre" align="center">';
1413 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1416 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1417 print
'<td class="liste_titre"></td>';
1419 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
1420 print
'<td class="liste_titre" align="right">';
1423 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1424 print
'<td class="liste_titre right">';
1427 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1428 print
'<td class="liste_titre right">';
1431 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1433 print
'<td class="liste_titre">';
1434 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1437 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1439 print
'<td class="liste_titre">';
1440 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1443 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1445 print
'<td class="liste_titre right">';
1446 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1449 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1451 print
'<td class="liste_titre right">';
1452 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1455 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1457 print
'<td class="liste_titre right">';
1458 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1461 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1462 print
'<td class="liste_titre">';
1465 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1466 print
'<td class="liste_titre right">';
1469 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1470 print
'<td class="liste_titre right">';
1473 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1474 print
'<td class="liste_titre right">';
1477 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1478 print
'<td class="liste_titre right">';
1481 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1482 print
'<td class="liste_titre right">';
1487 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1490 $parameters = array(
'arrayfields'=>$arrayfields);
1491 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1492 print $hookmanager->resPrint;
1494 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1495 print
'<td class="liste_titre">';
1499 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1500 print
'<td class="liste_titre">';
1504 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
1505 print
'<td class="liste_titre">';
1508 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1510 print
'<td class="liste_titre">';
1513 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1515 print
'<td class="liste_titre">';
1518 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
1520 print
'<td class="liste_titre maxwidthonsmartphone right">';
1521 print
'<input class="flat maxwidth50imp" type="text" name="search_fac_rec_source_title" id="search_fac_rec_source_title" value="'.dol_escape_htmltag($search_fac_rec_source_title).
'">';
1525 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1526 print
'<td class="liste_titre maxwidthonsmartphone right">';
1527 $liststatus = array(
'0'=>$langs->trans(
"BillShortStatusDraft"),
'0,1'=>$langs->trans(
"BillShortStatusDraft").
'+'.$langs->trans(
"BillShortStatusNotPaid"),
'1'=>$langs->trans(
"BillShortStatusNotPaid"),
'1,2'=>$langs->trans(
"BillShortStatusNotPaid").
'+'.$langs->trans(
"BillShortStatusPaid"),
'2'=>$langs->trans(
"BillShortStatusPaid"),
'3'=>$langs->trans(
"BillShortStatusCanceled"));
1528 print
$form->selectarray(
'search_status', $liststatus, $search_status, 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1532 print
'<td class="liste_titre" align="middle">';
1533 $searchpicto =
$form->showFilterButtons();
1538 print
'<tr class="liste_titre">';
1539 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
1542 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1543 print_liste_field_titre($arrayfields[
'f.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'f.ref',
'', $param,
'', $sortfield, $sortorder);
1545 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1546 print_liste_field_titre($arrayfields[
'f.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'f.ref_client',
'', $param,
'', $sortfield, $sortorder);
1548 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1549 print_liste_field_titre($arrayfields[
'f.type'][
'label'], $_SERVER[
"PHP_SELF"],
'f.type',
'', $param,
'', $sortfield, $sortorder);
1551 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1552 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
'PHP_SELF'],
'f.datef',
'', $param,
'align="center"', $sortfield, $sortorder);
1554 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
1555 print_liste_field_titre($arrayfields[
'f.date_valid'][
'label'], $_SERVER[
'PHP_SELF'],
'f.date_valid',
'', $param,
'align="center"', $sortfield, $sortorder);
1557 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1558 print_liste_field_titre($arrayfields[
'f.date_lim_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_lim_reglement",
'', $param,
'align="center"', $sortfield, $sortorder);
1560 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1561 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
'PHP_SELF'],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
1563 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1564 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
'PHP_SELF'],
"p.title",
'', $param,
'', $sortfield, $sortorder);
1566 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1567 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1569 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1570 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1572 if (!empty($arrayfields[
's.town'][
'checked'])) {
1573 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1575 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1576 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1578 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1579 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1581 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1582 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'align="center"', $sortfield, $sortorder);
1584 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1585 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'align="center"', $sortfield, $sortorder);
1587 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1588 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_mode_reglement",
"", $param,
"", $sortfield, $sortorder);
1590 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1591 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_cond_reglement",
"", $param,
"", $sortfield, $sortorder);
1593 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
1594 print_liste_field_titre($arrayfields[
'f.module_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.module_source",
"", $param,
"", $sortfield, $sortorder);
1596 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
1597 print_liste_field_titre($arrayfields[
'f.pos_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.pos_source",
"", $param,
"", $sortfield, $sortorder);
1599 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1600 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1602 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
1603 print_liste_field_titre($arrayfields[
'f.total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1605 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1606 print_liste_field_titre($arrayfields[
'f.total_localtax1'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax1',
'', $param,
'class="right"', $sortfield, $sortorder);
1608 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1609 print_liste_field_titre($arrayfields[
'f.total_localtax2'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax2',
'', $param,
'class="right"', $sortfield, $sortorder);
1611 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1612 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1614 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1615 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1617 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1618 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
1620 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
1621 print_liste_field_titre($arrayfields[
'f.retained_warranty'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'align="right"', $sortfield, $sortorder);
1623 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1624 print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1626 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1627 print_liste_field_titre($arrayfields[
'rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1629 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1630 print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1632 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1633 print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1635 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1636 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1638 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1639 print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1641 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1642 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1644 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1645 print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1647 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1648 print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1650 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1651 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1653 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1654 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1656 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1657 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1659 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1660 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1663 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1665 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1666 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1667 print $hookmanager->resPrint;
1668 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1669 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1671 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1672 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1674 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
1675 print_liste_field_titre($arrayfields[
'f.date_closing'][
'label'], $_SERVER[
"PHP_SELF"],
"f.date_closing",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1677 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1678 print_liste_field_titre($arrayfields[
'f.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_public",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1680 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1681 print_liste_field_titre($arrayfields[
'f.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_private",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1683 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
1684 print_liste_field_titre($arrayfields[
'f.fk_fac_rec_source'][
'label'], $_SERVER[
"PHP_SELF"],
"facrec.titre",
"", $param,
'', $sortfield, $sortorder);
1686 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1687 print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_statut,f.paye,f.type",
"", $param,
'class="right"', $sortfield, $sortorder);
1689 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
1692 $projectstatic =
new Project($db);
1694 $userstatic =
new User($db);
1698 $totalarray = array();
1699 $totalarray[
'nbfield'] = 0;
1700 $totalarray[
'val'] = array();
1701 $totalarray[
'val'][
'f.total_ht'] = 0;
1702 $totalarray[
'val'][
'f.total_ttc'] = 0;
1704 $with_margin_info =
false;
1706 !empty($arrayfields[
'total_pa'][
'checked'])
1707 || !empty($arrayfields[
'total_margin'][
'checked'])
1708 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
1709 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
1712 $with_margin_info =
true;
1717 $last_num = min($num, $limit);
1718 while ($i < $last_num) {
1719 $obj = $db->fetch_object(
$resql);
1721 $datelimit = $db->jdate($obj->datelimite);
1723 $facturestatic->id = $obj->id;
1724 $facturestatic->ref = $obj->ref;
1725 $facturestatic->ref_client = $obj->ref_client;
1726 $facturestatic->type = $obj->type;
1727 $facturestatic->total_ht = $obj->total_ht;
1728 $facturestatic->total_tva = $obj->total_tva;
1729 $facturestatic->total_ttc = $obj->total_ttc;
1730 $facturestatic->multicurrency_code = $obj->multicurrency_code;
1731 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1732 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1733 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1734 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1735 $facturestatic->statut = $obj->fk_statut;
1736 $facturestatic->close_code = $obj->close_code;
1737 $facturestatic->total_ttc = $obj->total_ttc;
1738 $facturestatic->paye = $obj->paye;
1739 $facturestatic->fk_soc = $obj->fk_soc;
1741 $facturestatic->date = $db->jdate($obj->datef);
1742 $facturestatic->date_valid = $db->jdate($obj->date_valid);
1743 $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
1745 $facturestatic->note_public = $obj->note_public;
1746 $facturestatic->note_private = $obj->note_private;
1747 if (!empty($conf->global->INVOICE_USE_SITUATION) && !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) {
1748 $facturestatic->retained_warranty = $obj->retained_warranty;
1749 $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit;
1750 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
1751 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
1752 $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref;
1753 $facturestatic->situation_counter = $obj->situation_counter;
1756 $companystatic->id = $obj->socid;
1757 $companystatic->name = $obj->name;
1758 $companystatic->name_alias = $obj->alias;
1759 $companystatic->client = $obj->client;
1760 $companystatic->fournisseur = $obj->fournisseur;
1761 $companystatic->code_client = $obj->code_client;
1762 $companystatic->code_compta_client = $obj->code_compta_client;
1763 $companystatic->code_fournisseur = $obj->code_fournisseur;
1764 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1765 $companystatic->email = $obj->email;
1766 $companystatic->phone = $obj->phone;
1767 $companystatic->fax = $obj->fax;
1768 $companystatic->address = $obj->address;
1769 $companystatic->zip = $obj->zip;
1770 $companystatic->town = $obj->town;
1771 $companystatic->country_code = $obj->country_code;
1773 $projectstatic->id = $obj->project_id;
1774 $projectstatic->ref = $obj->project_ref;
1775 $projectstatic->title = $obj->project_label;
1777 $paiement = $facturestatic->getSommePaiement();
1778 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1779 $totaldeposits = $facturestatic->getSumDepositsUsed();
1780 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1781 $remaintopay =
price2num($facturestatic->total_ttc - $totalpay);
1782 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1783 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1784 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1785 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1786 $multicurrency_remaintopay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1790 $multicurrency_remaintopay = 0;
1793 $remaincreditnote = $discount->getAvailableDiscounts($companystatic,
'',
'rc.fk_facture_source='.$facturestatic->id);
1794 $remaintopay = -$remaincreditnote;
1795 $totalpay =
price2num($facturestatic->total_ttc - $remaintopay);
1796 $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($companystatic,
'',
'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
1797 $multicurrency_remaintopay = -$multicurrency_remaincreditnote;
1798 $multicurrency_totalpay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
1801 $facturestatic->alreadypaid = $paiement;
1803 $marginInfo = array();
1804 if ($with_margin_info ===
true) {
1805 $facturestatic->fetch_lines();
1806 $marginInfo = $formmargin->getMarginInfosArray($facturestatic);
1807 $total_ht += $obj->total_ht;
1808 $total_margin += $marginInfo[
'total_margin'];
1811 print
'<tr class="oddeven"';
1812 if ($contextpage ==
'poslist') {
1813 print
' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.
'\',
function() {parent.$.colorbox.close();
';
1814 if (strpos($obj->ref, 'PROV
') !== false) {
1815 //If is a draft invoice, load var to be able to add products
1816 $place = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
1817 print 'parent.place=\
''.$place.
'\'';
1824 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
1825 print
'<td>'.(($offset * $limit) + $i).
'</td>';
1829 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1830 print
'<td class="nowraponall">';
1832 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1834 print
'<td class="nobordernopadding nowraponall">';
1835 if ($contextpage ==
'poslist') {
1838 print $facturestatic->getNomUrl(1,
'', 200, 0,
'', 0, 1);
1843 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->id;
1844 print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
1851 $totalarray[
'nbfield']++;
1856 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1857 print
'<td class="nowrap tdoverflowmax200">';
1861 $totalarray[
'nbfield']++;
1866 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1867 print
'<td class="nowraponall tdoverflowmax100" title="'.$facturestatic->getLibType().
'">';
1868 print $facturestatic->getLibType();
1871 $totalarray[
'nbfield']++;
1876 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1877 print
'<td align="center" class="nowraponall">';
1881 $totalarray[
'nbfield']++;
1886 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
1887 print
'<td align="center" class="nowraponall">';
1891 $totalarray[
'nbfield']++;
1896 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1897 print
'<td align="center" class="nowraponall">'.dol_print_date($datelimit,
'day');
1898 if ($facturestatic->hasDelay()) {
1899 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
1903 $totalarray[
'nbfield']++;
1908 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1909 print
'<td class="nocellnopadd nowraponall">';
1910 if ($obj->project_id > 0) {
1911 print $projectstatic->getNomUrl(1);
1915 $totalarray[
'nbfield']++;
1920 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1921 print
'<td class="nowraponall">';
1922 if ($obj->project_id > 0) {
1927 $totalarray[
'nbfield']++;
1932 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1933 print
'<td class="tdoverflowmax200">';
1934 if ($contextpage ==
'poslist') {
1937 print $companystatic->getNomUrl(1,
'customer', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1941 $totalarray[
'nbfield']++;
1945 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1946 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).
'">';
1950 $totalarray[
'nbfield']++;
1954 if (!empty($arrayfields[
's.town'][
'checked'])) {
1955 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
1959 $totalarray[
'nbfield']++;
1963 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1964 print
'<td class="nowraponall">';
1968 $totalarray[
'nbfield']++;
1972 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1973 print
"<td>".dol_escape_htmltag($obj->state_name).
"</td>\n";
1975 $totalarray[
'nbfield']++;
1979 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1980 print
'<td class="center">';
1981 $tmparray =
getCountry($obj->fk_pays,
'all');
1982 print $tmparray[
'label'];
1985 $totalarray[
'nbfield']++;
1989 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1990 print
'<td class="center">';
1991 if (!is_array($typenArray) || count($typenArray) == 0) {
1992 $typenArray = $formcompany->typent_array(1);
1994 print $typenArray[$obj->typent_code];
1997 $totalarray[
'nbfield']++;
2001 if (!empty($arrayfields[
'staff.code'][
'checked'])) {
2002 print
'<td class="center">';
2003 if (!is_array($conf->cache[
'staff']) || count($conf->cache[
'staff']) == 0) {
2004 $conf->cache[
'staff'] = $formcompany->effectif_array(1);
2006 print $conf->cache[
'staff'][$obj->staff_code];
2009 $totalarray[
'nbfield']++;
2014 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
2015 print
'<td class="tdoverflowmax100">';
2016 $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1);
2019 $totalarray[
'nbfield']++;
2024 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
2026 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none');
2029 $totalarray[
'nbfield']++;
2034 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
2039 $totalarray[
'nbfield']++;
2044 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
2049 $totalarray[
'nbfield']++;
2054 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
2055 print
'<td class="right nowraponall">'.price($obj->total_ht).
"</td>\n";
2057 $totalarray[
'nbfield']++;
2060 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
2062 $totalarray[
'val'][
'f.total_ht'] += $obj->total_ht;
2065 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
2066 print
'<td class="right nowraponall amount">'.price($obj->total_tva).
"</td>\n";
2068 $totalarray[
'nbfield']++;
2071 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_tva';
2073 $totalarray[
'val'][
'f.total_tva'] += $obj->total_tva;
2076 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
2077 print
'<td class="right nowraponall amount">'.price($obj->total_localtax1).
"</td>\n";
2079 $totalarray[
'nbfield']++;
2082 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax1';
2084 $totalarray[
'val'][
'f.total_localtax1'] += $obj->total_localtax1;
2087 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
2088 print
'<td class="right nowraponall amount">'.price($obj->total_localtax2).
"</td>\n";
2090 $totalarray[
'nbfield']++;
2093 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax2';
2095 $totalarray[
'val'][
'f.total_localtax2'] += $obj->total_localtax2;
2098 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
2099 print
'<td class="right nowraponall amount">'.price($obj->total_ttc).
"</td>\n";
2101 $totalarray[
'nbfield']++;
2104 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
2106 $totalarray[
'val'][
'f.total_ttc'] += $obj->total_ttc;
2109 $userstatic->id = $obj->fk_user_author;
2110 $userstatic->login = $obj->login;
2111 $userstatic->lastname = $obj->lastname;
2112 $userstatic->firstname = $obj->firstname;
2113 $userstatic->email = $obj->user_email;
2114 $userstatic->statut = $obj->user_statut;
2115 $userstatic->entity = $obj->entity;
2116 $userstatic->photo = $obj->photo;
2117 $userstatic->office_phone = $obj->office_phone;
2118 $userstatic->office_fax = $obj->office_fax;
2119 $userstatic->user_mobile = $obj->user_mobile;
2120 $userstatic->job = $obj->job;
2121 $userstatic->gender = $obj->gender;
2124 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2125 print
'<td class="tdoverflowmax200">';
2126 if ($userstatic->id) {
2127 print $userstatic->getNomUrl(-1);
2133 $totalarray[
'nbfield']++;
2137 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2140 if ($obj->socid > 0) {
2141 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2142 if ($listsalesrepresentatives < 0) {
2145 $nbofsalesrepresentative = count($listsalesrepresentatives);
2146 if ($nbofsalesrepresentative > 6) {
2148 print $nbofsalesrepresentative;
2149 } elseif ($nbofsalesrepresentative > 0) {
2151 foreach ($listsalesrepresentatives as $val) {
2152 $userstatic->id = $val[
'id'];
2153 $userstatic->lastname = $val[
'lastname'];
2154 $userstatic->firstname = $val[
'firstname'];
2155 $userstatic->email = $val[
'email'];
2156 $userstatic->statut = $val[
'statut'];
2157 $userstatic->entity = $val[
'entity'];
2158 $userstatic->photo = $val[
'photo'];
2159 $userstatic->login = $val[
'login'];
2160 $userstatic->office_phone = $val[
'office_phone'];
2161 $userstatic->office_fax = $val[
'office_fax'];
2162 $userstatic->user_mobile = $val[
'user_mobile'];
2163 $userstatic->job = $val[
'job'];
2164 $userstatic->gender = $val[
'gender'];
2166 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2168 if ($j < $nbofsalesrepresentative) {
2180 $totalarray[
'nbfield']++;
2184 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
2185 print
'<td align="right">'.(!empty($obj->retained_warranty) ?
price($obj->retained_warranty).
'%' :
' ').
'</td>';
2188 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
2189 print
'<td class="right nowraponall amount">'.(!empty($totalpay) ?
price($totalpay, 0, $langs) :
' ').
'</td>';
2191 $totalarray[
'nbfield']++;
2194 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalam';
2196 $totalarray[
'val'][
'totalam'] += $totalpay;
2200 if (!empty($arrayfields[
'rtp'][
'checked'])) {
2201 print
'<td class="right nowraponall amount">';
2202 print (!empty($remaintopay) ?
price($remaintopay, 0, $langs) :
' ');
2205 $totalarray[
'nbfield']++;
2208 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'rtp';
2210 $totalarray[
'val'][
'rtp'] += $remaintopay;
2215 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
2216 print
'<td class="nowraponall tdoverflowmax125" title="'.dol_escape_htmltag($obj->multicurrency_code.
' - '.$langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code)).
'">';
2217 if (empty($conf->global->MAIN_SHOW_ONLY_CODE_MULTICURRENCY)) {
2218 print $langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code);
2224 $totalarray[
'nbfield']++;
2229 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
2230 print
'<td class="nowraponall">';
2231 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2234 $totalarray[
'nbfield']++;
2238 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
2239 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ht).
"</td>\n";
2241 $totalarray[
'nbfield']++;
2245 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
2246 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_vat).
"</td>\n";
2248 $totalarray[
'nbfield']++;
2252 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
2253 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ttc).
"</td>\n";
2255 $totalarray[
'nbfield']++;
2258 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
2259 print
'<td class="right nowraponall amount">'.(!empty($multicurrency_totalpay) ?
price($multicurrency_totalpay, 0, $langs) :
' ').
'</td>';
2261 $totalarray[
'nbfield']++;
2266 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
2267 print
'<td class="right nowraponall">';
2268 print (!empty($multicurrency_remaintopay) ?
price($multicurrency_remaintopay, 0, $langs) :
' ');
2271 $totalarray[
'nbfield']++;
2276 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2277 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total']).
'</td>';
2279 $totalarray[
'nbfield']++;
2283 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2284 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin']).
'</td>';
2286 $totalarray[
'nbfield']++;
2289 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_margin';
2291 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2294 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2295 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2297 $totalarray[
'nbfield']++;
2301 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2302 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2304 $totalarray[
'nbfield']++;
2307 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_mark_rate';
2309 if ($i >= $last_num - 1) {
2310 if (!empty($total_ht)) {
2311 $totalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2313 $totalarray[
'val'][
'total_mark_rate'] =
'';
2319 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2321 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
2322 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2323 print $hookmanager->resPrint;
2325 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
2326 print
'<td class="nowraponall center">';
2327 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2330 $totalarray[
'nbfield']++;
2334 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
2335 print
'<td class="nowraponall center">';
2336 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
2339 $totalarray[
'nbfield']++;
2343 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
2344 print
'<td class="nowraponall center">';
2345 print
dol_print_date($db->jdate($obj->date_closing),
'dayhour',
'tzuser');
2348 $totalarray[
'nbfield']++;
2352 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
2353 print
'<td class="center">';
2357 $totalarray[
'nbfield']++;
2361 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
2362 print
'<td class="center">';
2366 $totalarray[
'nbfield']++;
2370 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
2371 print
'<td class="center">';
2372 if (!empty($obj->fk_fac_rec_source)) {
2374 $result = $facrec->fetch($obj->fk_fac_rec_source);
2378 print $facrec->getNomUrl();
2383 $totalarray[
'nbfield']++;
2387 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
2388 print
'<td class="nowrap right">';
2389 print $facturestatic->getLibStatut(5, $paiement);
2392 $totalarray[
'nbfield']++;
2397 print
'<td class="nowrap" align="center">';
2398 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
2400 if (in_array($obj->id, $arrayofselected)) {
2403 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2407 $totalarray[
'nbfield']++;
2416 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2422 foreach ($arrayfields as $key => $val) {
2423 if (!empty($val[
'checked'])) {
2427 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2432 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
2433 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
2434 print $hookmanager->resPrint;
2436 print
'</table>'.
"\n";
2437 print
'</div>'.
"\n";
2439 print
'</form>'.
"\n";
2442 if ($contextpage !=
'poslist') {
2443 $hidegeneratedfilelistifempty = 1;
2444 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2445 $hidegeneratedfilelistifempty = 0;
2449 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2450 $urlsource .= str_replace(
'&',
'&', $param);
2452 $filedir = $diroutputmassaction;
2453 $genallowed = $user->rights->facture->lire;
2454 $delallowed = $user->rights->facture->creer;
2457 print $formfile->showdocuments(
'massfilesarea_invoices',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);