39 require
'../../main.inc.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
47 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
55 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
56 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
58 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
62 $langs->loadLangs(array(
'bills',
'companies',
'products',
'categories'));
64 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
65 $projectid = (
GETPOST(
'projectid') ?
GETPOST(
'projectid',
'int') : 0);
69 $socid =
GETPOST(
'socid',
'int');
71 $action =
GETPOST(
'action',
'aZ09');
72 $massaction =
GETPOST(
'massaction',
'alpha');
73 $show_files =
GETPOST(
'show_files',
'int');
74 $confirm =
GETPOST(
'confirm',
'alpha');
75 $toselect =
GETPOST(
'toselect',
'array');
76 $optioncss =
GETPOST(
'optioncss',
'alpha');
77 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'invoicelist';
78 $mode =
GETPOST(
'mode',
'alpha');
80 if ($contextpage ==
'poslist') {
84 $lineid =
GETPOST(
'lineid',
'int');
85 $userid =
GETPOST(
'userid',
'int');
87 $search_refcustomer =
GETPOST(
'search_refcustomer',
'alpha');
88 $search_type =
GETPOST(
'search_type',
'int');
89 $search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
90 $search_project =
GETPOST(
'search_project',
'alpha');
91 $search_company =
GETPOST(
'search_company',
'alpha');
92 $search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
93 $search_parent_name = trim(
GETPOST(
'search_parent_name',
'alphanohtml'));
94 $search_montant_ht =
GETPOST(
'search_montant_ht',
'alpha');
95 $search_montant_vat =
GETPOST(
'search_montant_vat',
'alpha');
96 $search_montant_localtax1 =
GETPOST(
'search_montant_localtax1',
'alpha');
97 $search_montant_localtax2 =
GETPOST(
'search_montant_localtax2',
'alpha');
98 $search_montant_ttc =
GETPOST(
'search_montant_ttc',
'alpha');
99 $search_login =
GETPOST(
'search_login',
'alpha');
100 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
101 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
102 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
103 $search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
104 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
105 $search_status =
GETPOST(
'search_status',
'intcomma');
106 $search_paymentmode =
GETPOST(
'search_paymentmode',
'int');
107 $search_paymentterms =
GETPOST(
'search_paymentterms',
'int');
108 $search_module_source =
GETPOST(
'search_module_source',
'alpha');
109 $search_pos_source =
GETPOST(
'search_pos_source',
'alpha');
110 $search_town =
GETPOST(
'search_town',
'alpha');
111 $search_zip =
GETPOST(
'search_zip',
'alpha');
112 $search_state =
GETPOST(
"search_state");
113 $search_country =
GETPOST(
"search_country",
'alpha');
114 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
115 $search_user =
GETPOST(
'search_user',
'int');
116 $search_sale =
GETPOST(
'search_sale',
'int');
117 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
118 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
119 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
120 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
121 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
122 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
123 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
124 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
125 $search_date_valid_startday =
GETPOST(
'search_date_valid_startday',
'int');
126 $search_date_valid_startmonth =
GETPOST(
'search_date_valid_startmonth',
'int');
127 $search_date_valid_startyear =
GETPOST(
'search_date_valid_startyear',
'int');
128 $search_date_valid_endday =
GETPOST(
'search_date_valid_endday',
'int');
129 $search_date_valid_endmonth =
GETPOST(
'search_date_valid_endmonth',
'int');
130 $search_date_valid_endyear =
GETPOST(
'search_date_valid_endyear',
'int');
131 $search_date_valid_start =
dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear);
132 $search_date_valid_end =
dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
133 $search_datelimit_startday =
GETPOST(
'search_datelimit_startday',
'int');
134 $search_datelimit_startmonth =
GETPOST(
'search_datelimit_startmonth',
'int');
135 $search_datelimit_startyear =
GETPOST(
'search_datelimit_startyear',
'int');
136 $search_datelimit_endday =
GETPOST(
'search_datelimit_endday',
'int');
137 $search_datelimit_endmonth =
GETPOST(
'search_datelimit_endmonth',
'int');
138 $search_datelimit_endyear =
GETPOST(
'search_datelimit_endyear',
'int');
139 $search_datelimit_start =
dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
140 $search_datelimit_end =
dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
141 $search_categ_cus =
GETPOST(
"search_categ_cus",
'int');
142 $search_product_category =
GETPOST(
'search_product_category',
'int');
143 $search_fac_rec_source_title =
GETPOST(
"search_fac_rec_source_title",
'alpha');
144 $search_btn =
GETPOST(
'button_search',
'alpha');
145 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
147 $option =
GETPOST(
'search_option');
148 if ($option ==
'late') {
149 $search_status =
'1';
151 $filtre =
GETPOST(
'filtre',
'alpha');
153 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
154 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
155 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
157 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
160 $offset = $limit * $page;
161 if (!$sortorder && !empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status ==
'1') {
162 $sortorder = $conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER;
168 $sortfield =
'f.datef';
170 $pageprev = $page - 1;
171 $pagenext = $page + 1;
174 $fieldid = (!empty($ref) ?
'ref' :
'rowid');
175 if (!empty($user->socid)) {
176 $socid = $user->socid;
178 $result =
restrictedArea($user,
'facture', $id,
'',
'',
'fk_soc', $fieldid);
180 $diroutputmassaction = $conf->facture->dir_output.
'/temp/massgeneration/'.$user->id;
189 $hookmanager->initHooks(array(
'invoicelist'));
193 $extrafields->fetch_name_optionals_label($object->table_element);
195 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
198 $fieldstosearchall = array(
200 'f.ref_client'=>
'RefCustomer',
201 'f.note_public'=>
'NotePublic',
202 's.nom'=>
"ThirdParty",
203 's.code_client'=>
"CustomerCodeShort",
204 's.name_alias'=>
"AliasNameShort",
207 'pd.description'=>
'Description',
209 if (empty($user->socid)) {
210 $fieldstosearchall[
"f.note_private"] =
"NotePrivate";
213 $checkedtypetiers = 0;
214 $arrayfields = array(
215 'f.ref'=>array(
'label'=>
"Ref",
'checked'=>1,
'position'=>5),
216 'f.ref_client'=>array(
'label'=>
"RefCustomer",
'checked'=>-1,
'position'=>10),
217 'f.type'=>array(
'label'=>
"Type",
'checked'=>0,
'position'=>15),
218 'f.datef'=>array(
'label'=>
"DateInvoice",
'checked'=>1,
'position'=>20),
219 'f.date_valid'=>array(
'label'=>
"DateValidation",
'checked'=>0,
'position'=>22),
220 'f.date_lim_reglement'=>array(
'label'=>
"DateDue",
'checked'=>1,
'position'=>25),
221 'f.date_closing'=>array(
'label'=>
"DateClosing",
'checked'=>0,
'position'=>30),
222 'p.ref'=>array(
'label'=>
"ProjectRef",
'checked'=>1,
'enabled'=>(!
isModEnabled(
'project') ? 0 : 1),
'position'=>40),
223 'p.title'=>array(
'label'=>
"ProjectLabel",
'checked'=>0,
'enabled'=>(!
isModEnabled(
'project') ? 0 : 1),
'position'=>41),
224 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>50),
225 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'checked'=>1,
'position'=>51),
226 's.code_client'=>array(
'label'=>
"CustomerCodeShort",
'checked'=>-1,
'position'=>52),
227 's2.nom'=>array(
'label'=>
'ParentCompany',
'position'=>32,
'checked'=>0),
228 's.town'=>array(
'label'=>
"Town",
'checked'=>-1,
'position'=>55),
229 's.zip'=>array(
'label'=>
"Zip",
'checked'=>1,
'position'=>60),
230 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0,
'position'=>65),
231 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0,
'position'=>70),
232 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers,
'position'=>75),
233 'f.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>1,
'position'=>80),
234 'f.fk_cond_reglement'=>array(
'label'=>
"PaymentConditionsShort",
'checked'=>1,
'position'=>85),
235 '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),
236 '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),
237 'f.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1,
'position'=>95),
238 'f.total_tva'=>array(
'label'=>
"AmountVAT",
'checked'=>0,
'position'=>100),
239 'f.total_localtax1'=>array(
'label'=>$langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked'=>0,
'enabled'=>($mysoc->localtax1_assuj ==
"1"),
'position'=>110),
240 'f.total_localtax2'=>array(
'label'=>$langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked'=>0,
'enabled'=>($mysoc->localtax2_assuj ==
"1"),
'position'=>120),
241 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0,
'position'=>130),
242 'dynamount_payed'=>array(
'label'=>
"Received",
'checked'=>0,
'position'=>140),
243 'rtp'=>array(
'label'=>
"Rest",
'checked'=>0,
'position'=>150),
244 'u.login'=>array(
'label'=>
"Author",
'checked'=>1,
'position'=>165),
245 'sale_representative'=>array(
'label'=>
"SaleRepresentativesOfThirdParty",
'checked'=>0,
'position'=>166),
246 'f.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>280),
247 'f.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>285),
248 'f.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>290),
249 'f.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>291),
250 'f.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>292),
251 'multicurrency_dynamount_payed'=>array(
'label'=>
'MulticurrencyAlreadyPaid',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>295),
252 'multicurrency_rtp'=>array(
'label'=>
'MulticurrencyRemainderToPay',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>296),
253 'total_pa' => array(
'label' => ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE ==
'1') ?
'BuyingPrice' :
'CostPrice'),
'checked' => 0,
'position' => 300,
'enabled' => (!
isModEnabled(
'margin') || empty($user->rights->margins->liretous) ? 0 : 1)),
254 'total_margin' => array(
'label' =>
'Margin',
'checked' => 0,
'position' => 301,
'enabled' => (!
isModEnabled(
'margin') || empty($user->rights->margins->liretous) ? 0 : 1)),
255 'total_margin_rate' => array(
'label' =>
'MarginRate',
'checked' => 0,
'position' => 302,
'enabled' => (!
isModEnabled(
'margin') || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)),
256 'total_mark_rate' => array(
'label' =>
'MarkRate',
'checked' => 0,
'position' => 303,
'enabled' => (!
isModEnabled(
'margin') || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)),
257 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>500),
258 'f.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>502),
259 'f.note_public'=>array(
'label'=>
'NotePublic',
'checked'=>0,
'position'=>510,
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES'))),
260 'f.note_private'=>array(
'label'=>
'NotePrivate',
'checked'=>0,
'position'=>511,
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES'))),
261 'f.fk_fac_rec_source'=>array(
'label'=>
'GeneratedFromTemplate',
'checked'=>0,
'position'=>520,
'enabled'=>
'1'),
262 'f.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000),
265 if (
getDolGlobalString(
"INVOICE_USE_SITUATION") && !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) {
266 $arrayfields[
'f.retained_warranty'] = array(
'label'=>$langs->trans(
"RetainedWarranty"),
'checked'=>0,
'position'=>86);
269 foreach ($object->fields as $key => $val) {
271 if (!empty($val[
'visible'])) {
272 $visible = (int)
dol_eval($val[
'visible'], 1, 1,
'1');
274 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; }
276 $arrayfields[$newkey] = array(
277 'label'=>$val[
'label'],
278 'checked'=>(($visible < 0) ? 0 : 1),
279 'enabled'=>($visible != 3 &&
dol_eval($val[
'enabled'], 1, 1,
'1')),
280 'position'=>$val[
'position'],
281 'help' => empty($val[
'help']) ?
'' : $val[
'help'],
287 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
297 if (
GETPOST(
'cancel',
'alpha')) {
301 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
305 $parameters = array(
'socid'=>$socid,
'arrayfields'=>&$arrayfields);
306 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
311 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
314 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha')) {
317 $search_product_category =
'';
319 $search_refcustomer =
'';
321 $search_project_ref =
'';
322 $search_project =
'';
323 $search_company =
'';
324 $search_company_alias =
'';
325 $search_parent_name =
'';
326 $search_montant_ht =
'';
327 $search_montant_vat =
'';
328 $search_montant_localtax1 =
'';
329 $search_montant_localtax2 =
'';
330 $search_montant_ttc =
'';
332 $search_multicurrency_code =
'';
333 $search_multicurrency_tx =
'';
334 $search_multicurrency_montant_ht =
'';
335 $search_multicurrency_montant_vat =
'';
336 $search_multicurrency_montant_ttc =
'';
338 $search_paymentmode =
'';
339 $search_paymentterms =
'';
340 $search_module_source =
'';
341 $search_pos_source =
'';
345 $search_country =
'';
346 $search_type_thirdparty =
'';
347 $search_date_startday =
'';
348 $search_date_startmonth =
'';
349 $search_date_startyear =
'';
350 $search_date_endday =
'';
351 $search_date_endmonth =
'';
352 $search_date_endyear =
'';
353 $search_date_start =
'';
354 $search_date_end =
'';
355 $search_date_valid_startday =
'';
356 $search_date_valid_startmonth =
'';
357 $search_date_valid_startyear =
'';
358 $search_date_valid_endday =
'';
359 $search_date_valid_endmonth =
'';
360 $search_date_valid_endyear =
'';
361 $search_date_valid_start =
'';
362 $search_date_valid_end =
'';
363 $search_datelimit_startday =
'';
364 $search_datelimit_startmonth =
'';
365 $search_datelimit_startyear =
'';
366 $search_datelimit_endday =
'';
367 $search_datelimit_endmonth =
'';
368 $search_datelimit_endyear =
'';
369 $search_datelimit_start =
'';
370 $search_datelimit_end =
'';
371 $search_fac_rec_source_title =
'';
373 $search_array_options = array();
374 $search_categ_cus = 0;
379 if (empty($reshook)) {
380 $objectclass =
'Facture';
381 $objectlabel =
'Invoices';
382 $permissiontoread = $user->hasRight(
"facture",
"lire");
383 $permissiontoadd = $user->hasRight(
"facture",
"creer");
384 $permissiontodelete = $user->hasRight(
"facture",
"supprimer");
385 $uploaddir = $conf->facture->dir_output;
386 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
389 if ($action ==
'makepayment_confirm' && !empty($user->rights->facture->paiement)) {
390 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
391 $arrayofselected = is_array($toselect) ? $toselect : array();
392 if (!empty($arrayofselected)) {
393 $bankid =
GETPOST(
'bankid',
'int');
394 $paiementid =
GETPOST(
'paiementid',
'int');
396 if (empty($paiementdate)) {
397 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
399 $action =
'makepayment';
403 foreach ($arrayofselected as $toselectid) {
406 $result = $facture->fetch($toselectid);
415 $paiementAmount = $facture->getSommePaiement();
416 $totalcreditnotes = $facture->getSumCreditNotesUsed();
417 $totaldeposits = $facture->getSumDepositsUsed();
418 $totalpay = $paiementAmount + $totalcreditnotes + $totaldeposits;
419 $remaintopay =
price2num($facture->total_ttc - $totalpay);
420 if ($remaintopay != 0) {
421 $resultBank = $facture->setBankAccount($bankid);
422 if ($resultBank < 0) {
427 $paiement->datepaye = $paiementdate;
428 $paiement->amounts[$facture->id] = $remaintopay;
429 $paiement->multicurrency_amounts[$facture->id] = $remaintopay;
430 $paiement->paiementid = $paiementid;
431 $paiement_id = $paiement->create($user, 1, $facture->thirdparty);
432 if ($paiement_id < 0) {
433 $langs->load(
"errors");
434 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
437 $result = $paiement->addPaymentToBank($user,
'payment',
'', $bankid,
'',
'');
439 $langs->load(
"errors");
440 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
446 setEventMessage($langs->trans(
'NoPaymentAvailable', $facture->ref),
'warnings');
450 setEventMessage($langs->trans(
'BulkPaymentNotPossibleForInvoice', $facture->ref),
'warnings');
455 if (empty($errorpayment)) {
456 setEventMessage($langs->trans(
'PaymentRegisteredAndInvoiceSetToPaid', $facture->ref));
464 } elseif ($massaction ==
'withdrawrequest') {
465 $langs->load(
"withdrawals");
467 if (!$user->rights->prelevement->bons->creer) {
474 $arrayofselected = is_array($toselect) ? $toselect : array();
475 $listofbills = array();
476 foreach ($arrayofselected as $toselectid) {
478 $result = $objecttmp->fetch($toselectid);
480 $totalpaid = $objecttmp->getSommePaiement();
481 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
482 $totaldeposits = $objecttmp->getSumDepositsUsed();
483 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
486 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
487 } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
489 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
490 } elseif ($objecttmp->resteapayer < 0) {
492 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
495 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
496 $rsql .=
" , pfd.date_traite as date_traite";
497 $rsql .=
" , pfd.amount";
498 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
499 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
500 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
501 $rsql .=
" WHERE fk_facture = ".((int) $objecttmp->id);
502 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
503 $rsql .=
" AND pfd.traite = 0";
504 $rsql .=
" ORDER BY pfd.date_demande DESC";
506 $result_sql = $db->query($rsql);
508 $numprlv = $db->num_rows($result_sql);
513 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
514 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'PRE') {
516 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"BadPaymentMethod"), $objecttmp->errors,
'errors');
518 $listofbills[] = $objecttmp;
524 if (!empty($listofbills)) {
525 $nbwithdrawrequestok = 0;
526 foreach ($listofbills as $aBill) {
528 $result = $aBill->demande_prelevement($user, $aBill->resteapayer,
'direct-debit',
'facture');
531 $nbwithdrawrequestok++;
537 if ($nbwithdrawrequestok > 0) {
538 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
557 $bankaccountstatic =
new Account($db);
558 $facturestatic =
new Facture($db);
560 $companystatic =
new Societe($db);
561 $companyparent =
new Societe($db);
562 $company_url_list = array();
564 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
565 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
568 if ($sall || $search_user > 0) {
569 $sql =
'SELECT DISTINCT';
571 $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,';
572 $sql .=
' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
573 $sql .=
' f.fk_user_author,';
574 $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,';
575 $sql .=
' f.datef, f.date_valid, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,';
576 $sql .=
' f.paye as paye, f.fk_statut, f.close_code,';
577 $sql .=
' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,';
578 $sql .=
' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
579 $sql .=
' s.rowid as socid, s.nom as name, s.name_alias as alias, s.code_client as code_client, 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,';
580 $sql .=
" s.parent as fk_parent,";
581 $sql .=
" s2.nom as name2,";
582 $sql .=
' typent.code as typent_code,';
583 $sql .=
' state.code_departement as state_code, state.nom as state_name,';
584 $sql .=
' country.code as country_code,';
585 $sql .=
' f.fk_fac_rec_source,';
586 $sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
587 $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';
597 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
598 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
599 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
603 $parameters = array();
604 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
605 $sql .= $hookmanager->resPrint;
609 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
610 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s2 ON s2.rowid = s.parent";
611 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
612 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
613 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
614 $sql .=
', '.MAIN_DB_PREFIX.
'facture as f';
615 if ($sortfield ==
"f.datef") {
616 $sql .= $db->hintindex(
'idx_facture_datef');
618 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
619 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
629 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facturedet as pd ON f.rowid=pd.fk_facture';
631 if (!empty($search_fac_rec_source_title)) {
632 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_rec as facrec ON f.fk_fac_rec_source=facrec.rowid';
634 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
635 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
637 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
638 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
640 if ($search_user > 0) {
641 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
642 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
645 $parameters = array();
646 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
647 $sql .= $hookmanager->resPrint;
649 $sql .=
' WHERE f.fk_soc = s.rowid';
650 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
651 if (empty($user->rights->societe->client->voir) && !$socid) {
652 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
655 $sql .=
' AND s.rowid = '.((int) $socid);
659 $sql .=
' AND f.fk_user_author IS NULL';
661 $sql .=
' AND f.fk_user_author = '.((int) $userid);
667 if ($search_refcustomer) {
670 if ($search_type !=
'' && $search_type !=
'-1') {
671 $sql .=
" AND f.type IN (".$db->sanitize($db->escape($search_type)).
")";
673 if ($search_project_ref) {
676 if ($search_project) {
679 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
682 if ($search_company) {
685 if ($search_company_alias) {
689 if ($search_parent_name) {
692 if ($search_company_code_client) {
704 if (strlen(trim($search_country))) {
706 $country_code_in_EEC = $country_code_in_EEC_without_me =
'';
707 foreach ($arrayofcode as $key => $value) {
708 $country_code_in_EEC .= ($country_code_in_EEC ?
"," :
"").
"'".$value.
"'";
709 if ($value != $mysoc->country_code) {
710 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ?
"," :
"").
"'".$value.
"'";
713 if ($search_country ==
'special_allnotme') {
714 $sql .=
" AND country.code <> '".$db->escape($mysoc->country_code).
"'";
715 } elseif ($search_country ==
'special_eec') {
716 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC, 1).
")";
717 } elseif ($search_country ==
'special_eecnotme') {
718 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).
")";
719 } elseif ($search_country ==
'special_noteec') {
720 $sql .=
" AND country.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).
")";
725 if ($search_type_thirdparty !=
'' && $search_type_thirdparty !=
'-1') {
726 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
728 if ($search_montant_ht !=
'') {
731 if ($search_montant_vat !=
'') {
734 if ($search_montant_localtax1 !=
'') {
737 if ($search_montant_localtax2 !=
'') {
740 if ($search_montant_ttc !=
'') {
743 if ($search_multicurrency_code !=
'') {
744 $sql .=
" AND f.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
746 if ($search_multicurrency_tx !=
'') {
749 if ($search_multicurrency_montant_ht !=
'') {
750 $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
752 if ($search_multicurrency_montant_vat !=
'') {
753 $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
755 if ($search_multicurrency_montant_ttc !=
'') {
756 $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
761 if ($search_status !=
'-1' && $search_status !=
'') {
762 if (is_numeric($search_status) && $search_status >= 0) {
763 if ($search_status ==
'0') {
764 $sql .=
" AND f.fk_statut = 0";
766 if ($search_status ==
'1') {
767 $sql .=
" AND f.fk_statut = 1";
769 if ($search_status ==
'2') {
770 $sql .=
" AND f.fk_statut = 2";
772 if ($search_status ==
'3') {
773 $sql .=
" AND f.fk_statut = 3";
776 $sql .=
" AND f.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
780 if ($search_paymentmode > 0) {
781 $sql .=
" AND f.fk_mode_reglement = ".((int) $search_paymentmode);
783 if ($search_paymentterms > 0) {
784 $sql .=
" AND f.fk_cond_reglement = ".((int) $search_paymentterms);
786 if ($search_module_source) {
789 if ($search_pos_source) {
792 if ($search_date_start) {
793 $sql .=
" AND f.datef >= '".$db->idate($search_date_start).
"'";
795 if ($search_date_end) {
796 $sql .=
" AND f.datef <= '".$db->idate($search_date_end).
"'";
798 if ($search_date_valid_start) {
799 $sql .=
" AND f.date_valid >= '".$db->idate($search_date_valid_start).
"'";
801 if ($search_date_valid_end) {
802 $sql .=
" AND f.date_valid <= '".$db->idate($search_date_valid_end).
"'";
804 if ($search_datelimit_start) {
805 $sql .=
" AND f.date_lim_reglement >= '".$db->idate($search_datelimit_start).
"'";
807 if ($search_datelimit_end) {
808 $sql .=
" AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end).
"'";
810 if ($option ==
'late') {
811 $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() - $conf->facture->client->warning_delay).
"'";
813 if ($search_sale > 0) {
814 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
816 if ($search_user > 0) {
817 $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);
819 if (!empty($search_fac_rec_source_title)) {
823 $searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
824 $searchCategoryProductOperator = 0;
825 if (!empty($searchCategoryProductList)) {
826 $searchCategoryProductSqlList = array();
827 $listofcategoryid =
'';
828 foreach ($searchCategoryProductList as $searchCategoryProduct) {
829 if (intval($searchCategoryProduct) == -2) {
830 $searchCategoryProductSqlList[] =
"NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facturedet as fd WHERE fd.fk_facture = f.rowid AND fd.fk_product = ck.fk_product)";
831 } elseif (intval($searchCategoryProduct) > 0) {
832 if ($searchCategoryProductOperator == 0) {
833 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facturedet as fd WHERE fd.fk_facture = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
835 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
839 if ($listofcategoryid) {
840 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facturedet as fd WHERE fd.fk_facture = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
842 if ($searchCategoryProductOperator == 1) {
843 if (!empty($searchCategoryProductSqlList)) {
844 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
847 if (!empty($searchCategoryProductSqlList)) {
848 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
852 $searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array();
853 $searchCategoryCustomerOperator = 0;
855 if (!empty($searchCategoryCustomerList)) {
856 $searchCategoryCustomerSqlList = array();
857 $listofcategoryid =
'';
858 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
859 if (intval($searchCategoryCustomer) == -2) {
860 $searchCategoryCustomerSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
861 } elseif (intval($searchCategoryCustomer) > 0) {
862 if ($searchCategoryCustomerOperator == 0) {
863 $searchCategoryCustomerSqlList[] =
" EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).
")";
865 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryCustomer);
869 if ($listofcategoryid) {
870 $searchCategoryCustomerSqlList[] =
" EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
872 if ($searchCategoryCustomerOperator == 1) {
873 if (!empty($searchCategoryCustomerSqlList)) {
874 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
877 if (!empty($searchCategoryCustomerSqlList)) {
878 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
883 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
885 $parameters = array();
886 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
887 $sql .= $hookmanager->resPrint;
926 $parameters = array();
927 $reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
928 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
932 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
934 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
935 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
936 $resql = $db->query($sqlforcount);
938 $objforcount = $db->fetch_object($resql);
952 $sql .= $db->order($sortfield, $sortorder);
954 $sql .= $db->plimit($limit + 1, $offset);
957 $resql = $db->query(
$sql);
960 $num = $db->num_rows($resql);
962 $arrayofselected = is_array($toselect) ? $toselect : array();
964 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
965 $obj = $db->fetch_object($resql);
968 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$id);
972 llxHeader(
'', $langs->trans(
'CustomersInvoices'),
'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
977 if (empty($search_company)) {
978 $search_company = $soc->name;
982 $param =
'&socid='.urlencode($socid);
984 $param .=
'&mode='.urlencode($mode);
986 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
987 $param .=
'&contextpage='.urlencode($contextpage);
989 if ($limit > 0 && $limit != $conf->liste_limit) {
990 $param .=
'&limit='.urlencode($limit);
993 $param .=
'&sall='.urlencode($sall);
995 if ($search_date_startday) {
996 $param .=
'&search_date_startday='.urlencode($search_date_startday);
998 if ($search_date_startmonth) {
999 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
1001 if ($search_date_startyear) {
1002 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
1004 if ($search_date_endday) {
1005 $param .=
'&search_date_endday='.urlencode($search_date_endday);
1007 if ($search_date_endmonth) {
1008 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
1010 if ($search_date_endyear) {
1011 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
1013 if ($search_date_valid_startday) {
1014 $param .=
'&search_date_valid_startday='.urlencode($search_date_valid_startday);
1016 if ($search_date_valid_startmonth) {
1017 $param .=
'&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
1019 if ($search_date_valid_startyear) {
1020 $param .=
'&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
1022 if ($search_date_valid_endday) {
1023 $param .=
'&search_date_valid_endday='.urlencode($search_date_valid_endday);
1025 if ($search_date_valid_endmonth) {
1026 $param .=
'&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
1028 if ($search_date_valid_endyear) {
1029 $param .=
'&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
1031 if ($search_datelimit_startday) {
1032 $param .=
'&search_datelimit_startday='.urlencode($search_datelimit_startday);
1034 if ($search_datelimit_startmonth) {
1035 $param .=
'&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth);
1037 if ($search_datelimit_startyear) {
1038 $param .=
'&search_datelimit_startyear='.urlencode($search_datelimit_startyear);
1040 if ($search_datelimit_endday) {
1041 $param .=
'&search_datelimit_endday='.urlencode($search_datelimit_endday);
1043 if ($search_datelimit_endmonth) {
1044 $param .=
'&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth);
1046 if ($search_datelimit_endyear) {
1047 $param .=
'&search_datelimit_endyear='.urlencode($search_datelimit_endyear);
1050 $param .=
'&search_ref='.urlencode($search_ref);
1052 if ($search_refcustomer) {
1053 $param .=
'&search_refcustomer='.urlencode($search_refcustomer);
1055 if ($search_project_ref) {
1056 $param .=
'&search_project_ref='.urlencode($search_project_ref);
1058 if ($search_project) {
1059 $param .=
'&search_project='.urlencode($search_project);
1061 if ($search_type !=
'') {
1062 $param .=
'&search_type='.urlencode($search_type);
1064 if ($search_company) {
1065 $param .=
'&search_company='.urlencode($search_company);
1067 if ($search_company_alias) {
1068 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1070 if ($search_parent_name !=
'') {
1071 $param .=
'&search_parent_name='.urlencode($search_parent_name);
1074 $param .=
'&search_town='.urlencode($search_town);
1077 $param .=
'&search_zip='.urlencode($search_zip);
1079 if ($search_country) {
1080 $param .=
"&search_country=".urlencode($search_country);
1082 if ($search_type_thirdparty !=
'') {
1083 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1085 if ($search_sale > 0) {
1086 $param .=
'&search_sale='.urlencode($search_sale);
1088 if ($search_user > 0) {
1089 $param .=
'&search_user='.urlencode($search_user);
1091 if ($search_login) {
1092 $param .=
'&search_login='.urlencode($search_login);
1094 if ($search_product_category > 0) {
1095 $param .=
'&search_product_category='.urlencode($search_product_category);
1097 if ($search_montant_ht !=
'') {
1098 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
1100 if ($search_montant_vat !=
'') {
1101 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
1103 if ($search_montant_localtax1 !=
'') {
1104 $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
1106 if ($search_montant_localtax2 !=
'') {
1107 $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
1109 if ($search_montant_ttc !=
'') {
1110 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
1112 if ($search_multicurrency_code !=
'') {
1113 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1115 if ($search_multicurrency_tx !=
'') {
1116 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1118 if ($search_multicurrency_montant_ht !=
'') {
1119 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1121 if ($search_multicurrency_montant_vat !=
'') {
1122 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1124 if ($search_multicurrency_montant_ttc !=
'') {
1125 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1127 if ($search_status !=
'') {
1128 $param .=
'&search_status='.urlencode($search_status);
1130 if ($search_paymentmode > 0) {
1131 $param .=
'&search_paymentmode='.urlencode($search_paymentmode);
1133 if ($search_paymentterms > 0) {
1134 $param .=
'&search_paymentterms='.urlencode($search_paymentterms);
1136 if ($search_module_source) {
1137 $param .=
'&search_module_source='.urlencode($search_module_source);
1139 if ($search_pos_source) {
1140 $param .=
'&search_pos_source='.urlencode($search_pos_source);
1143 $param .=
'&show_files='.urlencode($show_files);
1146 $param .=
"&search_option=".urlencode($option);
1148 if ($optioncss !=
'') {
1149 $param .=
'&optioncss='.urlencode($optioncss);
1151 if ($search_categ_cus > 0) {
1152 $param .=
'&search_categ_cus='.urlencode($search_categ_cus);
1154 if (!empty($search_fac_rec_source_title)) {
1155 $param .=
'&search_fac_rec_source_title='.urlencode($search_fac_rec_source_title);
1159 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1161 $parameters = array();
1162 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1163 $param .= $hookmanager->resPrint;
1165 $arrayofmassactions = array(
1166 'validate'=>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
1167 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1168 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1169 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1172 if (!empty($user->rights->facture->paiement)) {
1173 $arrayofmassactions[
'makepayment'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakePaymentAndClassifyPayed");
1175 if (!empty($conf->prelevement->enabled) && !empty($user->rights->prelevement->bons->creer)) {
1176 $langs->load(
"withdrawals");
1177 $arrayofmassactions[
'withdrawrequest'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeWithdrawRequest");
1179 if (!empty($user->rights->facture->supprimer)) {
1180 if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) {
1181 $arrayofmassactions[
'predeletedraft'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Deletedraft");
1182 } elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) {
1183 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1186 if (in_array($massaction, array(
'presend',
'predelete',
'makepayment'))) {
1187 $arrayofmassactions = array();
1189 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1192 if ($contextpage !=
'poslist') {
1193 $url = DOL_URL_ROOT.
'/compta/facture/card.php?action=create';
1194 if (!empty($socid)) {
1195 $url .=
'&socid='.$socid;
1197 $newcardbutton =
'';
1198 $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'));
1199 $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'));
1200 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', $user->hasRight(
"facture",
"creer"));
1204 print
'<form method="POST" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
1206 if ($optioncss !=
'') {
1207 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1209 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1210 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1211 if (!in_array($massaction, array(
'makepayment'))) {
1212 print
'<input type="hidden" name="action" value="list">';
1214 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1215 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1216 print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
1217 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1218 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1219 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1221 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);
1223 $topicmail =
"SendBillRef";
1224 $modelmail =
"facture_send";
1225 $objecttmp =
new Facture($db);
1226 $trackid =
'inv'.$object->id;
1227 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1229 if ($massaction ==
'makepayment') {
1231 $formquestion = array(
1235 array(
'type' =>
'date',
'name' =>
'datepaiment',
'label' => $langs->trans(
"Date"),
'datenow' => 1),
1236 array(
'type' =>
'other',
'name' =>
'paiementid',
'label' => $langs->trans(
"PaymentMode"),
'value' =>
$form->select_types_paiements(
GETPOST(
'search_paymentmode'),
'paiementid',
'', 0, 0, 1, 0, 1,
'', 1)),
1237 array(
'type' =>
'other',
'name' =>
'bankid',
'label' => $langs->trans(
"BankAccount"),
'value'=>
$form->select_comptes(
'',
'bankid', 0,
'', 0,
'', 0,
'', 1)),
1240 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
'MakePaymentAndClassifyPayed'), $langs->trans(
'EnterPaymentReceivedFromCustomer'),
'makepayment_confirm', $formquestion, 1, 0, 200, 500, 1);
1245 foreach ($fieldstosearchall as $key => $val) {
1246 $fieldstosearchall[$key] = $langs->trans($val);
1248 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
1252 $moreforfilter =
'';
1253 if ($user->hasRight(
"user",
"user",
"lire")) {
1254 $langs->load(
"commercial");
1255 $moreforfilter .=
'<div class="divsearchfield">';
1256 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1257 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250');
1258 $moreforfilter .=
'</div>';
1261 if ($user->hasRight(
"user",
"user",
"lire")) {
1262 $moreforfilter .=
'<div class="divsearchfield">';
1263 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1264 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250');
1265 $moreforfilter .=
'</div>';
1268 if (
isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"lire") && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
1269 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1270 $moreforfilter .=
'<div class="divsearchfield">';
1271 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1272 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1273 $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);
1274 $moreforfilter .=
'</div>';
1276 if (
isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"lire")) {
1277 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1278 $moreforfilter .=
'<div class="divsearchfield">';
1279 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
1280 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle);
1281 $moreforfilter .=
'</div>';
1283 $parameters = array();
1284 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1285 if (empty($reshook)) {
1286 $moreforfilter .= $hookmanager->resPrint;
1288 $moreforfilter = $hookmanager->resPrint;
1291 if ($moreforfilter) {
1292 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1293 print $moreforfilter;
1297 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1298 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
1301 if ($massactionbutton && $contextpage !=
'poslist') {
1302 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1305 print
'<div class="div-table-responsive">';
1306 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1309 print
'<tr class="liste_titre_filter">';
1311 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1313 print
'<td class="liste_titre center actioncolumn">';
1314 $searchpicto =
$form->showFilterButtons(
'left');
1319 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
1320 print
'<td class="liste_titre">';
1324 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1325 print
'<td class="liste_titre" align="left">';
1326 print
'<input class="flat maxwidth50imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1330 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1331 print
'<td class="liste_titre">';
1332 print
'<input class="flat maxwidth50imp" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).
'">';
1336 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1337 print
'<td class="liste_titre maxwidthonsmartphone">';
1344 if (!empty($conf->global->INVOICE_USE_SITUATION)) {
1348 print
$form->selectarray(
'search_type', $listtype, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100');
1352 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1353 print
'<td class="liste_titre center">';
1354 print
'<div class="nowrap">';
1355 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1357 print
'<div class="nowrap">';
1358 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1363 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
1364 print
'<td class="liste_titre center">';
1365 print
'<div class="nowrap">';
1366 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'));
1368 print
'<div class="nowrap">';
1369 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'));
1374 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1375 print
'<td class="liste_titre center">';
1376 print
'<div class="nowrap">';
1383 print
$form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"Before"));
1384 print
'<br><input type="checkbox" name="search_option" value="late"'.($option ==
'late' ?
' checked' :
'').
'> '.$langs->trans(
"Alert");
1389 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1390 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1393 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1394 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1397 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1398 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'"'.($socid > 0 ?
" disabled" :
"").
'></td>';
1401 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1402 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1405 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1406 print
'<td class="liste_titre">';
1407 print
'<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).
'">';
1411 if (!empty($arrayfields[
's.code_client'][
'checked'])) {
1412 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company_code_client" value="'.dol_escape_htmltag($search_company_code_client).
'"></td>';
1415 if (!empty($arrayfields[
's.town'][
'checked'])) {
1416 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1419 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1420 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1423 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1424 print
'<td class="liste_titre">';
1425 print
'<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1429 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1430 print
'<td class="liste_titre" align="center">';
1431 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth150imp maxwidth150',
'code2', 1, 0, 1,
null, 1);
1435 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1436 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1437 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);
1441 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1442 print
'<td class="liste_titre">';
1443 print
$form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 0, 1,
'minwidth100 maxwidth100', 1);
1447 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1448 print
'<td class="liste_titre">';
1449 print
$form->getSelectConditionsPaiements($search_paymentterms,
'search_paymentterms', -1, 1, 1,
'minwidth100 maxwidth100');
1453 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
1454 print
'<td class="liste_titre">';
1455 print
'<input class="flat maxwidth75" type="text" name="search_module_source" value="'.dol_escape_htmltag($search_module_source).
'">';
1459 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
1460 print
'<td class="liste_titre">';
1461 print
'<input class="flat maxwidth50" type="text" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).
'">';
1464 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1466 print
'<td class="liste_titre right">';
1467 print
'<input class="flat" type="text" size="4" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
1470 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
1472 print
'<td class="liste_titre right">';
1473 print
'<input class="flat" type="text" size="4" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
1476 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1478 print
'<td class="liste_titre right">';
1479 print
'<input class="flat" type="text" size="4" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).
'">';
1482 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1484 print
'<td class="liste_titre right">';
1485 print
'<input class="flat" type="text" size="4" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).
'">';
1488 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1490 print
'<td class="liste_titre right">';
1491 print
'<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
1494 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1496 print
'<td class="liste_titre" align="center">';
1497 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1500 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1501 print
'<td class="liste_titre"></td>';
1503 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
1504 print
'<td class="liste_titre" align="right">';
1507 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1508 print
'<td class="liste_titre right">';
1511 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1512 print
'<td class="liste_titre right">';
1515 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1517 print
'<td class="liste_titre">';
1518 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1521 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1523 print
'<td class="liste_titre">';
1524 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1527 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1529 print
'<td class="liste_titre right">';
1530 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1533 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1535 print
'<td class="liste_titre right">';
1536 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1539 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1541 print
'<td class="liste_titre right">';
1542 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1545 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1546 print
'<td class="liste_titre">';
1549 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1550 print
'<td class="liste_titre right">';
1553 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1554 print
'<td class="liste_titre right">';
1557 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1558 print
'<td class="liste_titre right">';
1561 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1562 print
'<td class="liste_titre right">';
1565 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1566 print
'<td class="liste_titre right">';
1571 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1574 $parameters = array(
'arrayfields'=>$arrayfields);
1575 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1576 print $hookmanager->resPrint;
1578 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1579 print
'<td class="liste_titre">';
1583 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1584 print
'<td class="liste_titre">';
1588 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
1589 print
'<td class="liste_titre">';
1592 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1594 print
'<td class="liste_titre">';
1597 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1599 print
'<td class="liste_titre">';
1602 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
1604 print
'<td class="liste_titre maxwidthonsmartphone right">';
1605 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).
'">';
1609 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1610 print
'<td class="liste_titre right parentonrightofpage">';
1611 $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"));
1612 print
$form->selectarray(
'search_status', $liststatus, $search_status, 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage', 1);
1616 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1617 print
'<td class="liste_titre center actioncolumn">';
1618 $searchpicto =
$form->showFilterButtons();
1624 print
'<tr class="liste_titre">';
1626 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1627 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
1630 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
1633 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1634 print_liste_field_titre($arrayfields[
'f.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'f.ref',
'', $param,
'', $sortfield, $sortorder);
1636 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1637 print_liste_field_titre($arrayfields[
'f.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'f.ref_client',
'', $param,
'', $sortfield, $sortorder);
1639 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1640 print_liste_field_titre($arrayfields[
'f.type'][
'label'], $_SERVER[
"PHP_SELF"],
'f.type',
'', $param,
'', $sortfield, $sortorder);
1642 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1643 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
'PHP_SELF'],
'f.datef',
'', $param,
'align="center"', $sortfield, $sortorder);
1645 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
1646 print_liste_field_titre($arrayfields[
'f.date_valid'][
'label'], $_SERVER[
'PHP_SELF'],
'f.date_valid',
'', $param,
'align="center"', $sortfield, $sortorder);
1648 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1649 print_liste_field_titre($arrayfields[
'f.date_lim_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_lim_reglement",
'', $param,
'align="center"', $sortfield, $sortorder);
1651 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1652 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
'PHP_SELF'],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
1654 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1655 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
'PHP_SELF'],
"p.title",
'', $param,
'', $sortfield, $sortorder);
1657 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1658 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1660 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1661 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1663 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1664 print_liste_field_titre($arrayfields[
's2.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's2.nom',
'', $param,
'', $sortfield, $sortorder);
1666 if (!empty($arrayfields[
's.code_client'][
'checked'])) {
1667 print_liste_field_titre($arrayfields[
's.code_client'][
'label'], $_SERVER[
'PHP_SELF'],
's.code_client',
'', $param,
'', $sortfield, $sortorder);
1669 if (!empty($arrayfields[
's.town'][
'checked'])) {
1670 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1672 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1673 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1675 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1676 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1678 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1679 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'align="center"', $sortfield, $sortorder);
1681 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1682 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'align="center"', $sortfield, $sortorder);
1684 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1685 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_mode_reglement",
"", $param,
"", $sortfield, $sortorder);
1687 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1688 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_cond_reglement",
"", $param,
"", $sortfield, $sortorder);
1690 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
1691 print_liste_field_titre($arrayfields[
'f.module_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.module_source",
"", $param,
"", $sortfield, $sortorder);
1693 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
1694 print_liste_field_titre($arrayfields[
'f.pos_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.pos_source",
"", $param,
"", $sortfield, $sortorder);
1696 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1697 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1699 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
1700 print_liste_field_titre($arrayfields[
'f.total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1702 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1703 print_liste_field_titre($arrayfields[
'f.total_localtax1'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax1',
'', $param,
'class="right"', $sortfield, $sortorder);
1705 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1706 print_liste_field_titre($arrayfields[
'f.total_localtax2'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax2',
'', $param,
'class="right"', $sortfield, $sortorder);
1708 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1709 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1711 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1712 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1714 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1715 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
1717 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
1718 print_liste_field_titre($arrayfields[
'f.retained_warranty'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'align="right"', $sortfield, $sortorder);
1720 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1721 print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1723 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1724 print_liste_field_titre($arrayfields[
'rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1726 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1727 print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1729 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1730 print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1732 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1733 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1735 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1736 print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1738 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1739 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1741 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1742 print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1744 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1745 print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1747 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1748 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1750 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1751 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1753 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1754 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1756 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1757 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1760 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1762 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1763 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1764 print $hookmanager->resPrint;
1765 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1766 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1768 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1769 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1771 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
1772 print_liste_field_titre($arrayfields[
'f.date_closing'][
'label'], $_SERVER[
"PHP_SELF"],
"f.date_closing",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1774 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1775 print_liste_field_titre($arrayfields[
'f.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_public",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1777 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1778 print_liste_field_titre($arrayfields[
'f.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_private",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1780 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
1781 print_liste_field_titre($arrayfields[
'f.fk_fac_rec_source'][
'label'], $_SERVER[
"PHP_SELF"],
"facrec.titre",
"", $param,
'', $sortfield, $sortorder);
1783 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1784 print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_statut,f.paye,f.type",
"", $param,
'class="right"', $sortfield, $sortorder);
1786 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1787 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
1792 $projectstatic =
new Project($db);
1794 $userstatic =
new User($db);
1798 $typenArray = $formcompany->typent_array(1);
1799 $totalarray = array();
1800 $totalarray[
'nbfield'] = 0;
1801 $totalarray[
'val'] = array();
1802 $totalarray[
'val'][
'f.total_tva'] = 0;
1803 $totalarray[
'val'][
'f.total_ht'] = 0;
1804 $totalarray[
'val'][
'f.total_ttc'] = 0;
1806 $with_margin_info =
false;
1808 !empty($arrayfields[
'total_pa'][
'checked'])
1809 || !empty($arrayfields[
'total_margin'][
'checked'])
1810 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
1811 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
1814 $with_margin_info =
true;
1819 $savnbfield = $totalarray[
'nbfield'];
1820 $totalarray[
'nbfield'] = 0;
1821 $imaxinloop = ($limit ? min($num, $limit) : $num);
1822 while ($i < $imaxinloop) {
1823 $obj = $db->fetch_object($resql);
1825 $datelimit = $db->jdate($obj->datelimite);
1827 $facturestatic->id = $obj->id;
1828 $facturestatic->ref = $obj->ref;
1829 $facturestatic->ref_client = $obj->ref_client;
1830 $facturestatic->type = $obj->type;
1831 $facturestatic->total_ht = $obj->total_ht;
1832 $facturestatic->total_tva = $obj->total_tva;
1833 $facturestatic->total_ttc = $obj->total_ttc;
1834 $facturestatic->multicurrency_code = $obj->multicurrency_code;
1835 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1836 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1837 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1838 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1839 $facturestatic->statut = $obj->fk_statut;
1840 $facturestatic->status = $obj->fk_statut;
1841 $facturestatic->close_code = $obj->close_code;
1842 $facturestatic->total_ttc = $obj->total_ttc;
1843 $facturestatic->paye = $obj->paye;
1844 $facturestatic->socid = $obj->fk_soc;
1846 $facturestatic->date = $db->jdate($obj->datef);
1847 $facturestatic->date_validation = $db->jdate($obj->date_valid);
1848 $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
1850 $facturestatic->note_public = $obj->note_public;
1851 $facturestatic->note_private = $obj->note_private;
1853 if (!empty($conf->global->INVOICE_USE_SITUATION) && !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) {
1854 $facturestatic->retained_warranty = $obj->retained_warranty;
1855 $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit;
1856 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
1857 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
1858 $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref;
1859 $facturestatic->situation_counter = $obj->situation_counter;
1862 $companystatic->id = $obj->socid;
1863 $companystatic->name = $obj->name;
1864 $companystatic->name_alias = $obj->alias;
1865 $companystatic->code_client = $obj->code_client;
1866 $companystatic->client = $obj->client;
1867 $companystatic->fournisseur = $obj->fournisseur;
1868 $companystatic->code_client = $obj->code_client;
1869 $companystatic->code_compta_client = $obj->code_compta_client;
1870 $companystatic->code_fournisseur = $obj->code_fournisseur;
1871 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1872 $companystatic->email = $obj->email;
1873 $companystatic->phone = $obj->phone;
1874 $companystatic->fax = $obj->fax;
1875 $companystatic->address = $obj->address;
1876 $companystatic->zip = $obj->zip;
1877 $companystatic->town = $obj->town;
1878 $companystatic->country_code = $obj->country_code;
1880 $projectstatic->id = $obj->project_id;
1881 $projectstatic->ref = $obj->project_ref;
1882 $projectstatic->title = $obj->project_label;
1884 $paiement = $facturestatic->getSommePaiement();
1885 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1886 $totaldeposits = $facturestatic->getSumDepositsUsed();
1888 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1889 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1890 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1892 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1893 $remaintopay =
price2num($facturestatic->total_ttc - $totalpay);
1895 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1896 $multicurrency_remaintopay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1900 $multicurrency_remaintopay = 0;
1903 $remaincreditnote = $discount->getAvailableDiscounts($companystatic,
'',
'rc.fk_facture_source='.$facturestatic->id);
1904 $remaintopay = -$remaincreditnote;
1905 $totalpay =
price2num($facturestatic->total_ttc - $remaintopay);
1906 $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($companystatic,
'',
'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
1907 $multicurrency_remaintopay = -$multicurrency_remaincreditnote;
1908 $multicurrency_totalpay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
1911 $facturestatic->alreadypaid = $paiement;
1913 $marginInfo = array();
1914 if ($with_margin_info ===
true) {
1915 $facturestatic->fetch_lines();
1916 $marginInfo = $formmargin->getMarginInfosArray($facturestatic);
1917 $total_ht += $obj->total_ht;
1918 $total_margin += $marginInfo[
'total_margin'];
1921 if ($mode ==
'kanban') {
1923 print
'<tr><td colspan="12">';
1924 print
'<div class="box-flex-container kanban">';
1927 $facturestatic->socid = $companystatic->getNomUrl(1,
'company', 15);
1928 $userstatic->fetch($obj->fk_user_author);
1929 $facturestatic->fk_user_author = $userstatic->getNomUrl(1);
1930 print $facturestatic->getKanbanView(
'');
1931 if ($i == (min($num, $limit) - 1)) {
1936 print
'<tr class="oddeven"';
1937 if ($contextpage ==
'poslist') {
1938 print
' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.
'\',
function() {parent.$.colorbox.close();
';
1939 if (strpos($obj->ref, 'PROV
') !== false) {
1940 //If is a draft invoice, load var to be able to add products
1941 $place = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
1942 print 'parent.place=\
''.$place.
'\'';
1949 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1950 print
'<td class="nowrap" align="center">';
1951 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1953 if (in_array($obj->id, $arrayofselected)) {
1956 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1962 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
1963 print
'<td>'.(($offset * $limit) + $i).
'</td>';
1967 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1968 print
'<td class="nowraponall">';
1970 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1972 print
'<td class="nobordernopadding nowraponall">';
1973 if ($contextpage ==
'poslist') {
1976 print $facturestatic->getNomUrl(1,
'', 200, 0,
'', 0, 1);
1981 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->id;
1982 print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
1989 $totalarray[
'nbfield']++;
1994 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1995 print
'<td class="nowrap tdoverflowmax200">';
1999 $totalarray[
'nbfield']++;
2004 if (!empty($arrayfields[
'f.type'][
'checked'])) {
2005 print
'<td class="nowraponall tdoverflowmax100" title="'.$facturestatic->getLibType().
'">';
2006 print $facturestatic->getLibType(2);
2009 $totalarray[
'nbfield']++;
2014 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
2015 print
'<td align="center" class="nowraponall">';
2019 $totalarray[
'nbfield']++;
2024 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
2025 print
'<td align="center" class="nowraponall">';
2029 $totalarray[
'nbfield']++;
2034 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
2035 print
'<td align="center" class="nowraponall">'.dol_print_date($datelimit,
'day');
2036 if ($facturestatic->hasDelay()) {
2037 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
2041 $totalarray[
'nbfield']++;
2046 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
2047 print
'<td class="nocellnopadd nowraponall">';
2048 if ($obj->project_id > 0) {
2049 print $projectstatic->getNomUrl(1);
2053 $totalarray[
'nbfield']++;
2058 if (!empty($arrayfields[
'p.title'][
'checked'])) {
2059 print
'<td class="nowraponall">';
2060 if ($obj->project_id > 0) {
2065 $totalarray[
'nbfield']++;
2070 if (!empty($arrayfields[
's.nom'][
'checked'])) {
2071 print
'<td class="tdoverflowmax200">';
2072 if ($contextpage ==
'poslist') {
2075 print $companystatic->getNomUrl(1,
'customer', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2079 $totalarray[
'nbfield']++;
2083 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2084 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).
'">';
2088 $totalarray[
'nbfield']++;
2092 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
2093 print
'<td class="tdoverflowmax200">';
2094 if ($obj->fk_parent > 0) {
2095 if (!isset($company_url_list[$obj->fk_parent])) {
2096 $companyparent =
new Societe($db);
2097 $res = $companyparent->fetch($obj->fk_parent);
2099 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2102 if (isset($company_url_list[$obj->fk_parent])) {
2103 print $company_url_list[$obj->fk_parent];
2108 $totalarray[
'nbfield']++;
2112 if (!empty($arrayfields[
's.code_client'][
'checked'])) {
2113 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->code_client).
'">';
2117 $totalarray[
'nbfield']++;
2121 if (!empty($arrayfields[
's.town'][
'checked'])) {
2122 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
2126 $totalarray[
'nbfield']++;
2130 if (!empty($arrayfields[
's.zip'][
'checked'])) {
2131 print
'<td class="nowraponall">';
2135 $totalarray[
'nbfield']++;
2139 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2140 print
"<td>".dol_escape_htmltag($obj->state_name).
"</td>\n";
2142 $totalarray[
'nbfield']++;
2146 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2147 print
'<td class="center">';
2148 $tmparray =
getCountry($obj->fk_pays,
'all');
2149 print $tmparray[
'label'];
2152 $totalarray[
'nbfield']++;
2156 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2157 print
'<td class="center">';
2158 if (!is_array($typenArray) || count($typenArray) == 0) {
2159 $typenArray = $formcompany->typent_array(1);
2161 print $typenArray[$obj->typent_code];
2164 $totalarray[
'nbfield']++;
2168 if (!empty($arrayfields[
'staff.code'][
'checked'])) {
2169 print
'<td class="center">';
2170 if (!is_array($conf->cache[
'staff']) || count($conf->cache[
'staff']) == 0) {
2171 $conf->cache[
'staff'] = $formcompany->effectif_array(1);
2173 print $conf->cache[
'staff'][$obj->staff_code];
2176 $totalarray[
'nbfield']++;
2181 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
2182 $s =
$form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1, 0,
'', 1);
2183 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
2187 $totalarray[
'nbfield']++;
2192 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
2193 $s =
$form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', -1, -1, 1);
2194 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
2198 $totalarray[
'nbfield']++;
2203 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
2208 $totalarray[
'nbfield']++;
2213 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
2218 $totalarray[
'nbfield']++;
2223 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
2224 print
'<td class="right nowraponall amount">'.price($obj->total_ht).
"</td>\n";
2226 $totalarray[
'nbfield']++;
2229 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
2231 $totalarray[
'val'][
'f.total_ht'] += $obj->total_ht;
2234 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
2235 print
'<td class="right nowraponall amount">'.price($obj->total_tva).
"</td>\n";
2237 $totalarray[
'nbfield']++;
2240 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_tva';
2242 $totalarray[
'val'][
'f.total_tva'] += $obj->total_tva;
2245 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
2246 print
'<td class="right nowraponall amount">'.price($obj->total_localtax1).
"</td>\n";
2248 $totalarray[
'nbfield']++;
2251 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax1';
2253 $totalarray[
'val'][
'f.total_localtax1'] += $obj->total_localtax1;
2256 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
2257 print
'<td class="right nowraponall amount">'.price($obj->total_localtax2).
"</td>\n";
2259 $totalarray[
'nbfield']++;
2262 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax2';
2264 $totalarray[
'val'][
'f.total_localtax2'] += $obj->total_localtax2;
2267 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
2268 print
'<td class="right nowraponall amount">'.price($obj->total_ttc).
"</td>\n";
2270 $totalarray[
'nbfield']++;
2273 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
2275 $totalarray[
'val'][
'f.total_ttc'] += $obj->total_ttc;
2278 $userstatic->id = $obj->fk_user_author;
2279 $userstatic->login = $obj->login;
2280 $userstatic->lastname = $obj->lastname;
2281 $userstatic->firstname = $obj->firstname;
2282 $userstatic->email = $obj->user_email;
2283 $userstatic->statut = $obj->user_statut;
2284 $userstatic->entity = $obj->entity;
2285 $userstatic->photo = $obj->photo;
2286 $userstatic->office_phone = $obj->office_phone;
2287 $userstatic->office_fax = $obj->office_fax;
2288 $userstatic->user_mobile = $obj->user_mobile;
2289 $userstatic->job = $obj->job;
2290 $userstatic->gender = $obj->gender;
2293 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2294 print
'<td class="tdoverflowmax200">';
2295 if ($userstatic->id) {
2296 print $userstatic->getNomUrl(-1);
2302 $totalarray[
'nbfield']++;
2306 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2309 if ($obj->socid > 0) {
2310 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2311 if ($listsalesrepresentatives < 0) {
2314 $nbofsalesrepresentative = count($listsalesrepresentatives);
2315 if ($nbofsalesrepresentative > 6) {
2317 print $nbofsalesrepresentative;
2318 } elseif ($nbofsalesrepresentative > 0) {
2320 foreach ($listsalesrepresentatives as $val) {
2321 $userstatic->id = $val[
'id'];
2322 $userstatic->lastname = $val[
'lastname'];
2323 $userstatic->firstname = $val[
'firstname'];
2324 $userstatic->email = $val[
'email'];
2325 $userstatic->statut = $val[
'statut'];
2326 $userstatic->entity = $val[
'entity'];
2327 $userstatic->photo = $val[
'photo'];
2328 $userstatic->login = $val[
'login'];
2329 $userstatic->office_phone = $val[
'office_phone'];
2330 $userstatic->office_fax = $val[
'office_fax'];
2331 $userstatic->user_mobile = $val[
'user_mobile'];
2332 $userstatic->job = $val[
'job'];
2333 $userstatic->gender = $val[
'gender'];
2335 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2337 if ($j < $nbofsalesrepresentative) {
2349 $totalarray[
'nbfield']++;
2353 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
2354 print
'<td align="right">'.(!empty($obj->retained_warranty) ?
price($obj->retained_warranty).
'%' :
' ').
'</td>';
2357 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
2358 print
'<td class="right nowraponall amount">'.(!empty($totalpay) ?
price($totalpay, 0, $langs) :
' ').
'</td>';
2360 $totalarray[
'nbfield']++;
2363 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalam';
2365 $totalarray[
'val'][
'totalam'] += $totalpay;
2369 if (!empty($arrayfields[
'rtp'][
'checked'])) {
2370 print
'<td class="right nowraponall amount">';
2371 print (!empty($remaintopay) ?
price($remaintopay, 0, $langs) :
' ');
2374 $totalarray[
'nbfield']++;
2377 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'rtp';
2379 $totalarray[
'val'][
'rtp'] += $remaintopay;
2384 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
2385 print
'<td class="nowraponall tdoverflowmax125" title="'.dol_escape_htmltag($obj->multicurrency_code.
' - '.$langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code)).
'">';
2386 if (empty($conf->global->MAIN_SHOW_ONLY_CODE_MULTICURRENCY)) {
2387 print $langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code);
2393 $totalarray[
'nbfield']++;
2398 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
2399 print
'<td class="nowraponall">';
2400 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2403 $totalarray[
'nbfield']++;
2407 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
2408 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ht).
"</td>\n";
2410 $totalarray[
'nbfield']++;
2414 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
2415 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_vat).
"</td>\n";
2417 $totalarray[
'nbfield']++;
2421 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
2422 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ttc).
"</td>\n";
2424 $totalarray[
'nbfield']++;
2427 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
2428 print
'<td class="right nowraponall amount">'.(!empty($multicurrency_totalpay) ?
price($multicurrency_totalpay, 0, $langs) :
' ').
'</td>';
2430 $totalarray[
'nbfield']++;
2435 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
2436 print
'<td class="right nowraponall">';
2437 print (!empty($multicurrency_remaintopay) ?
price($multicurrency_remaintopay, 0, $langs) :
' ');
2440 $totalarray[
'nbfield']++;
2445 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2446 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total']).
'</td>';
2448 $totalarray[
'nbfield']++;
2452 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2453 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin']).
'</td>';
2455 $totalarray[
'nbfield']++;
2458 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_margin';
2460 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2463 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2464 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2466 $totalarray[
'nbfield']++;
2470 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2471 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2473 $totalarray[
'nbfield']++;
2476 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_mark_rate';
2478 if ($i >= $imaxinloop - 1) {
2479 if (!empty($total_ht)) {
2480 $totalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2482 $totalarray[
'val'][
'total_mark_rate'] =
'';
2488 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2490 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
2491 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2492 print $hookmanager->resPrint;
2494 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
2495 print
'<td class="nowraponall center">';
2496 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2499 $totalarray[
'nbfield']++;
2503 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
2504 print
'<td class="nowraponall center">';
2505 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
2508 $totalarray[
'nbfield']++;
2512 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
2513 print
'<td class="nowraponall center">';
2514 print
dol_print_date($db->jdate($obj->date_closing),
'dayhour',
'tzuser');
2517 $totalarray[
'nbfield']++;
2521 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
2522 print
'<td class="center">';
2526 $totalarray[
'nbfield']++;
2530 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
2531 print
'<td class="center">';
2535 $totalarray[
'nbfield']++;
2539 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
2540 print
'<td class="center">';
2541 if (!empty($obj->fk_fac_rec_source)) {
2543 $result = $facrec->fetch($obj->fk_fac_rec_source);
2547 print $facrec->getNomUrl();
2552 $totalarray[
'nbfield']++;
2556 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
2557 print
'<td class="nowrap right">';
2558 print $facturestatic->getLibStatut(5, $paiement);
2561 $totalarray[
'nbfield']++;
2567 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
2568 print
'<td class="nowrap" align="center">';
2569 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
2571 if (in_array($obj->id, $arrayofselected)) {
2574 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2578 $totalarray[
'nbfield']++;
2589 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2595 foreach ($arrayfields as $key => $val) {
2596 if (!empty($val[
'checked'])) {
2600 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2605 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
2606 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2607 print $hookmanager->resPrint;
2609 print
'</table>'.
"\n";
2610 print
'</div>'.
"\n";
2612 print
'</form>'.
"\n";
2615 if ($contextpage !=
'poslist') {
2616 $hidegeneratedfilelistifempty = 1;
2617 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2618 $hidegeneratedfilelistifempty = 0;
2622 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2623 $urlsource .= str_replace(
'&',
'&', $param);
2625 $filedir = $diroutputmassaction;
2626 $genallowed = $user->hasRight(
"facture",
"lire");
2627 $delallowed = $user->hasRight(
"facture",
"creer");
2630 print $formfile->showdocuments(
'massfilesarea_invoices',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);