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_company_code_client =
GETPOST(
"search_type_thirdparty",
'alpha');
116 $search_user =
GETPOST(
'search_user',
'int');
117 $search_sale =
GETPOST(
'search_sale',
'int');
118 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
119 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
120 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
121 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
122 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
123 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
124 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
125 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
126 $search_date_valid_startday =
GETPOST(
'search_date_valid_startday',
'int');
127 $search_date_valid_startmonth =
GETPOST(
'search_date_valid_startmonth',
'int');
128 $search_date_valid_startyear =
GETPOST(
'search_date_valid_startyear',
'int');
129 $search_date_valid_endday =
GETPOST(
'search_date_valid_endday',
'int');
130 $search_date_valid_endmonth =
GETPOST(
'search_date_valid_endmonth',
'int');
131 $search_date_valid_endyear =
GETPOST(
'search_date_valid_endyear',
'int');
132 $search_date_valid_start =
dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear);
133 $search_date_valid_end =
dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
134 $search_datelimit_startday =
GETPOST(
'search_datelimit_startday',
'int');
135 $search_datelimit_startmonth =
GETPOST(
'search_datelimit_startmonth',
'int');
136 $search_datelimit_startyear =
GETPOST(
'search_datelimit_startyear',
'int');
137 $search_datelimit_endday =
GETPOST(
'search_datelimit_endday',
'int');
138 $search_datelimit_endmonth =
GETPOST(
'search_datelimit_endmonth',
'int');
139 $search_datelimit_endyear =
GETPOST(
'search_datelimit_endyear',
'int');
140 $search_datelimit_start =
dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
141 $search_datelimit_end =
dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
142 $search_categ_cus =
GETPOST(
"search_categ_cus",
'int');
143 $search_product_category =
GETPOST(
'search_product_category',
'int');
144 $search_fac_rec_source_title =
GETPOST(
"search_fac_rec_source_title",
'alpha');
145 $search_btn =
GETPOST(
'button_search',
'alpha');
146 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
148 $option =
GETPOST(
'search_option');
149 if ($option ==
'late') {
150 $search_status =
'1';
152 $filtre =
GETPOST(
'filtre',
'alpha');
154 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
155 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
156 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
158 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
161 $offset = $limit * $page;
162 if (!$sortorder && !empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status ==
'1') {
163 $sortorder = $conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER;
169 $sortfield =
'f.datef';
171 $pageprev = $page - 1;
172 $pagenext = $page + 1;
175 $fieldid = (!empty($ref) ?
'ref' :
'rowid');
176 if (!empty($user->socid)) {
177 $socid = $user->socid;
179 $result =
restrictedArea($user,
'facture', $id,
'',
'',
'fk_soc', $fieldid);
181 $diroutputmassaction = $conf->facture->dir_output.
'/temp/massgeneration/'.$user->id;
190 $hookmanager->initHooks(array($contextpage));
194 $extrafields->fetch_name_optionals_label($object->table_element);
196 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
199 $fieldstosearchall = array(
201 'f.ref_client'=>
'RefCustomer',
202 'f.note_public'=>
'NotePublic',
203 's.nom'=>
"ThirdParty",
204 's.code_client'=>
"CustomerCodeShort",
205 's.name_alias'=>
"AliasNameShort",
208 'pd.description'=>
'Description',
210 if (empty($user->socid)) {
211 $fieldstosearchall[
"f.note_private"] =
"NotePrivate";
214 $checkedtypetiers = 0;
215 $arrayfields = array(
216 'f.ref'=>array(
'label'=>
"Ref",
'checked'=>1,
'position'=>5),
217 'f.ref_client'=>array(
'label'=>
"RefCustomer",
'checked'=>-1,
'position'=>10),
218 'f.type'=>array(
'label'=>
"Type",
'checked'=>0,
'position'=>15),
219 'f.datef'=>array(
'label'=>
"DateInvoice",
'checked'=>1,
'position'=>20),
220 'f.date_valid'=>array(
'label'=>
"DateValidation",
'checked'=>0,
'position'=>22),
221 'f.date_lim_reglement'=>array(
'label'=>
"DateDue",
'checked'=>1,
'position'=>25),
222 'f.date_closing'=>array(
'label'=>
"DateClosing",
'checked'=>0,
'position'=>30),
223 'p.ref'=>array(
'label'=>
"ProjectRef",
'checked'=>1,
'enabled'=>(!
isModEnabled(
'project') ? 0 : 1),
'position'=>40),
224 'p.title'=>array(
'label'=>
"ProjectLabel",
'checked'=>0,
'enabled'=>(!
isModEnabled(
'project') ? 0 : 1),
'position'=>41),
225 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>50),
226 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'checked'=>1,
'position'=>51),
227 's.code_client'=>array(
'label'=>
"CustomerCodeShort",
'checked'=>-1,
'position'=>52),
228 's2.nom'=>array(
'label'=>
'ParentCompany',
'position'=>32,
'checked'=>0),
229 's.town'=>array(
'label'=>
"Town",
'checked'=>-1,
'position'=>55),
230 's.zip'=>array(
'label'=>
"Zip",
'checked'=>1,
'position'=>60),
231 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0,
'position'=>65),
232 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0,
'position'=>70),
233 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers,
'position'=>75),
234 'f.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>1,
'position'=>80),
235 'f.fk_cond_reglement'=>array(
'label'=>
"PaymentConditionsShort",
'checked'=>1,
'position'=>85),
236 'f.module_source'=>array(
'label'=>
"POSModule",
'langs'=>
'cashdesk',
'checked'=>($contextpage ==
'poslist' ? 1 : 0),
'enabled'=>((empty($conf->cashdesk->enabled) && empty($conf->takepos->enabled) && empty($conf->global->INVOICE_SHOW_POS)) ? 0 : 1),
'position'=>90),
237 'f.pos_source'=>array(
'label'=>
"POSTerminal",
'langs'=>
'cashdesk',
'checked'=>($contextpage ==
'poslist' ? 1 : 0),
'enabled'=>((empty($conf->cashdesk->enabled) && empty($conf->takepos->enabled) && empty($conf->global->INVOICE_SHOW_POS)) ? 0 : 1),
'position'=>91),
238 'f.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1,
'position'=>95),
239 'f.total_tva'=>array(
'label'=>
"AmountVAT",
'checked'=>0,
'position'=>100),
240 'f.total_localtax1'=>array(
'label'=>$langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked'=>0,
'enabled'=>($mysoc->localtax1_assuj ==
"1"),
'position'=>110),
241 'f.total_localtax2'=>array(
'label'=>$langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked'=>0,
'enabled'=>($mysoc->localtax2_assuj ==
"1"),
'position'=>120),
242 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0,
'position'=>130),
243 'dynamount_payed'=>array(
'label'=>
"Received",
'checked'=>0,
'position'=>140),
244 'rtp'=>array(
'label'=>
"Rest",
'checked'=>0,
'position'=>150),
245 'f.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>280),
246 'f.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>285),
247 'f.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>290),
248 'f.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>291),
249 'f.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>292),
250 'multicurrency_dynamount_payed'=>array(
'label'=>
'MulticurrencyAlreadyPaid',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>295),
251 'multicurrency_rtp'=>array(
'label'=>
'MulticurrencyRemainderToPay',
'checked'=>0,
'enabled'=>(!
isModEnabled(
'multicurrency') ? 0 : 1),
'position'=>296),
252 '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)),
253 'total_margin' => array(
'label' =>
'Margin',
'checked' => 0,
'position' => 301,
'enabled' => (!
isModEnabled(
'margin') || empty($user->rights->margins->liretous) ? 0 : 1)),
254 '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)),
255 '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)),
256 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>500),
257 'f.tms' =>array(
'type'=>
'timestamp',
'label'=>
'DateModificationShort',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>502),
258 'u.login'=>array(
'label'=>
"UserAuthor",
'checked'=>1,
'position'=>504),
259 'sale_representative'=>array(
'label'=>
"SaleRepresentativesOfThirdParty",
'checked'=>0,
'position'=>506),
264 'f.note_public'=>array(
'label'=>
'NotePublic',
'checked'=>0,
'position'=>520,
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES'))),
265 'f.note_private'=>array(
'label'=>
'NotePrivate',
'checked'=>0,
'position'=>521,
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES'))),
266 'f.fk_fac_rec_source'=>array(
'label'=>
'GeneratedFromTemplate',
'checked'=>0,
'position'=>530,
'enabled'=>
'1'),
267 'f.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000),
270 if (
getDolGlobalString(
"INVOICE_USE_SITUATION") && !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) {
271 $arrayfields[
'f.retained_warranty'] = array(
'label'=>$langs->trans(
"RetainedWarranty"),
'checked'=>0,
'position'=>86);
274 foreach ($object->fields as $key => $val) {
277 if (!empty($val[
'visible'])) {
278 $visible = (int)
dol_eval($val[
'visible'], 1, 1,
'1');
280 if (array_key_exists($key, $arrayfields)) { $newkey = $key; } elseif (array_key_exists(
'f.'.$key, $arrayfields)) { $newkey =
'f.'.$key; } elseif (array_key_exists(
'f.'.$key, $arrayfields)) { $newkey =
'f.'.$key; } elseif (array_key_exists(
's.'.$key, $arrayfields)) { $newkey =
's.'.$key; }
282 $arrayfields[$newkey] = array(
283 'label'=>$val[
'label'],
284 'checked'=>(($visible < 0) ? 0 : 1),
285 'enabled'=>($visible != 3 &&
dol_eval($val[
'enabled'], 1, 1,
'1')),
286 'position'=>$val[
'position'],
287 'help' => empty($val[
'help']) ?
'' : $val[
'help'],
293 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
303 if (
GETPOST(
'cancel',
'alpha')) {
307 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
311 $parameters = array(
'socid'=>$socid,
'arrayfields'=>&$arrayfields);
312 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
317 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
320 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha')) {
323 $search_product_category =
'';
325 $search_refcustomer =
'';
327 $search_project_ref =
'';
328 $search_project =
'';
329 $search_company =
'';
330 $search_company_alias =
'';
331 $search_parent_name =
'';
332 $search_montant_ht =
'';
333 $search_montant_vat =
'';
334 $search_montant_localtax1 =
'';
335 $search_montant_localtax2 =
'';
336 $search_montant_ttc =
'';
338 $search_multicurrency_code =
'';
339 $search_multicurrency_tx =
'';
340 $search_multicurrency_montant_ht =
'';
341 $search_multicurrency_montant_vat =
'';
342 $search_multicurrency_montant_ttc =
'';
344 $search_paymentmode =
'';
345 $search_paymentterms =
'';
346 $search_module_source =
'';
347 $search_pos_source =
'';
351 $search_country =
'';
352 $search_type_thirdparty =
'';
353 $search_date_startday =
'';
354 $search_date_startmonth =
'';
355 $search_date_startyear =
'';
356 $search_date_endday =
'';
357 $search_date_endmonth =
'';
358 $search_date_endyear =
'';
359 $search_date_start =
'';
360 $search_date_end =
'';
361 $search_date_valid_startday =
'';
362 $search_date_valid_startmonth =
'';
363 $search_date_valid_startyear =
'';
364 $search_date_valid_endday =
'';
365 $search_date_valid_endmonth =
'';
366 $search_date_valid_endyear =
'';
367 $search_date_valid_start =
'';
368 $search_date_valid_end =
'';
369 $search_datelimit_startday =
'';
370 $search_datelimit_startmonth =
'';
371 $search_datelimit_startyear =
'';
372 $search_datelimit_endday =
'';
373 $search_datelimit_endmonth =
'';
374 $search_datelimit_endyear =
'';
375 $search_datelimit_start =
'';
376 $search_datelimit_end =
'';
377 $search_fac_rec_source_title =
'';
379 $search_array_options = array();
380 $search_categ_cus = 0;
385 if (empty($reshook)) {
386 $objectclass =
'Facture';
387 $objectlabel =
'Invoices';
388 $permissiontoread = $user->hasRight(
"facture",
"lire");
389 $permissiontoadd = $user->hasRight(
"facture",
"creer");
390 $permissiontodelete = $user->hasRight(
"facture",
"supprimer");
391 $uploaddir = $conf->facture->dir_output;
392 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
395 if ($action ==
'makepayment_confirm' && $user->hasRight(
'facture',
'paiement')) {
396 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
397 $arrayofselected = is_array($toselect) ? $toselect : array();
398 if (!empty($arrayofselected)) {
399 $bankid =
GETPOST(
'bankid',
'int');
400 $paiementid =
GETPOST(
'paiementid',
'int');
402 if (empty($paiementdate)) {
403 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
405 $action =
'makepayment';
409 foreach ($arrayofselected as $toselectid) {
412 $result = $facture->fetch($toselectid);
421 $paiementAmount = $facture->getSommePaiement();
422 $totalcreditnotes = $facture->getSumCreditNotesUsed();
423 $totaldeposits = $facture->getSumDepositsUsed();
424 $totalpay = $paiementAmount + $totalcreditnotes + $totaldeposits;
425 $remaintopay =
price2num($facture->total_ttc - $totalpay);
426 if ($remaintopay != 0) {
427 $resultBank = $facture->setBankAccount($bankid);
428 if ($resultBank < 0) {
433 $paiement->datepaye = $paiementdate;
434 $paiement->amounts[$facture->id] = $remaintopay;
435 $paiement->multicurrency_amounts[$facture->id] = $remaintopay;
436 $paiement->paiementid = $paiementid;
437 $paiement_id = $paiement->create($user, 1, $facture->thirdparty);
438 if ($paiement_id < 0) {
439 $langs->load(
"errors");
440 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
443 $result = $paiement->addPaymentToBank($user,
'payment',
'', $bankid,
'',
'');
445 $langs->load(
"errors");
446 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
452 setEventMessage($langs->trans(
'NoPaymentAvailable', $facture->ref),
'warnings');
456 setEventMessage($langs->trans(
'BulkPaymentNotPossibleForInvoice', $facture->ref),
'warnings');
461 if (empty($errorpayment)) {
462 setEventMessage($langs->trans(
'PaymentRegisteredAndInvoiceSetToPaid', $facture->ref));
470 } elseif ($massaction ==
'withdrawrequest') {
471 $langs->load(
"withdrawals");
473 if (!$user->rights->prelevement->bons->creer) {
480 $arrayofselected = is_array($toselect) ? $toselect : array();
481 $listofbills = array();
482 foreach ($arrayofselected as $toselectid) {
484 $result = $objecttmp->fetch($toselectid);
486 $totalpaid = $objecttmp->getSommePaiement();
487 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
488 $totaldeposits = $objecttmp->getSumDepositsUsed();
489 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
492 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
493 } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
495 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
496 } elseif ($objecttmp->resteapayer < 0) {
498 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
501 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
502 $rsql .=
" , pfd.date_traite as date_traite";
503 $rsql .=
" , pfd.amount";
504 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
505 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
506 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
507 $rsql .=
" WHERE fk_facture = ".((int) $objecttmp->id);
508 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
509 $rsql .=
" AND pfd.traite = 0";
510 $rsql .=
" ORDER BY pfd.date_demande DESC";
512 $result_sql = $db->query($rsql);
514 $numprlv = $db->num_rows($result_sql);
519 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
520 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'PRE') {
522 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"BadPaymentMethod"), $objecttmp->errors,
'errors');
524 $listofbills[] = $objecttmp;
530 if (!empty($listofbills)) {
531 $nbwithdrawrequestok = 0;
532 foreach ($listofbills as $aBill) {
534 $result = $aBill->demande_prelevement($user, $aBill->resteapayer,
'direct-debit',
'facture');
537 $nbwithdrawrequestok++;
543 if ($nbwithdrawrequestok > 0) {
544 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
563 $bankaccountstatic =
new Account($db);
564 $facturestatic =
new Facture($db);
566 $companystatic =
new Societe($db);
567 $companyparent =
new Societe($db);
568 $company_url_list = array();
570 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
571 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
574 if ($sall || $search_user > 0) {
575 $sql =
'SELECT DISTINCT';
577 $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,';
578 $sql .=
' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
579 $sql .=
' f.fk_user_author,';
580 $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,';
581 $sql .=
' f.datef, f.date_valid, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,';
582 $sql .=
' f.paye as paye, f.fk_statut, f.close_code,';
583 $sql .=
' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,';
584 $sql .=
' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
585 $sql .=
' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,';
586 $sql .=
" s.parent as fk_parent,";
587 $sql .=
" s2.nom as name2,";
588 $sql .=
' typent.code as typent_code,';
589 $sql .=
' state.code_departement as state_code, state.nom as state_name,';
590 $sql .=
' country.code as country_code,';
591 $sql .=
' f.fk_fac_rec_source,';
592 $sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
593 $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';
603 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
604 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
605 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
609 $parameters = array();
610 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
611 $sql .= $hookmanager->resPrint;
612 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
617 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
618 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s2 ON s2.rowid = s.parent";
619 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
620 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
621 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
622 $sql .=
', '.MAIN_DB_PREFIX.
'facture as f';
623 if ($sortfield ==
"f.datef") {
624 $sql .= $db->hintindex(
'idx_facture_datef');
626 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
627 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
637 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facturedet as pd ON f.rowid=pd.fk_facture';
639 if (!empty($search_fac_rec_source_title)) {
640 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_rec as facrec ON f.fk_fac_rec_source=facrec.rowid';
642 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
643 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
645 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
646 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
648 if ($search_user > 0) {
649 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
650 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
653 $parameters = array();
654 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
655 $sql .= $hookmanager->resPrint;
657 $sql .=
' WHERE f.fk_soc = s.rowid';
658 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
659 if (empty($user->rights->societe->client->voir) && !$socid) {
660 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
663 $sql .=
' AND s.rowid = '.((int) $socid);
667 $sql .=
' AND f.fk_user_author IS NULL';
669 $sql .=
' AND f.fk_user_author = '.((int) $userid);
675 if ($search_refcustomer) {
678 if ($search_type !=
'' && $search_type !=
'-1') {
679 $sql .=
" AND f.type IN (".$db->sanitize($db->escape($search_type)).
")";
681 if ($search_project_ref) {
684 if ($search_project) {
687 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
690 if ($search_company) {
693 if ($search_company_alias) {
697 if ($search_parent_name) {
700 if ($search_company_code_client) {
712 if (strlen(trim($search_country))) {
714 $country_code_in_EEC = $country_code_in_EEC_without_me =
'';
715 foreach ($arrayofcode as $key => $value) {
716 $country_code_in_EEC .= ($country_code_in_EEC ?
"," :
"").
"'".$value.
"'";
717 if ($value != $mysoc->country_code) {
718 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ?
"," :
"").
"'".$value.
"'";
721 if ($search_country ==
'special_allnotme') {
722 $sql .=
" AND country.code <> '".$db->escape($mysoc->country_code).
"'";
723 } elseif ($search_country ==
'special_eec') {
724 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC, 1).
")";
725 } elseif ($search_country ==
'special_eecnotme') {
726 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).
")";
727 } elseif ($search_country ==
'special_noteec') {
728 $sql .=
" AND country.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).
")";
733 if ($search_type_thirdparty !=
'' && $search_type_thirdparty !=
'-1') {
734 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
736 if ($search_montant_ht !=
'') {
739 if ($search_montant_vat !=
'') {
742 if ($search_montant_localtax1 !=
'') {
745 if ($search_montant_localtax2 !=
'') {
748 if ($search_montant_ttc !=
'') {
751 if ($search_multicurrency_code !=
'') {
752 $sql .=
" AND f.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
754 if ($search_multicurrency_tx !=
'') {
757 if ($search_multicurrency_montant_ht !=
'') {
758 $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
760 if ($search_multicurrency_montant_vat !=
'') {
761 $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
763 if ($search_multicurrency_montant_ttc !=
'') {
764 $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
769 if ($search_status !=
'-1' && $search_status !=
'') {
770 if (is_numeric($search_status) && $search_status >= 0) {
771 if ($search_status ==
'0') {
772 $sql .=
" AND f.fk_statut = 0";
774 if ($search_status ==
'1') {
775 $sql .=
" AND f.fk_statut = 1";
777 if ($search_status ==
'2') {
778 $sql .=
" AND f.fk_statut = 2";
780 if ($search_status ==
'3') {
781 $sql .=
" AND f.fk_statut = 3";
784 $sql .=
" AND f.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
788 if ($search_paymentmode > 0) {
789 $sql .=
" AND f.fk_mode_reglement = ".((int) $search_paymentmode);
791 if ($search_paymentterms > 0) {
792 $sql .=
" AND f.fk_cond_reglement = ".((int) $search_paymentterms);
794 if ($search_module_source) {
797 if ($search_pos_source) {
800 if ($search_date_start) {
801 $sql .=
" AND f.datef >= '".$db->idate($search_date_start).
"'";
803 if ($search_date_end) {
804 $sql .=
" AND f.datef <= '".$db->idate($search_date_end).
"'";
806 if ($search_date_valid_start) {
807 $sql .=
" AND f.date_valid >= '".$db->idate($search_date_valid_start).
"'";
809 if ($search_date_valid_end) {
810 $sql .=
" AND f.date_valid <= '".$db->idate($search_date_valid_end).
"'";
812 if ($search_datelimit_start) {
813 $sql .=
" AND f.date_lim_reglement >= '".$db->idate($search_datelimit_start).
"'";
815 if ($search_datelimit_end) {
816 $sql .=
" AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end).
"'";
818 if ($option ==
'late') {
819 $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() - $conf->facture->client->warning_delay).
"'";
821 if ($search_sale > 0) {
822 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
824 if ($search_user > 0) {
825 $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);
827 if (!empty($search_fac_rec_source_title)) {
831 $searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
832 $searchCategoryProductOperator = 0;
833 if (!empty($searchCategoryProductList)) {
834 $searchCategoryProductSqlList = array();
835 $listofcategoryid =
'';
836 foreach ($searchCategoryProductList as $searchCategoryProduct) {
837 if (intval($searchCategoryProduct) == -2) {
838 $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)";
839 } elseif (intval($searchCategoryProduct) > 0) {
840 if ($searchCategoryProductOperator == 0) {
841 $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).
")";
843 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
847 if ($listofcategoryid) {
848 $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).
"))";
850 if ($searchCategoryProductOperator == 1) {
851 if (!empty($searchCategoryProductSqlList)) {
852 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
855 if (!empty($searchCategoryProductSqlList)) {
856 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
860 $searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array();
861 $searchCategoryCustomerOperator = 0;
863 if (!empty($searchCategoryCustomerList)) {
864 $searchCategoryCustomerSqlList = array();
865 $listofcategoryid =
'';
866 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
867 if (intval($searchCategoryCustomer) == -2) {
868 $searchCategoryCustomerSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
869 } elseif (intval($searchCategoryCustomer) > 0) {
870 if ($searchCategoryCustomerOperator == 0) {
871 $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).
")";
873 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryCustomer);
877 if ($listofcategoryid) {
878 $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).
"))";
880 if ($searchCategoryCustomerOperator == 1) {
881 if (!empty($searchCategoryCustomerSqlList)) {
882 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
885 if (!empty($searchCategoryCustomerSqlList)) {
886 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
891 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
893 $parameters = array();
894 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
895 $sql .= $hookmanager->resPrint;
934 $parameters = array();
935 $reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
936 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
939 $nbtotalofrecords =
'';
942 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
943 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
944 $resql = $db->query($sqlforcount);
946 $objforcount = $db->fetch_object($resql);
947 $nbtotalofrecords = $objforcount->nbtotalofrecords;
952 if (($page * $limit) > $nbtotalofrecords) {
960 $sql .= $db->order($sortfield, $sortorder);
962 $sql .= $db->plimit($limit + 1, $offset);
965 $resql = $db->query(
$sql);
968 $num = $db->num_rows($resql);
970 $arrayofselected = is_array($toselect) ? $toselect : array();
972 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
973 $obj = $db->fetch_object($resql);
976 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$id);
983 llxHeader(
'', $title,
'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
988 if (empty($search_company)) {
989 $search_company = $soc->name;
993 $param =
'&socid='.urlencode($socid);
995 $param .=
'&mode='.urlencode($mode);
997 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
998 $param .=
'&contextpage='.urlencode($contextpage);
1000 if ($limit > 0 && $limit != $conf->liste_limit) {
1001 $param .=
'&limit='.((int) $limit);
1004 $param .=
'&sall='.urlencode($sall);
1006 if ($search_date_startday) {
1007 $param .=
'&search_date_startday='.urlencode($search_date_startday);
1009 if ($search_date_startmonth) {
1010 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
1012 if ($search_date_startyear) {
1013 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
1015 if ($search_date_endday) {
1016 $param .=
'&search_date_endday='.urlencode($search_date_endday);
1018 if ($search_date_endmonth) {
1019 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
1021 if ($search_date_endyear) {
1022 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
1024 if ($search_date_valid_startday) {
1025 $param .=
'&search_date_valid_startday='.urlencode($search_date_valid_startday);
1027 if ($search_date_valid_startmonth) {
1028 $param .=
'&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
1030 if ($search_date_valid_startyear) {
1031 $param .=
'&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
1033 if ($search_date_valid_endday) {
1034 $param .=
'&search_date_valid_endday='.urlencode($search_date_valid_endday);
1036 if ($search_date_valid_endmonth) {
1037 $param .=
'&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
1039 if ($search_date_valid_endyear) {
1040 $param .=
'&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
1042 if ($search_datelimit_startday) {
1043 $param .=
'&search_datelimit_startday='.urlencode($search_datelimit_startday);
1045 if ($search_datelimit_startmonth) {
1046 $param .=
'&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth);
1048 if ($search_datelimit_startyear) {
1049 $param .=
'&search_datelimit_startyear='.urlencode($search_datelimit_startyear);
1051 if ($search_datelimit_endday) {
1052 $param .=
'&search_datelimit_endday='.urlencode($search_datelimit_endday);
1054 if ($search_datelimit_endmonth) {
1055 $param .=
'&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth);
1057 if ($search_datelimit_endyear) {
1058 $param .=
'&search_datelimit_endyear='.urlencode($search_datelimit_endyear);
1061 $param .=
'&search_ref='.urlencode($search_ref);
1063 if ($search_refcustomer) {
1064 $param .=
'&search_refcustomer='.urlencode($search_refcustomer);
1066 if ($search_project_ref) {
1067 $param .=
'&search_project_ref='.urlencode($search_project_ref);
1069 if ($search_project) {
1070 $param .=
'&search_project='.urlencode($search_project);
1072 if ($search_type !=
'') {
1073 $param .=
'&search_type='.urlencode($search_type);
1075 if ($search_company) {
1076 $param .=
'&search_company='.urlencode($search_company);
1078 if ($search_company_alias) {
1079 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1081 if ($search_parent_name !=
'') {
1082 $param .=
'&search_parent_name='.urlencode($search_parent_name);
1085 $param .=
'&search_town='.urlencode($search_town);
1088 $param .=
'&search_zip='.urlencode($search_zip);
1090 if ($search_country) {
1091 $param .=
"&search_country=".urlencode($search_country);
1093 if ($search_type_thirdparty !=
'') {
1094 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1096 if ($search_sale > 0) {
1097 $param .=
'&search_sale='.urlencode($search_sale);
1099 if ($search_user > 0) {
1100 $param .=
'&search_user='.urlencode($search_user);
1102 if ($search_login) {
1103 $param .=
'&search_login='.urlencode($search_login);
1105 if ($search_product_category > 0) {
1106 $param .=
'&search_product_category='.urlencode($search_product_category);
1108 if ($search_montant_ht !=
'') {
1109 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
1111 if ($search_montant_vat !=
'') {
1112 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
1114 if ($search_montant_localtax1 !=
'') {
1115 $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
1117 if ($search_montant_localtax2 !=
'') {
1118 $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
1120 if ($search_montant_ttc !=
'') {
1121 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
1123 if ($search_multicurrency_code !=
'') {
1124 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1126 if ($search_multicurrency_tx !=
'') {
1127 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1129 if ($search_multicurrency_montant_ht !=
'') {
1130 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1132 if ($search_multicurrency_montant_vat !=
'') {
1133 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1135 if ($search_multicurrency_montant_ttc !=
'') {
1136 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1138 if ($search_status !=
'') {
1139 $param .=
'&search_status='.urlencode($search_status);
1141 if ($search_paymentmode > 0) {
1142 $param .=
'&search_paymentmode='.urlencode($search_paymentmode);
1144 if ($search_paymentterms > 0) {
1145 $param .=
'&search_paymentterms='.urlencode($search_paymentterms);
1147 if ($search_module_source) {
1148 $param .=
'&search_module_source='.urlencode($search_module_source);
1150 if ($search_pos_source) {
1151 $param .=
'&search_pos_source='.urlencode($search_pos_source);
1154 $param .=
'&show_files='.urlencode($show_files);
1157 $param .=
"&search_option=".urlencode($option);
1159 if ($optioncss !=
'') {
1160 $param .=
'&optioncss='.urlencode($optioncss);
1162 if ($search_categ_cus > 0) {
1163 $param .=
'&search_categ_cus='.urlencode($search_categ_cus);
1165 if (!empty($search_fac_rec_source_title)) {
1166 $param .=
'&search_fac_rec_source_title='.urlencode($search_fac_rec_source_title);
1170 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1172 $parameters = array();
1173 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1174 $param .= $hookmanager->resPrint;
1176 $arrayofmassactions = array(
1177 'validate'=>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
1178 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1179 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1180 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1183 if ($user->hasRight(
'facture',
'paiement')) {
1184 $arrayofmassactions[
'makepayment'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakePaymentAndClassifyPayed");
1186 if (
isModEnabled(
'prelevement') && !empty($user->rights->prelevement->bons->creer)) {
1187 $langs->load(
"withdrawals");
1188 $arrayofmassactions[
'withdrawrequest'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeWithdrawRequest");
1190 if (!empty($user->rights->facture->supprimer)) {
1191 if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) {
1192 $arrayofmassactions[
'predeletedraft'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Deletedraft");
1193 } elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) {
1194 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1197 if (in_array($massaction, array(
'presend',
'predelete',
'makepayment'))) {
1198 $arrayofmassactions = array();
1200 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1203 $newcardbutton =
'';
1204 if ($contextpage !=
'poslist') {
1205 $url = DOL_URL_ROOT.
'/compta/facture/card.php?action=create';
1206 if (!empty($socid)) {
1207 $url .=
'&socid='.$socid;
1209 $newcardbutton =
'';
1210 $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'));
1211 $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'));
1212 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', $user->hasRight(
"facture",
"creer"));
1216 print
'<form method="POST" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
1217 if ($optioncss !=
'') {
1218 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1220 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1221 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1222 if (!in_array($massaction, array(
'makepayment'))) {
1223 print
'<input type="hidden" name="action" value="list">';
1225 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1226 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1227 print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
1228 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1229 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1230 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1232 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);
1234 $topicmail =
"SendBillRef";
1235 $modelmail =
"facture_send";
1236 $objecttmp =
new Facture($db);
1237 $trackid =
'inv'.$object->id;
1238 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1240 if ($massaction ==
'makepayment') {
1242 $formquestion = array(
1246 array(
'type' =>
'date',
'name' =>
'datepaiment',
'label' => $langs->trans(
"Date"),
'datenow' => 1),
1247 array(
'type' =>
'other',
'name' =>
'paiementid',
'label' => $langs->trans(
"PaymentMode"),
'value' =>
$form->select_types_paiements(
GETPOST(
'search_paymentmode'),
'paiementid',
'', 0, 0, 1, 0, 1,
'', 1)),
1248 array(
'type' =>
'other',
'name' =>
'bankid',
'label' => $langs->trans(
"BankAccount"),
'value'=>
$form->select_comptes(
'',
'bankid', 0,
'', 0,
'', 0,
'', 1)),
1251 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
'MakePaymentAndClassifyPayed'), $langs->trans(
'EnterPaymentReceivedFromCustomer'),
'makepayment_confirm', $formquestion, 1, 0, 200, 500, 1);
1256 foreach ($fieldstosearchall as $key => $val) {
1257 $fieldstosearchall[$key] = $langs->trans($val);
1259 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
1263 $moreforfilter =
'';
1264 if ($user->hasRight(
"user",
"user",
"lire")) {
1265 $langs->load(
"commercial");
1266 $moreforfilter .=
'<div class="divsearchfield">';
1267 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1268 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250');
1269 $moreforfilter .=
'</div>';
1272 if ($user->hasRight(
"user",
"user",
"lire")) {
1273 $moreforfilter .=
'<div class="divsearchfield">';
1274 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1275 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250');
1276 $moreforfilter .=
'</div>';
1279 if (
isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"lire") && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
1280 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1281 $moreforfilter .=
'<div class="divsearchfield">';
1282 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1283 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1284 $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);
1285 $moreforfilter .=
'</div>';
1287 if (
isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"lire")) {
1288 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1289 $moreforfilter .=
'<div class="divsearchfield">';
1290 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
1291 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle);
1292 $moreforfilter .=
'</div>';
1294 $parameters = array();
1295 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1296 if (empty($reshook)) {
1297 $moreforfilter .= $hookmanager->resPrint;
1299 $moreforfilter = $hookmanager->resPrint;
1302 if ($moreforfilter) {
1303 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1304 print $moreforfilter;
1308 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1309 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
1312 if ($massactionbutton && $contextpage !=
'poslist') {
1313 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1316 print
'<div class="div-table-responsive">';
1317 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1321 print
'<tr class="liste_titre_filter">';
1325 print
'<td class="liste_titre center actioncolumn">';
1326 $searchpicto =
$form->showFilterButtons(
'left');
1331 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
1332 print
'<td class="liste_titre">';
1336 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1337 print
'<td class="liste_titre" align="left">';
1338 print
'<input class="flat maxwidth50imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1342 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1343 print
'<td class="liste_titre">';
1344 print
'<input class="flat maxwidth50imp" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).
'">';
1348 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1349 print
'<td class="liste_titre maxwidthonsmartphone">';
1356 if (!empty($conf->global->INVOICE_USE_SITUATION)) {
1360 print
$form->selectarray(
'search_type', $listtype, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100');
1364 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1365 print
'<td class="liste_titre center">';
1366 print
'<div class="nowrap">';
1367 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1369 print
'<div class="nowrap">';
1370 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1375 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
1376 print
'<td class="liste_titre center">';
1377 print
'<div class="nowrap">';
1378 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'));
1380 print
'<div class="nowrap">';
1381 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'));
1386 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1387 print
'<td class="liste_titre center">';
1388 print
'<div class="nowrap">';
1395 print
$form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"Before"));
1396 print
'<br><input type="checkbox" name="search_option" value="late"'.($option ==
'late' ?
' checked' :
'').
'> '.$langs->trans(
"Alert");
1401 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1402 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1405 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1406 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1409 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1410 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'"'.($socid > 0 ?
" disabled" :
"").
'></td>';
1413 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1414 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1417 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1418 print
'<td class="liste_titre">';
1419 print
'<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).
'">';
1423 if (!empty($arrayfields[
's.code_client'][
'checked'])) {
1424 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>';
1427 if (!empty($arrayfields[
's.town'][
'checked'])) {
1428 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1431 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1432 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1435 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1436 print
'<td class="liste_titre">';
1437 print
'<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1441 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1442 print
'<td class="liste_titre" align="center">';
1443 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth150imp maxwidth150',
'code2', 1, 0, 1,
null, 1);
1447 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1448 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1449 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);
1453 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1454 print
'<td class="liste_titre">';
1455 print
$form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 0, 1,
'minwidth100 maxwidth100', 1);
1459 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1460 print
'<td class="liste_titre">';
1461 print
$form->getSelectConditionsPaiements($search_paymentterms,
'search_paymentterms', -1, 1, 1,
'minwidth100 maxwidth100');
1465 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
1466 print
'<td class="liste_titre">';
1467 print
'<input class="flat maxwidth75" type="text" name="search_module_source" value="'.dol_escape_htmltag($search_module_source).
'">';
1471 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
1472 print
'<td class="liste_titre">';
1473 print
'<input class="flat maxwidth50" type="text" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).
'">';
1476 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1478 print
'<td class="liste_titre right">';
1479 print
'<input class="flat" type="text" size="4" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
1482 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
1484 print
'<td class="liste_titre right">';
1485 print
'<input class="flat" type="text" size="4" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
1488 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1490 print
'<td class="liste_titre right">';
1491 print
'<input class="flat" type="text" size="4" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).
'">';
1494 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1496 print
'<td class="liste_titre right">';
1497 print
'<input class="flat" type="text" size="4" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).
'">';
1500 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1502 print
'<td class="liste_titre right">';
1503 print
'<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
1506 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1508 print
'<td class="liste_titre" align="center">';
1509 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1512 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1513 print
'<td class="liste_titre"></td>';
1515 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
1516 print
'<td class="liste_titre" align="right">';
1519 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1520 print
'<td class="liste_titre right">';
1523 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1524 print
'<td class="liste_titre right">';
1527 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1529 print
'<td class="liste_titre">';
1530 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1533 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1535 print
'<td class="liste_titre">';
1536 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1539 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1541 print
'<td class="liste_titre right">';
1542 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1545 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1547 print
'<td class="liste_titre right">';
1548 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1551 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1553 print
'<td class="liste_titre right">';
1554 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1557 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1558 print
'<td class="liste_titre">';
1561 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1562 print
'<td class="liste_titre right">';
1565 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1566 print
'<td class="liste_titre right">';
1569 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1570 print
'<td class="liste_titre right">';
1573 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1574 print
'<td class="liste_titre right">';
1577 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1578 print
'<td class="liste_titre right">';
1583 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1586 $parameters = array(
'arrayfields'=>$arrayfields);
1587 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1588 print $hookmanager->resPrint;
1590 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1591 print
'<td class="liste_titre">';
1595 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1596 print
'<td class="liste_titre">';
1600 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
1601 print
'<td class="liste_titre">';
1604 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1606 print
'<td class="liste_titre">';
1609 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1611 print
'<td class="liste_titre">';
1614 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
1616 print
'<td class="liste_titre maxwidthonsmartphone right">';
1617 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).
'">';
1621 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1622 print
'<td class="liste_titre right parentonrightofpage">';
1623 $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"));
1624 print
$form->selectarray(
'search_status', $liststatus, $search_status, 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage', 1);
1628 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1629 print
'<td class="liste_titre center actioncolumn">';
1630 $searchpicto =
$form->showFilterButtons();
1636 print
'<tr class="liste_titre">';
1638 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1639 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
1642 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
1645 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1646 print_liste_field_titre($arrayfields[
'f.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'f.ref',
'', $param,
'', $sortfield, $sortorder);
1648 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1649 print_liste_field_titre($arrayfields[
'f.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'f.ref_client',
'', $param,
'', $sortfield, $sortorder);
1651 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1652 print_liste_field_titre($arrayfields[
'f.type'][
'label'], $_SERVER[
"PHP_SELF"],
'f.type',
'', $param,
'', $sortfield, $sortorder);
1654 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1655 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
'PHP_SELF'],
'f.datef',
'', $param,
'align="center"', $sortfield, $sortorder);
1657 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
1658 print_liste_field_titre($arrayfields[
'f.date_valid'][
'label'], $_SERVER[
'PHP_SELF'],
'f.date_valid',
'', $param,
'align="center"', $sortfield, $sortorder);
1660 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1661 print_liste_field_titre($arrayfields[
'f.date_lim_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_lim_reglement",
'', $param,
'align="center"', $sortfield, $sortorder);
1663 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1664 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
'PHP_SELF'],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
1666 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1667 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
'PHP_SELF'],
"p.title",
'', $param,
'', $sortfield, $sortorder);
1669 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1670 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1672 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1673 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1675 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1676 print_liste_field_titre($arrayfields[
's2.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's2.nom',
'', $param,
'', $sortfield, $sortorder);
1678 if (!empty($arrayfields[
's.code_client'][
'checked'])) {
1679 print_liste_field_titre($arrayfields[
's.code_client'][
'label'], $_SERVER[
'PHP_SELF'],
's.code_client',
'', $param,
'', $sortfield, $sortorder);
1681 if (!empty($arrayfields[
's.town'][
'checked'])) {
1682 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1684 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1685 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1687 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1688 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1690 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1691 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'align="center"', $sortfield, $sortorder);
1693 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1694 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'align="center"', $sortfield, $sortorder);
1696 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1697 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_mode_reglement",
"", $param,
"", $sortfield, $sortorder);
1699 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1700 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_cond_reglement",
"", $param,
"", $sortfield, $sortorder);
1702 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
1703 print_liste_field_titre($arrayfields[
'f.module_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.module_source",
"", $param,
"", $sortfield, $sortorder);
1705 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
1706 print_liste_field_titre($arrayfields[
'f.pos_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.pos_source",
"", $param,
"", $sortfield, $sortorder);
1708 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1709 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1711 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
1712 print_liste_field_titre($arrayfields[
'f.total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1714 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1715 print_liste_field_titre($arrayfields[
'f.total_localtax1'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax1',
'', $param,
'class="right"', $sortfield, $sortorder);
1717 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1718 print_liste_field_titre($arrayfields[
'f.total_localtax2'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax2',
'', $param,
'class="right"', $sortfield, $sortorder);
1720 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1721 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1723 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1724 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1726 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1727 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
1729 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
1730 print_liste_field_titre($arrayfields[
'f.retained_warranty'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'align="right"', $sortfield, $sortorder);
1732 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1733 print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1735 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1736 print_liste_field_titre($arrayfields[
'rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1738 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1739 print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1741 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1742 print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1744 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1745 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1747 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1748 print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1750 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1751 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1753 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1754 print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1756 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1757 print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1759 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1760 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1762 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1763 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1765 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1766 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1768 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1769 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1772 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1774 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1775 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1776 print $hookmanager->resPrint;
1777 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1778 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1780 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1781 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1783 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
1784 print_liste_field_titre($arrayfields[
'f.date_closing'][
'label'], $_SERVER[
"PHP_SELF"],
"f.date_closing",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1786 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1787 print_liste_field_titre($arrayfields[
'f.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_public",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1789 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1790 print_liste_field_titre($arrayfields[
'f.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_private",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1792 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
1793 print_liste_field_titre($arrayfields[
'f.fk_fac_rec_source'][
'label'], $_SERVER[
"PHP_SELF"],
"facrec.titre",
"", $param,
'', $sortfield, $sortorder);
1795 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1796 print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_statut,f.paye,f.type",
"", $param,
'class="right"', $sortfield, $sortorder);
1798 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1799 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
1804 $projectstatic =
new Project($db);
1806 $userstatic =
new User($db);
1810 $typenArray = $formcompany->typent_array(1);
1811 $totalarray = array();
1812 $totalarray[
'nbfield'] = 0;
1813 $totalarray[
'val'] = array();
1814 $totalarray[
'val'][
'f.total_tva'] = 0;
1815 $totalarray[
'val'][
'f.total_ht'] = 0;
1816 $totalarray[
'val'][
'f.total_ttc'] = 0;
1818 $with_margin_info =
false;
1820 !empty($arrayfields[
'total_pa'][
'checked'])
1821 || !empty($arrayfields[
'total_margin'][
'checked'])
1822 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
1823 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
1826 $with_margin_info =
true;
1831 $savnbfield = $totalarray[
'nbfield'];
1832 $totalarray[
'nbfield'] = 0;
1833 $imaxinloop = ($limit ? min($num, $limit) : $num);
1834 while ($i < $imaxinloop) {
1835 $obj = $db->fetch_object($resql);
1837 $datelimit = $db->jdate($obj->datelimite);
1839 $facturestatic->id = $obj->id;
1840 $facturestatic->ref = $obj->ref;
1841 $facturestatic->ref_client = $obj->ref_client;
1842 $facturestatic->type = $obj->type;
1843 $facturestatic->total_ht = $obj->total_ht;
1844 $facturestatic->total_tva = $obj->total_tva;
1845 $facturestatic->total_ttc = $obj->total_ttc;
1846 $facturestatic->multicurrency_code = $obj->multicurrency_code;
1847 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1848 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1849 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1850 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1851 $facturestatic->statut = $obj->fk_statut;
1852 $facturestatic->status = $obj->fk_statut;
1853 $facturestatic->close_code = $obj->close_code;
1854 $facturestatic->total_ttc = $obj->total_ttc;
1855 $facturestatic->paye = $obj->paye;
1856 $facturestatic->socid = $obj->fk_soc;
1858 $facturestatic->date = $db->jdate($obj->datef);
1859 $facturestatic->date_validation = $db->jdate($obj->date_valid);
1860 $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
1862 $facturestatic->note_public = $obj->note_public;
1863 $facturestatic->note_private = $obj->note_private;
1865 if (!empty($conf->global->INVOICE_USE_SITUATION) && !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) {
1866 $facturestatic->retained_warranty = $obj->retained_warranty;
1867 $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit;
1868 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
1869 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
1870 $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref;
1871 $facturestatic->situation_counter = $obj->situation_counter;
1874 $companystatic->id = $obj->socid;
1875 $companystatic->name = $obj->name;
1876 $companystatic->name_alias = $obj->alias;
1877 $companystatic->client = $obj->client;
1878 $companystatic->fournisseur = $obj->fournisseur;
1879 $companystatic->code_client = $obj->code_client;
1880 $companystatic->code_compta_client = $obj->code_compta_client;
1881 $companystatic->code_fournisseur = $obj->code_fournisseur;
1882 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1883 $companystatic->email = $obj->email;
1884 $companystatic->phone = $obj->phone;
1885 $companystatic->fax = $obj->fax;
1886 $companystatic->address = $obj->address;
1887 $companystatic->zip = $obj->zip;
1888 $companystatic->town = $obj->town;
1889 $companystatic->country_code = $obj->country_code;
1891 $projectstatic->id = $obj->project_id;
1892 $projectstatic->ref = $obj->project_ref;
1893 $projectstatic->title = $obj->project_label;
1895 $paiement = $facturestatic->getSommePaiement();
1896 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1897 $totaldeposits = $facturestatic->getSumDepositsUsed();
1899 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1900 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1901 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1903 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1904 $remaintopay =
price2num($facturestatic->total_ttc - $totalpay);
1906 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1907 $multicurrency_remaintopay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1911 $multicurrency_remaintopay = 0;
1914 $remaincreditnote = $discount->getAvailableDiscounts($companystatic,
'',
'rc.fk_facture_source='.$facturestatic->id);
1915 $remaintopay = -$remaincreditnote;
1916 $totalpay =
price2num($facturestatic->total_ttc - $remaintopay);
1917 $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($companystatic,
'',
'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
1918 $multicurrency_remaintopay = -$multicurrency_remaincreditnote;
1919 $multicurrency_totalpay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
1922 $facturestatic->alreadypaid = $paiement;
1924 $marginInfo = array();
1925 if ($with_margin_info ===
true) {
1926 $facturestatic->fetch_lines();
1927 $marginInfo = $formmargin->getMarginInfosArray($facturestatic);
1928 $total_ht += $obj->total_ht;
1929 $total_margin += $marginInfo[
'total_margin'];
1932 if ($mode ==
'kanban') {
1934 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1935 print
'<div class="box-flex-container kanban">';
1938 print $facturestatic->getKanbanView(
'', array(
'thirdparty'=>$companystatic->getNomUrl(1,
'company', 15),
'userauthor'=>$userstatic->getNomUrl(1),
'selected' => in_array($object->id, $arrayofselected)));
1939 if ($i == ($imaxinloop - 1)) {
1944 print
'<tr class="oddeven"';
1945 if ($contextpage ==
'poslist') {
1946 print
' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.
'\',
function() {parent.$.colorbox.close();
';
1947 if (strpos($obj->ref, 'PROV
') !== false) {
1948 //If is a draft invoice, load var to be able to add products
1949 $place = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
1950 print 'parent.place=\
''.$place.
'\'';
1957 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1958 print
'<td class="nowrap center">';
1959 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1961 if (in_array($obj->id, $arrayofselected)) {
1964 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1968 $totalarray[
'nbfield']++;
1973 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
1974 print
'<td>'.(($offset * $limit) + $i).
'</td>';
1976 $totalarray[
'nbfield']++;
1981 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1982 print
'<td class="nowraponall">';
1984 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1986 print
'<td class="nobordernopadding nowraponall">';
1987 if ($contextpage ==
'poslist') {
1990 print $facturestatic->getNomUrl(1,
'', 200, 0,
'', 0, 1);
1995 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->id;
1996 print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
2003 $totalarray[
'nbfield']++;
2008 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
2009 print
'<td class="nowrap tdoverflowmax200">';
2013 $totalarray[
'nbfield']++;
2018 if (!empty($arrayfields[
'f.type'][
'checked'])) {
2019 print
'<td class="nowraponall tdoverflowmax100" title="'.$facturestatic->getLibType().
'">';
2020 print $facturestatic->getLibType(2);
2023 $totalarray[
'nbfield']++;
2028 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
2029 print
'<td align="center" class="nowraponall">';
2033 $totalarray[
'nbfield']++;
2038 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
2039 print
'<td align="center" class="nowraponall">';
2043 $totalarray[
'nbfield']++;
2048 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
2049 print
'<td align="center" class="nowraponall">'.dol_print_date($datelimit,
'day');
2050 if ($facturestatic->hasDelay()) {
2051 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
2055 $totalarray[
'nbfield']++;
2060 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
2061 print
'<td class="nocellnopadd nowraponall">';
2062 if ($obj->project_id > 0) {
2063 print $projectstatic->getNomUrl(1);
2067 $totalarray[
'nbfield']++;
2072 if (!empty($arrayfields[
'p.title'][
'checked'])) {
2073 print
'<td class="nowraponall">';
2074 if ($obj->project_id > 0) {
2079 $totalarray[
'nbfield']++;
2084 if (!empty($arrayfields[
's.nom'][
'checked'])) {
2085 print
'<td class="tdoverflowmax200">';
2086 if ($contextpage ==
'poslist') {
2089 print $companystatic->getNomUrl(1,
'customer', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2093 $totalarray[
'nbfield']++;
2097 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2098 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).
'">';
2102 $totalarray[
'nbfield']++;
2106 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
2107 print
'<td class="tdoverflowmax200">';
2108 if ($obj->fk_parent > 0) {
2109 if (!isset($company_url_list[$obj->fk_parent])) {
2110 $companyparent =
new Societe($db);
2111 $res = $companyparent->fetch($obj->fk_parent);
2113 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2116 if (isset($company_url_list[$obj->fk_parent])) {
2117 print $company_url_list[$obj->fk_parent];
2122 $totalarray[
'nbfield']++;
2126 if (!empty($arrayfields[
's.code_client'][
'checked'])) {
2127 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->code_client).
'">';
2131 $totalarray[
'nbfield']++;
2135 if (!empty($arrayfields[
's.town'][
'checked'])) {
2136 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
2140 $totalarray[
'nbfield']++;
2144 if (!empty($arrayfields[
's.zip'][
'checked'])) {
2145 print
'<td class="nowraponall">';
2149 $totalarray[
'nbfield']++;
2153 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2154 print
"<td>".dol_escape_htmltag($obj->state_name).
"</td>\n";
2156 $totalarray[
'nbfield']++;
2160 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2161 print
'<td class="center">';
2162 $tmparray =
getCountry($obj->fk_pays,
'all');
2163 print $tmparray[
'label'];
2166 $totalarray[
'nbfield']++;
2170 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2171 print
'<td class="center">';
2172 if (!is_array($typenArray) || count($typenArray) == 0) {
2173 $typenArray = $formcompany->typent_array(1);
2175 print $typenArray[$obj->typent_code];
2178 $totalarray[
'nbfield']++;
2182 if (!empty($arrayfields[
'staff.code'][
'checked'])) {
2183 print
'<td class="center">';
2184 if (!is_array($conf->cache[
'staff']) || count($conf->cache[
'staff']) == 0) {
2185 $conf->cache[
'staff'] = $formcompany->effectif_array(1);
2187 print $conf->cache[
'staff'][$obj->staff_code];
2190 $totalarray[
'nbfield']++;
2195 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
2196 $s =
$form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1, 0,
'', 1);
2197 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
2201 $totalarray[
'nbfield']++;
2206 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
2207 $s =
$form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', -1, -1, 1);
2208 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
2212 $totalarray[
'nbfield']++;
2217 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
2222 $totalarray[
'nbfield']++;
2227 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
2232 $totalarray[
'nbfield']++;
2237 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
2238 print
'<td class="right nowraponall amount">'.price($obj->total_ht).
"</td>\n";
2240 $totalarray[
'nbfield']++;
2243 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
2245 $totalarray[
'val'][
'f.total_ht'] += $obj->total_ht;
2248 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
2249 print
'<td class="right nowraponall amount">'.price($obj->total_tva).
"</td>\n";
2251 $totalarray[
'nbfield']++;
2254 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_tva';
2256 $totalarray[
'val'][
'f.total_tva'] += $obj->total_tva;
2259 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
2260 print
'<td class="right nowraponall amount">'.price($obj->total_localtax1).
"</td>\n";
2262 $totalarray[
'nbfield']++;
2265 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax1';
2267 $totalarray[
'val'][
'f.total_localtax1'] += $obj->total_localtax1;
2270 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
2271 print
'<td class="right nowraponall amount">'.price($obj->total_localtax2).
"</td>\n";
2273 $totalarray[
'nbfield']++;
2276 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax2';
2278 $totalarray[
'val'][
'f.total_localtax2'] += $obj->total_localtax2;
2281 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
2282 print
'<td class="right nowraponall amount">'.price($obj->total_ttc).
"</td>\n";
2284 $totalarray[
'nbfield']++;
2287 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
2289 $totalarray[
'val'][
'f.total_ttc'] += $obj->total_ttc;
2292 $userstatic->id = $obj->fk_user_author;
2293 $userstatic->login = $obj->login;
2294 $userstatic->lastname = $obj->lastname;
2295 $userstatic->firstname = $obj->firstname;
2296 $userstatic->email = $obj->user_email;
2297 $userstatic->statut = $obj->user_statut;
2298 $userstatic->entity = $obj->entity;
2299 $userstatic->photo = $obj->photo;
2300 $userstatic->office_phone = $obj->office_phone;
2301 $userstatic->office_fax = $obj->office_fax;
2302 $userstatic->user_mobile = $obj->user_mobile;
2303 $userstatic->job = $obj->job;
2304 $userstatic->gender = $obj->gender;
2307 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2308 print
'<td class="tdoverflowmax200">';
2309 if ($userstatic->id) {
2310 print $userstatic->getNomUrl(-1);
2316 $totalarray[
'nbfield']++;
2320 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2323 if ($obj->socid > 0) {
2324 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2325 if ($listsalesrepresentatives < 0) {
2328 $nbofsalesrepresentative = count($listsalesrepresentatives);
2329 if ($nbofsalesrepresentative > 6) {
2331 print $nbofsalesrepresentative;
2332 } elseif ($nbofsalesrepresentative > 0) {
2334 foreach ($listsalesrepresentatives as $val) {
2335 $userstatic->id = $val[
'id'];
2336 $userstatic->lastname = $val[
'lastname'];
2337 $userstatic->firstname = $val[
'firstname'];
2338 $userstatic->email = $val[
'email'];
2339 $userstatic->statut = $val[
'statut'];
2340 $userstatic->entity = $val[
'entity'];
2341 $userstatic->photo = $val[
'photo'];
2342 $userstatic->login = $val[
'login'];
2343 $userstatic->office_phone = $val[
'office_phone'];
2344 $userstatic->office_fax = $val[
'office_fax'];
2345 $userstatic->user_mobile = $val[
'user_mobile'];
2346 $userstatic->job = $val[
'job'];
2347 $userstatic->gender = $val[
'gender'];
2349 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2351 if ($j < $nbofsalesrepresentative) {
2363 $totalarray[
'nbfield']++;
2367 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
2368 print
'<td align="right">'.(!empty($obj->retained_warranty) ?
price($obj->retained_warranty).
'%' :
' ').
'</td>';
2370 $totalarray[
'nbfield']++;
2374 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
2375 print
'<td class="right nowraponall amount">'.(!empty($totalpay) ?
price($totalpay, 0, $langs) :
' ').
'</td>';
2377 $totalarray[
'nbfield']++;
2380 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalam';
2382 $totalarray[
'val'][
'totalam'] += $totalpay;
2386 if (!empty($arrayfields[
'rtp'][
'checked'])) {
2387 print
'<td class="right nowraponall amount">';
2388 print (!empty($remaintopay) ?
price($remaintopay, 0, $langs) :
' ');
2391 $totalarray[
'nbfield']++;
2394 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'rtp';
2396 $totalarray[
'val'][
'rtp'] += $remaintopay;
2401 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
2402 print
'<td class="nowraponall tdoverflowmax125" title="'.dol_escape_htmltag($obj->multicurrency_code.
' - '.$langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code)).
'">';
2403 if (empty($conf->global->MAIN_SHOW_ONLY_CODE_MULTICURRENCY)) {
2404 print $langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code);
2410 $totalarray[
'nbfield']++;
2415 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
2416 print
'<td class="nowraponall">';
2417 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2420 $totalarray[
'nbfield']++;
2424 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
2425 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ht).
"</td>\n";
2427 $totalarray[
'nbfield']++;
2431 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
2432 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_vat).
"</td>\n";
2434 $totalarray[
'nbfield']++;
2438 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
2439 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ttc).
"</td>\n";
2441 $totalarray[
'nbfield']++;
2444 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
2445 print
'<td class="right nowraponall amount">'.(!empty($multicurrency_totalpay) ?
price($multicurrency_totalpay, 0, $langs) :
' ').
'</td>';
2447 $totalarray[
'nbfield']++;
2452 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
2453 print
'<td class="right nowraponall">';
2454 print (!empty($multicurrency_remaintopay) ?
price($multicurrency_remaintopay, 0, $langs) :
' ');
2457 $totalarray[
'nbfield']++;
2462 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2463 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total'], 0, $langs, 1, -1,
'MT').
'</td>';
2465 $totalarray[
'nbfield']++;
2466 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_pa';
2468 $totalarray[
'val'][
'total_pa'] += $marginInfo[
'pa_total'];
2471 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2472 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin'], 0, $langs, 1, -1,
'MT').
'</td>';
2474 $totalarray[
'nbfield']++;
2475 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_margin';
2477 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2480 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2481 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2483 $totalarray[
'nbfield']++;
2487 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2488 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2490 $totalarray[
'nbfield']++;
2491 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_mark_rate';
2493 if ($i >= $imaxinloop - 1) {
2494 if (!empty($total_ht)) {
2495 $totalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2497 $totalarray[
'val'][
'total_mark_rate'] =
'';
2503 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2505 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
2506 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2507 print $hookmanager->resPrint;
2509 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
2510 print
'<td class="nowraponall center">';
2511 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2514 $totalarray[
'nbfield']++;
2518 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
2519 print
'<td class="nowraponall center">';
2520 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
2523 $totalarray[
'nbfield']++;
2527 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
2528 print
'<td class="nowraponall center">';
2529 print
dol_print_date($db->jdate($obj->date_closing),
'dayhour',
'tzuser');
2532 $totalarray[
'nbfield']++;
2536 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
2537 print
'<td class="center">';
2541 $totalarray[
'nbfield']++;
2545 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
2546 print
'<td class="center">';
2550 $totalarray[
'nbfield']++;
2554 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
2555 print
'<td class="center">';
2556 if (!empty($obj->fk_fac_rec_source)) {
2558 $result = $facrec->fetch($obj->fk_fac_rec_source);
2562 print $facrec->getNomUrl();
2567 $totalarray[
'nbfield']++;
2571 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
2572 print
'<td class="nowrap right">';
2573 print $facturestatic->getLibStatut(5, $paiement);
2576 $totalarray[
'nbfield']++;
2582 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
2583 print
'<td class="nowrap center">';
2584 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
2586 if (in_array($obj->id, $arrayofselected)) {
2589 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2593 $totalarray[
'nbfield']++;
2604 $totalarray[
'val'][
'total_pa'] = (isset($totalarray[
'val'][
'total_pa']) ?
price2num($totalarray[
'val'][
'total_pa'],
'MT') : null);
2605 $totalarray[
'val'][
'total_margin'] = (isset($totalarray[
'val'][
'total_margin']) ?
price2num($totalarray[
'val'][
'total_margin'],
'MT') : null);
2608 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2614 foreach ($arrayfields as $key => $val) {
2615 if (!empty($val[
'checked'])) {
2619 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2624 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
2625 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2626 print $hookmanager->resPrint;
2628 print
'</table>'.
"\n";
2629 print
'</div>'.
"\n";
2631 print
'</form>'.
"\n";
2634 if ($contextpage !=
'poslist') {
2635 $hidegeneratedfilelistifempty = 1;
2636 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2637 $hidegeneratedfilelistifempty = 0;
2641 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2642 $urlsource .= str_replace(
'&',
'&', $param);
2644 $filedir = $diroutputmassaction;
2645 $genallowed = $user->hasRight(
"facture",
"lire");
2646 $delallowed = $user->hasRight(
"facture",
"creer");
2649 print $formfile->showdocuments(
'massfilesarea_invoices',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);