34 require
'../../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
47 $langs->loadLangs(array(
"orders",
"sendings",
'deliveries',
'companies',
'compta',
'bills',
'projects',
'suppliers',
'products'));
49 $action =
GETPOST(
'action',
'aZ09');
50 $massaction =
GETPOST(
'massaction',
'alpha');
51 $show_files =
GETPOST(
'show_files',
'int');
52 $confirm =
GETPOST(
'confirm',
'alpha');
53 $toselect =
GETPOST(
'toselect',
'array');
54 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierorderlist';
56 $search_date_order_startday =
GETPOST(
'search_date_order_startday',
'int');
57 $search_date_order_startmonth =
GETPOST(
'search_date_order_startmonth',
'int');
58 $search_date_order_startyear =
GETPOST(
'search_date_order_startyear',
'int');
59 $search_date_order_endday =
GETPOST(
'search_date_order_endday',
'int');
60 $search_date_order_endmonth =
GETPOST(
'search_date_order_endmonth',
'int');
61 $search_date_order_endyear =
GETPOST(
'search_date_order_endyear',
'int');
62 $search_date_order_start =
dol_mktime(0, 0, 0, $search_date_order_startmonth, $search_date_order_startday, $search_date_order_startyear);
63 $search_date_order_end =
dol_mktime(23, 59, 59, $search_date_order_endmonth, $search_date_order_endday, $search_date_order_endyear);
64 $search_date_delivery_startday =
GETPOST(
'search_date_delivery_startday',
'int');
65 $search_date_delivery_startmonth =
GETPOST(
'search_date_delivery_startmonth',
'int');
66 $search_date_delivery_startyear =
GETPOST(
'search_date_delivery_startyear',
'int');
67 $search_date_delivery_endday =
GETPOST(
'search_date_delivery_endday',
'int');
68 $search_date_delivery_endmonth =
GETPOST(
'search_date_delivery_endmonth',
'int');
69 $search_date_delivery_endyear =
GETPOST(
'search_date_delivery_endyear',
'int');
70 $search_date_delivery_start =
dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear);
71 $search_date_delivery_end =
dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
73 $search_date_valid_startday =
GETPOST(
'search_date_valid_startday',
'int');
74 $search_date_valid_startmonth =
GETPOST(
'search_date_valid_startmonth',
'int');
75 $search_date_valid_startyear =
GETPOST(
'search_date_valid_startyear',
'int');
76 $search_date_valid_endday =
GETPOST(
'search_date_valid_endday',
'int');
77 $search_date_valid_endmonth =
GETPOST(
'search_date_valid_endmonth',
'int');
78 $search_date_valid_endyear =
GETPOST(
'search_date_valid_endyear',
'int');
79 $search_date_valid_start =
dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear);
80 $search_date_valid_end =
dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
81 $search_date_approve_startday =
GETPOST(
'search_date_approve_startday',
'int');
82 $search_date_approve_startmonth =
GETPOST(
'search_date_approve_startmonth',
'int');
83 $search_date_approve_startyear =
GETPOST(
'search_date_approve_startyear',
'int');
84 $search_date_approve_endday =
GETPOST(
'search_date_approve_endday',
'int');
85 $search_date_approve_endmonth =
GETPOST(
'search_date_approve_endmonth',
'int');
86 $search_date_approve_endyear =
GETPOST(
'search_date_approve_endyear',
'int');
87 $search_date_approve_start =
dol_mktime(0, 0, 0, $search_date_approve_startmonth, $search_date_approve_startday, $search_date_approve_startyear);
88 $search_date_approve_end =
dol_mktime(23, 59, 59, $search_date_approve_endmonth, $search_date_approve_endday, $search_date_approve_endyear);
90 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
92 $search_product_category =
GETPOST(
'search_product_category',
'int');
93 $search_ref =
GETPOST(
'search_ref',
'alpha');
94 $search_refsupp =
GETPOST(
'search_refsupp',
'alpha');
95 $search_company =
GETPOST(
'search_company',
'alpha');
96 $search_town =
GETPOST(
'search_town',
'alpha');
97 $search_zip =
GETPOST(
'search_zip',
'alpha');
98 $search_state =
GETPOST(
"search_state",
'alpha');
99 $search_country =
GETPOST(
"search_country",
'int');
100 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
101 $search_user =
GETPOST(
'search_user',
'int');
102 $search_request_author =
GETPOST(
'search_request_author',
'alpha');
103 $search_ht =
GETPOST(
'search_ht',
'alpha');
104 $search_ttc =
GETPOST(
'search_ttc',
'alpha');
105 $optioncss =
GETPOST(
'optioncss',
'alpha');
106 $socid =
GETPOST(
'socid',
'int');
107 $search_sale =
GETPOST(
'search_sale',
'int');
108 $search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
109 $search_total_tva =
GETPOST(
'search_total_tva',
'alpha');
110 $search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
111 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
112 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
113 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
114 $search_multicurrency_montant_tva =
GETPOST(
'search_multicurrency_montant_tva',
'alpha');
115 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
116 $optioncss =
GETPOST(
'optioncss',
'alpha');
117 $search_billed =
GETPOST(
'search_billed',
'int');
118 $search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
119 $search_btn =
GETPOST(
'button_search',
'alpha');
120 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
122 if (is_array(
GETPOST(
'search_status',
'none'))) {
123 $search_status = join(
',',
GETPOST(
'search_status',
'array:intcomma'));
125 $search_status = (
GETPOST(
'search_status',
'intcomma') !=
'' ?
GETPOST(
'search_status',
'intcomma') :
GETPOST(
'statut',
'intcomma'));
129 $orderid =
GETPOST(
'orderid',
'int');
131 $socid = $user->socid;
133 $result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
135 $diroutputmassaction = $conf->fournisseur->commande->dir_output.
'/temp/massgeneration/'.$user->id;
137 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
138 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
139 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
141 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction ===
'0')) {
144 $offset = $limit * $page;
145 $pageprev = $page - 1;
146 $pagenext = $page + 1;
148 $sortfield =
'cf.ref';
156 $hookmanager->initHooks(array(
'supplierorderlist'));
160 $extrafields->fetch_name_optionals_label($object->table_element);
162 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
165 $fieldstosearchall = array();
166 foreach ($object->fields as $key => $val) {
167 if (!empty($val[
'searchall'])) {
168 $fieldstosearchall[
'cf.'.$key] = $val[
'label'];
171 $fieldstosearchall[
'pd.description'] =
'Description';
172 $fieldstosearchall[
's.nom'] =
"ThirdParty";
173 $fieldstosearchall[
's.name_alias'] =
"AliasNameShort";
174 $fieldstosearchall[
's.zip'] =
"Zip";
175 $fieldstosearchall[
's.town'] =
"Town";
176 if (empty($user->socid)) {
177 $fieldstosearchall[
"cf.note_private"] =
"NotePrivate";
180 $checkedtypetiers = 0;
183 $arrayfields = array(
184 's.town'=>array(
'label'=>
"Town",
'enabled'=>1,
'position'=>47,
'checked'=>1),
185 's.zip'=>array(
'label'=>
"Zip",
'enabled'=>1,
'position'=>47,
'checked'=>1),
186 'state.nom'=>array(
'label'=>
"StateShort",
'enabled'=>1,
'position'=>48),
187 'country.code_iso'=>array(
'label'=>
"Country",
'enabled'=>1,
'position'=>49),
188 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'enabled'=>$checkedtypetiers,
'position'=>50),
189 'u.login'=>array(
'label'=>
"AuthorRequest",
'enabled'=>1,
'position'=>51)
191 foreach ($object->fields as $key => $val) {
193 if (!empty($val[
'visible'])) {
194 $visible = (int)
dol_eval($val[
'visible'], 1);
195 $arrayfields[
'cf.'.$key] = array(
196 'label'=>$val[
'label'],
197 'checked'=>(($visible < 0) ? 0 : 1),
198 'enabled'=>(abs($visible) != 3 &&
dol_eval($val[
'enabled'], 1)),
199 'position'=>$val[
'position'],
200 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
205 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
212 $permissiontoread = ($user->rights->fournisseur->commande->lire || $user->rights->supplier_order->lire);
213 $permissiontoadd = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer);
214 $permissiontodelete = ($user->rights->fournisseur->commande->supprimer || $user->rights->supplier_order->supprimer);
215 $permissiontovalidate = $permissiontoadd;
216 $permissiontoapprove = ($user->rights->fournisseur->commande->approuver || $user->rights->supplier_order->approuver);
223 if (
GETPOST(
'cancel',
'alpha')) {
224 $action =
'list'; $massaction =
'';
226 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createsupplierbills') {
230 $parameters = array(
'socid'=>$socid);
231 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
236 if (empty($reshook)) {
238 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
241 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
245 $search_product_category =
'';
247 $search_refsupp =
'';
248 $search_company =
'';
253 $search_country =
'';
254 $search_type_thirdparty =
'';
255 $search_request_author =
'';
256 $search_total_ht =
'';
257 $search_total_tva =
'';
258 $search_total_ttc =
'';
259 $search_multicurrency_code =
'';
260 $search_multicurrency_tx =
'';
261 $search_multicurrency_montant_ht =
'';
262 $search_multicurrency_montant_tva =
'';
263 $search_multicurrency_montant_ttc =
'';
264 $search_project_ref =
'';
266 $search_date_order_startday =
'';
267 $search_date_order_startmonth =
'';
268 $search_date_order_startyear =
'';
269 $search_date_order_endday =
'';
270 $search_date_order_endmonth =
'';
271 $search_date_order_endyear =
'';
272 $search_date_order_start =
'';
273 $search_date_order_end =
'';
274 $search_date_delivery_startday =
'';
275 $search_date_delivery_startmonth =
'';
276 $search_date_delivery_startyear =
'';
277 $search_date_delivery_endday =
'';
278 $search_date_delivery_endmonth =
'';
279 $search_date_delivery_endyear =
'';
280 $search_date_delivery_start =
'';
281 $search_date_delivery_end =
'';
282 $search_date_valid_startday =
'';
283 $search_date_valid_startmonth =
'';
284 $search_date_valid_startyear =
'';
285 $search_date_valid_endday =
'';
286 $search_date_valid_endmonth =
'';
287 $search_date_valid_endyear =
'';
288 $search_date_valid_start =
'';
289 $search_date_valid_end =
'';
290 $search_date_approve_startday =
'';
291 $search_date_approve_startmonth =
'';
292 $search_date_approve_startyear =
'';
293 $search_date_approve_endday =
'';
294 $search_date_approve_endmonth =
'';
295 $search_date_approve_endyear =
'';
296 $search_date_approve_start =
'';
297 $search_date_approve_end =
'';
301 $search_array_options = array();
303 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
304 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
309 $objectclass =
'CommandeFournisseur';
310 $objectlabel =
'SupplierOrders';
311 $uploaddir = $conf->fournisseur->commande->dir_output;
312 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
314 if ($action ==
'validate' && $permissiontovalidate) {
315 if (
GETPOST(
'confirm') ==
'yes') {
320 foreach ($toselect as $checked) {
321 if ($objecttmp->fetch($checked)) {
322 if ($objecttmp->statut == 0) {
323 $objecttmp->date_commande =
dol_now();
324 $result = $objecttmp->valid($user);
327 if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $permissiontoapprove && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $objecttmp->hasProductsOrServices(1))) {
328 $result = $objecttmp->approve($user);
329 setEventMessages($langs->trans(
"SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
331 setEventMessages($langs->trans(
"SupplierOrderValidated"), array($objecttmp->ref));
341 if (!$error) $db->commit();
342 else $db->rollback();
347 if ($massaction ==
'confirm_createsupplierbills') {
348 $orders =
GETPOST(
'toselect',
'array');
349 $createbills_onebythird =
GETPOST(
'createbills_onebythird',
'int');
350 $validate_invoices =
GETPOST(
'validate_invoices',
'int');
353 $TFactThird = array();
355 $nb_bills_created = 0;
363 foreach ($orders as $id_order) {
365 if ($cmd->fetch($id_order) <= 0) {
370 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
371 $objecttmp = $TFactThird[$cmd->socid];
373 $objecttmp->socid = $cmd->socid;
374 $objecttmp->type = $objecttmp::TYPE_STANDARD;
375 $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
376 $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
377 $objecttmp->fk_project = $cmd->fk_project;
378 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
379 $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
380 $default_ref_supplier+=1;
383 if (empty($datefacture)) {
387 $objecttmp->date = $datefacture;
388 $objecttmp->origin =
'order_supplier';
389 $objecttmp->origin_id = $id_order;
391 $res = $objecttmp->create($user);
395 $lastref = $objecttmp->ref;
396 $lastid = $objecttmp->id;
400 if ($objecttmp->id > 0) {
401 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_element (";
403 $sql .=
", sourcetype";
404 $sql .=
", fk_target";
405 $sql .=
", targettype";
406 $sql .=
") VALUES (";
408 $sql .=
", '".$db->escape($objecttmp->origin).
"'";
409 $sql .=
", ".((int) $objecttmp->id);
410 $sql .=
", '".$db->escape($objecttmp->element).
"'";
413 if (!$db->query($sql)) {
418 $lines = $cmd->lines;
419 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
421 $lines = $cmd->lines;
425 $num = count($lines);
427 for ($i = 0; $i < $num; $i++) {
428 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
429 if ($lines[$i]->subprice < 0) {
432 $discount->fk_soc = $objecttmp->socid;
433 $discount->amount_ht = abs($lines[$i]->total_ht);
434 $discount->amount_tva = abs($lines[$i]->total_tva);
435 $discount->amount_ttc = abs($lines[$i]->total_ttc);
436 $discount->tva_tx = $lines[$i]->tva_tx;
437 $discount->fk_user = $user->id;
438 $discount->description = $desc;
439 $discountid = $discount->create($user);
440 if ($discountid > 0) {
441 $result = $objecttmp->insert_discount($discountid);
450 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
453 if ($lines[$i]->date_debut_prevue) {
454 $date_start = $lines[$i]->date_debut_prevue;
456 if ($lines[$i]->date_debut_reel) {
457 $date_start = $lines[$i]->date_debut_reel;
459 if ($lines[$i]->date_start) {
460 $date_start = $lines[$i]->date_start;
464 if ($lines[$i]->date_fin_prevue) {
465 $date_end = $lines[$i]->date_fin_prevue;
467 if ($lines[$i]->date_fin_reel) {
468 $date_end = $lines[$i]->date_fin_reel;
470 if ($lines[$i]->date_end) {
471 $date_end = $lines[$i]->date_end;
474 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
477 $result = $objecttmp->addline(
479 $lines[$i]->subprice,
481 $lines[$i]->localtax1_tx,
482 $lines[$i]->localtax2_tx,
484 $lines[$i]->fk_product,
485 $lines[$i]->remise_percent,
489 $lines[$i]->info_bits,
494 $lines[$i]->array_options,
496 $objecttmp->origin_id,
498 $lines[$i]->ref_supplier,
499 $lines[$i]->special_code,
510 if ($result > 0 && $lines[$i]->product_type == 9) {
511 $fk_parent_line = $result;
518 $cmd->classifyBilled($user);
520 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
521 $TFactThird[$cmd->socid] = $objecttmp;
523 $TFact[$objecttmp->id] = $objecttmp;
528 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
531 if (!$error && $validate_invoices) {
532 $massaction = $action =
'builddoc';
534 foreach ($TAllFact as &$objecttmp) {
535 $objecttmp->validate($user);
542 $id = $objecttmp->id;
546 $upload_dir = $conf->fournisseur->facture->dir_output;
547 $permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
551 $massaction = $action =
'confirm_createsupplierbills';
557 if ($nb_bills_created == 1) {
558 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
559 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?id='.urlencode($lastid).
'">'.$lastref.
'</a>', $texttoshow);
562 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
567 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
568 $param .=
'&contextpage='.urlencode($contextpage);
570 if ($limit > 0 && $limit != $conf->liste_limit) {
571 $param .=
'&limit='.urlencode($limit);
574 $param .=
'&sall='.urlencode($sall);
577 $param .=
'&socid='.urlencode($socid);
579 if ($search_status !=
'') {
580 $param .=
'&search_status='.urlencode($search_status);
582 if ($search_date_order_startday) {
583 $param .=
'&search_date_order_startday='.urlencode($search_date_order_startday);
585 if ($search_date_order_startmonth) {
586 $param .=
'&search_date_order_startmonth='.urlencode($search_date_order_startmonth);
588 if ($search_date_order_startyear) {
589 $param .=
'&search_date_order_startyear='.urlencode($search_date_order_startyear);
591 if ($search_date_order_endday) {
592 $param .=
'&search_date_order_endday='.urlencode($search_date_order_endday);
594 if ($search_date_order_endmonth) {
595 $param .=
'&search_date_order_endmonth='.urlencode($search_date_order_endmonth);
597 if ($search_date_order_endyear) {
598 $param .=
'&search_date_order_endyear='.urlencode($search_date_order_endyear);
600 if ($search_date_delivery_startday) {
601 $param .=
'&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
603 if ($search_date_delivery_startmonth) {
604 $param .=
'&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
606 if ($search_date_delivery_startyear) {
607 $param .=
'&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
609 if ($search_date_delivery_endday) {
610 $param .=
'&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
612 if ($search_date_delivery_endmonth) {
613 $param .=
'&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
615 if ($search_date_delivery_endyear) {
616 $param .=
'&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
618 if ($search_date_valid_startday) {
619 $param .=
'&search_date_valid_startday='.urlencode($search_date_valid_startday);
621 if ($search_date_valid_startmonth) {
622 $param .=
'&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
624 if ($search_date_valid_startyear) {
625 $param .=
'&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
627 if ($search_date_valid_endday) {
628 $param .=
'&search_date_valid_endday='.urlencode($search_date_valid_endday);
630 if ($search_date_valid_endmonth) {
631 $param .=
'&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
633 if ($search_date_valid_endyear) {
634 $param .=
'&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
636 if ($search_date_approve_startday) {
637 $param .=
'&search_date_approve_startday='.urlencode($search_date_approve_startday);
639 if ($search_date_approve_startmonth) {
640 $param .=
'&search_date_approve_startmonth='.urlencode($search_date_approve_startmonth);
642 if ($search_date_approve_startyear) {
643 $param .=
'&search_date_approve_startyear='.urlencode($search_date_approve_startyear);
645 if ($search_date_approve_endday) {
646 $param .=
'&search_date_approve_endday='.urlencode($search_date_approve_endday);
648 if ($search_date_approve_endmonth) {
649 $param .=
'&search_date_approve_endmonth='.urlencode($search_date_approve_endmonth);
651 if ($search_date_approve_endyear) {
652 $param .=
'&search_date_approve_endyear='.urlencode($search_date_approve_endyear);
655 $param .=
'&search_ref='.urlencode($search_ref);
657 if ($search_company) {
658 $param .=
'&search_company='.urlencode($search_company);
661 if ($search_user > 0) {
662 $param .=
'&search_user='.urlencode($search_user);
664 if ($search_sale > 0) {
665 $param .=
'&search_sale='.urlencode($search_sale);
667 if ($search_total_ht !=
'') {
668 $param .=
'&search_total_ht='.urlencode($search_total_ht);
670 if ($search_total_tva !=
'') {
671 $param .=
'&search_total_tva='.urlencode($search_total_tva);
673 if ($search_total_ttc !=
'') {
674 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
676 if ($search_project_ref >= 0) {
677 $param .=
"&search_project_ref=".urlencode($search_project_ref);
680 $param .=
'&show_files='.urlencode($show_files);
682 if ($optioncss !=
'') {
683 $param .=
'&optioncss='.urlencode($optioncss);
686 $param .=
'&billed='.urlencode($billed);
689 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
694 $_GET[
"origin"] = $_POST[
"origin"];
695 $_GET[
"originid"] = $_POST[
"originid"];
717 $title = $langs->trans(
"SuppliersOrders");
720 $fourn->fetch($socid);
721 $title .=
' - '.$fourn->name;
732 if ($search_billed > 0) {
733 $title .=
' - '.$langs->trans(
"Billed");
741 if ($sall || $search_product_category > 0) {
742 $sql =
'SELECT DISTINCT';
744 $sql .=
' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,';
745 $sql .=
" typent.code as typent_code,";
746 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
747 $sql .=
" cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,cf.date_valid, cf.date_approve,";
748 $sql .=
' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
749 $sql .=
' cf.date_creation as date_creation, cf.tms as date_update,';
750 $sql .=
' cf.note_public, cf.note_private,';
751 $sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
752 $sql .=
" u.firstname, u.lastname, u.photo, u.login, u.email as user_email, u.statut as user_status";
754 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
755 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
756 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
760 $parameters = array();
761 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
762 $sql .= $hookmanager->resPrint;
763 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
764 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
765 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
766 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
767 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
768 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
769 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cf.rowid = ef.fk_object)";
771 if ($sall || $search_product_category > 0) {
772 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
774 if ($search_product_category > 0) {
775 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=pd.fk_product';
777 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON cf.fk_user_author = u.rowid";
778 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = cf.fk_projet";
780 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
781 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
783 $parameters = array();
784 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
785 $sql .= $hookmanager->resPrint;
786 $sql .=
' WHERE cf.fk_soc = s.rowid';
787 $sql .=
' AND cf.entity IN ('.getEntity(
'supplier_order').
')';
789 $sql .=
" AND s.rowid = ".((int) $socid);
791 if (empty($user->rights->societe->client->voir) && !$socid) {
792 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
797 if ($search_refsupp) {
803 if ($search_company) {
806 if ($search_request_author) {
807 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_request_author);
809 if ($search_billed !=
'' && $search_billed >= 0) {
810 $sql .=
" AND cf.billed = ".((int) $search_billed);
812 if ($search_product_category > 0) {
813 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
816 if (
GETPOST(
'statut',
'intcomma') !==
'') {
817 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(
GETPOST(
'statut',
'intcomma')))).
")";
819 if ($search_status !=
'' && $search_status !=
'-1') {
820 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
822 if ($search_date_order_start) {
823 $sql .=
" AND cf.date_commande >= '".$db->idate($search_date_order_start).
"'";
825 if ($search_date_order_end) {
826 $sql .=
" AND cf.date_commande <= '".$db->idate($search_date_order_end).
"'";
828 if ($search_date_delivery_start) {
829 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_delivery_start).
"'";
831 if ($search_date_delivery_end) {
832 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_delivery_end).
"'";
834 if ($search_date_valid_start) {
835 $sql .=
" AND cf.date_commande >= '".$db->idate($search_date_valid_start).
"'";
837 if ($search_date_valid_end) {
838 $sql .=
" AND cf.date_commande <= '".$db->idate($search_date_valid_end).
"'";
840 if ($search_date_approve_start) {
841 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_approve_start).
"'";
843 if ($search_date_approve_end) {
844 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_approve_end).
"'";
855 if ($search_country) {
856 $sql .=
" AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).
')';
858 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
859 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
861 if ($search_company) {
864 if ($search_sale > 0) {
865 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
867 if ($search_user > 0) {
868 $sql .=
" AND EXISTS (";
869 $sql .=
" SELECT ec.rowid ";
870 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_contact as ec";
871 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
872 $sql .=
" WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
873 $sql .=
" AND tc.element = 'order_supplier' AND tc.source = 'internal'";
876 if ($search_total_ht !=
'') {
879 if ($search_total_tva !=
'') {
882 if ($search_total_ttc !=
'') {
885 if ($search_multicurrency_code !=
'') {
886 $sql .=
" AND cf.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
888 if ($search_multicurrency_tx !=
'') {
889 $sql .=
natural_search(
'cf.multicurrency_tx', $search_multicurrency_tx, 1);
891 if ($search_multicurrency_montant_ht !=
'') {
892 $sql .=
natural_search(
'cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
894 if ($search_multicurrency_montant_tva !=
'') {
895 $sql .=
natural_search(
'cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1);
897 if ($search_multicurrency_montant_ttc !=
'') {
898 $sql .=
natural_search(
'cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
900 if ($search_project_ref !=
'') {
904 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
906 $parameters = array();
907 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
908 $sql .= $hookmanager->resPrint;
910 $sql .= $db->order($sortfield, $sortorder);
913 $nbtotalofrecords =
'';
914 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
915 $result = $db->query($sql);
916 $nbtotalofrecords = $db->num_rows($result);
917 if (($page * $limit) > $nbtotalofrecords) {
923 $sql .= $db->plimit($limit + 1, $offset);
926 $resql = $db->query($sql);
928 $num = $db->num_rows(
$resql);
930 $arrayofselected = is_array($toselect) ? $toselect : array();
932 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
933 $obj = $db->fetch_object(
$resql);
935 header(
"Location: ".DOL_URL_ROOT.
'/fourn/commande/card.php?id='.$id);
942 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
943 $param .=
'&contextpage='.urlencode($contextpage);
945 if ($limit > 0 && $limit != $conf->liste_limit) {
946 $param .=
'&limit='.urlencode($limit);
949 $param .=
'&sall='.urlencode($sall);
952 $param .=
'&socid='.urlencode($socid);
955 $param .=
"&search_all=".urlencode($sall);
957 if ($search_date_order_startday) {
958 $param .=
'&search_date_order_startday='.urlencode($search_date_order_startday);
960 if ($search_date_order_startmonth) {
961 $param .=
'&search_date_order_startmonth='.urlencode($search_date_order_startmonth);
963 if ($search_date_order_startyear) {
964 $param .=
'&search_date_order_startyear='.urlencode($search_date_order_startyear);
966 if ($search_date_order_endday) {
967 $param .=
'&search_date_order_endday='.urlencode($search_date_order_endday);
969 if ($search_date_order_endmonth) {
970 $param .=
'&search_date_order_endmonth='.urlencode($search_date_order_endmonth);
972 if ($search_date_order_endyear) {
973 $param .=
'&search_date_order_endyear='.urlencode($search_date_order_endyear);
975 if ($search_date_delivery_startday) {
976 $param .=
'&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
978 if ($search_date_delivery_startmonth) {
979 $param .=
'&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
981 if ($search_date_delivery_startyear) {
982 $param .=
'&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
984 if ($search_date_delivery_endday) {
985 $param .=
'&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
987 if ($search_date_delivery_endmonth) {
988 $param .=
'&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
990 if ($search_date_delivery_endyear) {
991 $param .=
'&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
993 if ($search_date_valid_startday) {
994 $param .=
'&search_date_valid_startday='.urlencode($search_date_valid_startday);
996 if ($search_date_valid_startmonth) {
997 $param .=
'&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
999 if ($search_date_valid_startyear) {
1000 $param .=
'&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
1002 if ($search_date_valid_endday) {
1003 $param .=
'&search_date_valid_endday='.urlencode($search_date_valid_endday);
1005 if ($search_date_valid_endmonth) {
1006 $param .=
'&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
1008 if ($search_date_valid_endyear) {
1009 $param .=
'&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
1011 if ($search_date_approve_startday) {
1012 $param .=
'&search_date_approve_startday='.urlencode($search_date_approve_startday);
1014 if ($search_date_approve_startmonth) {
1015 $param .=
'&search_date_approve_startmonth='.urlencode($search_date_approve_startmonth);
1017 if ($search_date_approve_startyear) {
1018 $param .=
'&search_date_approve_startyear='.urlencode($search_date_approve_startyear);
1020 if ($search_date_approve_endday) {
1021 $param .=
'&search_date_approve_endday='.urlencode($search_date_approve_endday);
1023 if ($search_date_approve_endmonth) {
1024 $param .=
'&search_date_approve_endmonth='.urlencode($search_date_approve_endmonth);
1026 if ($search_date_approve_endyear) {
1027 $param .=
'&search_date_approve_endyear='.urlencode($search_date_approve_endyear);
1030 $param .=
'&search_ref='.urlencode($search_ref);
1032 if ($search_company) {
1033 $param .=
'&search_company='.urlencode($search_company);
1035 if ($search_user > 0) {
1036 $param .=
'&search_user='.urlencode($search_user);
1038 if ($search_request_author) {
1039 $param .=
'&search_request_author='.urlencode($search_request_author);
1041 if ($search_sale > 0) {
1042 $param .=
'&search_sale='.urlencode($search_sale);
1044 if ($search_total_ht !=
'') {
1045 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1047 if ($search_total_ttc !=
'') {
1048 $param .=
"&search_total_ttc=".urlencode($search_total_ttc);
1050 if ($search_multicurrency_code !=
'') {
1051 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1053 if ($search_multicurrency_tx !=
'') {
1054 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1056 if ($search_multicurrency_montant_ht !=
'') {
1057 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1059 if ($search_multicurrency_montant_tva !=
'') {
1060 $param .=
'&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva);
1062 if ($search_multicurrency_montant_ttc !=
'') {
1063 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1065 if ($search_refsupp) {
1066 $param .=
"&search_refsupp=".urlencode($search_refsupp);
1068 if ($search_status !=
'' && $search_status !=
'-1') {
1069 $param .=
"&search_status=".urlencode($search_status);
1071 if ($search_project_ref >= 0) {
1072 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1074 if ($search_billed !=
'') {
1075 $param .=
"&search_billed=".urlencode($search_billed);
1078 $param .=
'&show_files='.urlencode($show_files);
1080 if ($optioncss !=
'') {
1081 $param .=
'&optioncss='.urlencode($optioncss);
1083 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
1084 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1088 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1090 $parameters = array();
1091 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1092 $param .= $hookmanager->resPrint;
1095 $arrayofmassactions = array(
1096 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1097 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1098 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1101 if ($permissiontovalidate) {
1102 if ($permissiontoapprove && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) {
1103 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"ValidateAndApprove");
1105 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1109 if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
1110 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisSupplier");
1112 if ($permissiontodelete) {
1113 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1115 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1116 $arrayofmassactions = array();
1118 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1120 $url = DOL_URL_ROOT.
'/fourn/commande/card.php?action=create';
1122 $url .=
'&socid='.((int) $socid);
1123 $url .=
'&backtopage='.urlencode(DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.((
int) $socid));
1125 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewSupplierOrderShort'),
'',
'fa fa-plus-circle', $url,
'', $permissiontoadd);
1128 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1129 if ($optioncss !=
'') {
1130 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1132 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1133 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1134 print
'<input type="hidden" name="action" value="list">';
1135 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1136 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1137 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1138 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1140 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'supplier_order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1142 $topicmail =
"SendOrderRef";
1143 $modelmail =
"order_supplier_send";
1145 $trackid =
'sord'.$object->id;
1146 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1148 if ($massaction ==
'prevalidate') {
1149 print
$form->formconfirm($_SERVER[
"PHP_SELF"].$fieldstosearchall, $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1152 if ($massaction ==
'createbills') {
1154 print
'<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
1156 print
'<table class="noborder" width="100%" >';
1158 print
'<td class="titlefield">';
1159 print $langs->trans(
'DateInvoice');
1162 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1167 print $langs->trans(
'CreateOneBillByThird');
1170 print
$form->selectyesno(
'createbills_onebythird',
'', 1);
1175 print $langs->trans(
'ValidateInvoices');
1178 print
$form->selectyesno(
'validate_invoices', 1, 1);
1184 print
'<div class="center">';
1185 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1186 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1192 foreach ($fieldstosearchall as $key => $val) {
1193 $fieldstosearchall[$key] = $langs->trans($val);
1195 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
1198 $moreforfilter =
'';
1201 if ($user->rights->user->user->lire) {
1202 $langs->load(
"commercial");
1203 $moreforfilter .=
'<div class="divsearchfield">';
1204 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1205 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1206 $moreforfilter .=
'</div>';
1209 if ($user->rights->user->user->lire) {
1210 $moreforfilter .=
'<div class="divsearchfield">';
1211 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1212 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1213 $moreforfilter .=
'</div>';
1216 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
1217 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1218 $moreforfilter .=
'<div class="divsearchfield">';
1219 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1220 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1221 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0, 0,
'maxwidth300 widthcentpercentminusx', 1);
1222 $moreforfilter .=
'</div>';
1224 $parameters = array();
1225 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1226 if (empty($reshook)) {
1227 $moreforfilter .= $hookmanager->resPrint;
1229 $moreforfilter = $hookmanager->resPrint;
1232 if (!empty($moreforfilter)) {
1233 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1234 print $moreforfilter;
1238 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1239 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
1240 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1242 if (
GETPOST(
'autoselectall',
'int')) {
1243 $selectedfields .=
'<script>';
1244 $selectedfields .=
' $(document).ready(function() {';
1245 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1246 $selectedfields .=
' $("#checkforselects").click();';
1247 $selectedfields .=
' $("#massaction").val("createbills").change();';
1248 $selectedfields .=
' });';
1249 $selectedfields .=
'</script>';
1252 print
'<div class="div-table-responsive">';
1253 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1255 print
'<tr class="liste_titre_filter">';
1257 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1258 print
'<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.
'"></td>';
1261 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1262 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.
'"></td>';
1265 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1266 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.
'"></td>';
1269 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1270 print
'<td class="liste_titre">';
1271 print
'<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.
'">';
1275 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1276 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.
'"></td>';
1279 if (!empty($arrayfields[
's.town'][
'checked'])) {
1280 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.
'"></td>';
1283 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1284 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.
'"></td>';
1287 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1288 print
'<td class="liste_titre">';
1289 print
'<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1293 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1294 print
'<td class="liste_titre center">';
1295 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1299 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1300 print
'<td class="liste_titre maxwidthonsmartphone center">';
1301 print
$form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
1305 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1306 print
'<td class="liste_titre center">';
1307 print
'<div class="nowrap">';
1308 print
$form->selectDate($search_date_order_start ? $search_date_order_start : -1,
'search_date_order_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1310 print
'<div class="nowrap">';
1311 print
$form->selectDate($search_date_order_end ? $search_date_order_end : -1,
'search_date_order_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1316 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1317 print
'<td class="liste_titre center">';
1318 print
'<div class="nowrap">';
1319 print
$form->selectDate($search_date_delivery_start ? $search_date_delivery_start : -1,
'search_date_delivery_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1321 print
'<div class="nowrap">';
1322 print
$form->selectDate($search_date_delivery_end ? $search_date_delivery_end : -1,
'search_date_delivery_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1326 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1328 print
'<td class="liste_titre right">';
1329 print
'<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.
'">';
1332 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1334 print
'<td class="liste_titre right">';
1335 print
'<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.
'">';
1338 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1340 print
'<td class="liste_titre right">';
1341 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1344 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1346 print
'<td class="liste_titre">';
1347 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1350 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1352 print
'<td class="liste_titre">';
1353 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1356 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1358 print
'<td class="liste_titre right">';
1359 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1362 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1364 print
'<td class="liste_titre right">';
1365 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).
'">';
1368 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1370 print
'<td class="liste_titre right">';
1371 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1375 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1378 $parameters = array(
'arrayfields'=>$arrayfields);
1379 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1380 print $hookmanager->resPrint;
1382 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1383 print
'<td class="liste_titre">';
1387 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1388 print
'<td class="liste_titre">';
1392 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1393 print
'<td class="liste_titre right">';
1394 $formorder->selectSupplierOrderStatus($search_status, 1,
'search_status');
1398 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1399 print
'<td class="liste_titre center">';
1400 print
$form->selectyesno(
'search_billed', $search_billed, 1, 0, 1, 1);
1404 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1405 print
'<td class="liste_titre center">';
1406 print
'<div class="nowrap">';
1407 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'));
1409 print
'<div class="nowrap">';
1410 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'));
1415 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1416 print
'<td class="liste_titre center">';
1417 print
'<div class="nowrap">';
1418 print
$form->selectDate($search_date_approve_start ? $search_date_approve_start : -1,
'search_date_approve_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1420 print
'<div class="nowrap">';
1421 print
$form->selectDate($search_date_approve_end ? $search_date_approve_end : -1,
'search_date_approve_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1426 print
'<td class="liste_titre middle">';
1427 $searchpicto =
$form->showFilterButtons();
1434 print
'<tr class="liste_titre">';
1435 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1436 print_liste_field_titre($arrayfields[
'cf.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref",
"", $param,
'', $sortfield, $sortorder);
1438 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1439 print_liste_field_titre($arrayfields[
'cf.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref_supplier",
"", $param,
'', $sortfield, $sortorder,
'tdoverflowmax100imp ');
1441 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1442 print_liste_field_titre($arrayfields[
'cf.fk_projet'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1444 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1445 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
"u.login",
"", $param,
'', $sortfield, $sortorder);
1447 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1448 print_liste_field_titre($arrayfields[
'cf.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
1450 if (!empty($arrayfields[
's.town'][
'checked'])) {
1451 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1453 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1454 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1456 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1457 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1459 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1460 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1462 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1463 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1465 if (!empty($arrayfields[
'cf.fk_author'][
'checked'])) {
1466 print_liste_field_titre($arrayfields[
'cf.fk_author'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_author",
"", $param,
'', $sortfield, $sortorder);
1468 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1469 print_liste_field_titre($arrayfields[
'cf.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_commande",
"", $param,
'', $sortfield, $sortorder,
'center ');
1471 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1472 print_liste_field_titre($arrayfields[
'cf.date_livraison'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1474 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1475 print_liste_field_titre($arrayfields[
'cf.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
1477 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1478 print_liste_field_titre($arrayfields[
'cf.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
1480 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1481 print_liste_field_titre($arrayfields[
'cf.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
1483 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1484 print_liste_field_titre($arrayfields[
'cf.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1486 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1487 print_liste_field_titre($arrayfields[
'cf.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1489 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1490 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1492 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1493 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1495 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1496 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1499 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1501 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1502 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1503 print $hookmanager->resPrint;
1504 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1505 print_liste_field_titre($arrayfields[
'cf.date_creation'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1507 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1508 print_liste_field_titre($arrayfields[
'cf.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1510 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1511 print_liste_field_titre($arrayfields[
'cf.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
1513 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1514 print_liste_field_titre($arrayfields[
'cf.billed'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.billed',
'', $param,
'', $sortfield, $sortorder,
'center ');
1516 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1517 print_liste_field_titre($arrayfields[
'cf.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
1519 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1520 print_liste_field_titre($arrayfields[
'cf.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_approve',
'', $param,
'', $sortfield, $sortorder,
'center ');
1522 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1528 $productstat_cache = array();
1530 $userstatic =
new User($db);
1532 $projectstatic =
new Project($db);
1535 $totalarray = array(
'nbfield' => 0,
'val' => array(),
'pos' => array());
1536 $totalarray[
'val'][
'cf.total_ht'] = 0;
1537 $totalarray[
'val'][
'cf.total_ttc'] = 0;
1538 $totalarray[
'val'][
'cf.total_tva'] = 0;
1540 $imaxinloop = ($limit ? min($num, $limit) : $num);
1541 while ($i < $imaxinloop) {
1542 $obj = $db->fetch_object(
$resql);
1550 $objectstatic->id = $obj->rowid;
1551 $objectstatic->ref = $obj->ref;
1552 $objectstatic->socid = $obj->socid;
1553 $objectstatic->ref_supplier = $obj->ref_supplier;
1554 $objectstatic->socid = $obj->socid;
1555 $objectstatic->total_ht = $obj->total_ht;
1556 $objectstatic->total_tva = $obj->total_tva;
1557 $objectstatic->total_ttc = $obj->total_ttc;
1558 $objectstatic->date_commande = $db->jdate($obj->date_commande);
1559 $objectstatic->delivery_date = $db->jdate($obj->date_livraison);
1560 $objectstatic->note_public = $obj->note_public;
1561 $objectstatic->note_private = $obj->note_private;
1562 $objectstatic->statut = $obj->fk_statut;
1564 print
'<tr class="oddeven">';
1567 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1568 print
'<td class="nowrap">';
1571 print $objectstatic->getNomUrl(1,
'', 0, -1, 1);
1575 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1579 $totalarray[
'nbfield']++;
1583 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1584 print
'<td>'.$obj->ref_supplier.
'</td>'.
"\n";
1586 $totalarray[
'nbfield']++;
1590 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1591 $projectstatic->id = $obj->project_id;
1592 $projectstatic->ref = $obj->project_ref;
1593 $projectstatic->title = $obj->project_title;
1595 if ($obj->project_id > 0) {
1596 print $projectstatic->getNomUrl(1);
1600 $totalarray[
'nbfield']++;
1604 $userstatic->id = $obj->fk_user_author;
1605 $userstatic->lastname = $obj->lastname;
1606 $userstatic->firstname = $obj->firstname;
1607 $userstatic->login = $obj->login;
1608 $userstatic->photo = $obj->photo;
1609 $userstatic->email = $obj->user_email;
1610 $userstatic->statut = $obj->user_status;
1611 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1612 print
'<td class="tdoverflowmax150">';
1613 if ($userstatic->id) {
1614 print $userstatic->getNomUrl(1);
1618 $totalarray[
'nbfield']++;
1622 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1623 print
'<td class="tdoverflowmax150">';
1624 $thirdpartytmp->id = $obj->socid;
1625 $thirdpartytmp->name = $obj->name;
1626 $thirdpartytmp->email = $obj->email;
1627 print $thirdpartytmp->getNomUrl(1,
'supplier');
1630 $totalarray[
'nbfield']++;
1634 if (!empty($arrayfields[
's.town'][
'checked'])) {
1639 $totalarray[
'nbfield']++;
1643 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1648 $totalarray[
'nbfield']++;
1652 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1653 print
"<td>".$obj->state_name.
"</td>\n";
1655 $totalarray[
'nbfield']++;
1659 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1660 print
'<td class="center">';
1661 $tmparray =
getCountry($obj->fk_pays,
'all');
1662 print $tmparray[
'label'];
1665 $totalarray[
'nbfield']++;
1669 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1670 print
'<td class="center">';
1671 if (empty($typenArray)) {
1672 $typenArray = $formcompany->typent_array(1);
1674 print $typenArray[$obj->typent_code];
1677 $totalarray[
'nbfield']++;
1682 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1683 print
'<td class="center">';
1685 if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1686 if ($objectstatic->hasDelay()) {
1687 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1692 $totalarray[
'nbfield']++;
1696 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1697 print
'<td class="center">';
1699 if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1700 if ($objectstatic->hasDelay()) {
1701 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1706 $totalarray[
'nbfield']++;
1710 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1711 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1713 $totalarray[
'nbfield']++;
1716 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ht';
1718 $totalarray[
'val'][
'cf.total_ht'] += $obj->total_ht;
1721 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1722 print
'<td class="right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
1724 $totalarray[
'nbfield']++;
1727 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_tva';
1729 $totalarray[
'val'][
'cf.total_tva'] += $obj->total_tva;
1732 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1733 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1735 $totalarray[
'nbfield']++;
1738 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ttc';
1740 $totalarray[
'val'][
'cf.total_ttc'] += $obj->total_ttc;
1744 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1745 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1747 $totalarray[
'nbfield']++;
1752 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1753 print
'<td class="nowrap">';
1754 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1757 $totalarray[
'nbfield']++;
1761 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1762 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
1764 $totalarray[
'nbfield']++;
1768 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1769 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva).
"</span></td>\n";
1771 $totalarray[
'nbfield']++;
1775 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1776 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
1778 $totalarray[
'nbfield']++;
1783 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1785 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1786 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1787 print $hookmanager->resPrint;
1789 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1790 print
'<td class="center nowrap">';
1791 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1794 $totalarray[
'nbfield']++;
1798 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1799 print
'<td class="center nowrap">';
1800 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1803 $totalarray[
'nbfield']++;
1807 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1808 print
'<td class="right nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).
'</td>';
1810 $totalarray[
'nbfield']++;
1814 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1815 print
'<td class="center">'.yn($obj->billed).
'</td>';
1817 $totalarray[
'nbfield']++;
1822 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1823 print
'<td class="center">';
1827 $totalarray[
'nbfield']++;
1831 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1832 print
'<td class="center">';
1836 $totalarray[
'nbfield']++;
1841 print
'<td class="nowrap center">';
1842 if ($massactionbutton || $massaction) {
1844 if (in_array($obj->rowid, $arrayofselected)) {
1847 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1851 $totalarray[
'nbfield']++;
1856 $total += $obj->total_ht;
1857 $subtotal += $obj->total_ht;
1862 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1867 foreach ($arrayfields as $key => $val) {
1868 if (!empty($val[
'checked'])) {
1872 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1877 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
1878 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
1879 print $hookmanager->resPrint;
1881 print
'</table>'.
"\n";
1884 print
'</form>'.
"\n";
1886 $hidegeneratedfilelistifempty = 1;
1887 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1888 $hidegeneratedfilelistifempty = 0;
1892 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1893 $urlsource .= str_replace(
'&',
'&', $param);
1895 $filedir = $diroutputmassaction;
1896 $genallowed = $permissiontoread;
1897 $delallowed = $permissiontoadd;
1899 print $formfile->showdocuments(
'massfilesarea_supplier_order',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);