36 require
'../../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
50 $langs->loadLangs(array(
"orders",
"sendings",
'deliveries',
'companies',
'compta',
'bills',
'projects',
'suppliers',
'products'));
53 $action =
GETPOST(
'action',
'aZ09');
54 $massaction =
GETPOST(
'massaction',
'alpha');
55 $show_files =
GETPOST(
'show_files',
'int');
56 $confirm =
GETPOST(
'confirm',
'alpha');
57 $toselect =
GETPOST(
'toselect',
'array');
58 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierorderlist';
61 $search_date_order_startday =
GETPOST(
'search_date_order_startday',
'int');
62 $search_date_order_startmonth =
GETPOST(
'search_date_order_startmonth',
'int');
63 $search_date_order_startyear =
GETPOST(
'search_date_order_startyear',
'int');
64 $search_date_order_endday =
GETPOST(
'search_date_order_endday',
'int');
65 $search_date_order_endmonth =
GETPOST(
'search_date_order_endmonth',
'int');
66 $search_date_order_endyear =
GETPOST(
'search_date_order_endyear',
'int');
67 $search_date_order_start =
dol_mktime(0, 0, 0, $search_date_order_startmonth, $search_date_order_startday, $search_date_order_startyear);
68 $search_date_order_end =
dol_mktime(23, 59, 59, $search_date_order_endmonth, $search_date_order_endday, $search_date_order_endyear);
70 $search_date_delivery_startday =
GETPOST(
'search_date_delivery_startday',
'int');
71 $search_date_delivery_startmonth =
GETPOST(
'search_date_delivery_startmonth',
'int');
72 $search_date_delivery_startyear =
GETPOST(
'search_date_delivery_startyear',
'int');
73 $search_date_delivery_endday =
GETPOST(
'search_date_delivery_endday',
'int');
74 $search_date_delivery_endmonth =
GETPOST(
'search_date_delivery_endmonth',
'int');
75 $search_date_delivery_endyear =
GETPOST(
'search_date_delivery_endyear',
'int');
76 $search_date_delivery_start =
dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear);
77 $search_date_delivery_end =
dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
79 $search_date_valid_startday =
GETPOST(
'search_date_valid_startday',
'int');
80 $search_date_valid_startmonth =
GETPOST(
'search_date_valid_startmonth',
'int');
81 $search_date_valid_startyear =
GETPOST(
'search_date_valid_startyear',
'int');
82 $search_date_valid_endday =
GETPOST(
'search_date_valid_endday',
'int');
83 $search_date_valid_endmonth =
GETPOST(
'search_date_valid_endmonth',
'int');
84 $search_date_valid_endyear =
GETPOST(
'search_date_valid_endyear',
'int');
85 $search_date_valid_start =
dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear);
86 $search_date_valid_end =
dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
88 $search_date_approve_startday =
GETPOST(
'search_date_approve_startday',
'int');
89 $search_date_approve_startmonth =
GETPOST(
'search_date_approve_startmonth',
'int');
90 $search_date_approve_startyear =
GETPOST(
'search_date_approve_startyear',
'int');
91 $search_date_approve_endday =
GETPOST(
'search_date_approve_endday',
'int');
92 $search_date_approve_endmonth =
GETPOST(
'search_date_approve_endmonth',
'int');
93 $search_date_approve_endyear =
GETPOST(
'search_date_approve_endyear',
'int');
94 $search_date_approve_start =
dol_mktime(0, 0, 0, $search_date_approve_startmonth, $search_date_approve_startday, $search_date_approve_startyear);
95 $search_date_approve_end =
dol_mktime(23, 59, 59, $search_date_approve_endmonth, $search_date_approve_endday, $search_date_approve_endyear);
97 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
99 $search_product_category =
GETPOST(
'search_product_category',
'int');
100 $search_ref =
GETPOST(
'search_ref',
'alpha');
101 $search_refsupp =
GETPOST(
'search_refsupp',
'alpha');
102 $search_company =
GETPOST(
'search_company',
'alpha');
103 $search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
104 $search_town =
GETPOST(
'search_town',
'alpha');
105 $search_zip =
GETPOST(
'search_zip',
'alpha');
106 $search_state =
GETPOST(
"search_state",
'alpha');
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_request_author =
GETPOST(
'search_request_author',
'alpha');
111 $search_ht =
GETPOST(
'search_ht',
'alpha');
112 $search_ttc =
GETPOST(
'search_ttc',
'alpha');
113 $optioncss =
GETPOST(
'optioncss',
'alpha');
114 $socid =
GETPOST(
'socid',
'int');
115 $search_sale =
GETPOST(
'search_sale',
'int');
116 $search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
117 $search_total_tva =
GETPOST(
'search_total_tva',
'alpha');
118 $search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
119 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
120 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
121 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
122 $search_multicurrency_montant_tva =
GETPOST(
'search_multicurrency_montant_tva',
'alpha');
123 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
124 $optioncss =
GETPOST(
'optioncss',
'alpha');
125 $search_billed =
GETPOST(
'search_billed',
'int');
126 $search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
127 $search_btn =
GETPOST(
'button_search',
'alpha');
128 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
131 $search_status = join(
',',
GETPOST(
'search_status',
'array:intcomma'));
133 $search_status = (
GETPOST(
'search_status',
'intcomma') !=
'' ?
GETPOST(
'search_status',
'intcomma') :
GETPOST(
'statut',
'intcomma'));
137 $orderid =
GETPOST(
'orderid',
'int');
139 $socid = $user->socid;
141 $result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
143 $diroutputmassaction = $conf->fournisseur->commande->dir_output.
'/temp/massgeneration/'.$user->id;
145 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
146 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
147 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
149 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction ===
'0')) {
152 $offset = $limit * $page;
153 $pageprev = $page - 1;
154 $pagenext = $page + 1;
156 $sortfield =
'cf.ref';
164 $hookmanager->initHooks(array(
'supplierorderlist'));
168 $extrafields->fetch_name_optionals_label($object->table_element);
170 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
173 $fieldstosearchall = array();
174 foreach ($object->fields as $key => $val) {
175 if (!empty($val[
'searchall'])) {
176 $fieldstosearchall[
'cf.'.$key] = $val[
'label'];
179 $fieldstosearchall[
'pd.description'] =
'Description';
180 $fieldstosearchall[
's.nom'] =
"ThirdParty";
181 $fieldstosearchall[
's.name_alias'] =
"AliasNameShort";
182 $fieldstosearchall[
's.zip'] =
"Zip";
183 $fieldstosearchall[
's.town'] =
"Town";
184 if (empty($user->socid)) {
185 $fieldstosearchall[
"cf.note_private"] =
"NotePrivate";
188 $checkedtypetiers = 0;
191 $arrayfields = array(
192 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'position'=>47,
'checked'=>0),
193 's.town'=>array(
'label'=>
"Town",
'enabled'=>1,
'position'=>47,
'checked'=>1),
194 's.zip'=>array(
'label'=>
"Zip",
'enabled'=>1,
'position'=>47,
'checked'=>1),
195 'state.nom'=>array(
'label'=>
"StateShort",
'enabled'=>1,
'position'=>48),
196 'country.code_iso'=>array(
'label'=>
"Country",
'enabled'=>1,
'position'=>49),
197 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'enabled'=>$checkedtypetiers,
'position'=>50),
198 'u.login'=>array(
'label'=>
"AuthorRequest",
'enabled'=>1,
'position'=>51),
199 'cf.note_public'=>array(
'label'=>
'NotePublic',
'checked'=>0,
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES')),
'position'=>100),
200 'cf.note_private'=>array(
'label'=>
'NotePrivate',
'checked'=>0,
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'position'=>110),
202 foreach ($object->fields as $key => $val) {
204 if (!empty($val[
'visible'])) {
205 $visible = (int)
dol_eval($val[
'visible'], 1);
206 $arrayfields[
'cf.'.$key] = array(
207 'label'=>$val[
'label'],
208 'checked'=>(($visible < 0) ? 0 : 1),
209 'enabled'=>(abs($visible) != 3 &&
dol_eval($val[
'enabled'], 1)),
210 'position'=>$val[
'position'],
211 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
216 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
223 $permissiontoread = ($user->rights->fournisseur->commande->lire || $user->rights->supplier_order->lire);
224 $permissiontoadd = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer);
225 $permissiontodelete = ($user->rights->fournisseur->commande->supprimer || $user->rights->supplier_order->supprimer);
226 $permissiontovalidate = $permissiontoadd;
227 $permissiontoapprove = ($user->rights->fournisseur->commande->approuver || $user->rights->supplier_order->approuver);
234 if (
GETPOST(
'cancel',
'alpha')) {
235 $action =
'list'; $massaction =
'';
237 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createsupplierbills') {
241 $parameters = array(
'socid'=>$socid);
242 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
247 if (empty($reshook)) {
249 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
252 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
256 $search_product_category =
'';
258 $search_refsupp =
'';
259 $search_company =
'';
260 $search_company_alias =
'';
265 $search_country =
'';
266 $search_type_thirdparty =
'';
267 $search_request_author =
'';
268 $search_total_ht =
'';
269 $search_total_tva =
'';
270 $search_total_ttc =
'';
271 $search_multicurrency_code =
'';
272 $search_multicurrency_tx =
'';
273 $search_multicurrency_montant_ht =
'';
274 $search_multicurrency_montant_tva =
'';
275 $search_multicurrency_montant_ttc =
'';
276 $search_project_ref =
'';
278 $search_date_order_startday =
'';
279 $search_date_order_startmonth =
'';
280 $search_date_order_startyear =
'';
281 $search_date_order_endday =
'';
282 $search_date_order_endmonth =
'';
283 $search_date_order_endyear =
'';
284 $search_date_order_start =
'';
285 $search_date_order_end =
'';
286 $search_date_delivery_startday =
'';
287 $search_date_delivery_startmonth =
'';
288 $search_date_delivery_startyear =
'';
289 $search_date_delivery_endday =
'';
290 $search_date_delivery_endmonth =
'';
291 $search_date_delivery_endyear =
'';
292 $search_date_delivery_start =
'';
293 $search_date_delivery_end =
'';
294 $search_date_valid_startday =
'';
295 $search_date_valid_startmonth =
'';
296 $search_date_valid_startyear =
'';
297 $search_date_valid_endday =
'';
298 $search_date_valid_endmonth =
'';
299 $search_date_valid_endyear =
'';
300 $search_date_valid_start =
'';
301 $search_date_valid_end =
'';
302 $search_date_approve_startday =
'';
303 $search_date_approve_startmonth =
'';
304 $search_date_approve_startyear =
'';
305 $search_date_approve_endday =
'';
306 $search_date_approve_endmonth =
'';
307 $search_date_approve_endyear =
'';
308 $search_date_approve_start =
'';
309 $search_date_approve_end =
'';
313 $search_array_options = array();
315 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
316 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
321 $objectclass =
'CommandeFournisseur';
322 $objectlabel =
'SupplierOrders';
323 $uploaddir = $conf->fournisseur->commande->dir_output;
324 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
326 if ($action ==
'validate' && $permissiontovalidate) {
327 if (
GETPOST(
'confirm') ==
'yes') {
332 foreach ($toselect as $checked) {
333 if ($objecttmp->fetch($checked)) {
334 if ($objecttmp->statut == 0) {
335 $objecttmp->date_commande =
dol_now();
336 $result = $objecttmp->valid($user);
339 if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $permissiontoapprove && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $objecttmp->hasProductsOrServices(1))) {
340 $result = $objecttmp->approve($user);
341 setEventMessages($langs->trans(
"SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
343 setEventMessages($langs->trans(
"SupplierOrderValidated"), array($objecttmp->ref));
353 if (!$error) $db->commit();
354 else $db->rollback();
359 if ($massaction ==
'confirm_createsupplierbills') {
360 $orders =
GETPOST(
'toselect',
'array');
361 $createbills_onebythird =
GETPOST(
'createbills_onebythird',
'int');
362 $validate_invoices =
GETPOST(
'validate_invoices',
'int');
366 $TFactThird = array();
368 $nb_bills_created = 0;
376 foreach ($orders as $id_order) {
378 if ($cmd->fetch($id_order) <= 0) {
383 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
384 $objecttmp = $TFactThird[$cmd->socid];
386 $objecttmp->socid = $cmd->socid;
387 $objecttmp->type = $objecttmp::TYPE_STANDARD;
388 $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
389 $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
390 $objecttmp->fk_project = $cmd->fk_project;
391 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
392 $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
393 $default_ref_supplier+=1;
396 if (empty($datefacture)) {
400 $objecttmp->date = $datefacture;
401 $objecttmp->origin =
'order_supplier';
402 $objecttmp->origin_id = $id_order;
404 $res = $objecttmp->create($user);
408 $lastref = $objecttmp->ref;
409 $lastid = $objecttmp->id;
413 if ($objecttmp->id > 0) {
414 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_element (";
416 $sql .=
", sourcetype";
417 $sql .=
", fk_target";
418 $sql .=
", targettype";
419 $sql .=
") VALUES (";
421 $sql .=
", '".$db->escape($objecttmp->origin).
"'";
422 $sql .=
", ".((int) $objecttmp->id);
423 $sql .=
", '".$db->escape($objecttmp->element).
"'";
426 if (!$db->query($sql)) {
431 $lines = $cmd->lines;
432 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
434 $lines = $cmd->lines;
438 $num = count($lines);
440 for ($i = 0; $i < $num; $i++) {
441 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
442 if ($lines[$i]->subprice < 0) {
445 $discount->fk_soc = $objecttmp->socid;
446 $discount->amount_ht = abs($lines[$i]->total_ht);
447 $discount->amount_tva = abs($lines[$i]->total_tva);
448 $discount->amount_ttc = abs($lines[$i]->total_ttc);
449 $discount->tva_tx = $lines[$i]->tva_tx;
450 $discount->fk_user = $user->id;
451 $discount->description = $desc;
452 $discountid = $discount->create($user);
453 if ($discountid > 0) {
454 $result = $objecttmp->insert_discount($discountid);
463 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
466 if ($lines[$i]->date_debut_prevue) {
467 $date_start = $lines[$i]->date_debut_prevue;
469 if ($lines[$i]->date_debut_reel) {
470 $date_start = $lines[$i]->date_debut_reel;
472 if ($lines[$i]->date_start) {
473 $date_start = $lines[$i]->date_start;
477 if ($lines[$i]->date_fin_prevue) {
478 $date_end = $lines[$i]->date_fin_prevue;
480 if ($lines[$i]->date_fin_reel) {
481 $date_end = $lines[$i]->date_fin_reel;
483 if ($lines[$i]->date_end) {
484 $date_end = $lines[$i]->date_end;
487 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
490 $result = $objecttmp->addline(
492 $lines[$i]->subprice,
494 $lines[$i]->localtax1_tx,
495 $lines[$i]->localtax2_tx,
497 $lines[$i]->fk_product,
498 $lines[$i]->remise_percent,
502 $lines[$i]->info_bits,
508 $lines[$i]->array_options,
511 $lines[$i]->fk_commande,
513 $lines[$i]->ref_supplier,
514 $lines[$i]->special_code,
525 if ($result > 0 && $lines[$i]->product_type == 9) {
526 $fk_parent_line = $result;
533 $cmd->classifyBilled($user);
535 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
536 $TFactThird[$cmd->socid] = $objecttmp;
538 $TFact[$objecttmp->id] = $objecttmp;
543 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
546 if (!$error && $validate_invoices) {
547 $massaction = $action =
'builddoc';
549 foreach ($TAllFact as &$objecttmp) {
550 $objecttmp->validate($user);
557 $id = $objecttmp->id;
561 $upload_dir = $conf->fournisseur->facture->dir_output;
562 $permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
566 $massaction = $action =
'confirm_createsupplierbills';
572 if ($nb_bills_created == 1) {
573 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
574 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?id='.urlencode($lastid).
'">'.$lastref.
'</a>', $texttoshow);
577 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
582 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
583 $param .=
'&contextpage='.urlencode($contextpage);
585 if ($limit > 0 && $limit != $conf->liste_limit) {
586 $param .=
'&limit='.urlencode($limit);
589 $param .=
'&sall='.urlencode($sall);
592 $param .=
'&socid='.urlencode($socid);
594 if ($search_status !=
'') {
595 $param .=
'&search_status='.urlencode($search_status);
597 if ($search_date_order_startday) {
598 $param .=
'&search_date_order_startday='.urlencode($search_date_order_startday);
600 if ($search_date_order_startmonth) {
601 $param .=
'&search_date_order_startmonth='.urlencode($search_date_order_startmonth);
603 if ($search_date_order_startyear) {
604 $param .=
'&search_date_order_startyear='.urlencode($search_date_order_startyear);
606 if ($search_date_order_endday) {
607 $param .=
'&search_date_order_endday='.urlencode($search_date_order_endday);
609 if ($search_date_order_endmonth) {
610 $param .=
'&search_date_order_endmonth='.urlencode($search_date_order_endmonth);
612 if ($search_date_order_endyear) {
613 $param .=
'&search_date_order_endyear='.urlencode($search_date_order_endyear);
615 if ($search_date_delivery_startday) {
616 $param .=
'&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
618 if ($search_date_delivery_startmonth) {
619 $param .=
'&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
621 if ($search_date_delivery_startyear) {
622 $param .=
'&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
624 if ($search_date_delivery_endday) {
625 $param .=
'&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
627 if ($search_date_delivery_endmonth) {
628 $param .=
'&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
630 if ($search_date_delivery_endyear) {
631 $param .=
'&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
633 if ($search_date_valid_startday) {
634 $param .=
'&search_date_valid_startday='.urlencode($search_date_valid_startday);
636 if ($search_date_valid_startmonth) {
637 $param .=
'&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
639 if ($search_date_valid_startyear) {
640 $param .=
'&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
642 if ($search_date_valid_endday) {
643 $param .=
'&search_date_valid_endday='.urlencode($search_date_valid_endday);
645 if ($search_date_valid_endmonth) {
646 $param .=
'&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
648 if ($search_date_valid_endyear) {
649 $param .=
'&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
651 if ($search_date_approve_startday) {
652 $param .=
'&search_date_approve_startday='.urlencode($search_date_approve_startday);
654 if ($search_date_approve_startmonth) {
655 $param .=
'&search_date_approve_startmonth='.urlencode($search_date_approve_startmonth);
657 if ($search_date_approve_startyear) {
658 $param .=
'&search_date_approve_startyear='.urlencode($search_date_approve_startyear);
660 if ($search_date_approve_endday) {
661 $param .=
'&search_date_approve_endday='.urlencode($search_date_approve_endday);
663 if ($search_date_approve_endmonth) {
664 $param .=
'&search_date_approve_endmonth='.urlencode($search_date_approve_endmonth);
666 if ($search_date_approve_endyear) {
667 $param .=
'&search_date_approve_endyear='.urlencode($search_date_approve_endyear);
670 $param .=
'&search_ref='.urlencode($search_ref);
672 if ($search_company) {
673 $param .=
'&search_company='.urlencode($search_company);
675 if ($search_company_alias) {
676 $param .=
'&search_company_alias='.urlencode($search_company_alias);
679 if ($search_user > 0) {
680 $param .=
'&search_user='.urlencode($search_user);
682 if ($search_sale > 0) {
683 $param .=
'&search_sale='.urlencode($search_sale);
685 if ($search_total_ht !=
'') {
686 $param .=
'&search_total_ht='.urlencode($search_total_ht);
688 if ($search_total_tva !=
'') {
689 $param .=
'&search_total_tva='.urlencode($search_total_tva);
691 if ($search_total_ttc !=
'') {
692 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
694 if ($search_project_ref >= 0) {
695 $param .=
"&search_project_ref=".urlencode($search_project_ref);
698 $param .=
'&show_files='.urlencode($show_files);
700 if ($optioncss !=
'') {
701 $param .=
'&optioncss='.urlencode($optioncss);
704 $param .=
'&billed='.urlencode($billed);
707 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
712 $_GET[
"origin"] = $_POST[
"origin"];
713 $_GET[
"originid"] = $_POST[
"originid"];
735 $title = $langs->trans(
"SuppliersOrders");
738 $fourn->fetch($socid);
739 $title .=
' - '.$fourn->name;
750 if ($search_billed > 0) {
751 $title .=
' - '.$langs->trans(
"Billed");
757 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
758 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
762 $sql =
'SELECT DISTINCT';
764 $sql .=
' s.rowid as socid, s.nom as name, s.name_alias as alias, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.email,';
765 $sql .=
" typent.code as typent_code,";
766 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
767 $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,";
768 $sql .=
' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
769 $sql .=
' cf.date_creation as date_creation, cf.tms as date_update,';
770 $sql .=
' cf.note_public, cf.note_private,';
771 $sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
772 $sql .=
" u.firstname, u.lastname, u.photo, u.login, u.email as user_email, u.statut as user_status";
774 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
775 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
776 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
780 $parameters = array();
781 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
782 $sql .= $hookmanager->resPrint;
786 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
787 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
788 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
789 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
790 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
791 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
792 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cf.rowid = ef.fk_object)";
795 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
797 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON cf.fk_user_author = u.rowid";
798 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = cf.fk_projet";
800 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
801 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
803 $parameters = array();
804 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
805 $sql .= $hookmanager->resPrint;
806 $sql .=
' WHERE cf.fk_soc = s.rowid';
807 $sql .=
' AND cf.entity IN ('.getEntity(
'supplier_order').
')';
809 $sql .=
" AND s.rowid = ".((int) $socid);
811 if (empty($user->rights->societe->client->voir) && !$socid) {
812 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
817 if ($search_refsupp) {
823 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
824 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
826 if ($search_company) {
829 if ($search_company_alias) {
833 if ($search_request_author) {
834 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_request_author);
836 if ($search_billed !=
'' && $search_billed >= 0) {
837 $sql .=
" AND cf.billed = ".((int) $search_billed);
840 if (
GETPOST(
'statut',
'intcomma') !==
'') {
841 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(
GETPOST(
'statut',
'intcomma')))).
")";
843 if ($search_status !=
'' && $search_status !=
'-1') {
844 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
846 if ($search_date_order_start) {
847 $sql .=
" AND cf.date_commande >= '".$db->idate($search_date_order_start).
"'";
849 if ($search_date_order_end) {
850 $sql .=
" AND cf.date_commande <= '".$db->idate($search_date_order_end).
"'";
852 if ($search_date_delivery_start) {
853 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_delivery_start).
"'";
855 if ($search_date_delivery_end) {
856 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_delivery_end).
"'";
858 if ($search_date_valid_start) {
859 $sql .=
" AND cf.date_commande >= '".$db->idate($search_date_valid_start).
"'";
861 if ($search_date_valid_end) {
862 $sql .=
" AND cf.date_commande <= '".$db->idate($search_date_valid_end).
"'";
864 if ($search_date_approve_start) {
865 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_approve_start).
"'";
867 if ($search_date_approve_end) {
868 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_approve_end).
"'";
879 if ($search_country) {
880 $sql .=
" AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).
')';
882 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
883 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
885 if ($search_sale > 0) {
886 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
888 if ($search_user > 0) {
889 $sql .=
" AND EXISTS (";
890 $sql .=
" SELECT ec.rowid ";
891 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_contact as ec";
892 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
893 $sql .=
" WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
894 $sql .=
" AND tc.element = 'order_supplier' AND tc.source = 'internal'";
897 if ($search_total_ht !=
'') {
900 if ($search_total_tva !=
'') {
903 if ($search_total_ttc !=
'') {
906 if ($search_multicurrency_code !=
'') {
907 $sql .=
" AND cf.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
909 if ($search_multicurrency_tx !=
'') {
910 $sql .=
natural_search(
'cf.multicurrency_tx', $search_multicurrency_tx, 1);
912 if ($search_multicurrency_montant_ht !=
'') {
913 $sql .=
natural_search(
'cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
915 if ($search_multicurrency_montant_tva !=
'') {
916 $sql .=
natural_search(
'cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1);
918 if ($search_multicurrency_montant_ttc !=
'') {
919 $sql .=
natural_search(
'cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
921 if ($search_project_ref !=
'') {
925 $searchCategoryProductOperator = -1;
926 $searchCategoryProductList = array($search_product_category);
927 if (!empty($searchCategoryProductList)) {
928 $searchCategoryProductSqlList = array();
929 $listofcategoryid =
'';
930 foreach ($searchCategoryProductList as $searchCategoryProduct) {
931 if (intval($searchCategoryProduct) == -2) {
932 $searchCategoryProductSqlList[] =
"NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product)";
933 } elseif (intval($searchCategoryProduct) > 0) {
934 if ($searchCategoryProductOperator == 0) {
935 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
937 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
941 if ($listofcategoryid) {
942 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
944 if ($searchCategoryProductOperator == 1) {
945 if (!empty($searchCategoryProductSqlList)) {
946 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
949 if (!empty($searchCategoryProductSqlList)) {
950 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
955 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
957 $parameters = array();
958 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
959 $sql .= $hookmanager->resPrint;
963 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
965 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
966 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
967 $resql = $db->query($sqlforcount);
969 $objforcount = $db->fetch_object(
$resql);
982 $sql .= $db->order($sortfield, $sortorder);
984 $sql .= $db->plimit($limit + 1, $offset);
988 $resql = $db->query($sql);
990 $num = $db->num_rows(
$resql);
992 $arrayofselected = is_array($toselect) ? $toselect : array();
994 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
995 $obj = $db->fetch_object(
$resql);
997 header(
"Location: ".DOL_URL_ROOT.
'/fourn/commande/card.php?id='.$id);
1004 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1005 $param .=
'&contextpage='.urlencode($contextpage);
1007 if ($limit > 0 && $limit != $conf->liste_limit) {
1008 $param .=
'&limit='.urlencode($limit);
1011 $param .=
'&sall='.urlencode($sall);
1014 $param .=
'&socid='.urlencode($socid);
1017 $param .=
"&search_all=".urlencode($sall);
1019 if ($search_date_order_startday) {
1020 $param .=
'&search_date_order_startday='.urlencode($search_date_order_startday);
1022 if ($search_date_order_startmonth) {
1023 $param .=
'&search_date_order_startmonth='.urlencode($search_date_order_startmonth);
1025 if ($search_date_order_startyear) {
1026 $param .=
'&search_date_order_startyear='.urlencode($search_date_order_startyear);
1028 if ($search_date_order_endday) {
1029 $param .=
'&search_date_order_endday='.urlencode($search_date_order_endday);
1031 if ($search_date_order_endmonth) {
1032 $param .=
'&search_date_order_endmonth='.urlencode($search_date_order_endmonth);
1034 if ($search_date_order_endyear) {
1035 $param .=
'&search_date_order_endyear='.urlencode($search_date_order_endyear);
1037 if ($search_date_delivery_startday) {
1038 $param .=
'&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
1040 if ($search_date_delivery_startmonth) {
1041 $param .=
'&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
1043 if ($search_date_delivery_startyear) {
1044 $param .=
'&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
1046 if ($search_date_delivery_endday) {
1047 $param .=
'&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
1049 if ($search_date_delivery_endmonth) {
1050 $param .=
'&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
1052 if ($search_date_delivery_endyear) {
1053 $param .=
'&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
1055 if ($search_date_valid_startday) {
1056 $param .=
'&search_date_valid_startday='.urlencode($search_date_valid_startday);
1058 if ($search_date_valid_startmonth) {
1059 $param .=
'&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
1061 if ($search_date_valid_startyear) {
1062 $param .=
'&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
1064 if ($search_date_valid_endday) {
1065 $param .=
'&search_date_valid_endday='.urlencode($search_date_valid_endday);
1067 if ($search_date_valid_endmonth) {
1068 $param .=
'&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
1070 if ($search_date_valid_endyear) {
1071 $param .=
'&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
1073 if ($search_date_approve_startday) {
1074 $param .=
'&search_date_approve_startday='.urlencode($search_date_approve_startday);
1076 if ($search_date_approve_startmonth) {
1077 $param .=
'&search_date_approve_startmonth='.urlencode($search_date_approve_startmonth);
1079 if ($search_date_approve_startyear) {
1080 $param .=
'&search_date_approve_startyear='.urlencode($search_date_approve_startyear);
1082 if ($search_date_approve_endday) {
1083 $param .=
'&search_date_approve_endday='.urlencode($search_date_approve_endday);
1085 if ($search_date_approve_endmonth) {
1086 $param .=
'&search_date_approve_endmonth='.urlencode($search_date_approve_endmonth);
1088 if ($search_date_approve_endyear) {
1089 $param .=
'&search_date_approve_endyear='.urlencode($search_date_approve_endyear);
1092 $param .=
'&search_ref='.urlencode($search_ref);
1094 if ($search_company) {
1095 $param .=
'&search_company='.urlencode($search_company);
1097 if ($search_company_alias) {
1098 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1100 if ($search_user > 0) {
1101 $param .=
'&search_user='.urlencode($search_user);
1103 if ($search_request_author) {
1104 $param .=
'&search_request_author='.urlencode($search_request_author);
1106 if ($search_sale > 0) {
1107 $param .=
'&search_sale='.urlencode($search_sale);
1109 if ($search_total_ht !=
'') {
1110 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1112 if ($search_total_ttc !=
'') {
1113 $param .=
"&search_total_ttc=".urlencode($search_total_ttc);
1115 if ($search_multicurrency_code !=
'') {
1116 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1118 if ($search_multicurrency_tx !=
'') {
1119 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1121 if ($search_multicurrency_montant_ht !=
'') {
1122 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1124 if ($search_multicurrency_montant_tva !=
'') {
1125 $param .=
'&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva);
1127 if ($search_multicurrency_montant_ttc !=
'') {
1128 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1130 if ($search_refsupp) {
1131 $param .=
"&search_refsupp=".urlencode($search_refsupp);
1133 if ($search_status !=
'' && $search_status !=
'-1') {
1134 $param .=
"&search_status=".urlencode($search_status);
1136 if ($search_project_ref >= 0) {
1137 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1139 if ($search_billed !=
'') {
1140 $param .=
"&search_billed=".urlencode($search_billed);
1143 $param .=
'&show_files='.urlencode($show_files);
1145 if ($optioncss !=
'') {
1146 $param .=
'&optioncss='.urlencode($optioncss);
1148 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
1149 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1153 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1155 $parameters = array();
1156 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1157 $param .= $hookmanager->resPrint;
1160 $arrayofmassactions = array(
1161 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1162 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1163 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1166 if ($permissiontovalidate) {
1167 if ($permissiontoapprove && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) {
1168 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"ValidateAndApprove");
1170 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1174 if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
1175 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisSupplier");
1177 if ($permissiontodelete) {
1178 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1180 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1181 $arrayofmassactions = array();
1183 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1185 $url = DOL_URL_ROOT.
'/fourn/commande/card.php?action=create';
1187 $url .=
'&socid='.((int) $socid);
1188 $url .=
'&backtopage='.urlencode(DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.((
int) $socid));
1190 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewSupplierOrderShort'),
'',
'fa fa-plus-circle', $url,
'', $permissiontoadd);
1193 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1194 if ($optioncss !=
'') {
1195 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1197 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1198 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1199 print
'<input type="hidden" name="action" value="list">';
1200 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1201 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1202 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1203 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1205 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'supplier_order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1207 $topicmail =
"SendOrderRef";
1208 $modelmail =
"order_supplier_send";
1210 $trackid =
'sord'.$object->id;
1211 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1213 if ($massaction ==
'prevalidate') {
1214 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1217 if ($massaction ==
'createbills') {
1219 print
'<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
1221 print
'<table class="noborder centpercent">';
1223 print
'<td class="titlefield">';
1224 print $langs->trans(
'DateInvoice');
1227 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1232 print $langs->trans(
'CreateOneBillByThird');
1235 print
$form->selectyesno(
'createbills_onebythird',
'', 1);
1240 print $langs->trans(
'ValidateInvoices');
1243 print
$form->selectyesno(
'validate_invoices', 1, 1);
1248 print
'<div class="center">';
1249 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1250 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1257 foreach ($fieldstosearchall as $key => $val) {
1258 $fieldstosearchall[$key] = $langs->trans($val);
1260 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
1263 $moreforfilter =
'';
1266 if ($user->rights->user->user->lire) {
1267 $langs->load(
"commercial");
1268 $moreforfilter .=
'<div class="divsearchfield">';
1269 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1270 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1271 $moreforfilter .=
'</div>';
1274 if ($user->rights->user->user->lire) {
1275 $moreforfilter .=
'<div class="divsearchfield">';
1276 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1277 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1278 $moreforfilter .=
'</div>';
1281 if (
isModEnabled(
'categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
1282 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1283 $moreforfilter .=
'<div class="divsearchfield">';
1284 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1285 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1286 $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);
1287 $moreforfilter .=
'</div>';
1289 $parameters = array();
1290 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1291 if (empty($reshook)) {
1292 $moreforfilter .= $hookmanager->resPrint;
1294 $moreforfilter = $hookmanager->resPrint;
1297 if (!empty($moreforfilter)) {
1298 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1299 print $moreforfilter;
1303 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1304 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1305 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1307 if (
GETPOST(
'autoselectall',
'int')) {
1308 $selectedfields .=
'<script>';
1309 $selectedfields .=
' $(document).ready(function() {';
1310 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1311 $selectedfields .=
' $("#checkforselects").click();';
1312 $selectedfields .=
' $("#massaction").val("createbills").change();';
1313 $selectedfields .=
' });';
1314 $selectedfields .=
'</script>';
1317 print
'<div class="div-table-responsive">';
1318 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1320 print
'<tr class="liste_titre_filter">';
1323 print
'<td class="liste_titre middle">';
1324 $searchpicto =
$form->showFilterButtons(
'left');
1329 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1330 print
'<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.
'"></td>';
1333 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1334 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.
'"></td>';
1337 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1338 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.
'"></td>';
1341 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1342 print
'<td class="liste_titre">';
1343 print
'<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.
'">';
1347 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1348 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.
'"></td>';
1351 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1352 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company_alias" value="'.$search_company_alias.
'"></td>';
1355 if (!empty($arrayfields[
's.town'][
'checked'])) {
1356 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.
'"></td>';
1359 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1360 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.
'"></td>';
1363 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1364 print
'<td class="liste_titre">';
1365 print
'<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1369 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1370 print
'<td class="liste_titre center">';
1371 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1375 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1376 print
'<td class="liste_titre maxwidthonsmartphone center">';
1377 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);
1381 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1382 print
'<td class="liste_titre center">';
1383 print
'<div class="nowrap">';
1384 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'));
1386 print
'<div class="nowrap">';
1387 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'));
1392 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1393 print
'<td class="liste_titre center">';
1394 print
'<div class="nowrap">';
1395 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'));
1397 print
'<div class="nowrap">';
1398 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'));
1402 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1404 print
'<td class="liste_titre right">';
1405 print
'<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.
'">';
1408 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1410 print
'<td class="liste_titre right">';
1411 print
'<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.
'">';
1414 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1416 print
'<td class="liste_titre right">';
1417 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1420 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1422 print
'<td class="liste_titre">';
1423 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1426 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1428 print
'<td class="liste_titre">';
1429 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1432 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1434 print
'<td class="liste_titre right">';
1435 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1438 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1440 print
'<td class="liste_titre right">';
1441 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).
'">';
1444 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1446 print
'<td class="liste_titre right">';
1447 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1451 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1454 $parameters = array(
'arrayfields'=>$arrayfields);
1455 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1456 print $hookmanager->resPrint;
1458 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1459 print
'<td class="liste_titre">';
1463 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1464 print
'<td class="liste_titre">';
1468 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1469 print
'<td class="liste_titre right">';
1470 $formorder->selectSupplierOrderStatus($search_status, 1,
'search_status');
1474 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1475 print
'<td class="liste_titre center">';
1476 print
$form->selectyesno(
'search_billed', $search_billed, 1,
false, 1, 1,
'maxwidth100 onrightofpage');
1480 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1481 print
'<td class="liste_titre center">';
1482 print
'<div class="nowrap">';
1483 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'));
1485 print
'<div class="nowrap">';
1486 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'));
1491 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1492 print
'<td class="liste_titre center">';
1493 print
'<div class="nowrap">';
1494 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'));
1496 print
'<div class="nowrap">';
1497 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'));
1502 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1503 print
'<td class="liste_titre">';
1507 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1508 print
'<td class="liste_titre">';
1513 print
'<td class="liste_titre middle">';
1514 $searchpicto =
$form->showFilterButtons();
1522 print
'<tr class="liste_titre">';
1524 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1526 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1527 print_liste_field_titre($arrayfields[
'cf.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref",
"", $param,
'', $sortfield, $sortorder);
1529 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1530 print_liste_field_titre($arrayfields[
'cf.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref_supplier",
"", $param,
'', $sortfield, $sortorder,
'tdoverflowmax100imp ');
1532 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1533 print_liste_field_titre($arrayfields[
'cf.fk_projet'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1535 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1536 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
"u.login",
"", $param,
'', $sortfield, $sortorder);
1538 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1539 print_liste_field_titre($arrayfields[
'cf.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
1541 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1542 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"s.name_alias",
"", $param,
'', $sortfield, $sortorder);
1544 if (!empty($arrayfields[
's.town'][
'checked'])) {
1545 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1547 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1548 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1550 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1551 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1553 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1554 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1556 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1557 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1559 if (!empty($arrayfields[
'cf.fk_author'][
'checked'])) {
1560 print_liste_field_titre($arrayfields[
'cf.fk_author'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_author",
"", $param,
'', $sortfield, $sortorder);
1562 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1563 print_liste_field_titre($arrayfields[
'cf.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_commande",
"", $param,
'', $sortfield, $sortorder,
'center ');
1565 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1566 print_liste_field_titre($arrayfields[
'cf.date_livraison'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1568 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1569 print_liste_field_titre($arrayfields[
'cf.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
1571 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1572 print_liste_field_titre($arrayfields[
'cf.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
1574 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1575 print_liste_field_titre($arrayfields[
'cf.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
1577 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1578 print_liste_field_titre($arrayfields[
'cf.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1580 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1581 print_liste_field_titre($arrayfields[
'cf.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1583 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1584 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1586 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1587 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1589 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1590 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1593 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1595 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1596 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1597 print $hookmanager->resPrint;
1598 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1599 print_liste_field_titre($arrayfields[
'cf.date_creation'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1601 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1602 print_liste_field_titre($arrayfields[
'cf.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1604 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1605 print_liste_field_titre($arrayfields[
'cf.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
1607 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1608 print_liste_field_titre($arrayfields[
'cf.billed'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.billed',
'', $param,
'', $sortfield, $sortorder,
'center ');
1610 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1611 print_liste_field_titre($arrayfields[
'cf.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
1613 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1614 print_liste_field_titre($arrayfields[
'cf.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_approve',
'', $param,
'', $sortfield, $sortorder,
'center ');
1616 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1617 print_liste_field_titre($arrayfields[
'cf.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_public",
"", $param,
'', $sortfield, $sortorder,
'center ');
1619 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1620 print_liste_field_titre($arrayfields[
'cf.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_private",
"", $param,
'', $sortfield, $sortorder,
'center ');
1623 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1630 $productstat_cache = array();
1632 $userstatic =
new User($db);
1634 $projectstatic =
new Project($db);
1637 $totalarray = array(
'nbfield' => 0,
'val' => array(),
'pos' => array());
1638 $totalarray[
'val'][
'cf.total_ht'] = 0;
1639 $totalarray[
'val'][
'cf.total_ttc'] = 0;
1640 $totalarray[
'val'][
'cf.total_tva'] = 0;
1642 $imaxinloop = ($limit ? min($num, $limit) : $num);
1643 while ($i < $imaxinloop) {
1644 $obj = $db->fetch_object(
$resql);
1652 $objectstatic->id = $obj->rowid;
1653 $objectstatic->ref = $obj->ref;
1654 $objectstatic->socid = $obj->socid;
1655 $objectstatic->ref_supplier = $obj->ref_supplier;
1656 $objectstatic->socid = $obj->socid;
1657 $objectstatic->total_ht = $obj->total_ht;
1658 $objectstatic->total_tva = $obj->total_tva;
1659 $objectstatic->total_ttc = $obj->total_ttc;
1660 $objectstatic->date_commande = $db->jdate($obj->date_commande);
1661 $objectstatic->delivery_date = $db->jdate($obj->date_livraison);
1662 $objectstatic->note_public = $obj->note_public;
1663 $objectstatic->note_private = $obj->note_private;
1664 $objectstatic->statut = $obj->fk_statut;
1666 print
'<tr class="oddeven">';
1669 print
'<td class="nowrap center">';
1670 if ($massactionbutton || $massaction) {
1672 if (in_array($obj->rowid, $arrayofselected)) {
1675 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1680 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1681 print
'<td class="nowrap">';
1684 print $objectstatic->getNomUrl(1,
'', 0, -1, 1);
1688 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1692 $totalarray[
'nbfield']++;
1696 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1697 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>'.
"\n";
1699 $totalarray[
'nbfield']++;
1703 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1704 $projectstatic->id = $obj->project_id;
1705 $projectstatic->ref = $obj->project_ref;
1706 $projectstatic->title = $obj->project_title;
1708 if ($obj->project_id > 0) {
1709 print $projectstatic->getNomUrl(1);
1713 $totalarray[
'nbfield']++;
1717 $userstatic->id = $obj->fk_user_author;
1718 $userstatic->lastname = $obj->lastname;
1719 $userstatic->firstname = $obj->firstname;
1720 $userstatic->login = $obj->login;
1721 $userstatic->photo = $obj->photo;
1722 $userstatic->email = $obj->user_email;
1723 $userstatic->statut = $obj->user_status;
1724 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1725 print
'<td class="tdoverflowmax150">';
1726 if ($userstatic->id) {
1727 print $userstatic->getNomUrl(1);
1731 $totalarray[
'nbfield']++;
1735 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1736 print
'<td class="tdoverflowmax150">';
1737 $thirdpartytmp->id = $obj->socid;
1738 $thirdpartytmp->name = $obj->name;
1739 $thirdpartytmp->email = $obj->email;
1740 $thirdpartytmp->name_alias = $obj->alias;
1741 $thirdpartytmp->client = $obj->client;
1742 $thirdpartytmp->fournisseur = $obj->fournisseur;
1743 print $thirdpartytmp->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1746 $totalarray[
'nbfield']++;
1750 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1751 print
'<td class="tdoverflowmax150">';
1755 $totalarray[
'nbfield']++;
1759 if (!empty($arrayfields[
's.town'][
'checked'])) {
1764 $totalarray[
'nbfield']++;
1768 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1773 $totalarray[
'nbfield']++;
1777 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1778 print
"<td>".$obj->state_name.
"</td>\n";
1780 $totalarray[
'nbfield']++;
1784 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1785 print
'<td class="center">';
1786 $tmparray =
getCountry($obj->fk_pays,
'all');
1787 print $tmparray[
'label'];
1790 $totalarray[
'nbfield']++;
1794 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1795 print
'<td class="center">';
1796 if (empty($typenArray)) {
1797 $typenArray = $formcompany->typent_array(1);
1799 print $typenArray[$obj->typent_code];
1802 $totalarray[
'nbfield']++;
1807 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1808 print
'<td class="center">';
1810 if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1811 if ($objectstatic->hasDelay()) {
1812 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1817 $totalarray[
'nbfield']++;
1821 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1822 print
'<td class="center">';
1824 if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1825 if ($objectstatic->hasDelay()) {
1826 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1831 $totalarray[
'nbfield']++;
1835 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1836 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1838 $totalarray[
'nbfield']++;
1841 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ht';
1843 $totalarray[
'val'][
'cf.total_ht'] += $obj->total_ht;
1846 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1847 print
'<td class="right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
1849 $totalarray[
'nbfield']++;
1852 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_tva';
1854 $totalarray[
'val'][
'cf.total_tva'] += $obj->total_tva;
1857 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1858 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1860 $totalarray[
'nbfield']++;
1863 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ttc';
1865 $totalarray[
'val'][
'cf.total_ttc'] += $obj->total_ttc;
1869 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1870 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1872 $totalarray[
'nbfield']++;
1877 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1878 print
'<td class="nowrap">';
1879 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1882 $totalarray[
'nbfield']++;
1886 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1887 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
1889 $totalarray[
'nbfield']++;
1893 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1894 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva).
"</span></td>\n";
1896 $totalarray[
'nbfield']++;
1900 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1901 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
1903 $totalarray[
'nbfield']++;
1908 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1910 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1911 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1912 print $hookmanager->resPrint;
1914 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1915 print
'<td class="center nowrap">';
1916 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1919 $totalarray[
'nbfield']++;
1923 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1924 print
'<td class="center nowrap">';
1925 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1928 $totalarray[
'nbfield']++;
1932 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1933 print
'<td class="right nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).
'</td>';
1935 $totalarray[
'nbfield']++;
1939 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1940 print
'<td class="center">'.yn($obj->billed).
'</td>';
1942 $totalarray[
'nbfield']++;
1947 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1948 print
'<td class="center">';
1952 $totalarray[
'nbfield']++;
1956 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1957 print
'<td class="center">';
1961 $totalarray[
'nbfield']++;
1965 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1966 print
'<td class="center">';
1970 $totalarray[
'nbfield']++;
1975 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1976 print
'<td class="center">';
1980 $totalarray[
'nbfield']++;
1986 print
'<td class="nowrap center">';
1987 if ($massactionbutton || $massaction) {
1989 if (in_array($obj->rowid, $arrayofselected)) {
1992 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1997 $totalarray[
'nbfield']++;
2002 $total += $obj->total_ht;
2003 $subtotal += $obj->total_ht;
2008 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2013 foreach ($arrayfields as $key => $val) {
2014 if (!empty($val[
'checked'])) {
2018 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2023 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
2024 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2025 print $hookmanager->resPrint;
2027 print
'</table>'.
"\n";
2030 print
'</form>'.
"\n";
2032 $hidegeneratedfilelistifempty = 1;
2033 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2034 $hidegeneratedfilelistifempty = 0;
2038 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2039 $urlsource .= str_replace(
'&',
'&', $param);
2041 $filedir = $diroutputmassaction;
2042 $genallowed = $permissiontoread;
2043 $delallowed = $permissiontoadd;
2045 print $formfile->showdocuments(
'massfilesarea_supplier_order',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage predefined suppliers products.
Class to manage absolute discounts.
Class to manage suppliers invoices.
Class to manage suppliers.
Class to manage projects.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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...
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.