38 require
'../../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
42 if (!empty($conf->margin->enabled)) {
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
46 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
54 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
55 if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
58 $langs->loadLangs(array(
'bills',
'companies',
'products',
'categories'));
60 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
61 $projectid = (
GETPOST(
'projectid') ?
GETPOST(
'projectid',
'int') : 0);
65 $socid =
GETPOST(
'socid',
'int');
67 $action =
GETPOST(
'action',
'aZ09');
68 $massaction =
GETPOST(
'massaction',
'alpha');
69 $show_files =
GETPOST(
'show_files',
'int');
70 $confirm =
GETPOST(
'confirm',
'alpha');
71 $toselect =
GETPOST(
'toselect',
'array');
72 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'invoicelist';
74 if ($contextpage ==
'poslist')
76 $_GET[
'optioncss'] =
'print';
79 $lineid =
GETPOST(
'lineid',
'int');
80 $userid =
GETPOST(
'userid',
'int');
81 $search_product_category =
GETPOST(
'search_product_category',
'int');
83 $search_refcustomer =
GETPOST(
'search_refcustomer',
'alpha');
84 $search_type =
GETPOST(
'search_type',
'int');
85 $search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
86 $search_project =
GETPOST(
'search_project',
'alpha');
87 $search_societe =
GETPOST(
'search_societe',
'alpha');
88 $search_montant_ht =
GETPOST(
'search_montant_ht',
'alpha');
89 $search_montant_vat =
GETPOST(
'search_montant_vat',
'alpha');
90 $search_montant_localtax1 =
GETPOST(
'search_montant_localtax1',
'alpha');
91 $search_montant_localtax2 =
GETPOST(
'search_montant_localtax2',
'alpha');
92 $search_montant_ttc =
GETPOST(
'search_montant_ttc',
'alpha');
93 $search_login =
GETPOST(
'search_login',
'alpha');
94 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
95 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
96 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
97 $search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
98 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
99 $search_status =
GETPOST(
'search_status',
'intcomma');
100 $search_paymentmode =
GETPOST(
'search_paymentmode',
'int');
101 $search_paymentterms =
GETPOST(
'search_paymentterms',
'int');
102 $search_module_source =
GETPOST(
'search_module_source',
'alpha');
103 $search_pos_source =
GETPOST(
'search_pos_source',
'alpha');
104 $search_town =
GETPOST(
'search_town',
'alpha');
105 $search_zip =
GETPOST(
'search_zip',
'alpha');
106 $search_state =
GETPOST(
"search_state");
107 $search_country =
GETPOST(
"search_country",
'int');
108 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
109 $search_user =
GETPOST(
'search_user',
'int');
110 $search_sale =
GETPOST(
'search_sale',
'int');
111 $search_date_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_date_startmonth',
'int'),
GETPOST(
'search_date_startday',
'int'),
GETPOST(
'search_date_startyear',
'int'));
112 $search_date_end =
dol_mktime(23, 59, 59,
GETPOST(
'search_date_endmonth',
'int'),
GETPOST(
'search_date_endday',
'int'),
GETPOST(
'search_date_endyear',
'int'));
113 $search_date_valid_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_date_valid_startmonth',
'int'),
GETPOST(
'search_date_valid_startday',
'int'),
GETPOST(
'search_date_valid_startyear',
'int'));
114 $search_date_valid_end =
dol_mktime(23, 59, 59,
GETPOST(
'search_date_valid_endmonth',
'int'),
GETPOST(
'search_date_valid_endday',
'int'),
GETPOST(
'search_date_valid_endyear',
'int'));
115 $search_datelimit_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_datelimit_startmonth',
'int'),
GETPOST(
'search_datelimit_startday',
'int'),
GETPOST(
'search_datelimit_startyear',
'int'));
116 $search_datelimit_end =
dol_mktime(23, 59, 59,
GETPOST(
'search_datelimit_endmonth',
'int'),
GETPOST(
'search_datelimit_endday',
'int'),
GETPOST(
'search_datelimit_endyear',
'int'));
117 $search_categ_cus =
GETPOST(
"search_categ_cus",
'int');
118 $search_btn =
GETPOST(
'button_search',
'alpha');
119 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
121 $option =
GETPOST(
'search_option');
122 if ($option ==
'late') {
123 $search_status =
'1';
125 $filtre =
GETPOST(
'filtre',
'alpha');
127 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
128 $sortfield =
GETPOST(
"sortfield",
'alpha');
129 $sortorder =
GETPOST(
"sortorder",
'alpha');
131 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) { $page = 0; }
132 $offset = $limit * $page;
133 if (!$sortorder && !empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status ==
'1') $sortorder = $conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER;
134 if (!$sortorder) $sortorder =
'DESC';
135 if (!$sortfield) $sortfield =
'f.datef';
136 $pageprev = $page - 1;
137 $pagenext = $page + 1;
140 $fieldid = (!empty($ref) ?
'ref' :
'rowid');
141 if (!empty($user->socid)) $socid = $user->socid;
142 $result =
restrictedArea($user,
'facture', $id,
'',
'',
'fk_soc', $fieldid);
144 $diroutputmassaction = $conf->facture->dir_output.
'/temp/massgeneration/'.$user->id;
152 $hookmanager->initHooks(array(
'invoicelist'));
156 $extrafields->fetch_name_optionals_label($object->table_element);
158 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
161 $fieldstosearchall = array(
163 'f.ref_client'=>
'RefCustomer',
164 'pd.description'=>
'Description',
165 's.nom'=>
"ThirdParty",
166 's.name_alias'=>
"AliasNameShort",
169 'f.note_public'=>
'NotePublic',
171 if (empty($user->socid)) $fieldstosearchall[
"f.note_private"] =
"NotePrivate";
173 $checkedtypetiers = 0;
174 $arrayfields = array(
175 'f.ref'=>array(
'label'=>
"Ref",
'checked'=>1,
'position'=>5),
176 'f.ref_client'=>array(
'label'=>
"RefCustomer",
'checked'=>1,
'position'=>10),
177 'f.type'=>array(
'label'=>
"Type",
'checked'=>0,
'position'=>15),
178 'f.date'=>array(
'label'=>
"DateInvoice",
'checked'=>1,
'position'=>20),
179 'f.date_valid'=>array(
'label'=>
"DateValidation",
'checked'=>0,
'position'=>22),
180 'f.date_lim_reglement'=>array(
'label'=>
"DateDue",
'checked'=>1,
'position'=>25),
181 'f.date_closing'=>array(
'label'=>
"DateClosing",
'checked'=>0,
'position'=>30),
182 'p.ref'=>array(
'label'=>
"ProjectRef",
'checked'=>1,
'enabled'=>(empty($conf->projet->enabled) ? 0 : 1),
'position'=>40),
183 'p.title'=>array(
'label'=>
"ProjectLabel",
'checked'=>0,
'enabled'=>(empty($conf->projet->enabled) ? 0 : 1),
'position'=>40),
184 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>50),
185 's.town'=>array(
'label'=>
"Town",
'checked'=>1,
'position'=>55),
186 's.zip'=>array(
'label'=>
"Zip",
'checked'=>1,
'position'=>60),
187 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0,
'position'=>65),
188 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0,
'position'=>70),
189 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers,
'position'=>75),
190 'f.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>1,
'position'=>80),
191 'f.fk_cond_reglement'=>array(
'label'=>
"PaymentConditionsShort",
'checked'=>1,
'position'=>85),
192 'f.module_source'=>array(
'label'=>
"Module",
'checked'=>($contextpage ==
'poslist' ? 1 : 0),
'enabled'=>($conf->cashdesk->enabled || $conf->takepos->enabled || $conf->global->INVOICE_SHOW_POS),
'position'=>90),
193 'f.pos_source'=>array(
'label'=>
"Terminal",
'checked'=>($contextpage ==
'poslist' ? 1 : 0),
'enabled'=>($conf->cashdesk->enabled || $conf->takepos->enabled || $conf->global->INVOICE_SHOW_POS),
'position'=>91),
194 'f.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1,
'position'=>95),
195 'f.total_vat'=>array(
'label'=>
"AmountVAT",
'checked'=>0,
'position'=>100),
196 'f.total_localtax1'=>array(
'label'=>$langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked'=>0,
'enabled'=>($mysoc->localtax1_assuj ==
"1"),
'position'=>110),
197 'f.total_localtax2'=>array(
'label'=>$langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked'=>0,
'enabled'=>($mysoc->localtax2_assuj ==
"1"),
'position'=>120),
198 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0,
'position'=>130),
199 'u.login'=>array(
'label'=>
"Author",
'checked'=>1,
'position'=>135),
200 'dynamount_payed'=>array(
'label'=>
"Received",
'checked'=>0,
'position'=>140),
201 'rtp'=>array(
'label'=>
"Rest",
'checked'=>0,
'position'=>150),
202 'f.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>160),
203 'f.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>170),
204 'f.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>180),
205 'f.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>190),
206 'f.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>200),
207 'multicurrency_dynamount_payed'=>array(
'label'=>
'MulticurrencyAlreadyPaid',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>210),
208 'multicurrency_rtp'=>array(
'label'=>
'MulticurrencyRemainderToPay',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>220),
209 'total_pa' => array(
'label' => ($conf->global->MARGIN_TYPE ==
'1' ?
'BuyingPrice' :
'CostPrice'),
'checked' => 0,
'position' => 300,
'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)),
210 'total_margin' => array(
'label' =>
'Margin',
'checked' => 0,
'position' => 301,
'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)),
211 'total_margin_rate' => array(
'label' =>
'MarginRate',
'checked' => 0,
'position' => 302,
'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)),
212 'total_mark_rate' => array(
'label' =>
'MarkRate',
'checked' => 0,
'position' => 303,
'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)),
213 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>500),
214 'f.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>500),
215 'f.note_public'=>array(
'label'=>
'NotePublic',
'checked'=>0,
'position'=>510,
'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))),
216 'f.note_private'=>array(
'label'=>
'NotePrivate',
'checked'=>0,
'position'=>511,
'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))),
217 'f.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000),
220 if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY)
222 $arrayfields[
'f.retained_warranty'] = array(
'label'=>$langs->trans(
"RetainedWarranty"),
'checked'=>0,
'position'=>86);
226 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
236 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
237 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
239 $parameters = array(
'socid'=>$socid);
240 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
241 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
243 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
246 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha'))
250 $search_product_category =
'';
252 $search_refcustomer =
'';
254 $search_project_ref =
'';
255 $search_project =
'';
256 $search_societe =
'';
257 $search_montant_ht =
'';
258 $search_montant_vat =
'';
259 $search_montant_localtax1 =
'';
260 $search_montant_localtax2 =
'';
261 $search_montant_ttc =
'';
263 $search_multicurrency_code =
'';
264 $search_multicurrency_tx =
'';
265 $search_multicurrency_montant_ht =
'';
266 $search_multicurrency_montant_vat =
'';
267 $search_multicurrency_montant_ttc =
'';
269 $search_paymentmode =
'';
270 $search_paymentterms =
'';
271 $search_module_source =
'';
272 $search_pos_source =
'';
277 $search_country =
'';
278 $search_type_thirdparty =
'';
279 $search_date_start =
'';
280 $search_date_end =
'';
281 $search_date_valid_start =
'';
282 $search_date_valid_end =
'';
283 $search_datelimit_start =
'';
284 $search_datelimit_end =
'';
288 $search_array_options = array();
289 $search_categ_cus = 0;
294 $objectclass =
'Facture';
295 $objectlabel =
'Invoices';
296 $permissiontoread = $user->rights->facture->lire;
297 $permissiontoadd = $user->rights->facture->creer;
298 $permissiontodelete = $user->rights->facture->supprimer;
299 $uploaddir = $conf->facture->dir_output;
300 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
303 if ($massaction ==
'makepayment') {
304 $arrayofselected = is_array($toselect) ? $toselect : array();
306 $loc =
dol_buildpath(
'/compta/paiement.php', 2).
'?action=create&facids='.implode(
',', $arrayofselected);
308 header(
'Location: '.$loc);
310 } elseif ($massaction ==
'withdrawrequest') {
311 $langs->load(
"withdrawals");
313 if (!$user->rights->prelevement->bons->creer) {
320 $arrayofselected = is_array($toselect) ? $toselect : array();
321 $listofbills = array();
322 foreach ($arrayofselected as $toselectid)
325 $result = $objecttmp->fetch($toselectid);
327 $totalpaye = $objecttmp->getSommePaiement();
328 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
329 $totaldeposits = $objecttmp->getSumDepositsUsed();
330 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,
'MT');
331 if ($objecttmp->paye || $objecttmp->resteapayer == 0) {
333 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
334 } elseif ($objecttmp->resteapayer < 0) {
336 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
340 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
343 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
344 $rsql .=
" , pfd.date_traite as date_traite";
345 $rsql .=
" , pfd.amount";
346 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
347 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
348 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
349 $rsql .=
" WHERE fk_facture = ".$objecttmp->id;
350 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
351 $rsql .=
" AND pfd.traite = 0";
352 $rsql .=
" ORDER BY pfd.date_demande DESC";
354 $result_sql = $db->query($rsql);
357 $numprlv = $db->num_rows($result_sql);
362 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
363 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'PRE') {
365 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"BadPaymentMethod"), $objecttmp->errors,
'errors');
367 $listofbills[] = $objecttmp;
373 if (!empty($listofbills))
375 $nbwithdrawrequestok = 0;
376 foreach ($listofbills as $aBill)
379 $result = $aBill->demande_prelevement($user, $aBill->resteapayer,
'direct-debit',
'facture');
383 $nbwithdrawrequestok++;
389 if ($nbwithdrawrequestok > 0)
391 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok), null,
'mesgs');
403 $form =
new Form($db);
407 if (!empty($conf->margin->enabled)) {
410 $bankaccountstatic =
new Account($db);
411 $facturestatic =
new Facture($db);
413 $thirdpartystatic =
new Societe($db);
416 if ($sall || $search_product_category > 0 || $search_user > 0) $sql =
'SELECT DISTINCT';
417 $sql .=
' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,';
418 $sql .=
' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
419 $sql .=
' f.fk_user_author,';
420 $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,';
421 $sql .=
' f.datef as df, f.date_valid, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,';
422 $sql .=
' f.paye as paye, f.fk_statut, f.close_code,';
423 $sql .=
' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,';
424 $sql .=
' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
425 $sql .=
' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,';
426 $sql .=
" typent.code as typent_code,";
427 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
428 $sql .=
" country.code as country_code,";
429 $sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
433 if (!$sall) $sql .=
', SUM(pf.amount) as dynamount_payed, SUM(pf.multicurrency_amount) as multicurrency_dynamount_payed';
434 if ($search_categ_cus) $sql .=
", cc.fk_categorie, cc.fk_soc";
436 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
437 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
' as options_'.$key :
'');
440 $parameters = array();
441 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
442 $sql .= $hookmanager->resPrint;
443 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
444 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
445 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
446 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
447 if (!empty($search_categ_cus)) $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"categorie_societe as cc ON s.rowid = cc.fk_soc";
449 $sql .=
', '.MAIN_DB_PREFIX.
'facture as f';
450 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
451 if (!$sall) $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON pf.fk_facture = f.rowid';
452 if ($sall || $search_product_category > 0) $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facturedet as pd ON f.rowid=pd.fk_facture';
453 if ($search_product_category > 0) $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=pd.fk_product';
454 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
455 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
457 if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
458 if ($search_user > 0)
460 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
461 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
464 $sql .=
' WHERE f.fk_soc = s.rowid';
465 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
466 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
467 if ($search_product_category > 0) $sql .=
" AND cp.fk_categorie = ".$db->escape($search_product_category);
468 if ($socid > 0) $sql .=
' AND s.rowid = '.$socid;
471 if ($userid == -1) $sql .=
' AND f.fk_user_author IS NULL';
472 else $sql .=
' AND f.fk_user_author = '.$userid;
476 $aFilter = explode(
',', $filtre);
477 foreach ($aFilter as $filter)
479 $filt = explode(
':', $filter);
480 $sql .=
' AND '.$db->escape(trim($filt[0])).
' = '.$db->escape(trim($filt[1]));
484 if ($search_refcustomer) $sql .=
natural_search(
'f.ref_client', $search_refcustomer);
485 if ($search_type !=
'' && $search_type !=
'-1') $sql .=
" AND f.type IN (".$db->sanitize($db->escape($search_type)).
")";
486 if ($search_project_ref) $sql .=
natural_search(
'p.ref', $search_project_ref);
487 if ($search_project) $sql .=
natural_search(
'p.title', $search_project);
488 if ($search_societe) $sql .=
natural_search(
's.nom', $search_societe);
491 if ($search_state) $sql .=
natural_search(
"state.nom", $search_state);
492 if ($search_country) $sql .=
" AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).
')';
493 if ($search_type_thirdparty) $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
494 if ($search_company) $sql .=
natural_search(
's.nom', $search_company);
495 if ($search_montant_ht !=
'') $sql .=
natural_search(
'f.total', $search_montant_ht, 1);
496 if ($search_montant_vat !=
'') $sql .=
natural_search(
'f.tva', $search_montant_vat, 1);
497 if ($search_montant_localtax1 !=
'') $sql .=
natural_search(
'f.localtax1', $search_montant_localtax1, 1);
498 if ($search_montant_localtax2 !=
'') $sql .=
natural_search(
'f.localtax2', $search_montant_localtax2, 1);
499 if ($search_montant_ttc !=
'') $sql .=
natural_search(
'f.total_ttc', $search_montant_ttc, 1);
500 if ($search_multicurrency_code !=
'') $sql .=
' AND f.multicurrency_code = "'.$db->escape($search_multicurrency_code).
'"';
501 if ($search_multicurrency_tx !=
'') $sql .=
natural_search(
'f.multicurrency_tx', $search_multicurrency_tx, 1);
502 if ($search_multicurrency_montant_ht !=
'') $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
503 if ($search_multicurrency_montant_vat !=
'') $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
504 if ($search_multicurrency_montant_ttc !=
'') $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
505 if ($search_login) $sql .=
natural_search(
'u.login', $search_login);
506 if ($search_categ_cus > 0) $sql .=
" AND cc.fk_categorie = ".$db->escape($search_categ_cus);
507 if ($search_categ_cus == -2) $sql .=
" AND cc.fk_categorie IS NULL";
508 if ($search_status !=
'-1' && $search_status !=
'')
510 if (is_numeric($search_status) && $search_status >= 0)
512 if ($search_status ==
'0') $sql .=
" AND f.fk_statut = 0";
513 if ($search_status ==
'1') $sql .=
" AND f.fk_statut = 1";
514 if ($search_status ==
'2') $sql .=
" AND f.fk_statut = 2";
515 if ($search_status ==
'3') $sql .=
" AND f.fk_statut = 3";
517 $sql .=
" AND f.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
521 if ($search_paymentmode > 0) $sql .=
" AND f.fk_mode_reglement = ".$db->escape($search_paymentmode);
522 if ($search_paymentterms > 0) $sql .=
" AND f.fk_cond_reglement = ".$db->escape($search_paymentterms);
523 if ($search_module_source) $sql .=
natural_search(
"f.module_source", $search_module_source);
524 if ($search_pos_source) $sql .=
natural_search(
"f.pos_source", $search_pos_source);
525 if ($search_date_start) $sql .=
" AND f.datef >= '".$db->idate($search_date_start).
"'";
526 if ($search_date_end) $sql .=
" AND f.datef <= '".$db->idate($search_date_end).
"'";
527 if ($search_date_valid_start) $sql .=
" AND f.date_valid >= '".$db->idate($search_date_valid_start).
"'";
528 if ($search_date_valid_end) $sql .=
" AND f.date_valid <= '".$db->idate($search_date_valid_end).
"'";
529 if ($search_datelimit_start) $sql .=
" AND f.date_lim_reglement >= '".$db->idate($search_datelimit_start).
"'";
530 if ($search_datelimit_end) $sql .=
" AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end).
"'";
531 if ($option ==
'late') $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() - $conf->facture->client->warning_delay).
"'";
532 if ($search_sale > 0) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".(int) $search_sale;
533 if ($search_user > 0)
535 $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 = ".$search_user;
538 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
540 $parameters = array();
541 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
542 $sql .= $hookmanager->resPrint;
546 $sql .=
' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total, f.tva, f.total_ttc,';
547 $sql .=
' f.localtax1, f.localtax2,';
548 $sql .=
' f.datef, f.date_valid, f.date_lim_reglement, f.module_source, f.pos_source,';
549 $sql .=
' f.paye, f.fk_statut, f.close_code,';
550 $sql .=
' f.datec, f.tms, f.date_closing,';
551 $sql .=
' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
552 $sql .=
' f.fk_user_author, f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva,';
553 $sql .=
' f.multicurrency_total_tva, f.multicurrency_total_ttc,';
554 $sql .=
' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
555 $sql .=
' typent.code,';
556 $sql .=
' state.code_departement, state.nom,';
557 $sql .=
' country.code,';
558 $sql .=
" p.rowid, p.ref, p.title,";
560 if ($search_categ_cus) $sql .=
", cc.fk_categorie, cc.fk_soc";
562 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
563 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key :
'');
569 $sql .=
' ORDER BY ';
570 $listfield = explode(
',', $sortfield);
571 $listorder = explode(
',', $sortorder);
572 foreach ($listfield as $key => $value) $sql .= $listfield[$key].
' '.($listorder[$key] ? $listorder[$key] :
'DESC').
',';
573 $sql .=
' f.rowid DESC ';
575 $nbtotalofrecords =
'';
576 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
578 $result = $db->query($sql);
579 $nbtotalofrecords = $db->num_rows($result);
580 if (($page * $limit) > $nbtotalofrecords)
587 $sql .= $db->plimit($limit + 1, $offset);
589 $resql = $db->query($sql);
593 $num = $db->num_rows(
$resql);
595 $arrayofselected = is_array($toselect) ? $toselect : array();
597 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
599 $obj = $db->fetch_object(
$resql);
602 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$id);
606 llxHeader(
'', $langs->trans(
'CustomersInvoices'),
'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
612 if (empty($search_societe)) $search_societe = $soc->name;
615 $param =
'&socid='.$socid;
616 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
617 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
618 if ($sall) $param .=
'&sall='.urlencode($sall);
619 if ($search_date_start) $param .=
'&search_date_start='.urlencode($search_date_start);
620 if ($search_date_end) $param .=
'&search_date_end='.urlencode($search_date_end);
621 if ($search_date_valid_start) $param .=
'&search_date_valid_start='.urlencode($search_date_valid_start);
622 if ($search_date_valid_end) $param .=
'&search_date_valid_end='.urlencode($search_date_valid_end);
623 if ($search_datelimit_start) $param .=
'&search_datelimit_start='.urlencode($search_datelimit_start);
624 if ($search_datelimit_end) $param .=
'&search_datelimit_end='.urlencode($search_datelimit_end);
625 if ($search_ref) $param .=
'&search_ref='.urlencode($search_ref);
626 if ($search_refcustomer) $param .=
'&search_refcustomer='.urlencode($search_refcustomer);
627 if ($search_project_ref) $param .=
'&search_project_ref='.urlencode($search_project_ref);
628 if ($search_project) $param .=
'&search_project='.urlencode($search_project);
629 if ($search_type !=
'') $param .=
'&search_type='.urlencode($search_type);
630 if ($search_societe) $param .=
'&search_societe='.urlencode($search_societe);
631 if ($search_town) $param .=
'&search_town='.urlencode($search_town);
632 if ($search_zip) $param .=
'&search_zip='.urlencode($search_zip);
633 if ($search_sale > 0) $param .=
'&search_sale='.urlencode($search_sale);
634 if ($search_user > 0) $param .=
'&search_user='.urlencode($search_user);
635 if ($search_login) $param .=
'&search_login='.urlencode($search_login);
636 if ($search_product_category > 0) $param .=
'&search_product_category='.urlencode($search_product_category);
637 if ($search_montant_ht !=
'') $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
638 if ($search_montant_vat !=
'') $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
639 if ($search_montant_localtax1 !=
'') $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
640 if ($search_montant_localtax2 !=
'') $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
641 if ($search_montant_ttc !=
'') $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
642 if ($search_multicurrency_code !=
'') $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
643 if ($search_multicurrency_tx !=
'') $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
644 if ($search_multicurrency_montant_ht !=
'') $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
645 if ($search_multicurrency_montant_vat !=
'') $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
646 if ($search_multicurrency_montant_ttc !=
'') $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
647 if ($search_status !=
'') $param .=
'&search_status='.urlencode($search_status);
648 if ($search_paymentmode > 0) $param .=
'&search_paymentmode='.urlencode($search_paymentmode);
649 if ($search_paymentterms > 0) $param .=
'&search_paymentterms='.urlencode($search_paymentterms);
650 if ($search_module_source) $param .=
'&search_module_source='.urlencode($search_module_source);
651 if ($search_pos_source) $param .=
'&search_pos_source='.urlencode($search_pos_source);
652 if ($show_files) $param .=
'&show_files='.urlencode($show_files);
653 if ($option) $param .=
"&search_option=".urlencode($option);
654 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
655 if ($search_categ_cus > 0) $param .=
'&search_categ_cus='.urlencode($search_categ_cus);
658 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
660 $arrayofmassactions = array(
661 'validate'=>$langs->trans(
"Validate"),
662 'generate_doc'=>$langs->trans(
"ReGeneratePDF"),
663 'builddoc'=>$langs->trans(
"PDFMerge"),
664 'presend'=>$langs->trans(
"SendByMail"),
667 if ($conf->prelevement->enabled && !empty($user->rights->prelevement->bons->creer)) {
668 $langs->load(
"withdrawals");
669 $arrayofmassactions[
'withdrawrequest'] = $langs->trans(
"MakeWithdrawRequest");
671 if ($user->rights->facture->supprimer) {
672 if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) {
673 $arrayofmassactions[
'predeletedraft'] = $langs->trans(
"Deletedraft");
674 } elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) {
675 $arrayofmassactions[
'predelete'] = $langs->trans(
"Delete");
678 if (in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
679 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
682 if ($contextpage !=
'poslist')
684 $url = DOL_URL_ROOT.
'/compta/facture/card.php?action=create';
685 if (!empty($socid)) $url .=
'&socid='.$socid;
686 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->facture->creer);
690 print '<form method="POST" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
692 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
693 print '<input type="hidden" name="token" value="'.newToken().
'">';
694 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
695 print '<input type="hidden" name="action" value="list">';
696 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
697 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
698 print '<input type="hidden" name="search_status" value="'.$search_status.
'">';
699 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
701 print_barre_liste($langs->trans(
'BillsCustomers').
' '.($socid ?
' '.$soc->name :
''), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bill', 0, $newcardbutton,
'', $limit, 0, 0, 1);
703 $topicmail =
"SendBillRef";
704 $modelmail =
"facture_send";
706 $trackid =
'inv'.$object->id;
707 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
711 foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
712 print '<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
717 if ($user->rights->societe->client->voir || $socid)
719 $langs->load(
"commercial");
720 $moreforfilter .=
'<div class="divsearchfield">';
721 $moreforfilter .= $langs->trans(
'ThirdPartiesOfSaleRepresentative').
': ';
722 $moreforfilter .= $formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, 1,
'maxwidth200');
723 $moreforfilter .=
'</div>';
726 if ($user->rights->societe->client->voir || $socid)
728 $moreforfilter .=
'<div class="divsearchfield">';
729 $moreforfilter .= $langs->trans(
'LinkedToSpecificUsers').
': ';
730 $moreforfilter .= $form->select_dolusers($search_user,
'search_user', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
731 $moreforfilter .=
'</div>';
734 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire))
736 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
737 $moreforfilter .=
'<div class="divsearchfield">';
738 $moreforfilter .= $langs->trans(
'IncludingProductWithTag').
': ';
739 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null,
'parent', null, null, 1);
740 $moreforfilter .= $form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, 1, 0, 0,
'', 0, 0, 0, 0,
'maxwidth300', 1);
741 $moreforfilter .=
'</div>';
743 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire)
745 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
746 $moreforfilter .=
'<div class="divsearchfield">';
747 $moreforfilter .= $langs->trans(
'CustomersProspectsCategoriesShort').
': ';
748 $moreforfilter .= $formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1);
749 $moreforfilter .=
'</div>';
751 $parameters = array();
752 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
753 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
754 else $moreforfilter = $hookmanager->resPrint;
758 print '<div class="liste_titre liste_titre_bydiv centpercent">';
759 print $moreforfilter;
763 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
764 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
766 if ($massactionbutton && $contextpage !=
'poslist') $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
768 print '<div class="div-table-responsive">';
769 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
772 print '<tr class="liste_titre_filter">';
773 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
774 print
'<td class="liste_titre">';
778 if (!empty($arrayfields[
'f.ref'][
'checked']))
780 print
'<td class="liste_titre" align="left">';
781 print
'<input class="flat maxwidth50imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
785 if (!empty($arrayfields[
'f.ref_client'][
'checked']))
787 print
'<td class="liste_titre">';
788 print
'<input class="flat maxwidth50imp" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).
'">';
792 if (!empty($arrayfields[
'f.type'][
'checked']))
794 print
'<td class="liste_titre maxwidthonsmartphone">';
801 if (!empty($conf->global->INVOICE_USE_SITUATION))
806 print $form->selectarray(
'search_type', $listtype, $search_type, 1, 0, 0,
'', 0, 0, 0,
'ASC',
'maxwidth100');
810 if (!empty($arrayfields[
'f.date'][
'checked']))
812 print
'<td class="liste_titre center">';
813 print
'<div class="nowrap">';
814 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
816 print
'<div class="nowrap">';
817 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
822 if (!empty($arrayfields[
'f.date_valid'][
'checked']))
824 print
'<td class="liste_titre center">';
825 print
'<div class="nowrap">';
826 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'));
828 print
'<div class="nowrap">';
829 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'));
834 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked']))
836 print
'<td class="liste_titre center">';
837 print
'<div class="nowrap">';
844 print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"Before"));
845 print
'<br><input type="checkbox" name="search_option" value="late"'.($option ==
'late' ?
' checked' :
'').
'> '.$langs->trans(
"Alert");
850 if (!empty($arrayfields[
'p.ref'][
'checked']))
852 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project_ref" value="'.$search_project_ref.
'"></td>';
855 if (!empty($arrayfields[
'p.title'][
'checked']))
857 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project" value="'.$search_project.
'"></td>';
860 if (!empty($arrayfields[
's.nom'][
'checked']))
862 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_societe" value="'.$search_societe.
'"></td>';
865 if (!empty($arrayfields[
's.town'][
'checked'])) print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
867 if (!empty($arrayfields[
's.zip'][
'checked'])) print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
869 if (!empty($arrayfields[
'state.nom'][
'checked']))
871 print
'<td class="liste_titre">';
872 print
'<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
876 if (!empty($arrayfields[
'country.code_iso'][
'checked']))
878 print
'<td class="liste_titre" align="center">';
879 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
883 if (!empty($arrayfields[
'typent.code'][
'checked']))
885 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
886 print $form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0,
'', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'maxwidth100');
890 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked']))
892 print
'<td class="liste_titre">';
893 $form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 10);
897 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked']))
899 print
'<td class="liste_titre">';
900 $form->select_conditions_paiements($search_paymentterms,
'search_paymentterms', -1, 1, 1);
904 if (!empty($arrayfields[
'f.module_source'][
'checked']))
906 print
'<td class="liste_titre">';
907 print
'<input class="flat maxwidth75" type="text" name="search_module_source" value="'.dol_escape_htmltag($search_module_source).
'">';
911 if (!empty($arrayfields[
'f.pos_source'][
'checked']))
913 print
'<td class="liste_titre">';
914 print
'<input class="flat maxwidth50" type="text" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).
'">';
917 if (!empty($arrayfields[
'f.total_ht'][
'checked']))
920 print
'<td class="liste_titre right">';
921 print
'<input class="flat" type="text" size="4" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
924 if (!empty($arrayfields[
'f.total_vat'][
'checked']))
927 print
'<td class="liste_titre right">';
928 print
'<input class="flat" type="text" size="4" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
931 if (!empty($arrayfields[
'f.total_localtax1'][
'checked']))
934 print
'<td class="liste_titre right">';
935 print
'<input class="flat" type="text" size="4" name="search_montant_localtax1" value="'.$search_montant_localtax1.
'">';
938 if (!empty($arrayfields[
'f.total_localtax2'][
'checked']))
941 print
'<td class="liste_titre right">';
942 print
'<input class="flat" type="text" size="4" name="search_montant_localtax2" value="'.$search_montant_localtax2.
'">';
945 if (!empty($arrayfields[
'f.total_ttc'][
'checked']))
948 print
'<td class="liste_titre right">';
949 print
'<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
952 if (!empty($arrayfields[
'u.login'][
'checked']))
955 print
'<td class="liste_titre" align="center">';
956 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
959 if (!empty($arrayfields[
'f.retained_warranty'][
'checked']))
961 print
'<td class="liste_titre" align="right">';
964 if (!empty($arrayfields[
'dynamount_payed'][
'checked']))
966 print
'<td class="liste_titre right">';
969 if (!empty($arrayfields[
'rtp'][
'checked']))
971 print
'<td class="liste_titre right">';
974 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked']))
977 print
'<td class="liste_titre">';
978 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
981 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked']))
984 print
'<td class="liste_titre">';
985 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
988 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked']))
991 print
'<td class="liste_titre right">';
992 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
995 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked']))
998 print
'<td class="liste_titre right">';
999 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1002 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked']))
1005 print
'<td class="liste_titre right">';
1006 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1009 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked']))
1011 print
'<td class="liste_titre">';
1014 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked']))
1016 print
'<td class="liste_titre right">';
1019 if (!empty($arrayfields[
'f.date_closing'][
'checked']))
1021 print
'<td class="liste_titre">';
1024 if (!empty($arrayfields[
'total_pa'][
'checked']))
1026 print
'<td class="liste_titre right">';
1029 if (!empty($arrayfields[
'total_margin'][
'checked']))
1031 print
'<td class="liste_titre right">';
1034 if (!empty($arrayfields[
'total_margin_rate'][
'checked']))
1036 print
'<td class="liste_titre right">';
1039 if (!empty($arrayfields[
'total_mark_rate'][
'checked']))
1041 print
'<td class="liste_titre right">';
1046 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1049 $parameters = array(
'arrayfields'=>$arrayfields);
1050 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1051 print $hookmanager->resPrint;
1053 if (!empty($arrayfields[
'f.datec'][
'checked']))
1055 print
'<td class="liste_titre">';
1059 if (!empty($arrayfields[
'f.tms'][
'checked']))
1061 print
'<td class="liste_titre">';
1064 if (!empty($arrayfields[
'f.note_public'][
'checked']))
1067 print
'<td class="liste_titre">';
1070 if (!empty($arrayfields[
'f.note_private'][
'checked']))
1073 print
'<td class="liste_titre">';
1077 if (!empty($arrayfields[
'f.fk_statut'][
'checked']))
1079 print
'<td class="liste_titre maxwidthonsmartphone right">';
1080 $liststatus = array(
'0'=>$langs->trans(
"BillShortStatusDraft"),
'1'=>$langs->trans(
"BillShortStatusNotPaid"),
'2'=>$langs->trans(
"BillShortStatusPaid"),
'1,2'=>$langs->trans(
"BillShortStatusNotPaid").
'+'.$langs->trans(
"BillShortStatusPaid"),
'3'=>$langs->trans(
"BillShortStatusCanceled"));
1081 print $form->selectarray(
'search_status', $liststatus, $search_status, 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1085 print
'<td class="liste_titre" align="middle">';
1086 $searchpicto = $form->showFilterButtons();
1091 print
'<tr class="liste_titre">';
1092 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST))
print_liste_field_titre(
'#',
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
1093 if (!empty($arrayfields[
'f.ref'][
'checked']))
print_liste_field_titre($arrayfields[
'f.ref'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.ref',
'', $param,
'', $sortfield, $sortorder);
1094 if (!empty($arrayfields[
'f.ref_client'][
'checked']))
print_liste_field_titre($arrayfields[
'f.ref_client'][
'label'],
$_SERVER[
"PHP_SELF"],
'f.ref_client',
'', $param,
'', $sortfield, $sortorder);
1095 if (!empty($arrayfields[
'f.type'][
'checked']))
print_liste_field_titre($arrayfields[
'f.type'][
'label'],
$_SERVER[
"PHP_SELF"],
'f.type',
'', $param,
'', $sortfield, $sortorder);
1096 if (!empty($arrayfields[
'f.date'][
'checked']))
print_liste_field_titre($arrayfields[
'f.date'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.datef',
'', $param,
'align="center"', $sortfield, $sortorder);
1097 if (!empty($arrayfields[
'f.date_valid'][
'checked']))
print_liste_field_titre($arrayfields[
'f.date_valid'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.date_valid',
'', $param,
'align="center"', $sortfield, $sortorder);
1098 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked']))
print_liste_field_titre($arrayfields[
'f.date_lim_reglement'][
'label'],
$_SERVER[
'PHP_SELF'],
"f.date_lim_reglement",
'', $param,
'align="center"', $sortfield, $sortorder);
1099 if (!empty($arrayfields[
'p.ref'][
'checked']))
print_liste_field_titre($arrayfields[
'p.ref'][
'label'],
$_SERVER[
'PHP_SELF'],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
1100 if (!empty($arrayfields[
'p.title'][
'checked']))
print_liste_field_titre($arrayfields[
'p.title'][
'label'],
$_SERVER[
'PHP_SELF'],
"p.title",
'', $param,
'', $sortfield, $sortorder);
1101 if (!empty($arrayfields[
's.nom'][
'checked']))
print_liste_field_titre($arrayfields[
's.nom'][
'label'],
$_SERVER[
'PHP_SELF'],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1102 if (!empty($arrayfields[
's.town'][
'checked']))
print_liste_field_titre($arrayfields[
's.town'][
'label'],
$_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1103 if (!empty($arrayfields[
's.zip'][
'checked']))
print_liste_field_titre($arrayfields[
's.zip'][
'label'],
$_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1104 if (!empty($arrayfields[
'state.nom'][
'checked']))
print_liste_field_titre($arrayfields[
'state.nom'][
'label'],
$_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1105 if (!empty($arrayfields[
'country.code_iso'][
'checked']))
print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'],
$_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'align="center"', $sortfield, $sortorder);
1106 if (!empty($arrayfields[
'typent.code'][
'checked']))
print_liste_field_titre($arrayfields[
'typent.code'][
'label'],
$_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'align="center"', $sortfield, $sortorder);
1107 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked']))
print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'],
$_SERVER[
"PHP_SELF"],
"f.fk_mode_reglement",
"", $param,
"", $sortfield, $sortorder);
1108 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked']))
print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'],
$_SERVER[
"PHP_SELF"],
"f.fk_cond_reglement",
"", $param,
"", $sortfield, $sortorder);
1109 if (!empty($arrayfields[
'f.module_source'][
'checked']))
print_liste_field_titre($arrayfields[
'f.module_source'][
'label'],
$_SERVER[
"PHP_SELF"],
"f.module_source",
"", $param,
"", $sortfield, $sortorder);
1110 if (!empty($arrayfields[
'f.pos_source'][
'checked']))
print_liste_field_titre($arrayfields[
'f.pos_source'][
'label'],
$_SERVER[
"PHP_SELF"],
"f.pos_source",
"", $param,
"", $sortfield, $sortorder);
1111 if (!empty($arrayfields[
'f.total_ht'][
'checked']))
print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.total',
'', $param,
'class="right"', $sortfield, $sortorder);
1112 if (!empty($arrayfields[
'f.total_vat'][
'checked']))
print_liste_field_titre($arrayfields[
'f.total_vat'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1113 if (!empty($arrayfields[
'f.total_localtax1'][
'checked']))
print_liste_field_titre($arrayfields[
'f.total_localtax1'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.localtax1',
'', $param,
'class="right"', $sortfield, $sortorder);
1114 if (!empty($arrayfields[
'f.total_localtax2'][
'checked']))
print_liste_field_titre($arrayfields[
'f.total_localtax2'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.localtax2',
'', $param,
'class="right"', $sortfield, $sortorder);
1115 if (!empty($arrayfields[
'f.total_ttc'][
'checked']))
print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1116 if (!empty($arrayfields[
'u.login'][
'checked']))
print_liste_field_titre($arrayfields[
'u.login'][
'label'],
$_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1117 if (!empty($arrayfields[
'f.retained_warranty'][
'checked']))
print_liste_field_titre($arrayfields[
'f.retained_warranty'][
'label'],
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'align="right"', $sortfield, $sortorder);
1118 if (!empty($arrayfields[
'dynamount_payed'][
'checked']))
print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'],
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1119 if (!empty($arrayfields[
'rtp'][
'checked']))
print_liste_field_titre($arrayfields[
'rtp'][
'label'],
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1120 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked']))
print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1121 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked']))
print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1122 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked']))
print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1123 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked']))
print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1124 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked']))
print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'],
$_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1125 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked']))
print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'],
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1126 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked']))
print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'],
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1127 if (!empty($arrayfields[
'total_pa'][
'checked']))
print_liste_field_titre($arrayfields[
'total_pa'][
'label'],
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1128 if (!empty($arrayfields[
'total_margin'][
'checked']))
print_liste_field_titre($arrayfields[
'total_margin'][
'label'],
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1129 if (!empty($arrayfields[
'total_margin_rate'][
'checked']))
print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'],
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1130 if (!empty($arrayfields[
'total_mark_rate'][
'checked']))
print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'],
$_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1132 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1134 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1135 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1136 print $hookmanager->resPrint;
1137 if (!empty($arrayfields[
'f.datec'][
'checked']))
print_liste_field_titre($arrayfields[
'f.datec'][
'label'],
$_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1138 if (!empty($arrayfields[
'f.tms'][
'checked']))
print_liste_field_titre($arrayfields[
'f.tms'][
'label'],
$_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1139 if (!empty($arrayfields[
'f.date_closing'][
'checked']))
print_liste_field_titre($arrayfields[
'f.date_closing'][
'label'],
$_SERVER[
"PHP_SELF"],
"f.date_closing",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
1140 if (!empty($arrayfields[
'f.note_public'][
'checked']))
print_liste_field_titre($arrayfields[
'f.note_public'][
'label'],
$_SERVER[
"PHP_SELF"],
"f.note_public",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1141 if (!empty($arrayfields[
'f.note_private'][
'checked']))
print_liste_field_titre($arrayfields[
'f.note_private'][
'label'],
$_SERVER[
"PHP_SELF"],
"f.note_private",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1142 if (!empty($arrayfields[
'f.fk_statut'][
'checked']))
print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'],
$_SERVER[
"PHP_SELF"],
"f.fk_statut,f.paye,f.type,dynamount_payed",
"", $param,
'class="right"', $sortfield, $sortorder);
1146 $projectstatic =
new Project($db);
1148 $userstatic =
new User($db);
1153 $totalarray = array();
1154 while ($i < min($num, $limit))
1156 $obj = $db->fetch_object(
$resql);
1158 $datelimit = $db->jdate($obj->datelimite);
1160 $facturestatic->id = $obj->id;
1161 $facturestatic->ref = $obj->ref;
1162 $facturestatic->ref_client = $obj->ref_client;
1163 $facturestatic->type = $obj->type;
1164 $facturestatic->total_ht = $obj->total_ht;
1165 $facturestatic->total_tva = $obj->total_vat;
1166 $facturestatic->total_ttc = $obj->total_ttc;
1167 $facturestatic->multicurrency_code = $obj->multicurrency_code;
1168 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1169 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1170 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1171 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1172 $facturestatic->statut = $obj->fk_statut;
1173 $facturestatic->close_code = $obj->close_code;
1174 $facturestatic->total_ttc = $obj->total_ttc;
1175 $facturestatic->paye = $obj->paye;
1176 $facturestatic->fk_soc = $obj->fk_soc;
1178 $facturestatic->date = $db->jdate($obj->df);
1179 $facturestatic->date_valid = $db->jdate($obj->date_valid);
1180 $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
1182 $facturestatic->note_public = $obj->note_public;
1183 $facturestatic->note_private = $obj->note_private;
1184 if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY)
1186 $facturestatic->retained_warranty = $obj->retained_warranty;
1187 $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit;
1188 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
1189 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
1190 $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref;
1191 $facturestatic->situation_counter = $obj->situation_counter;
1193 $thirdpartystatic->id = $obj->socid;
1194 $thirdpartystatic->name = $obj->name;
1195 $thirdpartystatic->client = $obj->client;
1196 $thirdpartystatic->fournisseur = $obj->fournisseur;
1197 $thirdpartystatic->code_client = $obj->code_client;
1198 $thirdpartystatic->code_compta_client = $obj->code_compta_client;
1199 $thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
1200 $thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1201 $thirdpartystatic->email = $obj->email;
1202 $thirdpartystatic->country_code = $obj->country_code;
1204 $projectstatic->id = $obj->project_id;
1205 $projectstatic->ref = $obj->project_ref;
1206 $projectstatic->title = $obj->project_label;
1208 $paiement = $facturestatic->getSommePaiement();
1209 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1210 $totaldeposits = $facturestatic->getSumDepositsUsed();
1211 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1212 $remaintopay =
price2num($facturestatic->total_ttc - $totalpay);
1213 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1214 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1215 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1216 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1217 $multicurrency_remaintopay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1221 $multicurrency_remaintopay = 0;
1224 $remaincreditnote = $discount->getAvailableDiscounts($thirdpartystatic,
'',
'rc.fk_facture_source='.$facturestatic->id);
1225 $remaintopay = -$remaincreditnote;
1226 $totalpay =
price2num($facturestatic->total_ttc - $remaintopay);
1227 $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($thirdpartystatic,
'',
'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
1228 $multicurrency_remaintopay = -$multicurrency_remaincreditnote;
1229 $multicurrency_totalpay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
1232 $facturestatic->alreadypaid = $paiement;
1234 $marginInfo = array();
1235 if (!empty($conf->margin->enabled)) {
1236 $facturestatic->fetch_lines();
1237 $marginInfo = $formmargin->getMarginInfosArray($facturestatic);
1240 print
'<tr class="oddeven"';
1241 if ($contextpage ==
'poslist')
1243 print
' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.
'\',
function() {parent.$.colorbox.close();});
"';
1248 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
1249 print '<td>'.(($offset * $limit) + $i).'</td>';
1253 if (!empty($arrayfields['f.ref']['checked']))
1255 print '<td class="nowraponall
">';
1257 print '<table class="nobordernopadding
"><tr class="nocellnopadd
">';
1259 print '<td class="nobordernopadding nowraponall
">';
1260 if ($contextpage == 'poslist')
1264 print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1);
1267 $filename = dol_sanitizeFileName($obj->ref);
1268 $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref);
1269 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->id;
1270 print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
1276 if (!$i) $totalarray['nbfield']++;
1280 if (!empty($arrayfields['f.ref_client']['checked']))
1282 print '<td class="nowrap tdoverflowmax200
">';
1283 print $obj->ref_client;
1285 if (!$i) $totalarray['nbfield']++;
1289 if (!empty($arrayfields['f.type']['checked']))
1291 print '<td class="nowraponall tdoverflowmax100
" title="'.$facturestatic->getLibType().'">';
1292 print $facturestatic->getLibType();
1294 if (!$i) $totalarray['nbfield']++;
1298 if (!empty($arrayfields['f.date']['checked']))
1300 print '<td align="center
" class="nowraponall
">';
1301 print dol_print_date($db->jdate($obj->df), 'day');
1303 if (!$i) $totalarray['nbfield']++;
1307 if (!empty($arrayfields['f.date_valid']['checked']))
1309 print '<td align="center
" class="nowraponall
">';
1310 print dol_print_date($db->jdate($obj->date_valid), 'day');
1312 if (!$i) $totalarray['nbfield']++;
1316 if (!empty($arrayfields['f.date_lim_reglement']['checked']))
1318 print '<td align="center
" class="nowraponall
">'.dol_print_date($datelimit, 'day');
1319 if ($facturestatic->hasDelay())
1321 print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
1324 if (!$i) $totalarray['nbfield']++;
1328 if (!empty($arrayfields['p.ref']['checked']))
1330 print '<td class="nocellnopadd nowraponall
">';
1331 if ($obj->project_id > 0)
1333 print $projectstatic->getNomUrl(1);
1336 if (!$i) $totalarray['nbfield']++;
1340 if (!empty($arrayfields['p.title']['checked']))
1342 print '<td class="nowraponall
">';
1343 if ($obj->project_id > 0)
1345 print $projectstatic->title;
1348 if (!$i) $totalarray['nbfield']++;
1352 if (!empty($arrayfields['s.nom']['checked']))
1354 print '<td class="tdoverflowmax200
">';
1355 if ($contextpage == 'poslist')
1357 print $thirdpartystatic->name;
1359 print $thirdpartystatic->getNomUrl(1, 'customer');
1362 if (!$i) $totalarray['nbfield']++;
1365 if (!empty($arrayfields['s.town']['checked']))
1370 if (!$i) $totalarray['nbfield']++;
1373 if (!empty($arrayfields['s.zip']['checked']))
1375 print '<td class="nowraponall
">';
1378 if (!$i) $totalarray['nbfield']++;
1381 if (!empty($arrayfields['state.nom']['checked']))
1383 print "<td>
".$obj->state_name."</td>
\n";
1384 if (!$i) $totalarray['nbfield']++;
1387 if (!empty($arrayfields['country.code_iso']['checked']))
1389 print '<td class="center
">';
1390 $tmparray = getCountry($obj->fk_pays, 'all');
1391 print $tmparray['label'];
1393 if (!$i) $totalarray['nbfield']++;
1396 if (!empty($arrayfields['typent.code']['checked']))
1398 print '<td class="center
">';
1399 if (!is_array($typenArray) || count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
1400 print $typenArray[$obj->typent_code];
1402 if (!$i) $totalarray['nbfield']++;
1405 if (!empty($arrayfields['staff.code']['checked']))
1407 print '<td class="center
">';
1408 if (!is_array($staffArray) || count($staffArray) == 0) $staffArray = $formcompany->effectif_array(1);
1409 print $staffArray[$obj->staff_code];
1411 if (!$i) $totalarray['nbfield']++;
1415 if (!empty($arrayfields['f.fk_mode_reglement']['checked']))
1417 print '<td class="tdoverflowmax100
">';
1418 $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
1420 if (!$i) $totalarray['nbfield']++;
1424 if (!empty($arrayfields['f.fk_cond_reglement']['checked']))
1427 $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none');
1429 if (!$i) $totalarray['nbfield']++;
1433 if (!empty($arrayfields['f.module_source']['checked']))
1436 print $obj->module_source;
1438 if (!$i) $totalarray['nbfield']++;
1442 if (!empty($arrayfields['f.pos_source']['checked']))
1445 print $obj->pos_source;
1447 if (!$i) $totalarray['nbfield']++;
1451 if (!empty($arrayfields['f.total_ht']['checked']))
1453 print '<td class="right nowraponall
">'.price($obj->total_ht)."</td>
\n";
1454 if (!$i) $totalarray['nbfield']++;
1455 if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht';
1456 $totalarray['val']['f.total_ht'] += $obj->total_ht;
1459 if (!empty($arrayfields['f.total_vat']['checked']))
1461 print '<td class="right nowraponall
">'.price($obj->total_vat)."</td>
\n";
1462 if (!$i) $totalarray['nbfield']++;
1463 if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat';
1464 $totalarray['val']['f.total_vat'] += $obj->total_vat;
1467 if (!empty($arrayfields['f.total_localtax1']['checked']))
1469 print '<td class="right nowraponall
">'.price($obj->total_localtax1)."</td>
\n";
1470 if (!$i) $totalarray['nbfield']++;
1471 if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1';
1472 $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1;
1475 if (!empty($arrayfields['f.total_localtax2']['checked']))
1477 print '<td class="right nowraponall
">'.price($obj->total_localtax2)."</td>
\n";
1478 if (!$i) $totalarray['nbfield']++;
1479 if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2';
1480 $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2;
1483 if (!empty($arrayfields['f.total_ttc']['checked']))
1485 print '<td class="right nowraponall
">'.price($obj->total_ttc)."</td>
\n";
1486 if (!$i) $totalarray['nbfield']++;
1487 if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
1488 $totalarray['val']['f.total_ttc'] += $obj->total_ttc;
1492 if (!empty($arrayfields['u.login']['checked']))
1494 $userstatic->id = $obj->fk_user_author;
1495 $userstatic->login = $obj->login;
1496 print '<td class="center tdoverflowmax100
">';
1497 if ($userstatic->id) print $userstatic->getLoginUrl(1);
1498 else print ' ';
1500 if (!$i) $totalarray['nbfield']++;
1503 if (!empty($arrayfields['f.retained_warranty']['checked']))
1505 print '<td align="right
">'.(!empty($obj->retained_warranty) ?price($obj->retained_warranty).'%' : ' ').'</td>';
1508 if (!empty($arrayfields['dynamount_payed']['checked']))
1510 print '<td class="right nowraponall
">'.(!empty($totalpay) ?price($totalpay, 0, $langs) : ' ').'</td>'; // TODO Use a denormalized field
1511 if (!$i) $totalarray['nbfield']++;
1512 if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalam';
1513 $totalarray['val']['totalam'] += $totalpay;
1517 if (!empty($arrayfields['rtp']['checked']))
1519 print '<td class="right nowraponall
">';
1520 print (!empty($remaintopay) ? price($remaintopay, 0, $langs) : ' ');
1521 print '</td>'; // TODO Use a denormalized field
1522 if (!$i) $totalarray['nbfield']++;
1523 if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'rtp';
1524 $totalarray['val']['rtp'] += $remaintopay;
1529 if (!empty($arrayfields['f.multicurrency_code']['checked']))
1531 print '<td class="nowraponall
">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>
\n";
1532 if (!$i) $totalarray['nbfield']++;
1536 if (!empty($arrayfields['f.multicurrency_tx']['checked']))
1538 print '<td class="nowraponall
">';
1539 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1541 if (!$i) $totalarray['nbfield']++;
1544 if (!empty($arrayfields['f.multicurrency_total_ht']['checked']))
1546 print '<td class="right nowraponall
">'.price($obj->multicurrency_total_ht)."</td>
\n";
1547 if (!$i) $totalarray['nbfield']++;
1550 if (!empty($arrayfields['f.multicurrency_total_vat']['checked']))
1552 print '<td class="right nowraponall
">'.price($obj->multicurrency_total_vat)."</td>
\n";
1553 if (!$i) $totalarray['nbfield']++;
1556 if (!empty($arrayfields['f.multicurrency_total_ttc']['checked']))
1558 print '<td class="right nowraponall
">'.price($obj->multicurrency_total_ttc)."</td>
\n";
1559 if (!$i) $totalarray['nbfield']++;
1561 if (!empty($arrayfields['multicurrency_dynamount_payed']['checked']))
1563 print '<td class="right nowraponall
">'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : ' ').'</td>'; // TODO Use a denormalized field
1564 if (!$i) $totalarray['nbfield']++;
1568 if (!empty($arrayfields['multicurrency_rtp']['checked']))
1570 print '<td class="right nowraponall
">';
1571 print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ' ');
1572 print '</td>'; // TODO Use a denormalized field
1573 if (!$i) $totalarray['nbfield']++;
1576 // Total buying or cost price
1577 if (!empty($arrayfields['total_pa']['checked']))
1579 print '<td class="right nowrap
">'.price($marginInfo['pa_total']).'</td>';
1580 if (!$i) $totalarray['nbfield']++;
1583 if (!empty($arrayfields['total_margin']['checked']))
1585 print '<td class="right nowrap
">'.price($marginInfo['total_margin']).'</td>';
1586 if (!$i) $totalarray['nbfield']++;
1588 // Total margin rate
1589 if (!empty($arrayfields['total_margin_rate']['checked']))
1591 print '<td class="right nowrap
">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').'</td>';
1592 if (!$i) $totalarray['nbfield']++;
1595 if (!empty($arrayfields['total_mark_rate']['checked']))
1597 print '<td class="right nowrap
">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'</td>';
1598 if (!$i) $totalarray['nbfield']++;
1602 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1604 $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1605 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1606 print $hookmanager->resPrint;
1608 if (!empty($arrayfields['f.datec']['checked']))
1610 print '<td align="center
" class="nowrap
">';
1611 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1613 if (!$i) $totalarray['nbfield']++;
1615 // Date modification
1616 if (!empty($arrayfields['f.tms']['checked']))
1618 print '<td align="center
" class="nowrap
">';
1619 print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1621 if (!$i) $totalarray['nbfield']++;
1624 if (!empty($arrayfields['f.date_closing']['checked']))
1626 print '<td align="center
" class="nowrap
">';
1627 print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuser');
1629 if (!$i) $totalarray['nbfield']++;
1632 if (!empty($arrayfields['f.note_public']['checked']))
1634 print '<td class="center
">';
1635 print dol_escape_htmltag($obj->note_public);
1637 if (!$i) $totalarray['nbfield']++;
1640 if (!empty($arrayfields['f.note_private']['checked']))
1642 print '<td class="center
">';
1643 print dol_escape_htmltag($obj->note_private);
1645 if (!$i) $totalarray['nbfield']++;
1648 if (!empty($arrayfields['f.fk_statut']['checked']))
1650 print '<td class="nowrap right
">';
1651 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type);
1653 if (!$i) $totalarray['nbfield']++;
1656 // Action column (Show the massaction button only when this page is not opend from the Extended POS)
1657 print '<td class="nowrap
" align="center
">';
1658 if (($massactionbutton || $massaction) && $contextpage != 'poslist') // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1661 if (in_array($obj->id, $arrayofselected)) $selected = 1;
1662 print '<input id="cb
'.$obj->id.'" class="flat checkforselect
" type="checkbox
" name="toselect[]
" value="'.$obj->id.'"'.($selected ? ' checked="checked
"' : '').'>';
1665 if (!$i) $totalarray['nbfield']++;
1673 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1678 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1679 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1680 print $hookmanager->resPrint;
1687 // Show the file area only when this page is not opend from the Extended POS
1688 if ($contextpage != 'poslist') {
1689 $hidegeneratedfilelistifempty = 1;
1690 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
1692 // Show list of available documents
1693 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1694 $urlsource .= str_replace('&', '&', $param);
1696 $filedir = $diroutputmassaction;
1697 $genallowed = $user->rights->facture->lire;
1698 $delallowed = $user->rights->facture->creer;
1701 print $formfile->showdocuments('massfilesarea_invoices', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1704 dol_print_error($db);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
const TYPE_STANDARD
Standard invoice.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
const TYPE_REPLACEMENT
Replacement invoice.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
const TYPE_SITUATION
Situation invoice.
Class to manage bank accounts.
const TYPE_CREDIT_NOTE
Credit note invoice.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage projects.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
const STATUS_DRAFT
Draft status.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
const STATUS_CLOSED
Classified paid.
print $_SERVER["PHP_SELF"]
Edit parameters.
const TYPE_DEPOSIT
Deposit invoice.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Class to manage absolute discounts.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Class to manage invoices.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.