38require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
54$langs->loadLangs(array(
"orders",
"sendings",
'deliveries',
'companies',
'compta',
'bills',
'projects',
'suppliers',
'products'));
57$action =
GETPOST(
'action',
'aZ09');
58$massaction =
GETPOST(
'massaction',
'alpha');
60$confirm =
GETPOST(
'confirm',
'alpha');
61$toselect =
GETPOST(
'toselect',
'array');
62$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierorderlist';
63$mode =
GETPOST(
'mode',
'alpha');
66$search_date_order_startday =
GETPOSTINT(
'search_date_order_startday');
67$search_date_order_startmonth =
GETPOSTINT(
'search_date_order_startmonth');
68$search_date_order_startyear =
GETPOSTINT(
'search_date_order_startyear');
69$search_date_order_endday =
GETPOSTINT(
'search_date_order_endday');
70$search_date_order_endmonth =
GETPOSTINT(
'search_date_order_endmonth');
71$search_date_order_endyear =
GETPOSTINT(
'search_date_order_endyear');
72$search_date_order_start =
dol_mktime(0, 0, 0, $search_date_order_startmonth, $search_date_order_startday, $search_date_order_startyear);
73$search_date_order_end =
dol_mktime(23, 59, 59, $search_date_order_endmonth, $search_date_order_endday, $search_date_order_endyear);
75$search_date_delivery_startday =
GETPOSTINT(
'search_date_delivery_startday');
76$search_date_delivery_startmonth =
GETPOSTINT(
'search_date_delivery_startmonth');
77$search_date_delivery_startyear =
GETPOSTINT(
'search_date_delivery_startyear');
78$search_date_delivery_endday =
GETPOSTINT(
'search_date_delivery_endday');
79$search_date_delivery_endmonth =
GETPOSTINT(
'search_date_delivery_endmonth');
80$search_date_delivery_endyear =
GETPOSTINT(
'search_date_delivery_endyear');
81$search_date_delivery_start =
dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear);
82$search_date_delivery_end =
dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
84$search_date_valid_startday =
GETPOSTINT(
'search_date_valid_startday');
85$search_date_valid_startmonth =
GETPOSTINT(
'search_date_valid_startmonth');
86$search_date_valid_startyear =
GETPOSTINT(
'search_date_valid_startyear');
87$search_date_valid_endday =
GETPOSTINT(
'search_date_valid_endday');
88$search_date_valid_endmonth =
GETPOSTINT(
'search_date_valid_endmonth');
89$search_date_valid_endyear =
GETPOSTINT(
'search_date_valid_endyear');
90$search_date_valid_start =
dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear);
91$search_date_valid_end =
dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
93$search_date_approve_startday =
GETPOSTINT(
'search_date_approve_startday');
94$search_date_approve_startmonth =
GETPOSTINT(
'search_date_approve_startmonth');
95$search_date_approve_startyear =
GETPOSTINT(
'search_date_approve_startyear');
96$search_date_approve_endday =
GETPOSTINT(
'search_date_approve_endday');
97$search_date_approve_endmonth =
GETPOSTINT(
'search_date_approve_endmonth');
98$search_date_approve_endyear =
GETPOSTINT(
'search_date_approve_endyear');
99$search_date_approve_start =
dol_mktime(0, 0, 0, $search_date_approve_startmonth, $search_date_approve_startday, $search_date_approve_startyear);
100$search_date_approve_end =
dol_mktime(23, 59, 59, $search_date_approve_endmonth, $search_date_approve_endday, $search_date_approve_endyear);
102$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
104$search_product_category =
GETPOSTINT(
'search_product_category');
105$search_ref =
GETPOST(
'search_ref',
'alpha');
106$search_refsupp =
GETPOST(
'search_refsupp',
'alpha');
107$search_company =
GETPOST(
'search_company',
'alpha');
108$search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
109$search_town =
GETPOST(
'search_town',
'alpha');
110$search_zip =
GETPOST(
'search_zip',
'alpha');
111$search_state =
GETPOST(
"search_state",
'alpha');
112$search_country =
GETPOST(
"search_country",
'aZ09');
113$search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'intcomma');
114$search_user =
GETPOST(
'search_user',
'intcomma');
115$search_request_author =
GETPOST(
'search_request_author',
'alpha');
116$optioncss =
GETPOST(
'optioncss',
'alpha');
118$search_sale =
GETPOST(
'search_sale',
'intcomma');
119$search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
120$search_total_tva =
GETPOST(
'search_total_tva',
'alpha');
121$search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
122$search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
123$search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
124$search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
125$search_multicurrency_montant_tva =
GETPOST(
'search_multicurrency_montant_tva',
'alpha');
126$search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
127$optioncss =
GETPOST(
'optioncss',
'alpha');
128$search_billed =
GETPOST(
'search_billed',
'intcomma');
129$search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
130$search_btn =
GETPOST(
'button_search',
'alpha');
131$search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
134 $search_status = implode(
',',
GETPOST(
'search_status',
'array:intcomma'));
136 $search_status = (
GETPOST(
'search_status',
'intcomma') !=
'' ?
GETPOST(
'search_status',
'intcomma') :
GETPOST(
'statut',
'intcomma'));
139$search_option =
GETPOST(
'search_option',
'alpha');
140if ($search_option ==
'late') {
141 $search_status =
'1,2';
144$diroutputmassaction = $conf->fournisseur->commande->dir_output.
'/temp/massgeneration/'.$user->id;
147$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
148$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
150if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
154$offset = $limit * $page;
155$pageprev = $page - 1;
156$pagenext = $page + 1;
158 $sortfield =
'cf.ref';
166$hookmanager->initHooks(array(
'supplierorderlist'));
170$extrafields->fetch_name_optionals_label(
$object->table_element);
172$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
175$fieldstosearchall = array();
176foreach (
$object->fields as $key => $val) {
177 if (!empty($val[
'searchall'])) {
178 $fieldstosearchall[
'cf.'.$key] = $val[
'label'];
181$fieldstosearchall[
'pd.description'] =
'Description';
182$fieldstosearchall[
's.nom'] =
"ThirdParty";
183$fieldstosearchall[
's.name_alias'] =
"AliasNameShort";
184$fieldstosearchall[
's.zip'] =
"Zip";
185$fieldstosearchall[
's.town'] =
"Town";
186if (empty($user->socid)) {
187 $fieldstosearchall[
"cf.note_private"] =
"NotePrivate";
190$checkedtypetiers = 0;
194 'u.login' => array(
'label' =>
"AuthorRequest",
'enabled' => 1,
'position' => 41),
195 's.name_alias' => array(
'label' =>
"AliasNameShort",
'position' => 51,
'checked' => 0),
196 's.town' => array(
'label' =>
"Town",
'enabled' => 1,
'position' => 55,
'checked' => 1),
197 's.zip' => array(
'label' =>
"Zip",
'enabled' => 1,
'position' => 56,
'checked' => 1),
198 'state.nom' => array(
'label' =>
"StateShort",
'enabled' => 1,
'position' => 57),
199 'country.code_iso' => array(
'label' =>
"Country",
'enabled' => 1,
'position' => 58),
200 'typent.code' => array(
'label' =>
"ThirdPartyType",
'enabled' => $checkedtypetiers,
'position' => 59),
201 'cf.total_localtax1' => array(
'label' => $langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked' => 0,
'enabled' => ($mysoc->localtax1_assuj ==
"1"),
'position' => 140),
202 'cf.total_localtax2' => array(
'label' => $langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked' => 0,
'enabled' => ($mysoc->localtax2_assuj ==
"1"),
'position' => 145),
203 'cf.note_public' => array(
'label' =>
'NotePublic',
'checked' => 0,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES')),
'position' => 750),
204 'cf.note_private' => array(
'label' =>
'NotePrivate',
'checked' => 0,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'position' => 760),
206foreach (
$object->fields as $key => $val) {
208 if (!empty($val[
'visible'])) {
209 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
210 $arrayfields[
'cf.'.$key] = array(
211 'label' => $val[
'label'],
212 'checked' => (($visible < 0) ? 0 : 1),
213 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
214 'position' => $val[
'position'],
215 'help' => isset($val[
'help']) ? $val[
'help'] :
''
220include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
224'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
228if (!$user->hasRight(
'societe',
'client',
'voir')) {
229 $search_sale = $user->id;
235 $socid = $user->socid;
237$result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
239$permissiontoread = ($user->hasRight(
"fournisseur",
"commande",
"lire") || $user->hasRight(
"supplier_order",
"lire"));
240$permissiontoadd = ($user->hasRight(
"fournisseur",
"commande",
"creer") || $user->hasRight(
"supplier_order",
"creer"));
241$permissiontodelete = ($user->hasRight(
"fournisseur",
"commande",
"supprimer") || $user->hasRight(
"supplier_order",
"supprimer"));
242$permissiontovalidate = $permissiontoadd;
243$permissiontoapprove = ($user->hasRight(
"fournisseur",
"commande",
"approuver") || $user->hasRight(
"supplier_order",
"approuver"));
250if (
GETPOST(
'cancel',
'alpha')) {
254if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createsupplierbills') {
258$parameters = array(
'socid' => $socid,
'arrayfields' => &$arrayfields);
259$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
264if (empty($reshook)) {
266 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
269 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
273 $search_product_category =
'';
275 $search_refsupp =
'';
276 $search_company =
'';
277 $search_company_alias =
'';
282 $search_country =
'';
283 $search_type_thirdparty =
'';
284 $search_request_author =
'';
285 $search_total_ht =
'';
286 $search_total_tva =
'';
287 $search_total_ttc =
'';
288 $search_multicurrency_code =
'';
289 $search_multicurrency_tx =
'';
290 $search_multicurrency_montant_ht =
'';
291 $search_multicurrency_montant_tva =
'';
292 $search_multicurrency_montant_ttc =
'';
293 $search_project_ref =
'';
296 $search_date_order_startday =
'';
297 $search_date_order_startmonth =
'';
298 $search_date_order_startyear =
'';
299 $search_date_order_endday =
'';
300 $search_date_order_endmonth =
'';
301 $search_date_order_endyear =
'';
302 $search_date_order_start =
'';
303 $search_date_order_end =
'';
304 $search_date_delivery_startday =
'';
305 $search_date_delivery_startmonth =
'';
306 $search_date_delivery_startyear =
'';
307 $search_date_delivery_endday =
'';
308 $search_date_delivery_endmonth =
'';
309 $search_date_delivery_endyear =
'';
310 $search_date_delivery_start =
'';
311 $search_date_delivery_end =
'';
312 $search_date_valid_startday =
'';
313 $search_date_valid_startmonth =
'';
314 $search_date_valid_startyear =
'';
315 $search_date_valid_endday =
'';
316 $search_date_valid_endmonth =
'';
317 $search_date_valid_endyear =
'';
318 $search_date_valid_start =
'';
319 $search_date_valid_end =
'';
320 $search_date_approve_startday =
'';
321 $search_date_approve_startmonth =
'';
322 $search_date_approve_startyear =
'';
323 $search_date_approve_endday =
'';
324 $search_date_approve_endmonth =
'';
325 $search_date_approve_endyear =
'';
326 $search_date_approve_start =
'';
327 $search_date_approve_end =
'';
331 $search_array_options = array();
333 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
334 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
339 $objectclass =
'CommandeFournisseur';
340 $objectlabel =
'SupplierOrders';
341 $uploaddir = $conf->fournisseur->commande->dir_output;
342 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
344 if ($action ==
'validate' && $permissiontovalidate) {
345 if (
GETPOST(
'confirm') ==
'yes') {
350 foreach ($toselect as $checked) {
351 if ($objecttmp->fetch($checked)) {
352 if ($objecttmp->statut == 0) {
353 $objecttmp->date_commande =
dol_now();
354 $result = $objecttmp->valid($user);
357 if (!
getDolGlobalString(
'SUPPLIER_ORDER_NO_DIRECT_APPROVE') && $permissiontoapprove && !(
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') && $objecttmp->hasProductsOrServices(1))) {
358 $result = $objecttmp->approve($user);
359 setEventMessages($langs->trans(
"SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
361 setEventMessages($langs->trans(
"SupplierOrderValidated"), array($objecttmp->ref));
380 if ($massaction ==
'confirm_createsupplierbills') {
381 $orders =
GETPOST(
'toselect',
'array');
382 $createbills_onebythird =
GETPOSTINT(
'createbills_onebythird');
383 $validate_invoices =
GETPOSTINT(
'validate_invoices');
387 $TFactThird = array();
389 $nb_bills_created = 0;
397 foreach ($orders as $id_order) {
399 if ($cmd->fetch($id_order) <= 0) {
404 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
406 $objecttmp = $TFactThird[$cmd->socid];
409 if (!empty($cmd->socid) > 0) {
411 $societe->fetch($cmd->socid);
412 $objecttmp->vat_reverse_charge = $societe->vat_reverse_charge;
414 $objecttmp->socid = $cmd->socid;
415 $objecttmp->type = $objecttmp::TYPE_STANDARD;
416 $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
417 $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
418 $objecttmp->fk_project = $cmd->fk_project;
419 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
420 $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
421 $default_ref_supplier += 1;
424 if (empty($datefacture)) {
428 $objecttmp->date = $datefacture;
429 $objecttmp->origin =
'order_supplier';
430 $objecttmp->origin_id = $id_order;
432 $res = $objecttmp->create($user);
436 $lastref = $objecttmp->ref;
437 $lastid = $objecttmp->id;
441 if ($objecttmp->id > 0) {
442 if (empty($objecttmp->note_public)) {
443 $objecttmp->note_public = $langs->transnoentities(
"Orders");
446 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_element (";
448 $sql .=
", sourcetype";
449 $sql .=
", fk_target";
450 $sql .=
", targettype";
451 $sql .=
") VALUES (";
453 $sql .=
", '".$db->escape($objecttmp->origin).
"'";
454 $sql .=
", ".((int) $objecttmp->id);
455 $sql .=
", '".$db->escape($objecttmp->element).
"'";
458 if (!$db->query($sql)) {
463 $lines = $cmd->lines;
464 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
466 $lines = $cmd->lines;
470 $num = count($lines);
472 for ($i = 0; $i < $num; $i++) {
473 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
474 if ($lines[$i]->subprice < 0) {
475 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
479 $discount->fk_soc = $objecttmp->socid;
480 $discount->socid = $objecttmp->socid;
481 $discount->amount_ht = abs($lines[$i]->total_ht);
482 $discount->amount_tva = abs($lines[$i]->total_tva);
483 $discount->amount_ttc = abs($lines[$i]->total_ttc);
484 $discount->tva_tx = $lines[$i]->tva_tx;
485 $discount->fk_user = $user->id;
486 $discount->description = $desc;
487 $discountid = $discount->create($user);
488 if ($discountid > 0) {
489 $result = $objecttmp->insert_discount($discountid);
498 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
501 if ($lines[$i]->date_debut_prevue) {
502 $date_start = $lines[$i]->date_debut_prevue;
504 if ($lines[$i]->date_debut_reel) {
505 $date_start = $lines[$i]->date_debut_reel;
507 if ($lines[$i]->date_start) {
508 $date_start = $lines[$i]->date_start;
512 if ($lines[$i]->date_fin_prevue) {
513 $date_end = $lines[$i]->date_fin_prevue;
515 if ($lines[$i]->date_fin_reel) {
516 $date_end = $lines[$i]->date_fin_reel;
518 if ($lines[$i]->date_end) {
519 $date_end = $lines[$i]->date_end;
522 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
525 $result = $objecttmp->addline(
527 $lines[$i]->subprice,
529 $lines[$i]->localtax1_tx,
530 $lines[$i]->localtax2_tx,
532 $lines[$i]->fk_product,
533 $lines[$i]->remise_percent,
537 $lines[$i]->info_bits,
543 $lines[$i]->array_options,
546 $lines[$i]->fk_commande,
548 $lines[$i]->ref_supplier,
549 $lines[$i]->special_code,
560 if ($result > 0 && $lines[$i]->product_type == 9) {
561 $fk_parent_line = $result;
569 $objecttmp->note_public =
dol_concatdesc($objecttmp->note_public, $langs->transnoentities($cmd->ref).(empty($cmd->ref_supplier) ?
'' :
' ('.$cmd->ref_supplier.
')'));
570 $objecttmp->update($user);
573 $cmd->classifyBilled($user);
575 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
576 $TFactThird[$cmd->socid] = $objecttmp;
578 $TFact[$objecttmp->id] = $objecttmp;
583 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
586 if (!$error && $validate_invoices) {
587 $massaction = $action =
'builddoc';
589 foreach ($TAllFact as &$objecttmp) {
590 $objecttmp->validate($user);
597 $id = $objecttmp->id;
601 $upload_dir = $conf->fournisseur->facture->dir_output;
602 $permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
606 $massaction = $action =
'confirm_createsupplierbills';
612 if ($nb_bills_created == 1) {
613 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
614 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?id='.urlencode((
string) ($lastid)).
'">'.$lastref.
'</a>', $texttoshow);
617 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
623 $param .=
'&mode='.urlencode($mode);
625 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
626 $param .=
'&contextpage='.urlencode($contextpage);
628 if ($limit > 0 && $limit != $conf->liste_limit) {
629 $param .=
'&limit='.((int) $limit);
632 $param .=
'&search_all='.urlencode($search_all);
635 $param .=
'&socid='.urlencode((
string) ($socid));
637 if ($search_status !=
'') {
638 $param .=
'&search_status='.urlencode($search_status);
640 if ($search_option) {
641 $param .=
'&search_option='.urlencode($search_option);
643 if ($search_date_order_startday) {
644 $param .=
'&search_date_order_startday='.urlencode((
string) ($search_date_order_startday));
646 if ($search_date_order_startmonth) {
647 $param .=
'&search_date_order_startmonth='.urlencode((
string) ($search_date_order_startmonth));
649 if ($search_date_order_startyear) {
650 $param .=
'&search_date_order_startyear='.urlencode((
string) ($search_date_order_startyear));
652 if ($search_date_order_endday) {
653 $param .=
'&search_date_order_endday='.urlencode((
string) ($search_date_order_endday));
655 if ($search_date_order_endmonth) {
656 $param .=
'&search_date_order_endmonth='.urlencode((
string) ($search_date_order_endmonth));
658 if ($search_date_order_endyear) {
659 $param .=
'&search_date_order_endyear='.urlencode((
string) ($search_date_order_endyear));
661 if ($search_date_delivery_startday) {
662 $param .=
'&search_date_delivery_startday='.urlencode((
string) ($search_date_delivery_startday));
664 if ($search_date_delivery_startmonth) {
665 $param .=
'&search_date_delivery_startmonth='.urlencode((
string) ($search_date_delivery_startmonth));
667 if ($search_date_delivery_startyear) {
668 $param .=
'&search_date_delivery_startyear='.urlencode((
string) ($search_date_delivery_startyear));
670 if ($search_date_delivery_endday) {
671 $param .=
'&search_date_delivery_endday='.urlencode((
string) ($search_date_delivery_endday));
673 if ($search_date_delivery_endmonth) {
674 $param .=
'&search_date_delivery_endmonth='.urlencode((
string) ($search_date_delivery_endmonth));
676 if ($search_date_delivery_endyear) {
677 $param .=
'&search_date_delivery_endyear='.urlencode((
string) ($search_date_delivery_endyear));
679 if ($search_date_valid_startday) {
680 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
682 if ($search_date_valid_startmonth) {
683 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
685 if ($search_date_valid_startyear) {
686 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
688 if ($search_date_valid_endday) {
689 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
691 if ($search_date_valid_endmonth) {
692 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
694 if ($search_date_valid_endyear) {
695 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
697 if ($search_date_approve_startday) {
698 $param .=
'&search_date_approve_startday='.urlencode((
string) ($search_date_approve_startday));
700 if ($search_date_approve_startmonth) {
701 $param .=
'&search_date_approve_startmonth='.urlencode((
string) ($search_date_approve_startmonth));
703 if ($search_date_approve_startyear) {
704 $param .=
'&search_date_approve_startyear='.urlencode((
string) ($search_date_approve_startyear));
706 if ($search_date_approve_endday) {
707 $param .=
'&search_date_approve_endday='.urlencode((
string) ($search_date_approve_endday));
709 if ($search_date_approve_endmonth) {
710 $param .=
'&search_date_approve_endmonth='.urlencode((
string) ($search_date_approve_endmonth));
712 if ($search_date_approve_endyear) {
713 $param .=
'&search_date_approve_endyear='.urlencode((
string) ($search_date_approve_endyear));
716 $param .=
'&search_ref='.urlencode($search_ref);
718 if ($search_company) {
719 $param .=
'&search_company='.urlencode($search_company);
721 if ($search_company_alias) {
722 $param .=
'&search_company_alias='.urlencode($search_company_alias);
725 if ($search_user > 0) {
726 $param .=
'&search_user='.urlencode((
string) ($search_user));
728 if ($search_sale > 0) {
729 $param .=
'&search_sale='.urlencode($search_sale);
731 if ($search_total_ht !=
'') {
732 $param .=
'&search_total_ht='.urlencode($search_total_ht);
734 if ($search_total_tva !=
'') {
735 $param .=
'&search_total_tva='.urlencode($search_total_tva);
737 if ($search_total_ttc !=
'') {
738 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
740 if ($search_project_ref >= 0) {
741 $param .=
"&search_project_ref=".urlencode($search_project_ref);
744 $param .=
'&show_files='.urlencode((
string) ($show_files));
746 if ($optioncss !=
'') {
747 $param .=
'&optioncss='.urlencode($optioncss);
750 $param .=
'&billed='.urlencode($billed);
753 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
758 $_GET[
"origin"] = $_POST[
"origin"];
759 $_GET[
"originid"] = $_POST[
"originid"];
773$form =
new Form($db);
781$title = $langs->trans(
"SuppliersOrders");
784 $fourn->fetch($socid);
785 $title .=
' - '.$fourn->name;
788if ($search_billed > 0) {
789 $title .=
' - '.$langs->trans(
"Billed");
795$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
796$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
800 $sql =
'SELECT DISTINCT';
802$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,';
803$sql .=
" typent.code as typent_code,";
804$sql .=
" state.code_departement as state_code, state.nom as state_name,";
805$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 delivery_date, cf.date_valid, cf.date_approve,";
806$sql .=
' cf.localtax1 as total_localtax1, cf.localtax2 as total_localtax2,';
807$sql .=
' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
808$sql .=
' cf.date_creation as date_creation, cf.tms as date_modification,';
809$sql .=
' cf.note_public, cf.note_private,';
810$sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
811$sql .=
" u.firstname, u.lastname, u.photo, u.login, u.email as user_email, u.statut as user_status";
813if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
814 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
815 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
819$parameters = array();
820$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
821$sql .= $hookmanager->resPrint;
825$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
826$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
827$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
828$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
829$sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
830if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
831 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cf.rowid = ef.fk_object)";
834 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
836$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON cf.fk_user_author = u.rowid";
837$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = cf.fk_projet";
838$parameters = array();
839$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
840$sql .= $hookmanager->resPrint;
841$sql .=
' WHERE cf.fk_soc = s.rowid';
842$sql .=
' AND cf.entity IN ('.getEntity(
'supplier_order').
')';
844 $sql .=
" AND s.rowid = ".((int) $socid);
849if ($search_refsupp) {
853 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
855if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
856 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
858 if ($search_company) {
861 if ($search_company_alias) {
865if ($search_request_author) {
866 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_request_author);
868if ($search_billed !=
'' && $search_billed >= 0) {
869 $sql .=
" AND cf.billed = ".((int) $search_billed);
872if (
GETPOST(
'statut',
'intcomma') !==
'') {
873 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(
GETPOST(
'statut',
'intcomma')))).
")";
875if ($search_status !=
'' && $search_status !=
'-1') {
876 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
878if ($search_option ==
'late') {
879 $sql .=
" AND cf.date_commande < '".$db->idate(
dol_now() - $conf->order->fournisseur->warning_delay).
"'";
881if ($search_date_order_start) {
882 $sql .=
" AND cf.date_commande >= '".$db->idate($search_date_order_start).
"'";
884if ($search_date_order_end) {
885 $sql .=
" AND cf.date_commande <= '".$db->idate($search_date_order_end).
"'";
887if ($search_date_delivery_start) {
888 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_delivery_start).
"'";
890if ($search_date_delivery_end) {
891 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_delivery_end).
"'";
893if ($search_date_valid_start) {
894 $sql .=
" AND cf.date_valid >= '".$db->idate($search_date_valid_start).
"'";
896if ($search_date_valid_end) {
897 $sql .=
" AND cf.date_valid <= '".$db->idate($search_date_valid_end).
"'";
899if ($search_date_approve_start) {
900 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_approve_start).
"'";
902if ($search_date_approve_end) {
903 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_approve_end).
"'";
914if ($search_country) {
915 $sql .=
" AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).
')';
917if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
918 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
923if ($search_user > 0) {
924 $sql .=
" AND EXISTS (";
925 $sql .=
" SELECT ec.rowid ";
926 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_contact as ec";
927 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
928 $sql .=
" WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
929 $sql .=
" AND tc.element = 'order_supplier' AND tc.source = 'internal'";
932if ($search_total_ht !=
'') {
935if ($search_total_tva !=
'') {
938if ($search_total_ttc !=
'') {
941if ($search_multicurrency_code !=
'') {
942 $sql .=
" AND cf.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
944if ($search_multicurrency_tx !=
'') {
945 $sql .=
natural_search(
'cf.multicurrency_tx', $search_multicurrency_tx, 1);
947if ($search_multicurrency_montant_ht !=
'') {
948 $sql .=
natural_search(
'cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
950if ($search_multicurrency_montant_tva !=
'') {
951 $sql .=
natural_search(
'cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1);
953if ($search_multicurrency_montant_ttc !=
'') {
954 $sql .=
natural_search(
'cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
956if ($search_project_ref !=
'') {
960if ($search_sale && $search_sale !=
'-1') {
961 if ($search_sale == -2) {
962 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = cf.fk_soc)";
963 } elseif ($search_sale > 0) {
964 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = cf.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
968$searchCategoryProductOperator = -1;
969$searchCategoryProductList = array($search_product_category);
970if (!empty($searchCategoryProductList)) {
971 $searchCategoryProductSqlList = array();
972 $listofcategoryid =
'';
973 foreach ($searchCategoryProductList as $searchCategoryProduct) {
974 if (intval($searchCategoryProduct) == -2) {
975 $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)";
976 } elseif (intval($searchCategoryProduct) > 0) {
977 if ($searchCategoryProductOperator == 0) {
978 $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).
")";
980 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
984 if ($listofcategoryid) {
985 $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).
"))";
987 if ($searchCategoryProductOperator == 1) {
988 if (!empty($searchCategoryProductSqlList)) {
989 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
992 if (!empty($searchCategoryProductSqlList)) {
993 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
998include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1000$parameters = array();
1001$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
1002$sql .= $hookmanager->resPrint;
1005$nbtotalofrecords =
'';
1008 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1009 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1010 $resql = $db->query($sqlforcount);
1012 $objforcount = $db->fetch_object($resql);
1013 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1018 if (($page * $limit) > $nbtotalofrecords) {
1025$sql .= $db->order($sortfield, $sortorder);
1027 $sql .= $db->plimit($limit + 1, $offset);
1031$resql = $db->query($sql);
1033 $num = $db->num_rows($resql);
1035 $arrayofselected = is_array($toselect) ? $toselect : array();
1037 if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1038 $obj = $db->fetch_object($resql);
1040 header(
"Location: ".DOL_URL_ROOT.
'/fourn/commande/card.php?id='.
$id);
1044 llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-supplier-order page-list');
1047 if (!empty($mode)) {
1048 $param .=
'&mode='.urlencode($mode);
1050 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1051 $param .=
'&contextpage='.urlencode($contextpage);
1053 if ($limit > 0 && $limit != $conf->liste_limit) {
1054 $param .=
'&limit='.((int) $limit);
1057 $param .=
'&search_all='.urlencode($search_all);
1060 $param .=
'&socid='.urlencode((
string) ($socid));
1063 $param .=
"&search_all=".urlencode($search_all);
1065 if ($search_date_order_startday) {
1066 $param .=
'&search_date_order_startday='.urlencode((
string) ($search_date_order_startday));
1068 if ($search_date_order_startmonth) {
1069 $param .=
'&search_date_order_startmonth='.urlencode((
string) ($search_date_order_startmonth));
1071 if ($search_date_order_startyear) {
1072 $param .=
'&search_date_order_startyear='.urlencode((
string) ($search_date_order_startyear));
1074 if ($search_date_order_endday) {
1075 $param .=
'&search_date_order_endday='.urlencode((
string) ($search_date_order_endday));
1077 if ($search_date_order_endmonth) {
1078 $param .=
'&search_date_order_endmonth='.urlencode((
string) ($search_date_order_endmonth));
1080 if ($search_date_order_endyear) {
1081 $param .=
'&search_date_order_endyear='.urlencode((
string) ($search_date_order_endyear));
1083 if ($search_date_delivery_startday) {
1084 $param .=
'&search_date_delivery_startday='.urlencode((
string) ($search_date_delivery_startday));
1086 if ($search_date_delivery_startmonth) {
1087 $param .=
'&search_date_delivery_startmonth='.urlencode((
string) ($search_date_delivery_startmonth));
1089 if ($search_date_delivery_startyear) {
1090 $param .=
'&search_date_delivery_startyear='.urlencode((
string) ($search_date_delivery_startyear));
1092 if ($search_date_delivery_endday) {
1093 $param .=
'&search_date_delivery_endday='.urlencode((
string) ($search_date_delivery_endday));
1095 if ($search_date_delivery_endmonth) {
1096 $param .=
'&search_date_delivery_endmonth='.urlencode((
string) ($search_date_delivery_endmonth));
1098 if ($search_date_delivery_endyear) {
1099 $param .=
'&search_date_delivery_endyear='.urlencode((
string) ($search_date_delivery_endyear));
1101 if ($search_date_valid_startday) {
1102 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
1104 if ($search_date_valid_startmonth) {
1105 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
1107 if ($search_date_valid_startyear) {
1108 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
1110 if ($search_date_valid_endday) {
1111 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
1113 if ($search_date_valid_endmonth) {
1114 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
1116 if ($search_date_valid_endyear) {
1117 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
1119 if ($search_date_approve_startday) {
1120 $param .=
'&search_date_approve_startday='.urlencode((
string) ($search_date_approve_startday));
1122 if ($search_date_approve_startmonth) {
1123 $param .=
'&search_date_approve_startmonth='.urlencode((
string) ($search_date_approve_startmonth));
1125 if ($search_date_approve_startyear) {
1126 $param .=
'&search_date_approve_startyear='.urlencode((
string) ($search_date_approve_startyear));
1128 if ($search_date_approve_endday) {
1129 $param .=
'&search_date_approve_endday='.urlencode((
string) ($search_date_approve_endday));
1131 if ($search_date_approve_endmonth) {
1132 $param .=
'&search_date_approve_endmonth='.urlencode((
string) ($search_date_approve_endmonth));
1134 if ($search_date_approve_endyear) {
1135 $param .=
'&search_date_approve_endyear='.urlencode((
string) ($search_date_approve_endyear));
1138 $param .=
'&search_ref='.urlencode($search_ref);
1140 if ($search_company) {
1141 $param .=
'&search_company='.urlencode($search_company);
1143 if ($search_company_alias) {
1144 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1146 if ($search_user > 0) {
1147 $param .=
'&search_user='.urlencode((
string) ($search_user));
1149 if ($search_request_author) {
1150 $param .=
'&search_request_author='.urlencode($search_request_author);
1152 if ($search_sale > 0) {
1153 $param .=
'&search_sale='.urlencode($search_sale);
1155 if ($search_total_ht !=
'') {
1156 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1158 if ($search_total_ttc !=
'') {
1159 $param .=
"&search_total_ttc=".urlencode($search_total_ttc);
1161 if ($search_multicurrency_code !=
'') {
1162 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1164 if ($search_multicurrency_tx !=
'') {
1165 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1167 if ($search_multicurrency_montant_ht !=
'') {
1168 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1170 if ($search_multicurrency_montant_tva !=
'') {
1171 $param .=
'&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva);
1173 if ($search_multicurrency_montant_ttc !=
'') {
1174 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1176 if ($search_refsupp) {
1177 $param .=
"&search_refsupp=".urlencode($search_refsupp);
1179 if ($search_status !=
'' && $search_status !=
'-1') {
1180 $param .=
"&search_status=".urlencode($search_status);
1182 if ($search_option) {
1183 $param .=
"&search_option=".urlencode($search_option);
1185 if ($search_project_ref >= 0) {
1186 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1188 if ($search_billed !=
'') {
1189 $param .=
"&search_billed=".urlencode($search_billed);
1192 $param .=
'&show_files='.urlencode((
string) ($show_files));
1194 if ($optioncss !=
'') {
1195 $param .=
'&optioncss='.urlencode($optioncss);
1197 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
1198 $param .=
'&search_type_thirdparty='.urlencode((
string) ($search_type_thirdparty));
1202 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1204 $parameters = array(
'param' => &$param);
1205 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1206 $param .= $hookmanager->resPrint;
1209 $arrayofmassactions = array(
1210 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1211 'builddoc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1212 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1215 if ($permissiontovalidate) {
1216 if ($permissiontoapprove && !
getDolGlobalString(
'SUPPLIER_ORDER_NO_DIRECT_APPROVE')) {
1217 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"ValidateAndApprove");
1219 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1223 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
"supplier_invoice",
"creer")) {
1224 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'supplier_invoice',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisSupplier");
1226 if ($permissiontodelete) {
1227 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1229 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1230 $arrayofmassactions = array();
1232 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1234 $url = DOL_URL_ROOT.
'/fourn/commande/card.php?action=create';
1236 $url .=
'&socid='.((int) $socid);
1237 $url .=
'&backtopage='.urlencode(DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.((
int) $socid));
1239 $newcardbutton =
'';
1240 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss' =>
'reposition'));
1241 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
1243 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewSupplierOrderShort'),
'',
'fa fa-plus-circle', $url,
'', (
int) $permissiontoadd);
1246 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1247 if ($optioncss !=
'') {
1248 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1250 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1251 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1252 print
'<input type="hidden" name="action" value="list">';
1253 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1254 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1255 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1256 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1257 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1259 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'supplier_order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1261 $topicmail =
"SendOrderRef";
1262 $modelmail =
"order_supplier_send";
1264 $trackid =
'sord'.$object->id;
1265 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1267 if ($massaction ==
'prevalidate') {
1268 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1271 if ($massaction ==
'createbills') {
1273 print
'<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
1275 print
'<table class="noborder centpercent">';
1277 print
'<td class="titlefield">';
1278 print $langs->trans(
'DateInvoice');
1281 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1286 print $langs->trans(
'CreateOneBillByThird');
1289 print $form->selectyesno(
'createbills_onebythird',
'', 1);
1294 print $langs->trans(
'ValidateInvoices');
1297 print $form->selectyesno(
'validate_invoices', 1, 1);
1302 print
'<div class="center">';
1303 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1304 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1311 foreach ($fieldstosearchall as $key => $val) {
1312 $fieldstosearchall[$key] = $langs->trans($val);
1314 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
1317 $moreforfilter =
'';
1320 if ($user->hasRight(
"user",
"user",
"lire")) {
1321 $langs->load(
"commercial");
1322 $moreforfilter .=
'<div class="divsearchfield">';
1323 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1324 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1325 $moreforfilter .=
'</div>';
1328 if ($user->hasRight(
"user",
"user",
"lire")) {
1329 $moreforfilter .=
'<div class="divsearchfield">';
1330 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1331 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1332 $moreforfilter .=
'</div>';
1335 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
1336 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1337 $moreforfilter .=
'<div class="divsearchfield">';
1338 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1339 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1340 $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);
1341 $moreforfilter .=
'</div>';
1344 $moreforfilter .=
'<div class="divsearchfield">';
1345 $moreforfilter .= $langs->trans(
'Alert').
' <input type="checkbox" name="search_option" value="late"'.($search_option ==
'late' ?
' checked' :
'').
'>';
1346 $moreforfilter .=
'</div>';
1347 $parameters = array();
1348 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1349 if (empty($reshook)) {
1350 $moreforfilter .= $hookmanager->resPrint;
1352 $moreforfilter = $hookmanager->resPrint;
1355 if (!empty($moreforfilter)) {
1356 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1357 print $moreforfilter;
1361 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1362 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1363 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
1366 $selectedfields .=
'<script>';
1367 $selectedfields .=
' $(document).ready(function() {';
1368 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1369 $selectedfields .=
' $("#checkforselects").click();';
1370 $selectedfields .=
' $("#massaction").val("createbills").change();';
1371 $selectedfields .=
' });';
1372 $selectedfields .=
'</script>';
1375 print
'<div class="div-table-responsive">';
1376 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1378 print
'<tr class="liste_titre_filter">';
1381 print
'<td class="liste_titre middle">';
1382 $searchpicto = $form->showFilterButtons(
'left');
1387 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1388 print
'<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.
'"></td>';
1391 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1392 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.
'"></td>';
1395 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1396 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.
'"></td>';
1399 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1400 print
'<td class="liste_titre">';
1401 print
'<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.
'">';
1405 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1406 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.
'"></td>';
1409 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1410 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company_alias" value="'.$search_company_alias.
'"></td>';
1413 if (!empty($arrayfields[
's.town'][
'checked'])) {
1414 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.
'"></td>';
1417 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1418 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.
'"></td>';
1421 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1422 print
'<td class="liste_titre">';
1423 print
'<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1427 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1428 print
'<td class="liste_titre center">';
1429 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1433 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1434 print
'<td class="liste_titre maxwidthonsmartphone center">';
1435 print $form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0, (!
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT') ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
1439 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1440 print
'<td class="liste_titre center">';
1441 print
'<div class="nowrapfordate">';
1442 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'));
1444 print
'<div class="nowrapfordate">';
1445 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'));
1450 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1451 print
'<td class="liste_titre center">';
1452 print
'<div class="nowrapfordate">';
1453 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'));
1455 print
'<div class="nowrapfordate">';
1456 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'));
1460 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1462 print
'<td class="liste_titre right">';
1463 print
'<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.
'">';
1466 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1468 print
'<td class="liste_titre right">';
1469 print
'<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.
'">';
1472 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1474 print
'<td class="liste_titre right">';
1475 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1478 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1480 print
'<td class="liste_titre">';
1481 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1484 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1486 print
'<td class="liste_titre">';
1487 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1490 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1492 print
'<td class="liste_titre right">';
1493 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1496 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1498 print
'<td class="liste_titre right">';
1499 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).
'">';
1502 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1504 print
'<td class="liste_titre right">';
1505 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1509 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1512 $parameters = array(
'arrayfields' => $arrayfields);
1513 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1514 print $hookmanager->resPrint;
1516 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1517 print
'<td class="liste_titre">';
1521 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1522 print
'<td class="liste_titre">';
1526 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1527 print
'<td class="liste_titre center parentonrightofpage">';
1528 print $form->selectyesno(
'search_billed', $search_billed, 1,
false, 1, 1,
'search_status width100 onrightofpage');
1532 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1533 print
'<td class="liste_titre center parentonrightofpage">';
1534 $formorder->selectSupplierOrderStatus($search_status, 1,
'search_status',
'search_status width125 onrightofpage');
1538 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1539 print
'<td class="liste_titre center">';
1540 print
'<div class="nowrapfordate">';
1541 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'));
1543 print
'<div class="nowrapfordate">';
1544 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'));
1549 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1550 print
'<td class="liste_titre center">';
1551 print
'<div class="nowrapfordate">';
1552 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'));
1554 print
'<div class="nowrapfordate">';
1555 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'));
1560 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1561 print
'<td class="liste_titre">';
1565 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1566 print
'<td class="liste_titre">';
1571 print
'<td class="liste_titre center">';
1572 $searchpicto = $form->showFilterButtons();
1579 $totalarray = array();
1580 $totalarray[
'nbfield'] = 0;
1583 print
'<tr class="liste_titre">';
1585 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1586 $totalarray[
'nbfield']++;
1588 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1589 print_liste_field_titre($arrayfields[
'cf.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref",
"", $param,
'', $sortfield, $sortorder);
1590 $totalarray[
'nbfield']++;
1592 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1593 print_liste_field_titre($arrayfields[
'cf.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref_supplier",
"", $param,
'', $sortfield, $sortorder,
'tdoverflowmax100imp ');
1594 $totalarray[
'nbfield']++;
1596 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1597 print_liste_field_titre($arrayfields[
'cf.fk_projet'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1598 $totalarray[
'nbfield']++;
1600 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1601 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
"u.login",
"", $param,
'', $sortfield, $sortorder);
1602 $totalarray[
'nbfield']++;
1604 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1605 print_liste_field_titre($arrayfields[
'cf.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
1606 $totalarray[
'nbfield']++;
1608 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1610 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"s.name_alias",
"", $param,
'', $sortfield, $sortorder);
1611 $totalarray[
'nbfield']++;
1613 if (!empty($arrayfields[
's.town'][
'checked'])) {
1614 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1615 $totalarray[
'nbfield']++;
1617 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1618 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1619 $totalarray[
'nbfield']++;
1621 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1622 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1623 $totalarray[
'nbfield']++;
1625 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1626 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1627 $totalarray[
'nbfield']++;
1629 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1630 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1631 $totalarray[
'nbfield']++;
1633 if (!empty($arrayfields[
'cf.fk_author'][
'checked'])) {
1634 print_liste_field_titre($arrayfields[
'cf.fk_author'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_author",
"", $param,
'', $sortfield, $sortorder);
1635 $totalarray[
'nbfield']++;
1637 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1638 print_liste_field_titre($arrayfields[
'cf.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_commande",
"", $param,
'', $sortfield, $sortorder,
'center ');
1639 $totalarray[
'nbfield']++;
1641 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1642 print_liste_field_titre($arrayfields[
'cf.date_livraison'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1643 $totalarray[
'nbfield']++;
1645 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1646 print_liste_field_titre($arrayfields[
'cf.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
1647 $totalarray[
'nbfield']++;
1649 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1650 print_liste_field_titre($arrayfields[
'cf.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
1651 $totalarray[
'nbfield']++;
1653 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1654 print_liste_field_titre($arrayfields[
'cf.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
1655 $totalarray[
'nbfield']++;
1657 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1658 print_liste_field_titre($arrayfields[
'cf.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1659 $totalarray[
'nbfield']++;
1661 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1662 print_liste_field_titre($arrayfields[
'cf.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1663 $totalarray[
'nbfield']++;
1665 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1666 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1667 $totalarray[
'nbfield']++;
1669 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1670 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1671 $totalarray[
'nbfield']++;
1673 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1674 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1675 $totalarray[
'nbfield']++;
1678 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1680 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1681 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1682 print $hookmanager->resPrint;
1683 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1684 print_liste_field_titre($arrayfields[
'cf.date_creation'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowraponall ');
1685 $totalarray[
'nbfield']++;
1687 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1688 print_liste_field_titre($arrayfields[
'cf.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowraponall ');
1689 $totalarray[
'nbfield']++;
1691 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1692 print_liste_field_titre($arrayfields[
'cf.billed'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.billed',
'', $param,
'', $sortfield, $sortorder,
'center ');
1693 $totalarray[
'nbfield']++;
1695 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1696 print_liste_field_titre($arrayfields[
'cf.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1697 $totalarray[
'nbfield']++;
1699 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1700 print_liste_field_titre($arrayfields[
'cf.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
1701 $totalarray[
'nbfield']++;
1703 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1704 print_liste_field_titre($arrayfields[
'cf.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_approve',
'', $param,
'', $sortfield, $sortorder,
'center ');
1705 $totalarray[
'nbfield']++;
1707 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1708 print_liste_field_titre($arrayfields[
'cf.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_public",
"", $param,
'', $sortfield, $sortorder,
'center ');
1709 $totalarray[
'nbfield']++;
1711 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1712 print_liste_field_titre($arrayfields[
'cf.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_private",
"", $param,
'', $sortfield, $sortorder,
'center ');
1713 $totalarray[
'nbfield']++;
1716 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1717 $totalarray[
'nbfield']++;
1723 $productstat_cache = array();
1725 $userstatic =
new User($db);
1727 $projectstatic =
new Project($db);
1730 $savnbfield = $totalarray[
'nbfield'];
1731 $totalarray = array(
'nbfield' => 0,
'val' => array(),
'pos' => array());
1732 $totalarray[
'val'][
'cf.total_ht'] = 0;
1733 $totalarray[
'val'][
'cf.total_ttc'] = 0;
1734 $totalarray[
'val'][
'cf.total_tva'] = 0;
1736 $imaxinloop = ($limit ? min($num, $limit) : $num);
1737 while ($i < $imaxinloop) {
1738 $obj = $db->fetch_object($resql);
1746 $objectstatic->id = $obj->rowid;
1747 $objectstatic->ref = $obj->ref;
1748 $objectstatic->ref_supplier = $obj->ref_supplier;
1749 $objectstatic->socid = $obj->socid;
1750 $objectstatic->total_ht = $obj->total_ht;
1751 $objectstatic->total_tva = $obj->total_tva;
1752 $objectstatic->total_ttc = $obj->total_ttc;
1753 $objectstatic->date_commande = $db->jdate($obj->date_commande);
1754 $objectstatic->delivery_date = $db->jdate($obj->delivery_date);
1755 $objectstatic->note_public = $obj->note_public;
1756 $objectstatic->note_private = $obj->note_private;
1757 $objectstatic->statut = $obj->fk_statut;
1759 if ($mode ==
'kanban') {
1761 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1762 print
'<div class="box-flex-container kanban">';
1765 $thirdpartytmp->id = $obj->socid;
1766 $thirdpartytmp->name = $obj->name;
1767 $thirdpartytmp->email = $obj->email;
1768 $thirdpartytmp->name_alias = $obj->alias;
1769 $thirdpartytmp->client = $obj->client;
1770 $thirdpartytmp->fournisseur = $obj->fournisseur;
1772 print $objectstatic->getKanbanView(
'', array(
'thirdparty' => $thirdpartytmp->getNomUrl(
'supplier', 0, 0, -1),
'selected' => in_array($objectstatic->id, $arrayofselected)));
1773 if ($i == ($imaxinloop - 1)) {
1778 print
'<tr class="oddeven '.((getDolGlobalInt(
'MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->billed == 1) ?
'opacitymedium' :
'').
'">';
1781 print
'<td class="nowrap center">';
1782 if ($massactionbutton || $massaction) {
1784 if (in_array($obj->rowid, $arrayofselected)) {
1787 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1792 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1793 print
'<td class="nowrap">';
1796 print $objectstatic->getNomUrl(1,
'', 0, -1, 1);
1800 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1804 $totalarray[
'nbfield']++;
1808 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1809 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>'.
"\n";
1811 $totalarray[
'nbfield']++;
1815 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1816 $projectstatic->id = $obj->project_id;
1817 $projectstatic->ref = $obj->project_ref;
1818 $projectstatic->title = $obj->project_title;
1820 if ($obj->project_id > 0) {
1821 print $projectstatic->getNomUrl(1);
1825 $totalarray[
'nbfield']++;
1829 $userstatic->id = $obj->fk_user_author;
1830 $userstatic->lastname = $obj->lastname;
1831 $userstatic->firstname = $obj->firstname;
1832 $userstatic->login = $obj->login;
1833 $userstatic->photo = $obj->photo;
1834 $userstatic->email = $obj->user_email;
1835 $userstatic->status = $obj->user_status;
1836 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1837 print
'<td class="tdoverflowmax150">';
1838 if ($userstatic->id) {
1839 print $userstatic->getNomUrl(1);
1843 $totalarray[
'nbfield']++;
1847 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1848 print
'<td class="tdoverflowmax150">';
1849 $thirdpartytmp->id = $obj->socid;
1850 $thirdpartytmp->name = $obj->name;
1851 $thirdpartytmp->email = $obj->email;
1852 $thirdpartytmp->name_alias = $obj->alias;
1853 $thirdpartytmp->client = $obj->client;
1854 $thirdpartytmp->fournisseur = $obj->fournisseur;
1855 print $thirdpartytmp->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1858 $totalarray[
'nbfield']++;
1862 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1863 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->alias).
'">';
1867 $totalarray[
'nbfield']++;
1871 if (!empty($arrayfields[
's.town'][
'checked'])) {
1872 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
1876 $totalarray[
'nbfield']++;
1880 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1881 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).
'">';
1885 $totalarray[
'nbfield']++;
1889 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1890 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).
'">'.
dol_escape_htmltag($obj->state_name).
"</td>\n";
1892 $totalarray[
'nbfield']++;
1896 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1897 print
'<td class="center">';
1898 $tmparray =
getCountry($obj->fk_pays,
'all');
1899 print $tmparray[
'label'];
1902 $totalarray[
'nbfield']++;
1906 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1907 print
'<td class="center">';
1908 if (empty($typenArray)) {
1909 $typenArray = $formcompany->typent_array(1);
1911 print $typenArray[$obj->typent_code];
1914 $totalarray[
'nbfield']++;
1919 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1920 print
'<td class="center">';
1922 if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1923 if ($objectstatic->hasDelay()) {
1924 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1929 $totalarray[
'nbfield']++;
1933 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1934 print
'<td class="center">';
1936 if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1937 if ($objectstatic->hasDelay()) {
1938 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1943 $totalarray[
'nbfield']++;
1947 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1948 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1950 $totalarray[
'nbfield']++;
1953 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ht';
1955 $totalarray[
'val'][
'cf.total_ht'] += $obj->total_ht;
1958 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1959 print
'<td class="right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
1961 $totalarray[
'nbfield']++;
1964 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_tva';
1966 $totalarray[
'val'][
'cf.total_tva'] += $obj->total_tva;
1969 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1970 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1972 $totalarray[
'nbfield']++;
1975 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ttc';
1977 $totalarray[
'val'][
'cf.total_ttc'] += $obj->total_ttc;
1981 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1982 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1984 $totalarray[
'nbfield']++;
1989 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1990 print
'<td class="nowrap">';
1991 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1994 $totalarray[
'nbfield']++;
1998 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1999 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
2001 $totalarray[
'nbfield']++;
2005 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
2006 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva).
"</span></td>\n";
2008 $totalarray[
'nbfield']++;
2012 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
2013 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
2015 $totalarray[
'nbfield']++;
2020 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2022 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
2023 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2024 print $hookmanager->resPrint;
2026 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
2027 print
'<td class="center nowraponall">';
2028 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2031 $totalarray[
'nbfield']++;
2035 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
2036 print
'<td class="center nowraponall">';
2037 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
2040 $totalarray[
'nbfield']++;
2044 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
2045 print
'<td class="center">'.yn($obj->billed).
'</td>';
2047 $totalarray[
'nbfield']++;
2051 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
2052 print
'<td class="center nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).
'</td>';
2054 $totalarray[
'nbfield']++;
2059 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
2060 print
'<td class="center">';
2064 $totalarray[
'nbfield']++;
2068 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
2069 print
'<td class="center">';
2073 $totalarray[
'nbfield']++;
2077 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
2078 print
'<td class="sensiblehtmlcontent center">';
2082 $totalarray[
'nbfield']++;
2087 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
2088 print
'<td class="sensiblehtmlcontent center">';
2092 $totalarray[
'nbfield']++;
2098 print
'<td class="nowrap center">';
2099 if ($massactionbutton || $massaction) {
2101 if (in_array($obj->rowid, $arrayofselected)) {
2104 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2109 $totalarray[
'nbfield']++;
2114 $total += $obj->total_ht;
2115 $subtotal += $obj->total_ht;
2121 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2126 foreach ($arrayfields as $key => $val) {
2127 if (!empty($val[
'checked'])) {
2131 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2136 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2137 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2138 print $hookmanager->resPrint;
2140 print
'</table>'.
"\n";
2143 print
'</form>'.
"\n";
2145 $hidegeneratedfilelistifempty = 1;
2146 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2147 $hidegeneratedfilelistifempty = 0;
2151 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2152 $urlsource .= str_replace(
'&',
'&', $param);
2154 $filedir = $diroutputmassaction;
2155 $genallowed = $permissiontoread;
2156 $delallowed = $permissiontoadd;
2158 print $formfile->showdocuments(
'massfilesarea_supplier_order',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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 third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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...
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 a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.