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'));
138$search_option =
GETPOST(
'search_option',
'alpha');
139if ($search_option ==
'late') {
140 $search_status =
'1,2';
143$diroutputmassaction = $conf->fournisseur->commande->dir_output.
'/temp/massgeneration/'.$user->id;
146$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
147$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
149if (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();
174foreach (
$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";
184if (empty($user->socid)) {
185 $fieldstosearchall[
"cf.note_private"] =
"NotePrivate";
188$checkedtypetiers = 0;
192 'u.login' => array(
'label' =>
"AuthorRequest",
'enabled' => 1,
'position' => 41),
193 's.name_alias' => array(
'label' =>
"AliasNameShort",
'position' => 51,
'checked' => 0),
194 's.town' => array(
'label' =>
"Town",
'enabled' => 1,
'position' => 55,
'checked' => 1),
195 's.zip' => array(
'label' =>
"Zip",
'enabled' => 1,
'position' => 56,
'checked' => 1),
196 'state.nom' => array(
'label' =>
"StateShort",
'enabled' => 1,
'position' => 57),
197 'country.code_iso' => array(
'label' =>
"Country",
'enabled' => 1,
'position' => 58),
198 'typent.code' => array(
'label' =>
"ThirdPartyType",
'enabled' => $checkedtypetiers,
'position' => 59),
199 'cf.total_localtax1' => array(
'label' => $langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked' => 0,
'enabled' => ($mysoc->localtax1_assuj ==
"1"),
'position' => 140),
200 'cf.total_localtax2' => array(
'label' => $langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked' => 0,
'enabled' => ($mysoc->localtax2_assuj ==
"1"),
'position' => 145),
201 'cf.note_public' => array(
'label' =>
'NotePublic',
'checked' => 0,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES')),
'position' => 750),
202 'cf.note_private' => array(
'label' =>
'NotePrivate',
'checked' => 0,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'position' => 760),
204foreach (
$object->fields as $key => $val) {
206 if (!empty($val[
'visible'])) {
207 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
208 $arrayfields[
'cf.'.$key] = array(
209 'label' => $val[
'label'],
210 'checked' => (($visible < 0) ? 0 : 1),
211 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
212 'position' => $val[
'position'],
213 'help' => isset($val[
'help']) ? $val[
'help'] :
''
218include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
222'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
226if (!$user->hasRight(
'societe',
'client',
'voir')) {
227 $search_sale = $user->id;
233 $socid = $user->socid;
235$result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
237$permissiontoread = ($user->hasRight(
"fournisseur",
"commande",
"lire") || $user->hasRight(
"supplier_order",
"lire"));
238$permissiontoadd = ($user->hasRight(
"fournisseur",
"commande",
"creer") || $user->hasRight(
"supplier_order",
"creer"));
239$permissiontodelete = ($user->hasRight(
"fournisseur",
"commande",
"supprimer") || $user->hasRight(
"supplier_order",
"supprimer"));
240$permissiontovalidate = $permissiontoadd;
241$permissiontoapprove = ($user->hasRight(
"fournisseur",
"commande",
"approuver") || $user->hasRight(
"supplier_order",
"approuver"));
248if (
GETPOST(
'cancel',
'alpha')) {
252if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createsupplierbills') {
256$parameters = array(
'socid' => $socid,
'arrayfields' => &$arrayfields);
257$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
262if (empty($reshook)) {
264 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
267 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
271 $search_product_category =
'';
273 $search_refsupp =
'';
274 $search_company =
'';
275 $search_company_alias =
'';
280 $search_country =
'';
281 $search_type_thirdparty =
'';
282 $search_request_author =
'';
283 $search_total_ht =
'';
284 $search_total_tva =
'';
285 $search_total_ttc =
'';
286 $search_multicurrency_code =
'';
287 $search_multicurrency_tx =
'';
288 $search_multicurrency_montant_ht =
'';
289 $search_multicurrency_montant_tva =
'';
290 $search_multicurrency_montant_ttc =
'';
291 $search_project_ref =
'';
294 $search_date_order_startday =
'';
295 $search_date_order_startmonth =
'';
296 $search_date_order_startyear =
'';
297 $search_date_order_endday =
'';
298 $search_date_order_endmonth =
'';
299 $search_date_order_endyear =
'';
300 $search_date_order_start =
'';
301 $search_date_order_end =
'';
302 $search_date_delivery_startday =
'';
303 $search_date_delivery_startmonth =
'';
304 $search_date_delivery_startyear =
'';
305 $search_date_delivery_endday =
'';
306 $search_date_delivery_endmonth =
'';
307 $search_date_delivery_endyear =
'';
308 $search_date_delivery_start =
'';
309 $search_date_delivery_end =
'';
310 $search_date_valid_startday =
'';
311 $search_date_valid_startmonth =
'';
312 $search_date_valid_startyear =
'';
313 $search_date_valid_endday =
'';
314 $search_date_valid_endmonth =
'';
315 $search_date_valid_endyear =
'';
316 $search_date_valid_start =
'';
317 $search_date_valid_end =
'';
318 $search_date_approve_startday =
'';
319 $search_date_approve_startmonth =
'';
320 $search_date_approve_startyear =
'';
321 $search_date_approve_endday =
'';
322 $search_date_approve_endmonth =
'';
323 $search_date_approve_endyear =
'';
324 $search_date_approve_start =
'';
325 $search_date_approve_end =
'';
329 $search_array_options = array();
331 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
332 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
337 $objectclass =
'CommandeFournisseur';
338 $objectlabel =
'SupplierOrders';
339 $uploaddir = $conf->fournisseur->commande->dir_output;
340 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
342 if ($action ==
'validate' && $permissiontovalidate) {
343 if (
GETPOST(
'confirm') ==
'yes') {
348 foreach ($toselect as $checked) {
349 if ($objecttmp->fetch($checked)) {
350 if ($objecttmp->statut == 0) {
351 $objecttmp->date_commande =
dol_now();
352 $result = $objecttmp->valid($user);
355 if (!
getDolGlobalString(
'SUPPLIER_ORDER_NO_DIRECT_APPROVE') && $permissiontoapprove && !(
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') && $objecttmp->hasProductsOrServices(1))) {
356 $result = $objecttmp->approve($user);
357 setEventMessages($langs->trans(
"SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
359 setEventMessages($langs->trans(
"SupplierOrderValidated"), array($objecttmp->ref));
378 if ($massaction ==
'confirm_createsupplierbills') {
379 $orders =
GETPOST(
'toselect',
'array');
380 $createbills_onebythird =
GETPOSTINT(
'createbills_onebythird');
381 $validate_invoices =
GETPOSTINT(
'validate_invoices');
385 $TFactThird = array();
387 $nb_bills_created = 0;
395 foreach ($orders as $id_order) {
397 if ($cmd->fetch($id_order) <= 0) {
402 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
404 $objecttmp = $TFactThird[$cmd->socid];
407 if (!empty($cmd->socid) > 0) {
409 $societe->fetch($cmd->socid);
410 $objecttmp->vat_reverse_charge = $societe->vat_reverse_charge;
412 $objecttmp->socid = $cmd->socid;
413 $objecttmp->type = $objecttmp::TYPE_STANDARD;
414 $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
415 $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
416 $objecttmp->fk_project = $cmd->fk_project;
417 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
418 $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
419 $default_ref_supplier += 1;
422 if (empty($datefacture)) {
426 $objecttmp->date = $datefacture;
427 $objecttmp->origin =
'order_supplier';
428 $objecttmp->origin_id = $id_order;
430 $res = $objecttmp->create($user);
434 $lastref = $objecttmp->ref;
435 $lastid = $objecttmp->id;
439 if ($objecttmp->id > 0) {
440 if (empty($objecttmp->note_public)) {
441 $objecttmp->note_public = $langs->transnoentities(
"Orders");
444 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_element (";
446 $sql .=
", sourcetype";
447 $sql .=
", fk_target";
448 $sql .=
", targettype";
449 $sql .=
") VALUES (";
451 $sql .=
", '".$db->escape($objecttmp->origin).
"'";
452 $sql .=
", ".((int) $objecttmp->id);
453 $sql .=
", '".$db->escape($objecttmp->element).
"'";
456 if (!$db->query($sql)) {
461 $lines = $cmd->lines;
462 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
464 $lines = $cmd->lines;
468 $num = count($lines);
470 for ($i = 0; $i < $num; $i++) {
471 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
472 if ($lines[$i]->subprice < 0) {
473 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
477 $discount->fk_soc = $objecttmp->socid;
478 $discount->socid = $objecttmp->socid;
479 $discount->amount_ht = abs($lines[$i]->total_ht);
480 $discount->amount_tva = abs($lines[$i]->total_tva);
481 $discount->amount_ttc = abs($lines[$i]->total_ttc);
482 $discount->tva_tx = $lines[$i]->tva_tx;
483 $discount->fk_user = $user->id;
484 $discount->description = $desc;
485 $discountid = $discount->create($user);
486 if ($discountid > 0) {
487 $result = $objecttmp->insert_discount($discountid);
496 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
499 if ($lines[$i]->date_debut_prevue) {
500 $date_start = $lines[$i]->date_debut_prevue;
502 if ($lines[$i]->date_debut_reel) {
503 $date_start = $lines[$i]->date_debut_reel;
505 if ($lines[$i]->date_start) {
506 $date_start = $lines[$i]->date_start;
510 if ($lines[$i]->date_fin_prevue) {
511 $date_end = $lines[$i]->date_fin_prevue;
513 if ($lines[$i]->date_fin_reel) {
514 $date_end = $lines[$i]->date_fin_reel;
516 if ($lines[$i]->date_end) {
517 $date_end = $lines[$i]->date_end;
520 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
523 $result = $objecttmp->addline(
525 $lines[$i]->subprice,
527 $lines[$i]->localtax1_tx,
528 $lines[$i]->localtax2_tx,
530 $lines[$i]->fk_product,
531 $lines[$i]->remise_percent,
535 $lines[$i]->info_bits,
541 $lines[$i]->array_options,
544 $lines[$i]->fk_commande,
546 $lines[$i]->ref_supplier,
547 $lines[$i]->special_code,
558 if ($result > 0 && $lines[$i]->product_type == 9) {
559 $fk_parent_line = $result;
567 $objecttmp->note_public =
dol_concatdesc($objecttmp->note_public, $langs->transnoentities($cmd->ref).(empty($cmd->ref_supplier) ?
'' :
' ('.$cmd->ref_supplier.
')'));
568 $objecttmp->update($user);
571 $cmd->classifyBilled($user);
573 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
574 $TFactThird[$cmd->socid] = $objecttmp;
576 $TFact[$objecttmp->id] = $objecttmp;
581 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
584 if (!$error && $validate_invoices) {
585 $massaction = $action =
'builddoc';
587 foreach ($TAllFact as &$objecttmp) {
588 $objecttmp->validate($user);
595 $id = $objecttmp->id;
599 $upload_dir = $conf->fournisseur->facture->dir_output;
600 $permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
604 $massaction = $action =
'confirm_createsupplierbills';
610 if ($nb_bills_created == 1) {
611 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
612 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?id='.urlencode((
string) ($lastid)).
'">'.$lastref.
'</a>', $texttoshow);
615 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
621 $param .=
'&mode='.urlencode($mode);
623 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
624 $param .=
'&contextpage='.urlencode($contextpage);
626 if ($limit > 0 && $limit != $conf->liste_limit) {
627 $param .=
'&limit='.((int) $limit);
630 $param .=
'&search_all='.urlencode($search_all);
633 $param .=
'&socid='.urlencode((
string) ($socid));
635 if ($search_status !=
'') {
636 $param .=
'&search_status='.urlencode($search_status);
638 if ($search_option) {
639 $param .=
'&search_option='.urlencode($search_option);
641 if ($search_date_order_startday) {
642 $param .=
'&search_date_order_startday='.urlencode((
string) ($search_date_order_startday));
644 if ($search_date_order_startmonth) {
645 $param .=
'&search_date_order_startmonth='.urlencode((
string) ($search_date_order_startmonth));
647 if ($search_date_order_startyear) {
648 $param .=
'&search_date_order_startyear='.urlencode((
string) ($search_date_order_startyear));
650 if ($search_date_order_endday) {
651 $param .=
'&search_date_order_endday='.urlencode((
string) ($search_date_order_endday));
653 if ($search_date_order_endmonth) {
654 $param .=
'&search_date_order_endmonth='.urlencode((
string) ($search_date_order_endmonth));
656 if ($search_date_order_endyear) {
657 $param .=
'&search_date_order_endyear='.urlencode((
string) ($search_date_order_endyear));
659 if ($search_date_delivery_startday) {
660 $param .=
'&search_date_delivery_startday='.urlencode((
string) ($search_date_delivery_startday));
662 if ($search_date_delivery_startmonth) {
663 $param .=
'&search_date_delivery_startmonth='.urlencode((
string) ($search_date_delivery_startmonth));
665 if ($search_date_delivery_startyear) {
666 $param .=
'&search_date_delivery_startyear='.urlencode((
string) ($search_date_delivery_startyear));
668 if ($search_date_delivery_endday) {
669 $param .=
'&search_date_delivery_endday='.urlencode((
string) ($search_date_delivery_endday));
671 if ($search_date_delivery_endmonth) {
672 $param .=
'&search_date_delivery_endmonth='.urlencode((
string) ($search_date_delivery_endmonth));
674 if ($search_date_delivery_endyear) {
675 $param .=
'&search_date_delivery_endyear='.urlencode((
string) ($search_date_delivery_endyear));
677 if ($search_date_valid_startday) {
678 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
680 if ($search_date_valid_startmonth) {
681 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
683 if ($search_date_valid_startyear) {
684 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
686 if ($search_date_valid_endday) {
687 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
689 if ($search_date_valid_endmonth) {
690 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
692 if ($search_date_valid_endyear) {
693 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
695 if ($search_date_approve_startday) {
696 $param .=
'&search_date_approve_startday='.urlencode((
string) ($search_date_approve_startday));
698 if ($search_date_approve_startmonth) {
699 $param .=
'&search_date_approve_startmonth='.urlencode((
string) ($search_date_approve_startmonth));
701 if ($search_date_approve_startyear) {
702 $param .=
'&search_date_approve_startyear='.urlencode((
string) ($search_date_approve_startyear));
704 if ($search_date_approve_endday) {
705 $param .=
'&search_date_approve_endday='.urlencode((
string) ($search_date_approve_endday));
707 if ($search_date_approve_endmonth) {
708 $param .=
'&search_date_approve_endmonth='.urlencode((
string) ($search_date_approve_endmonth));
710 if ($search_date_approve_endyear) {
711 $param .=
'&search_date_approve_endyear='.urlencode((
string) ($search_date_approve_endyear));
714 $param .=
'&search_ref='.urlencode($search_ref);
716 if ($search_company) {
717 $param .=
'&search_company='.urlencode($search_company);
719 if ($search_company_alias) {
720 $param .=
'&search_company_alias='.urlencode($search_company_alias);
723 if ($search_user > 0) {
724 $param .=
'&search_user='.urlencode((
string) ($search_user));
726 if ($search_sale > 0) {
727 $param .=
'&search_sale='.urlencode($search_sale);
729 if ($search_total_ht !=
'') {
730 $param .=
'&search_total_ht='.urlencode($search_total_ht);
732 if ($search_total_tva !=
'') {
733 $param .=
'&search_total_tva='.urlencode($search_total_tva);
735 if ($search_total_ttc !=
'') {
736 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
738 if ($search_project_ref >= 0) {
739 $param .=
"&search_project_ref=".urlencode($search_project_ref);
742 $param .=
'&show_files='.urlencode((
string) ($show_files));
744 if ($optioncss !=
'') {
745 $param .=
'&optioncss='.urlencode($optioncss);
748 $param .=
'&billed='.urlencode($billed);
751 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
756 $_GET[
"origin"] = $_POST[
"origin"];
757 $_GET[
"originid"] = $_POST[
"originid"];
771$form =
new Form($db);
779$title = $langs->trans(
"SuppliersOrders");
782 $fourn->fetch($socid);
783 $title .=
' - '.$fourn->name;
794if ($search_billed > 0) {
795 $title .=
' - '.$langs->trans(
"Billed");
801$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
802$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
806 $sql =
'SELECT DISTINCT';
808$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,';
809$sql .=
" typent.code as typent_code,";
810$sql .=
" state.code_departement as state_code, state.nom as state_name,";
811$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,";
812$sql .=
' cf.localtax1 as total_localtax1, cf.localtax2 as total_localtax2,';
813$sql .=
' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
814$sql .=
' cf.date_creation as date_creation, cf.tms as date_modification,';
815$sql .=
' cf.note_public, cf.note_private,';
816$sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
817$sql .=
" u.firstname, u.lastname, u.photo, u.login, u.email as user_email, u.statut as user_status";
819if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
820 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
821 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
825$parameters = array();
826$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
827$sql .= $hookmanager->resPrint;
831$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
832$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
833$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
834$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
835$sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
836if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
837 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cf.rowid = ef.fk_object)";
840 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
842$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON cf.fk_user_author = u.rowid";
843$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = cf.fk_projet";
844$parameters = array();
845$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
846$sql .= $hookmanager->resPrint;
847$sql .=
' WHERE cf.fk_soc = s.rowid';
848$sql .=
' AND cf.entity IN ('.getEntity(
'supplier_order').
')';
850 $sql .=
" AND s.rowid = ".((int) $socid);
855if ($search_refsupp) {
859 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
861if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
862 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
864 if ($search_company) {
867 if ($search_company_alias) {
871if ($search_request_author) {
872 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_request_author);
874if ($search_billed !=
'' && $search_billed >= 0) {
875 $sql .=
" AND cf.billed = ".((int) $search_billed);
878if (
GETPOST(
'statut',
'intcomma') !==
'') {
879 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(
GETPOST(
'statut',
'intcomma')))).
")";
881if ($search_status !=
'' && $search_status !=
'-1') {
882 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
884if ($search_option ==
'late') {
885 $sql .=
" AND cf.date_commande < '".$db->idate(
dol_now() - $conf->order->fournisseur->warning_delay).
"'";
887if ($search_date_order_start) {
888 $sql .=
" AND cf.date_commande >= '".$db->idate($search_date_order_start).
"'";
890if ($search_date_order_end) {
891 $sql .=
" AND cf.date_commande <= '".$db->idate($search_date_order_end).
"'";
893if ($search_date_delivery_start) {
894 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_delivery_start).
"'";
896if ($search_date_delivery_end) {
897 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_delivery_end).
"'";
899if ($search_date_valid_start) {
900 $sql .=
" AND cf.date_valid >= '".$db->idate($search_date_valid_start).
"'";
902if ($search_date_valid_end) {
903 $sql .=
" AND cf.date_valid <= '".$db->idate($search_date_valid_end).
"'";
905if ($search_date_approve_start) {
906 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_approve_start).
"'";
908if ($search_date_approve_end) {
909 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_approve_end).
"'";
920if ($search_country) {
921 $sql .=
" AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).
')';
923if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
924 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
929if ($search_user > 0) {
930 $sql .=
" AND EXISTS (";
931 $sql .=
" SELECT ec.rowid ";
932 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_contact as ec";
933 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
934 $sql .=
" WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
935 $sql .=
" AND tc.element = 'order_supplier' AND tc.source = 'internal'";
938if ($search_total_ht !=
'') {
941if ($search_total_tva !=
'') {
944if ($search_total_ttc !=
'') {
947if ($search_multicurrency_code !=
'') {
948 $sql .=
" AND cf.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
950if ($search_multicurrency_tx !=
'') {
951 $sql .=
natural_search(
'cf.multicurrency_tx', $search_multicurrency_tx, 1);
953if ($search_multicurrency_montant_ht !=
'') {
954 $sql .=
natural_search(
'cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
956if ($search_multicurrency_montant_tva !=
'') {
957 $sql .=
natural_search(
'cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1);
959if ($search_multicurrency_montant_ttc !=
'') {
960 $sql .=
natural_search(
'cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
962if ($search_project_ref !=
'') {
966if ($search_sale && $search_sale !=
'-1') {
967 if ($search_sale == -2) {
968 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = cf.fk_soc)";
969 } elseif ($search_sale > 0) {
970 $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).
")";
974$searchCategoryProductOperator = -1;
975$searchCategoryProductList = array($search_product_category);
976if (!empty($searchCategoryProductList)) {
977 $searchCategoryProductSqlList = array();
978 $listofcategoryid =
'';
979 foreach ($searchCategoryProductList as $searchCategoryProduct) {
980 if (intval($searchCategoryProduct) == -2) {
981 $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)";
982 } elseif (intval($searchCategoryProduct) > 0) {
983 if ($searchCategoryProductOperator == 0) {
984 $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).
")";
986 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
990 if ($listofcategoryid) {
991 $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).
"))";
993 if ($searchCategoryProductOperator == 1) {
994 if (!empty($searchCategoryProductSqlList)) {
995 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
998 if (!empty($searchCategoryProductSqlList)) {
999 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
1004include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1006$parameters = array();
1007$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
1008$sql .= $hookmanager->resPrint;
1011$nbtotalofrecords =
'';
1014 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1015 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1016 $resql = $db->query($sqlforcount);
1018 $objforcount = $db->fetch_object($resql);
1019 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1024 if (($page * $limit) > $nbtotalofrecords) {
1031$sql .= $db->order($sortfield, $sortorder);
1033 $sql .= $db->plimit($limit + 1, $offset);
1037$resql = $db->query($sql);
1039 $num = $db->num_rows($resql);
1041 $arrayofselected = is_array($toselect) ? $toselect : array();
1043 if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1044 $obj = $db->fetch_object($resql);
1046 header(
"Location: ".DOL_URL_ROOT.
'/fourn/commande/card.php?id='.
$id);
1050 llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-supplier-order page-list');
1053 if (!empty($mode)) {
1054 $param .=
'&mode='.urlencode($mode);
1056 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1057 $param .=
'&contextpage='.urlencode($contextpage);
1059 if ($limit > 0 && $limit != $conf->liste_limit) {
1060 $param .=
'&limit='.((int) $limit);
1063 $param .=
'&search_all='.urlencode($search_all);
1066 $param .=
'&socid='.urlencode((
string) ($socid));
1069 $param .=
"&search_all=".urlencode($search_all);
1071 if ($search_date_order_startday) {
1072 $param .=
'&search_date_order_startday='.urlencode((
string) ($search_date_order_startday));
1074 if ($search_date_order_startmonth) {
1075 $param .=
'&search_date_order_startmonth='.urlencode((
string) ($search_date_order_startmonth));
1077 if ($search_date_order_startyear) {
1078 $param .=
'&search_date_order_startyear='.urlencode((
string) ($search_date_order_startyear));
1080 if ($search_date_order_endday) {
1081 $param .=
'&search_date_order_endday='.urlencode((
string) ($search_date_order_endday));
1083 if ($search_date_order_endmonth) {
1084 $param .=
'&search_date_order_endmonth='.urlencode((
string) ($search_date_order_endmonth));
1086 if ($search_date_order_endyear) {
1087 $param .=
'&search_date_order_endyear='.urlencode((
string) ($search_date_order_endyear));
1089 if ($search_date_delivery_startday) {
1090 $param .=
'&search_date_delivery_startday='.urlencode((
string) ($search_date_delivery_startday));
1092 if ($search_date_delivery_startmonth) {
1093 $param .=
'&search_date_delivery_startmonth='.urlencode((
string) ($search_date_delivery_startmonth));
1095 if ($search_date_delivery_startyear) {
1096 $param .=
'&search_date_delivery_startyear='.urlencode((
string) ($search_date_delivery_startyear));
1098 if ($search_date_delivery_endday) {
1099 $param .=
'&search_date_delivery_endday='.urlencode((
string) ($search_date_delivery_endday));
1101 if ($search_date_delivery_endmonth) {
1102 $param .=
'&search_date_delivery_endmonth='.urlencode((
string) ($search_date_delivery_endmonth));
1104 if ($search_date_delivery_endyear) {
1105 $param .=
'&search_date_delivery_endyear='.urlencode((
string) ($search_date_delivery_endyear));
1107 if ($search_date_valid_startday) {
1108 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
1110 if ($search_date_valid_startmonth) {
1111 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
1113 if ($search_date_valid_startyear) {
1114 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
1116 if ($search_date_valid_endday) {
1117 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
1119 if ($search_date_valid_endmonth) {
1120 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
1122 if ($search_date_valid_endyear) {
1123 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
1125 if ($search_date_approve_startday) {
1126 $param .=
'&search_date_approve_startday='.urlencode((
string) ($search_date_approve_startday));
1128 if ($search_date_approve_startmonth) {
1129 $param .=
'&search_date_approve_startmonth='.urlencode((
string) ($search_date_approve_startmonth));
1131 if ($search_date_approve_startyear) {
1132 $param .=
'&search_date_approve_startyear='.urlencode((
string) ($search_date_approve_startyear));
1134 if ($search_date_approve_endday) {
1135 $param .=
'&search_date_approve_endday='.urlencode((
string) ($search_date_approve_endday));
1137 if ($search_date_approve_endmonth) {
1138 $param .=
'&search_date_approve_endmonth='.urlencode((
string) ($search_date_approve_endmonth));
1140 if ($search_date_approve_endyear) {
1141 $param .=
'&search_date_approve_endyear='.urlencode((
string) ($search_date_approve_endyear));
1144 $param .=
'&search_ref='.urlencode($search_ref);
1146 if ($search_company) {
1147 $param .=
'&search_company='.urlencode($search_company);
1149 if ($search_company_alias) {
1150 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1152 if ($search_user > 0) {
1153 $param .=
'&search_user='.urlencode((
string) ($search_user));
1155 if ($search_request_author) {
1156 $param .=
'&search_request_author='.urlencode($search_request_author);
1158 if ($search_sale > 0) {
1159 $param .=
'&search_sale='.urlencode($search_sale);
1161 if ($search_total_ht !=
'') {
1162 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1164 if ($search_total_ttc !=
'') {
1165 $param .=
"&search_total_ttc=".urlencode($search_total_ttc);
1167 if ($search_multicurrency_code !=
'') {
1168 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1170 if ($search_multicurrency_tx !=
'') {
1171 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1173 if ($search_multicurrency_montant_ht !=
'') {
1174 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1176 if ($search_multicurrency_montant_tva !=
'') {
1177 $param .=
'&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva);
1179 if ($search_multicurrency_montant_ttc !=
'') {
1180 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1182 if ($search_refsupp) {
1183 $param .=
"&search_refsupp=".urlencode($search_refsupp);
1185 if ($search_status !=
'' && $search_status !=
'-1') {
1186 $param .=
"&search_status=".urlencode($search_status);
1188 if ($search_option) {
1189 $param .=
"&search_option=".urlencode($search_option);
1191 if ($search_project_ref >= 0) {
1192 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1194 if ($search_billed !=
'') {
1195 $param .=
"&search_billed=".urlencode($search_billed);
1198 $param .=
'&show_files='.urlencode((
string) ($show_files));
1200 if ($optioncss !=
'') {
1201 $param .=
'&optioncss='.urlencode($optioncss);
1203 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
1204 $param .=
'&search_type_thirdparty='.urlencode((
string) ($search_type_thirdparty));
1208 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1210 $parameters = array(
'param' => &$param);
1211 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1212 $param .= $hookmanager->resPrint;
1215 $arrayofmassactions = array(
1216 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1217 'builddoc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1218 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1221 if ($permissiontovalidate) {
1222 if ($permissiontoapprove && !
getDolGlobalString(
'SUPPLIER_ORDER_NO_DIRECT_APPROVE')) {
1223 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"ValidateAndApprove");
1225 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1229 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
"supplier_invoice",
"creer")) {
1230 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'supplier_invoice',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisSupplier");
1232 if ($permissiontodelete) {
1233 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1235 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1236 $arrayofmassactions = array();
1238 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1240 $url = DOL_URL_ROOT.
'/fourn/commande/card.php?action=create';
1242 $url .=
'&socid='.((int) $socid);
1243 $url .=
'&backtopage='.urlencode(DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.((
int) $socid));
1245 $newcardbutton =
'';
1246 $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'));
1247 $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'));
1249 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewSupplierOrderShort'),
'',
'fa fa-plus-circle', $url,
'', (
int) $permissiontoadd);
1252 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1253 if ($optioncss !=
'') {
1254 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1256 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1257 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1258 print
'<input type="hidden" name="action" value="list">';
1259 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1260 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1261 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1262 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1263 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1265 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'supplier_order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1267 $topicmail =
"SendOrderRef";
1268 $modelmail =
"order_supplier_send";
1270 $trackid =
'sord'.$object->id;
1271 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1273 if ($massaction ==
'prevalidate') {
1274 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1277 if ($massaction ==
'createbills') {
1279 print
'<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
1281 print
'<table class="noborder centpercent">';
1283 print
'<td class="titlefield">';
1284 print $langs->trans(
'DateInvoice');
1287 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1292 print $langs->trans(
'CreateOneBillByThird');
1295 print $form->selectyesno(
'createbills_onebythird',
'', 1);
1300 print $langs->trans(
'ValidateInvoices');
1303 print $form->selectyesno(
'validate_invoices', 1, 1);
1308 print
'<div class="center">';
1309 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1310 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1317 foreach ($fieldstosearchall as $key => $val) {
1318 $fieldstosearchall[$key] = $langs->trans($val);
1320 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
1323 $moreforfilter =
'';
1326 if ($user->hasRight(
"user",
"user",
"lire")) {
1327 $langs->load(
"commercial");
1328 $moreforfilter .=
'<div class="divsearchfield">';
1329 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1330 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1331 $moreforfilter .=
'</div>';
1334 if ($user->hasRight(
"user",
"user",
"lire")) {
1335 $moreforfilter .=
'<div class="divsearchfield">';
1336 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1337 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1338 $moreforfilter .=
'</div>';
1341 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
1342 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1343 $moreforfilter .=
'<div class="divsearchfield">';
1344 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1345 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1346 $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);
1347 $moreforfilter .=
'</div>';
1350 $moreforfilter .=
'<div class="divsearchfield">';
1351 $moreforfilter .= $langs->trans(
'Alert').
' <input type="checkbox" name="search_option" value="late"'.($search_option ==
'late' ?
' checked' :
'').
'>';
1352 $moreforfilter .=
'</div>';
1353 $parameters = array();
1354 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1355 if (empty($reshook)) {
1356 $moreforfilter .= $hookmanager->resPrint;
1358 $moreforfilter = $hookmanager->resPrint;
1361 if (!empty($moreforfilter)) {
1362 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1363 print $moreforfilter;
1367 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1368 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1369 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
1372 $selectedfields .=
'<script>';
1373 $selectedfields .=
' $(document).ready(function() {';
1374 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1375 $selectedfields .=
' $("#checkforselects").click();';
1376 $selectedfields .=
' $("#massaction").val("createbills").change();';
1377 $selectedfields .=
' });';
1378 $selectedfields .=
'</script>';
1381 print
'<div class="div-table-responsive">';
1382 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1384 print
'<tr class="liste_titre_filter">';
1387 print
'<td class="liste_titre middle">';
1388 $searchpicto = $form->showFilterButtons(
'left');
1393 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1394 print
'<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.
'"></td>';
1397 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1398 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.
'"></td>';
1401 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1402 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.
'"></td>';
1405 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1406 print
'<td class="liste_titre">';
1407 print
'<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.
'">';
1411 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1412 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.
'"></td>';
1415 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1416 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company_alias" value="'.$search_company_alias.
'"></td>';
1419 if (!empty($arrayfields[
's.town'][
'checked'])) {
1420 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.
'"></td>';
1423 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1424 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.
'"></td>';
1427 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1428 print
'<td class="liste_titre">';
1429 print
'<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1433 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1434 print
'<td class="liste_titre center">';
1435 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1439 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1440 print
'<td class="liste_titre maxwidthonsmartphone center">';
1441 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);
1445 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1446 print
'<td class="liste_titre center">';
1447 print
'<div class="nowrapfordate">';
1448 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'));
1450 print
'<div class="nowrapfordate">';
1451 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'));
1456 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1457 print
'<td class="liste_titre center">';
1458 print
'<div class="nowrapfordate">';
1459 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'));
1461 print
'<div class="nowrapfordate">';
1462 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'));
1466 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1468 print
'<td class="liste_titre right">';
1469 print
'<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.
'">';
1472 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1474 print
'<td class="liste_titre right">';
1475 print
'<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.
'">';
1478 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1480 print
'<td class="liste_titre right">';
1481 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1484 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1486 print
'<td class="liste_titre">';
1487 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1490 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1492 print
'<td class="liste_titre">';
1493 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1496 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1498 print
'<td class="liste_titre right">';
1499 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1502 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1504 print
'<td class="liste_titre right">';
1505 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).
'">';
1508 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1510 print
'<td class="liste_titre right">';
1511 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1515 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1518 $parameters = array(
'arrayfields' => $arrayfields);
1519 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1520 print $hookmanager->resPrint;
1522 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1523 print
'<td class="liste_titre">';
1527 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1528 print
'<td class="liste_titre">';
1532 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1533 print
'<td class="liste_titre center parentonrightofpage">';
1534 print $form->selectyesno(
'search_billed', $search_billed, 1,
false, 1, 1,
'search_status width100 onrightofpage');
1538 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1539 print
'<td class="liste_titre center parentonrightofpage">';
1540 $formorder->selectSupplierOrderStatus($search_status, 1,
'search_status',
'search_status width100 onrightofpage');
1544 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1545 print
'<td class="liste_titre center">';
1546 print
'<div class="nowrapfordate">';
1547 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'));
1549 print
'<div class="nowrapfordate">';
1550 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'));
1555 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1556 print
'<td class="liste_titre center">';
1557 print
'<div class="nowrapfordate">';
1558 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'));
1560 print
'<div class="nowrapfordate">';
1561 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'));
1566 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1567 print
'<td class="liste_titre">';
1571 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1572 print
'<td class="liste_titre">';
1577 print
'<td class="liste_titre center">';
1578 $searchpicto = $form->showFilterButtons();
1585 $totalarray = array();
1586 $totalarray[
'nbfield'] = 0;
1589 print
'<tr class="liste_titre">';
1591 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1592 $totalarray[
'nbfield']++;
1594 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1595 print_liste_field_titre($arrayfields[
'cf.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref",
"", $param,
'', $sortfield, $sortorder);
1596 $totalarray[
'nbfield']++;
1598 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1599 print_liste_field_titre($arrayfields[
'cf.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref_supplier",
"", $param,
'', $sortfield, $sortorder,
'tdoverflowmax100imp ');
1600 $totalarray[
'nbfield']++;
1602 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1603 print_liste_field_titre($arrayfields[
'cf.fk_projet'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1604 $totalarray[
'nbfield']++;
1606 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1607 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
"u.login",
"", $param,
'', $sortfield, $sortorder);
1608 $totalarray[
'nbfield']++;
1610 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1611 print_liste_field_titre($arrayfields[
'cf.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
1612 $totalarray[
'nbfield']++;
1614 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1616 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"s.name_alias",
"", $param,
'', $sortfield, $sortorder);
1617 $totalarray[
'nbfield']++;
1619 if (!empty($arrayfields[
's.town'][
'checked'])) {
1620 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1621 $totalarray[
'nbfield']++;
1623 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1624 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1625 $totalarray[
'nbfield']++;
1627 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1628 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1629 $totalarray[
'nbfield']++;
1631 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1632 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1633 $totalarray[
'nbfield']++;
1635 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1636 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1637 $totalarray[
'nbfield']++;
1639 if (!empty($arrayfields[
'cf.fk_author'][
'checked'])) {
1640 print_liste_field_titre($arrayfields[
'cf.fk_author'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_author",
"", $param,
'', $sortfield, $sortorder);
1641 $totalarray[
'nbfield']++;
1643 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1644 print_liste_field_titre($arrayfields[
'cf.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_commande",
"", $param,
'', $sortfield, $sortorder,
'center ');
1645 $totalarray[
'nbfield']++;
1647 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1648 print_liste_field_titre($arrayfields[
'cf.date_livraison'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1649 $totalarray[
'nbfield']++;
1651 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1652 print_liste_field_titre($arrayfields[
'cf.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
1653 $totalarray[
'nbfield']++;
1655 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1656 print_liste_field_titre($arrayfields[
'cf.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
1657 $totalarray[
'nbfield']++;
1659 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1660 print_liste_field_titre($arrayfields[
'cf.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
1661 $totalarray[
'nbfield']++;
1663 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1664 print_liste_field_titre($arrayfields[
'cf.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1665 $totalarray[
'nbfield']++;
1667 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1668 print_liste_field_titre($arrayfields[
'cf.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1669 $totalarray[
'nbfield']++;
1671 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1672 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1673 $totalarray[
'nbfield']++;
1675 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1676 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1677 $totalarray[
'nbfield']++;
1679 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1680 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1681 $totalarray[
'nbfield']++;
1684 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1686 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1687 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1688 print $hookmanager->resPrint;
1689 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1690 print_liste_field_titre($arrayfields[
'cf.date_creation'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowraponall ');
1691 $totalarray[
'nbfield']++;
1693 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1694 print_liste_field_titre($arrayfields[
'cf.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowraponall ');
1695 $totalarray[
'nbfield']++;
1697 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1698 print_liste_field_titre($arrayfields[
'cf.billed'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.billed',
'', $param,
'', $sortfield, $sortorder,
'center ');
1699 $totalarray[
'nbfield']++;
1701 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1702 print_liste_field_titre($arrayfields[
'cf.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1703 $totalarray[
'nbfield']++;
1705 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1706 print_liste_field_titre($arrayfields[
'cf.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
1707 $totalarray[
'nbfield']++;
1709 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1710 print_liste_field_titre($arrayfields[
'cf.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_approve',
'', $param,
'', $sortfield, $sortorder,
'center ');
1711 $totalarray[
'nbfield']++;
1713 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1714 print_liste_field_titre($arrayfields[
'cf.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_public",
"", $param,
'', $sortfield, $sortorder,
'center ');
1715 $totalarray[
'nbfield']++;
1717 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1718 print_liste_field_titre($arrayfields[
'cf.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_private",
"", $param,
'', $sortfield, $sortorder,
'center ');
1719 $totalarray[
'nbfield']++;
1722 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1723 $totalarray[
'nbfield']++;
1729 $productstat_cache = array();
1731 $userstatic =
new User($db);
1733 $projectstatic =
new Project($db);
1736 $savnbfield = $totalarray[
'nbfield'];
1737 $totalarray = array(
'nbfield' => 0,
'val' => array(),
'pos' => array());
1738 $totalarray[
'val'][
'cf.total_ht'] = 0;
1739 $totalarray[
'val'][
'cf.total_ttc'] = 0;
1740 $totalarray[
'val'][
'cf.total_tva'] = 0;
1742 $imaxinloop = ($limit ? min($num, $limit) : $num);
1743 while ($i < $imaxinloop) {
1744 $obj = $db->fetch_object($resql);
1752 $objectstatic->id = $obj->rowid;
1753 $objectstatic->ref = $obj->ref;
1754 $objectstatic->ref_supplier = $obj->ref_supplier;
1755 $objectstatic->socid = $obj->socid;
1756 $objectstatic->total_ht = $obj->total_ht;
1757 $objectstatic->total_tva = $obj->total_tva;
1758 $objectstatic->total_ttc = $obj->total_ttc;
1759 $objectstatic->date_commande = $db->jdate($obj->date_commande);
1760 $objectstatic->delivery_date = $db->jdate($obj->delivery_date);
1761 $objectstatic->note_public = $obj->note_public;
1762 $objectstatic->note_private = $obj->note_private;
1763 $objectstatic->statut = $obj->fk_statut;
1765 if ($mode ==
'kanban') {
1767 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1768 print
'<div class="box-flex-container kanban">';
1771 $thirdpartytmp->id = $obj->socid;
1772 $thirdpartytmp->name = $obj->name;
1773 $thirdpartytmp->email = $obj->email;
1774 $thirdpartytmp->name_alias = $obj->alias;
1775 $thirdpartytmp->client = $obj->client;
1776 $thirdpartytmp->fournisseur = $obj->fournisseur;
1778 print $objectstatic->getKanbanView(
'', array(
'thirdparty' => $thirdpartytmp->getNomUrl(
'supplier', 0, 0, -1),
'selected' => in_array($objectstatic->id, $arrayofselected)));
1779 if ($i == ($imaxinloop - 1)) {
1784 print
'<tr class="oddeven '.((getDolGlobalInt(
'MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->billed == 1) ?
'opacitymedium' :
'').
'">';
1787 print
'<td class="nowrap center">';
1788 if ($massactionbutton || $massaction) {
1790 if (in_array($obj->rowid, $arrayofselected)) {
1793 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1798 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1799 print
'<td class="nowrap">';
1802 print $objectstatic->getNomUrl(1,
'', 0, -1, 1);
1806 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1810 $totalarray[
'nbfield']++;
1814 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1815 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>'.
"\n";
1817 $totalarray[
'nbfield']++;
1821 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1822 $projectstatic->id = $obj->project_id;
1823 $projectstatic->ref = $obj->project_ref;
1824 $projectstatic->title = $obj->project_title;
1826 if ($obj->project_id > 0) {
1827 print $projectstatic->getNomUrl(1);
1831 $totalarray[
'nbfield']++;
1835 $userstatic->id = $obj->fk_user_author;
1836 $userstatic->lastname = $obj->lastname;
1837 $userstatic->firstname = $obj->firstname;
1838 $userstatic->login = $obj->login;
1839 $userstatic->photo = $obj->photo;
1840 $userstatic->email = $obj->user_email;
1841 $userstatic->status = $obj->user_status;
1842 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1843 print
'<td class="tdoverflowmax150">';
1844 if ($userstatic->id) {
1845 print $userstatic->getNomUrl(1);
1849 $totalarray[
'nbfield']++;
1853 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1854 print
'<td class="tdoverflowmax150">';
1855 $thirdpartytmp->id = $obj->socid;
1856 $thirdpartytmp->name = $obj->name;
1857 $thirdpartytmp->email = $obj->email;
1858 $thirdpartytmp->name_alias = $obj->alias;
1859 $thirdpartytmp->client = $obj->client;
1860 $thirdpartytmp->fournisseur = $obj->fournisseur;
1861 print $thirdpartytmp->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1864 $totalarray[
'nbfield']++;
1868 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1869 print
'<td class="tdoverflowmax150">';
1873 $totalarray[
'nbfield']++;
1877 if (!empty($arrayfields[
's.town'][
'checked'])) {
1882 $totalarray[
'nbfield']++;
1886 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1891 $totalarray[
'nbfield']++;
1895 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1896 print
"<td>".$obj->state_name.
"</td>\n";
1898 $totalarray[
'nbfield']++;
1902 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1903 print
'<td class="center">';
1904 $tmparray =
getCountry($obj->fk_pays,
'all');
1905 print $tmparray[
'label'];
1908 $totalarray[
'nbfield']++;
1912 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1913 print
'<td class="center">';
1914 if (empty($typenArray)) {
1915 $typenArray = $formcompany->typent_array(1);
1917 print $typenArray[$obj->typent_code];
1920 $totalarray[
'nbfield']++;
1925 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1926 print
'<td class="center">';
1928 if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1929 if ($objectstatic->hasDelay()) {
1930 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1935 $totalarray[
'nbfield']++;
1939 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1940 print
'<td class="center">';
1942 if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1943 if ($objectstatic->hasDelay()) {
1944 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1949 $totalarray[
'nbfield']++;
1953 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1954 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1956 $totalarray[
'nbfield']++;
1959 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ht';
1961 $totalarray[
'val'][
'cf.total_ht'] += $obj->total_ht;
1964 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1965 print
'<td class="right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
1967 $totalarray[
'nbfield']++;
1970 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_tva';
1972 $totalarray[
'val'][
'cf.total_tva'] += $obj->total_tva;
1975 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1976 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1978 $totalarray[
'nbfield']++;
1981 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ttc';
1983 $totalarray[
'val'][
'cf.total_ttc'] += $obj->total_ttc;
1987 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1988 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1990 $totalarray[
'nbfield']++;
1995 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1996 print
'<td class="nowrap">';
1997 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2000 $totalarray[
'nbfield']++;
2004 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
2005 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
2007 $totalarray[
'nbfield']++;
2011 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
2012 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva).
"</span></td>\n";
2014 $totalarray[
'nbfield']++;
2018 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
2019 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
2021 $totalarray[
'nbfield']++;
2026 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2028 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
2029 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2030 print $hookmanager->resPrint;
2032 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
2033 print
'<td class="center nowraponall">';
2034 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2037 $totalarray[
'nbfield']++;
2041 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
2042 print
'<td class="center nowraponall">';
2043 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
2046 $totalarray[
'nbfield']++;
2050 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
2051 print
'<td class="center">'.yn($obj->billed).
'</td>';
2053 $totalarray[
'nbfield']++;
2057 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
2058 print
'<td class="center nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).
'</td>';
2060 $totalarray[
'nbfield']++;
2065 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
2066 print
'<td class="center">';
2070 $totalarray[
'nbfield']++;
2074 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
2075 print
'<td class="center">';
2079 $totalarray[
'nbfield']++;
2083 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
2084 print
'<td class="sensiblehtmlcontent center">';
2088 $totalarray[
'nbfield']++;
2093 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
2094 print
'<td class="sensiblehtmlcontent center">';
2098 $totalarray[
'nbfield']++;
2104 print
'<td class="nowrap center">';
2105 if ($massactionbutton || $massaction) {
2107 if (in_array($obj->rowid, $arrayofselected)) {
2110 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2115 $totalarray[
'nbfield']++;
2120 $total += $obj->total_ht;
2121 $subtotal += $obj->total_ht;
2127 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2132 foreach ($arrayfields as $key => $val) {
2133 if (!empty($val[
'checked'])) {
2137 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2142 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2143 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2144 print $hookmanager->resPrint;
2146 print
'</table>'.
"\n";
2149 print
'</form>'.
"\n";
2151 $hidegeneratedfilelistifempty = 1;
2152 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2153 $hidegeneratedfilelistifempty = 0;
2157 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2158 $urlsource .= str_replace(
'&',
'&', $param);
2160 $filedir = $diroutputmassaction;
2161 $genallowed = $permissiontoread;
2162 $delallowed = $permissiontoadd;
2164 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.
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.
print_barre_liste($title, $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.
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.