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';
63$langs->loadLangs(array(
"orders",
"sendings",
'deliveries',
'companies',
'compta',
'bills',
'projects',
'suppliers',
'products'));
66$action =
GETPOST(
'action',
'aZ09');
67$massaction =
GETPOST(
'massaction',
'alpha');
69$confirm =
GETPOST(
'confirm',
'alpha');
70$toselect =
GETPOST(
'toselect',
'array');
71$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierorderlist';
72$mode =
GETPOST(
'mode',
'alpha');
75$search_date_order_startday =
GETPOSTINT(
'search_date_order_startday');
76$search_date_order_startmonth =
GETPOSTINT(
'search_date_order_startmonth');
77$search_date_order_startyear =
GETPOSTINT(
'search_date_order_startyear');
78$search_date_order_endday =
GETPOSTINT(
'search_date_order_endday');
79$search_date_order_endmonth =
GETPOSTINT(
'search_date_order_endmonth');
80$search_date_order_endyear =
GETPOSTINT(
'search_date_order_endyear');
81$search_date_order_start =
dol_mktime(0, 0, 0, $search_date_order_startmonth, $search_date_order_startday, $search_date_order_startyear);
82$search_date_order_end =
dol_mktime(23, 59, 59, $search_date_order_endmonth, $search_date_order_endday, $search_date_order_endyear);
84$search_date_delivery_startday =
GETPOSTINT(
'search_date_delivery_startday');
85$search_date_delivery_startmonth =
GETPOSTINT(
'search_date_delivery_startmonth');
86$search_date_delivery_startyear =
GETPOSTINT(
'search_date_delivery_startyear');
87$search_date_delivery_endday =
GETPOSTINT(
'search_date_delivery_endday');
88$search_date_delivery_endmonth =
GETPOSTINT(
'search_date_delivery_endmonth');
89$search_date_delivery_endyear =
GETPOSTINT(
'search_date_delivery_endyear');
90$search_date_delivery_start =
dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear);
91$search_date_delivery_end =
dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
93$search_date_valid_startday =
GETPOSTINT(
'search_date_valid_startday');
94$search_date_valid_startmonth =
GETPOSTINT(
'search_date_valid_startmonth');
95$search_date_valid_startyear =
GETPOSTINT(
'search_date_valid_startyear');
96$search_date_valid_endday =
GETPOSTINT(
'search_date_valid_endday');
97$search_date_valid_endmonth =
GETPOSTINT(
'search_date_valid_endmonth');
98$search_date_valid_endyear =
GETPOSTINT(
'search_date_valid_endyear');
99$search_date_valid_start =
dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear);
100$search_date_valid_end =
dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
102$search_date_approve_startday =
GETPOSTINT(
'search_date_approve_startday');
103$search_date_approve_startmonth =
GETPOSTINT(
'search_date_approve_startmonth');
104$search_date_approve_startyear =
GETPOSTINT(
'search_date_approve_startyear');
105$search_date_approve_endday =
GETPOSTINT(
'search_date_approve_endday');
106$search_date_approve_endmonth =
GETPOSTINT(
'search_date_approve_endmonth');
107$search_date_approve_endyear =
GETPOSTINT(
'search_date_approve_endyear');
108$search_date_approve_start =
dol_mktime(0, 0, 0, $search_date_approve_startmonth, $search_date_approve_startday, $search_date_approve_startyear);
109$search_date_approve_end =
dol_mktime(23, 59, 59, $search_date_approve_endmonth, $search_date_approve_endday, $search_date_approve_endyear);
111$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
113$search_product_category =
GETPOSTINT(
'search_product_category');
114$search_ref =
GETPOST(
'search_ref',
'alpha');
115$search_refsupp =
GETPOST(
'search_refsupp',
'alpha');
116$search_company =
GETPOST(
'search_company',
'alpha');
117$search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
118$search_town =
GETPOST(
'search_town',
'alpha');
119$search_zip =
GETPOST(
'search_zip',
'alpha');
120$search_state =
GETPOST(
"search_state",
'alpha');
121$search_country =
GETPOST(
"search_country",
'aZ09');
122$search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'intcomma');
123$search_user =
GETPOST(
'search_user',
'intcomma');
124$search_request_author =
GETPOST(
'search_request_author',
'alpha');
125$optioncss =
GETPOST(
'optioncss',
'alpha');
127$search_sale =
GETPOST(
'search_sale',
'intcomma');
128$search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
129$search_total_tva =
GETPOST(
'search_total_tva',
'alpha');
130$search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
131$search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
132$search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
133$search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
134$search_multicurrency_montant_tva =
GETPOST(
'search_multicurrency_montant_tva',
'alpha');
135$search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
136$optioncss =
GETPOST(
'optioncss',
'alpha');
137$search_billed =
GETPOST(
'search_billed',
'intcomma');
138$search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
139$search_btn =
GETPOST(
'button_search',
'alpha');
140$search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
143 $search_status = implode(
',',
GETPOST(
'search_status',
'array:intcomma'));
145 $search_status = (
GETPOST(
'search_status',
'intcomma') !=
'' ?
GETPOST(
'search_status',
'intcomma') :
GETPOST(
'statut',
'intcomma'));
148$search_option =
GETPOST(
'search_option',
'alpha');
149if ($search_option ==
'late') {
150 $search_status =
'1,2';
153$diroutputmassaction =
$conf->fournisseur->commande->dir_output.
'/temp/massgeneration/'.$user->id;
156$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
157$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
159if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
163$offset = $limit * $page;
164$pageprev = $page - 1;
165$pagenext = $page + 1;
167 $sortfield =
'cf.ref';
175$hookmanager->initHooks(array(
'supplierorderlist'));
179$extrafields->fetch_name_optionals_label(
$object->table_element);
181$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
184$fieldstosearchall = array();
185foreach (
$object->fields as $key => $val) {
186 if (!empty($val[
'searchall'])) {
187 $fieldstosearchall[
'cf.'.$key] = $val[
'label'];
190$fieldstosearchall[
'pd.description'] =
'Description';
191$fieldstosearchall[
's.nom'] =
"ThirdParty";
192$fieldstosearchall[
's.name_alias'] =
"AliasNameShort";
193$fieldstosearchall[
's.zip'] =
"Zip";
194$fieldstosearchall[
's.town'] =
"Town";
195if (empty($user->socid)) {
196 $fieldstosearchall[
"cf.note_private"] =
"NotePrivate";
199$checkedtypetiers = 0;
203 'u.login' => array(
'label' =>
"AuthorRequest",
'enabled' => 1,
'position' => 41),
204 's.name_alias' => array(
'label' =>
"AliasNameShort",
'position' => 51,
'checked' => 0),
205 's.town' => array(
'label' =>
"Town",
'enabled' => 1,
'position' => 55,
'checked' => 1),
206 's.zip' => array(
'label' =>
"Zip",
'enabled' => 1,
'position' => 56,
'checked' => 1),
207 'state.nom' => array(
'label' =>
"StateShort",
'enabled' => 1,
'position' => 57),
208 'country.code_iso' => array(
'label' =>
"Country",
'enabled' => 1,
'position' => 58),
209 'typent.code' => array(
'label' =>
"ThirdPartyType",
'enabled' => $checkedtypetiers,
'position' => 59),
210 'cf.total_localtax1' => array(
'label' => $langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked' => 0,
'enabled' => ($mysoc->localtax1_assuj ==
"1"),
'position' => 140),
211 'cf.total_localtax2' => array(
'label' => $langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked' => 0,
'enabled' => ($mysoc->localtax2_assuj ==
"1"),
'position' => 145),
212 'cf.note_public' => array(
'label' =>
'NotePublic',
'checked' => 0,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES')),
'position' => 750),
213 'cf.note_private' => array(
'label' =>
'NotePrivate',
'checked' => 0,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'position' => 760),
215foreach (
$object->fields as $key => $val) {
217 if (!empty($val[
'visible'])) {
218 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
219 $arrayfields[
'cf.'.$key] = array(
220 'label' => $val[
'label'],
221 'checked' => (($visible < 0) ? 0 : 1),
222 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
223 'position' => $val[
'position'],
224 'help' => isset($val[
'help']) ? $val[
'help'] :
''
229include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
233'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
237if (!$user->hasRight(
'societe',
'client',
'voir')) {
238 $search_sale = $user->id;
244 $socid = $user->socid;
246$result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
248$permissiontoread = ($user->hasRight(
"fournisseur",
"commande",
"lire") || $user->hasRight(
"supplier_order",
"lire"));
249$permissiontoadd = ($user->hasRight(
"fournisseur",
"commande",
"creer") || $user->hasRight(
"supplier_order",
"creer"));
250$permissiontodelete = ($user->hasRight(
"fournisseur",
"commande",
"supprimer") || $user->hasRight(
"supplier_order",
"supprimer"));
251$permissiontovalidate = $permissiontoadd;
252$permissiontoapprove = ($user->hasRight(
"fournisseur",
"commande",
"approuver") || $user->hasRight(
"supplier_order",
"approuver"));
259if (
GETPOST(
'cancel',
'alpha')) {
263if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createsupplierbills') {
267$parameters = array(
'socid' => $socid,
'arrayfields' => &$arrayfields);
268$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
273if (empty($reshook)) {
275 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
278 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
282 $search_product_category =
'';
284 $search_refsupp =
'';
285 $search_company =
'';
286 $search_company_alias =
'';
291 $search_country =
'';
292 $search_type_thirdparty =
'';
293 $search_request_author =
'';
294 $search_total_ht =
'';
295 $search_total_tva =
'';
296 $search_total_ttc =
'';
297 $search_multicurrency_code =
'';
298 $search_multicurrency_tx =
'';
299 $search_multicurrency_montant_ht =
'';
300 $search_multicurrency_montant_tva =
'';
301 $search_multicurrency_montant_ttc =
'';
302 $search_project_ref =
'';
305 $search_date_order_startday =
'';
306 $search_date_order_startmonth =
'';
307 $search_date_order_startyear =
'';
308 $search_date_order_endday =
'';
309 $search_date_order_endmonth =
'';
310 $search_date_order_endyear =
'';
311 $search_date_order_start =
'';
312 $search_date_order_end =
'';
313 $search_date_delivery_startday =
'';
314 $search_date_delivery_startmonth =
'';
315 $search_date_delivery_startyear =
'';
316 $search_date_delivery_endday =
'';
317 $search_date_delivery_endmonth =
'';
318 $search_date_delivery_endyear =
'';
319 $search_date_delivery_start =
'';
320 $search_date_delivery_end =
'';
321 $search_date_valid_startday =
'';
322 $search_date_valid_startmonth =
'';
323 $search_date_valid_startyear =
'';
324 $search_date_valid_endday =
'';
325 $search_date_valid_endmonth =
'';
326 $search_date_valid_endyear =
'';
327 $search_date_valid_start =
'';
328 $search_date_valid_end =
'';
329 $search_date_approve_startday =
'';
330 $search_date_approve_startmonth =
'';
331 $search_date_approve_startyear =
'';
332 $search_date_approve_endday =
'';
333 $search_date_approve_endmonth =
'';
334 $search_date_approve_endyear =
'';
335 $search_date_approve_start =
'';
336 $search_date_approve_end =
'';
340 $search_array_options = array();
342 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
343 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
348 $objectclass =
'CommandeFournisseur';
349 $objectlabel =
'SupplierOrders';
350 $uploaddir =
$conf->fournisseur->commande->dir_output;
351 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
353 if ($action ==
'validate' && $permissiontovalidate) {
354 if (
GETPOST(
'confirm') ==
'yes') {
359 foreach ($toselect as $checked) {
360 if ($objecttmp->fetch($checked)) {
361 if ($objecttmp->statut == 0) {
362 $objecttmp->date_commande =
dol_now();
363 $result = $objecttmp->valid($user);
366 if (!
getDolGlobalString(
'SUPPLIER_ORDER_NO_DIRECT_APPROVE') && $permissiontoapprove && !(
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') && $objecttmp->hasProductsOrServices(1))) {
367 $result = $objecttmp->approve($user);
368 setEventMessages($langs->trans(
"SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
370 setEventMessages($langs->trans(
"SupplierOrderValidated"), array($objecttmp->ref));
389 if ($massaction ==
'confirm_createsupplierbills') {
390 $orders =
GETPOST(
'toselect',
'array');
391 $createbills_onebythird =
GETPOSTINT(
'createbills_onebythird');
392 $validate_invoices =
GETPOSTINT(
'validate_invoices');
396 $TFactThird = array();
398 $nb_bills_created = 0;
406 foreach ($orders as $id_order) {
408 if ($cmd->fetch($id_order) <= 0) {
413 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
415 $objecttmp = $TFactThird[$cmd->socid];
418 if (!empty($cmd->socid) > 0) {
420 $societe->fetch($cmd->socid);
421 $objecttmp->vat_reverse_charge = $societe->vat_reverse_charge;
422 $objecttmp->thirdparty = $societe;
424 $objecttmp->socid = $cmd->socid;
425 $objecttmp->type = $objecttmp::TYPE_STANDARD;
426 $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
427 $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
428 $objecttmp->fk_project = $cmd->fk_project;
429 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
430 $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
431 $default_ref_supplier += 1;
434 if (empty($datefacture)) {
438 $objecttmp->date = $datefacture;
439 $objecttmp->origin =
'order_supplier';
440 $objecttmp->origin_id = $id_order;
442 $res = $objecttmp->create($user);
446 $lastref = $objecttmp->ref;
447 $lastid = $objecttmp->id;
451 if ($objecttmp->id > 0) {
452 if (empty($objecttmp->note_public)) {
453 $objecttmp->note_public = $langs->transnoentities(
"Orders");
456 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_element (";
458 $sql .=
", sourcetype";
459 $sql .=
", fk_target";
460 $sql .=
", targettype";
461 $sql .=
") VALUES (";
463 $sql .=
", '".$db->escape($objecttmp->origin).
"'";
464 $sql .=
", ".((int) $objecttmp->id);
465 $sql .=
", '".$db->escape($objecttmp->element).
"'";
468 if (!$db->query($sql)) {
473 $lines = $cmd->lines;
474 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
476 $lines = $cmd->lines;
480 $num = count($lines);
482 for ($i = 0; $i < $num; $i++) {
483 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
484 if ($lines[$i]->subprice < 0) {
485 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
489 $discount->fk_soc = $objecttmp->socid;
490 $discount->socid = $objecttmp->socid;
491 $discount->amount_ht = abs($lines[$i]->total_ht);
492 $discount->amount_tva = abs($lines[$i]->total_tva);
493 $discount->amount_ttc = abs($lines[$i]->total_ttc);
494 $discount->tva_tx = $lines[$i]->tva_tx;
495 $discount->fk_user = $user->id;
496 $discount->description = $desc;
497 $discountid = $discount->create($user);
498 if ($discountid > 0) {
499 $result = $objecttmp->insert_discount($discountid);
508 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
511 if ($lines[$i]->date_debut_prevue) {
512 $date_start = $lines[$i]->date_debut_prevue;
514 if ($lines[$i]->date_debut_reel) {
515 $date_start = $lines[$i]->date_debut_reel;
517 if ($lines[$i]->date_start) {
518 $date_start = $lines[$i]->date_start;
522 if ($lines[$i]->date_fin_prevue) {
523 $date_end = $lines[$i]->date_fin_prevue;
525 if ($lines[$i]->date_fin_reel) {
526 $date_end = $lines[$i]->date_fin_reel;
528 if ($lines[$i]->date_end) {
529 $date_end = $lines[$i]->date_end;
532 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
536 $tva_tx = $lines[$i]->tva_tx;
537 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', (
string) $tva_tx)) {
538 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
541 $result = $objecttmp->addline(
543 $lines[$i]->subprice,
545 $lines[$i]->localtax1_tx,
546 $lines[$i]->localtax2_tx,
548 $lines[$i]->fk_product,
549 $lines[$i]->remise_percent,
553 $lines[$i]->info_bits,
559 $lines[$i]->array_options,
562 $lines[$i]->fk_commande,
564 $lines[$i]->ref_supplier,
565 $lines[$i]->special_code,
576 if ($result > 0 && $lines[$i]->product_type == 9) {
577 $fk_parent_line = $result;
585 $objecttmp->note_public =
dol_concatdesc($objecttmp->note_public, $langs->transnoentities($cmd->ref).(empty($cmd->ref_supplier) ?
'' :
' ('.$cmd->ref_supplier.
')'));
586 $objecttmp->update($user);
589 $cmd->classifyBilled($user);
591 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
592 $TFactThird[$cmd->socid] = $objecttmp;
594 $TFact[$objecttmp->id] = $objecttmp;
599 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
602 if (!$error && $validate_invoices) {
603 $massaction = $action =
'builddoc';
605 foreach ($TAllFact as &$objecttmp) {
606 $objecttmp->validate($user);
613 $id = $objecttmp->id;
617 $upload_dir =
$conf->fournisseur->facture->dir_output;
618 $permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
622 $massaction = $action =
'confirm_createsupplierbills';
628 if ($nb_bills_created == 1) {
629 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
630 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?id='.urlencode((
string) ($lastid)).
'">'.$lastref.
'</a>', $texttoshow);
633 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
639 $param .=
'&mode='.urlencode($mode);
641 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
642 $param .=
'&contextpage='.urlencode($contextpage);
644 if ($limit > 0 && $limit !=
$conf->liste_limit) {
645 $param .=
'&limit='.((int) $limit);
648 $param .=
'&search_all='.urlencode($search_all);
651 $param .=
'&socid='.urlencode((
string) ($socid));
653 if ($search_status !=
'') {
654 $param .=
'&search_status='.urlencode($search_status);
656 if ($search_option) {
657 $param .=
'&search_option='.urlencode($search_option);
659 if ($search_date_order_startday) {
660 $param .=
'&search_date_order_startday='.urlencode((
string) ($search_date_order_startday));
662 if ($search_date_order_startmonth) {
663 $param .=
'&search_date_order_startmonth='.urlencode((
string) ($search_date_order_startmonth));
665 if ($search_date_order_startyear) {
666 $param .=
'&search_date_order_startyear='.urlencode((
string) ($search_date_order_startyear));
668 if ($search_date_order_endday) {
669 $param .=
'&search_date_order_endday='.urlencode((
string) ($search_date_order_endday));
671 if ($search_date_order_endmonth) {
672 $param .=
'&search_date_order_endmonth='.urlencode((
string) ($search_date_order_endmonth));
674 if ($search_date_order_endyear) {
675 $param .=
'&search_date_order_endyear='.urlencode((
string) ($search_date_order_endyear));
677 if ($search_date_delivery_startday) {
678 $param .=
'&search_date_delivery_startday='.urlencode((
string) ($search_date_delivery_startday));
680 if ($search_date_delivery_startmonth) {
681 $param .=
'&search_date_delivery_startmonth='.urlencode((
string) ($search_date_delivery_startmonth));
683 if ($search_date_delivery_startyear) {
684 $param .=
'&search_date_delivery_startyear='.urlencode((
string) ($search_date_delivery_startyear));
686 if ($search_date_delivery_endday) {
687 $param .=
'&search_date_delivery_endday='.urlencode((
string) ($search_date_delivery_endday));
689 if ($search_date_delivery_endmonth) {
690 $param .=
'&search_date_delivery_endmonth='.urlencode((
string) ($search_date_delivery_endmonth));
692 if ($search_date_delivery_endyear) {
693 $param .=
'&search_date_delivery_endyear='.urlencode((
string) ($search_date_delivery_endyear));
695 if ($search_date_valid_startday) {
696 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
698 if ($search_date_valid_startmonth) {
699 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
701 if ($search_date_valid_startyear) {
702 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
704 if ($search_date_valid_endday) {
705 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
707 if ($search_date_valid_endmonth) {
708 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
710 if ($search_date_valid_endyear) {
711 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
713 if ($search_date_approve_startday) {
714 $param .=
'&search_date_approve_startday='.urlencode((
string) ($search_date_approve_startday));
716 if ($search_date_approve_startmonth) {
717 $param .=
'&search_date_approve_startmonth='.urlencode((
string) ($search_date_approve_startmonth));
719 if ($search_date_approve_startyear) {
720 $param .=
'&search_date_approve_startyear='.urlencode((
string) ($search_date_approve_startyear));
722 if ($search_date_approve_endday) {
723 $param .=
'&search_date_approve_endday='.urlencode((
string) ($search_date_approve_endday));
725 if ($search_date_approve_endmonth) {
726 $param .=
'&search_date_approve_endmonth='.urlencode((
string) ($search_date_approve_endmonth));
728 if ($search_date_approve_endyear) {
729 $param .=
'&search_date_approve_endyear='.urlencode((
string) ($search_date_approve_endyear));
732 $param .=
'&search_ref='.urlencode($search_ref);
734 if ($search_company) {
735 $param .=
'&search_company='.urlencode($search_company);
737 if ($search_company_alias) {
738 $param .=
'&search_company_alias='.urlencode($search_company_alias);
741 if ($search_user > 0) {
742 $param .=
'&search_user='.urlencode((
string) ($search_user));
744 if ($search_sale > 0) {
745 $param .=
'&search_sale='.urlencode($search_sale);
747 if ($search_total_ht !=
'') {
748 $param .=
'&search_total_ht='.urlencode($search_total_ht);
750 if ($search_total_tva !=
'') {
751 $param .=
'&search_total_tva='.urlencode($search_total_tva);
753 if ($search_total_ttc !=
'') {
754 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
756 if ($search_project_ref >= 0) {
757 $param .=
"&search_project_ref=".urlencode($search_project_ref);
760 $param .=
'&show_files='.urlencode((
string) ($show_files));
762 if ($optioncss !=
'') {
763 $param .=
'&optioncss='.urlencode($optioncss);
766 $param .=
'&billed='.urlencode($billed);
769 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
774 $_GET[
"origin"] = $_POST[
"origin"];
775 $_GET[
"originid"] = $_POST[
"originid"];
789$form =
new Form($db);
797$title = $langs->trans(
"SuppliersOrders");
800 $fourn->fetch($socid);
801 $title .=
' - '.$fourn->name;
804if ($search_billed > 0) {
805 $title .=
' - '.$langs->trans(
"Billed");
811$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
812$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
816 $sql =
'SELECT DISTINCT';
818$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,';
819$sql .=
" typent.code as typent_code,";
820$sql .=
" state.code_departement as state_code, state.nom as state_name,";
821$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,";
822$sql .=
' cf.localtax1 as total_localtax1, cf.localtax2 as total_localtax2,';
823$sql .=
' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
824$sql .=
' cf.date_creation as date_creation, cf.tms as date_modification,';
825$sql .=
' cf.note_public, cf.note_private,';
826$sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
827$sql .=
" u.firstname, u.lastname, u.photo, u.login, u.email as user_email, u.statut as user_status";
829if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
830 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
831 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
835$parameters = array();
836$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
837$sql .= $hookmanager->resPrint;
841$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
842$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
843$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
844$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
845$sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
846if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
847 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cf.rowid = ef.fk_object)";
850 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
852$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON cf.fk_user_author = u.rowid";
853$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = cf.fk_projet";
854$parameters = array();
855$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
856$sql .= $hookmanager->resPrint;
857$sql .=
' WHERE cf.fk_soc = s.rowid';
858$sql .=
' AND cf.entity IN ('.getEntity(
'supplier_order').
')';
860 $sql .=
" AND s.rowid = ".((int) $socid);
865if ($search_refsupp) {
869 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
871if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
872 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
874 if ($search_company) {
877 if ($search_company_alias) {
881if ($search_request_author) {
882 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_request_author);
884if ($search_billed !=
'' && $search_billed >= 0) {
885 $sql .=
" AND cf.billed = ".((int) $search_billed);
888if (
GETPOST(
'statut',
'intcomma') !==
'') {
889 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(
GETPOST(
'statut',
'intcomma')))).
")";
891if ($search_status !=
'' && $search_status !=
'-1') {
892 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
894if ($search_option ==
'late') {
895 $sql .=
" AND cf.date_commande < '".$db->idate(
dol_now() -
$conf->order->fournisseur->warning_delay).
"'";
897if ($search_date_order_start) {
898 $sql .=
" AND cf.date_commande >= '".$db->idate($search_date_order_start).
"'";
900if ($search_date_order_end) {
901 $sql .=
" AND cf.date_commande <= '".$db->idate($search_date_order_end).
"'";
903if ($search_date_delivery_start) {
904 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_delivery_start).
"'";
906if ($search_date_delivery_end) {
907 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_delivery_end).
"'";
909if ($search_date_valid_start) {
910 $sql .=
" AND cf.date_valid >= '".$db->idate($search_date_valid_start).
"'";
912if ($search_date_valid_end) {
913 $sql .=
" AND cf.date_valid <= '".$db->idate($search_date_valid_end).
"'";
915if ($search_date_approve_start) {
916 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_approve_start).
"'";
918if ($search_date_approve_end) {
919 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_approve_end).
"'";
930if ($search_country) {
931 $sql .=
" AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).
')';
933if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
934 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
939if ($search_user > 0) {
940 $sql .=
" AND EXISTS (";
941 $sql .=
" SELECT ec.rowid ";
942 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_contact as ec";
943 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
944 $sql .=
" WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
945 $sql .=
" AND tc.element = 'order_supplier' AND tc.source = 'internal'";
948if ($search_total_ht !=
'') {
951if ($search_total_tva !=
'') {
954if ($search_total_ttc !=
'') {
957if ($search_multicurrency_code !=
'') {
958 $sql .=
" AND cf.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
960if ($search_multicurrency_tx !=
'') {
961 $sql .=
natural_search(
'cf.multicurrency_tx', $search_multicurrency_tx, 1);
963if ($search_multicurrency_montant_ht !=
'') {
964 $sql .=
natural_search(
'cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
966if ($search_multicurrency_montant_tva !=
'') {
967 $sql .=
natural_search(
'cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1);
969if ($search_multicurrency_montant_ttc !=
'') {
970 $sql .=
natural_search(
'cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
972if ($search_project_ref !=
'') {
976if ($search_sale && $search_sale !=
'-1') {
977 if ($search_sale == -2) {
978 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = cf.fk_soc)";
979 } elseif ($search_sale > 0) {
980 $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).
")";
984$searchCategoryProductOperator = -1;
985$searchCategoryProductList = array($search_product_category);
986if (!empty($searchCategoryProductList)) {
987 $searchCategoryProductSqlList = array();
988 $listofcategoryid =
'';
989 foreach ($searchCategoryProductList as $searchCategoryProduct) {
990 if (intval($searchCategoryProduct) == -2) {
991 $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)";
992 } elseif (intval($searchCategoryProduct) > 0) {
993 if ($searchCategoryProductOperator == 0) {
994 $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).
")";
996 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
1000 if ($listofcategoryid) {
1001 $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).
"))";
1003 if ($searchCategoryProductOperator == 1) {
1004 if (!empty($searchCategoryProductSqlList)) {
1005 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
1008 if (!empty($searchCategoryProductSqlList)) {
1009 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
1014include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1016$parameters = array();
1017$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
1018$sql .= $hookmanager->resPrint;
1021$nbtotalofrecords =
'';
1024 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1025 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1026 $resql = $db->query($sqlforcount);
1028 $objforcount = $db->fetch_object($resql);
1029 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1034 if (($page * $limit) > $nbtotalofrecords) {
1041$sql .= $db->order($sortfield, $sortorder);
1043 $sql .= $db->plimit($limit + 1, $offset);
1047$resql = $db->query($sql);
1049 $num = $db->num_rows($resql);
1051 $arrayofselected = is_array($toselect) ? $toselect : array();
1053 if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1054 $obj = $db->fetch_object($resql);
1056 header(
"Location: ".DOL_URL_ROOT.
'/fourn/commande/card.php?id='.
$id);
1060 llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-supplier-order page-list');
1063 if (!empty($mode)) {
1064 $param .=
'&mode='.urlencode($mode);
1066 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1067 $param .=
'&contextpage='.urlencode($contextpage);
1069 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1070 $param .=
'&limit='.((int) $limit);
1073 $param .=
'&search_all='.urlencode($search_all);
1076 $param .=
'&socid='.urlencode((
string) ($socid));
1079 $param .=
"&search_all=".urlencode($search_all);
1081 if ($search_date_order_startday) {
1082 $param .=
'&search_date_order_startday='.urlencode((
string) ($search_date_order_startday));
1084 if ($search_date_order_startmonth) {
1085 $param .=
'&search_date_order_startmonth='.urlencode((
string) ($search_date_order_startmonth));
1087 if ($search_date_order_startyear) {
1088 $param .=
'&search_date_order_startyear='.urlencode((
string) ($search_date_order_startyear));
1090 if ($search_date_order_endday) {
1091 $param .=
'&search_date_order_endday='.urlencode((
string) ($search_date_order_endday));
1093 if ($search_date_order_endmonth) {
1094 $param .=
'&search_date_order_endmonth='.urlencode((
string) ($search_date_order_endmonth));
1096 if ($search_date_order_endyear) {
1097 $param .=
'&search_date_order_endyear='.urlencode((
string) ($search_date_order_endyear));
1099 if ($search_date_delivery_startday) {
1100 $param .=
'&search_date_delivery_startday='.urlencode((
string) ($search_date_delivery_startday));
1102 if ($search_date_delivery_startmonth) {
1103 $param .=
'&search_date_delivery_startmonth='.urlencode((
string) ($search_date_delivery_startmonth));
1105 if ($search_date_delivery_startyear) {
1106 $param .=
'&search_date_delivery_startyear='.urlencode((
string) ($search_date_delivery_startyear));
1108 if ($search_date_delivery_endday) {
1109 $param .=
'&search_date_delivery_endday='.urlencode((
string) ($search_date_delivery_endday));
1111 if ($search_date_delivery_endmonth) {
1112 $param .=
'&search_date_delivery_endmonth='.urlencode((
string) ($search_date_delivery_endmonth));
1114 if ($search_date_delivery_endyear) {
1115 $param .=
'&search_date_delivery_endyear='.urlencode((
string) ($search_date_delivery_endyear));
1117 if ($search_date_valid_startday) {
1118 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
1120 if ($search_date_valid_startmonth) {
1121 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
1123 if ($search_date_valid_startyear) {
1124 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
1126 if ($search_date_valid_endday) {
1127 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
1129 if ($search_date_valid_endmonth) {
1130 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
1132 if ($search_date_valid_endyear) {
1133 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
1135 if ($search_date_approve_startday) {
1136 $param .=
'&search_date_approve_startday='.urlencode((
string) ($search_date_approve_startday));
1138 if ($search_date_approve_startmonth) {
1139 $param .=
'&search_date_approve_startmonth='.urlencode((
string) ($search_date_approve_startmonth));
1141 if ($search_date_approve_startyear) {
1142 $param .=
'&search_date_approve_startyear='.urlencode((
string) ($search_date_approve_startyear));
1144 if ($search_date_approve_endday) {
1145 $param .=
'&search_date_approve_endday='.urlencode((
string) ($search_date_approve_endday));
1147 if ($search_date_approve_endmonth) {
1148 $param .=
'&search_date_approve_endmonth='.urlencode((
string) ($search_date_approve_endmonth));
1150 if ($search_date_approve_endyear) {
1151 $param .=
'&search_date_approve_endyear='.urlencode((
string) ($search_date_approve_endyear));
1154 $param .=
'&search_ref='.urlencode($search_ref);
1156 if ($search_company) {
1157 $param .=
'&search_company='.urlencode($search_company);
1159 if ($search_company_alias) {
1160 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1162 if ($search_user > 0) {
1163 $param .=
'&search_user='.urlencode((
string) ($search_user));
1165 if ($search_request_author) {
1166 $param .=
'&search_request_author='.urlencode($search_request_author);
1168 if ($search_sale > 0) {
1169 $param .=
'&search_sale='.urlencode($search_sale);
1171 if ($search_total_ht !=
'') {
1172 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1174 if ($search_total_ttc !=
'') {
1175 $param .=
"&search_total_ttc=".urlencode($search_total_ttc);
1177 if ($search_multicurrency_code !=
'') {
1178 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1180 if ($search_multicurrency_tx !=
'') {
1181 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1183 if ($search_multicurrency_montant_ht !=
'') {
1184 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1186 if ($search_multicurrency_montant_tva !=
'') {
1187 $param .=
'&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva);
1189 if ($search_multicurrency_montant_ttc !=
'') {
1190 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1192 if ($search_refsupp) {
1193 $param .=
"&search_refsupp=".urlencode($search_refsupp);
1195 if ($search_status !=
'' && $search_status !=
'-1') {
1196 $param .=
"&search_status=".urlencode($search_status);
1198 if ($search_option) {
1199 $param .=
"&search_option=".urlencode($search_option);
1201 if ($search_project_ref >= 0) {
1202 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1204 if ($search_billed !=
'') {
1205 $param .=
"&search_billed=".urlencode($search_billed);
1208 $param .=
'&show_files='.urlencode((
string) ($show_files));
1210 if ($optioncss !=
'') {
1211 $param .=
'&optioncss='.urlencode($optioncss);
1213 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
1214 $param .=
'&search_type_thirdparty='.urlencode((
string) ($search_type_thirdparty));
1218 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1220 $parameters = array(
'param' => &$param);
1221 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1222 $param .= $hookmanager->resPrint;
1225 $arrayofmassactions = array(
1226 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1227 'builddoc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1228 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1231 if ($permissiontovalidate) {
1232 if ($permissiontoapprove && !
getDolGlobalString(
'SUPPLIER_ORDER_NO_DIRECT_APPROVE')) {
1233 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"ValidateAndApprove");
1235 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1239 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
"supplier_invoice",
"creer")) {
1240 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'supplier_invoice',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisSupplier");
1242 if ($permissiontodelete) {
1243 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1245 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1246 $arrayofmassactions = array();
1248 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1250 $url = DOL_URL_ROOT.
'/fourn/commande/card.php?action=create';
1252 $url .=
'&socid='.((int) $socid);
1253 $url .=
'&backtopage='.urlencode(DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.((
int) $socid));
1255 $newcardbutton =
'';
1256 $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'));
1257 $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'));
1259 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewSupplierOrderShort'),
'',
'fa fa-plus-circle', $url,
'', (
int) $permissiontoadd);
1262 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1263 if ($optioncss !=
'') {
1264 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1266 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1267 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1268 print
'<input type="hidden" name="action" value="list">';
1269 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1270 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1271 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1272 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1273 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1275 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'supplier_order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1277 $topicmail =
"SendOrderRef";
1278 $modelmail =
"order_supplier_send";
1280 $trackid =
'sord'.$object->id;
1281 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1283 if ($massaction ==
'prevalidate') {
1284 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1287 if ($massaction ==
'createbills') {
1289 print
'<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
1291 print
'<table class="noborder centpercent">';
1293 print
'<td class="titlefield">';
1294 print $langs->trans(
'DateInvoice');
1297 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1302 print $langs->trans(
'CreateOneBillByThird');
1305 print $form->selectyesno(
'createbills_onebythird',
'', 1);
1310 print $langs->trans(
'ValidateInvoices');
1313 print $form->selectyesno(
'validate_invoices', 1, 1);
1318 print
'<div class="center">';
1319 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1320 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1327 foreach ($fieldstosearchall as $key => $val) {
1328 $fieldstosearchall[$key] = $langs->trans($val);
1330 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
1333 $moreforfilter =
'';
1336 if ($user->hasRight(
"user",
"user",
"lire")) {
1337 $langs->load(
"commercial");
1338 $moreforfilter .=
'<div class="divsearchfield">';
1339 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1340 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1341 $moreforfilter .=
'</div>';
1344 if ($user->hasRight(
"user",
"user",
"lire")) {
1345 $moreforfilter .=
'<div class="divsearchfield">';
1346 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1347 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1348 $moreforfilter .=
'</div>';
1351 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
1352 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1353 $moreforfilter .=
'<div class="divsearchfield">';
1354 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1355 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1356 $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);
1357 $moreforfilter .=
'</div>';
1360 $moreforfilter .=
'<div class="divsearchfield">';
1361 $moreforfilter .= $langs->trans(
'Alert').
' <input type="checkbox" name="search_option" value="late"'.($search_option ==
'late' ?
' checked' :
'').
'>';
1362 $moreforfilter .=
'</div>';
1363 $parameters = array();
1364 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1365 if (empty($reshook)) {
1366 $moreforfilter .= $hookmanager->resPrint;
1368 $moreforfilter = $hookmanager->resPrint;
1371 if (!empty($moreforfilter)) {
1372 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1373 print $moreforfilter;
1377 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1378 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1379 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
1382 $selectedfields .=
'<script>';
1383 $selectedfields .=
' $(document).ready(function() {';
1384 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1385 $selectedfields .=
' $("#checkforselects").click();';
1386 $selectedfields .=
' $("#massaction").val("createbills").change();';
1387 $selectedfields .=
' });';
1388 $selectedfields .=
'</script>';
1391 print
'<div class="div-table-responsive">';
1392 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1394 print
'<tr class="liste_titre_filter">';
1397 print
'<td class="liste_titre middle">';
1398 $searchpicto = $form->showFilterButtons(
'left');
1403 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1404 print
'<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.
'"></td>';
1407 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1408 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.
'"></td>';
1411 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1412 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.
'"></td>';
1415 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1416 print
'<td class="liste_titre">';
1417 print
'<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.
'">';
1421 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1422 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.
'"></td>';
1425 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1426 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company_alias" value="'.$search_company_alias.
'"></td>';
1429 if (!empty($arrayfields[
's.town'][
'checked'])) {
1430 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.
'"></td>';
1433 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1434 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.
'"></td>';
1437 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1438 print
'<td class="liste_titre">';
1439 print
'<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1443 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1444 print
'<td class="liste_titre center">';
1445 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1449 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1450 print
'<td class="liste_titre maxwidthonsmartphone center">';
1451 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);
1455 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1456 print
'<td class="liste_titre center">';
1457 print
'<div class="nowrapfordate">';
1458 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'));
1460 print
'<div class="nowrapfordate">';
1461 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'));
1466 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1467 print
'<td class="liste_titre center">';
1468 print
'<div class="nowrapfordate">';
1469 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'));
1471 print
'<div class="nowrapfordate">';
1472 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'));
1476 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1478 print
'<td class="liste_titre right">';
1479 print
'<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.
'">';
1482 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1484 print
'<td class="liste_titre right">';
1485 print
'<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.
'">';
1488 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1490 print
'<td class="liste_titre right">';
1491 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1494 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1496 print
'<td class="liste_titre">';
1497 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1500 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1502 print
'<td class="liste_titre">';
1503 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1506 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1508 print
'<td class="liste_titre right">';
1509 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1512 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1514 print
'<td class="liste_titre right">';
1515 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).
'">';
1518 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1520 print
'<td class="liste_titre right">';
1521 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1525 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1528 $parameters = array(
'arrayfields' => $arrayfields);
1529 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1530 print $hookmanager->resPrint;
1532 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1533 print
'<td class="liste_titre">';
1537 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1538 print
'<td class="liste_titre">';
1542 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1543 print
'<td class="liste_titre center parentonrightofpage">';
1544 print $form->selectyesno(
'search_billed', $search_billed, 1,
false, 1, 1,
'search_status width100 onrightofpage');
1548 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1549 print
'<td class="liste_titre center parentonrightofpage">';
1550 $formorder->selectSupplierOrderStatus($search_status, 1,
'search_status',
'search_status width125 onrightofpage');
1554 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1555 print
'<td class="liste_titre center">';
1556 print
'<div class="nowrapfordate">';
1557 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'));
1559 print
'<div class="nowrapfordate">';
1560 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'));
1565 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1566 print
'<td class="liste_titre center">';
1567 print
'<div class="nowrapfordate">';
1568 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'));
1570 print
'<div class="nowrapfordate">';
1571 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'));
1576 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1577 print
'<td class="liste_titre">';
1581 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1582 print
'<td class="liste_titre">';
1587 print
'<td class="liste_titre center">';
1588 $searchpicto = $form->showFilterButtons();
1595 $totalarray = array();
1596 $totalarray[
'nbfield'] = 0;
1599 print
'<tr class="liste_titre">';
1601 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1602 $totalarray[
'nbfield']++;
1604 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1605 print_liste_field_titre($arrayfields[
'cf.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref",
"", $param,
'', $sortfield, $sortorder);
1606 $totalarray[
'nbfield']++;
1608 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1609 print_liste_field_titre($arrayfields[
'cf.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref_supplier",
"", $param,
'', $sortfield, $sortorder,
'tdoverflowmax100imp ');
1610 $totalarray[
'nbfield']++;
1612 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1613 print_liste_field_titre($arrayfields[
'cf.fk_projet'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1614 $totalarray[
'nbfield']++;
1616 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1617 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
"u.login",
"", $param,
'', $sortfield, $sortorder);
1618 $totalarray[
'nbfield']++;
1620 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1621 print_liste_field_titre($arrayfields[
'cf.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
1622 $totalarray[
'nbfield']++;
1624 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1626 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"s.name_alias",
"", $param,
'', $sortfield, $sortorder);
1627 $totalarray[
'nbfield']++;
1629 if (!empty($arrayfields[
's.town'][
'checked'])) {
1630 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1631 $totalarray[
'nbfield']++;
1633 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1634 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1635 $totalarray[
'nbfield']++;
1637 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1638 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1639 $totalarray[
'nbfield']++;
1641 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1642 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1643 $totalarray[
'nbfield']++;
1645 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1646 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1647 $totalarray[
'nbfield']++;
1649 if (!empty($arrayfields[
'cf.fk_author'][
'checked'])) {
1650 print_liste_field_titre($arrayfields[
'cf.fk_author'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_author",
"", $param,
'', $sortfield, $sortorder);
1651 $totalarray[
'nbfield']++;
1653 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1654 print_liste_field_titre($arrayfields[
'cf.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_commande",
"", $param,
'', $sortfield, $sortorder,
'center ');
1655 $totalarray[
'nbfield']++;
1657 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1658 print_liste_field_titre($arrayfields[
'cf.date_livraison'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1659 $totalarray[
'nbfield']++;
1661 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1662 print_liste_field_titre($arrayfields[
'cf.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
1663 $totalarray[
'nbfield']++;
1665 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1666 print_liste_field_titre($arrayfields[
'cf.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
1667 $totalarray[
'nbfield']++;
1669 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1670 print_liste_field_titre($arrayfields[
'cf.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
1671 $totalarray[
'nbfield']++;
1673 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1674 print_liste_field_titre($arrayfields[
'cf.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1675 $totalarray[
'nbfield']++;
1677 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1678 print_liste_field_titre($arrayfields[
'cf.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1679 $totalarray[
'nbfield']++;
1681 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1682 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1683 $totalarray[
'nbfield']++;
1685 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1686 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1687 $totalarray[
'nbfield']++;
1689 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1690 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1691 $totalarray[
'nbfield']++;
1694 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1696 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1697 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1698 print $hookmanager->resPrint;
1699 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1700 print_liste_field_titre($arrayfields[
'cf.date_creation'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowraponall ');
1701 $totalarray[
'nbfield']++;
1703 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1704 print_liste_field_titre($arrayfields[
'cf.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowraponall ');
1705 $totalarray[
'nbfield']++;
1707 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1708 print_liste_field_titre($arrayfields[
'cf.billed'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.billed',
'', $param,
'', $sortfield, $sortorder,
'center ');
1709 $totalarray[
'nbfield']++;
1711 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1712 print_liste_field_titre($arrayfields[
'cf.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1713 $totalarray[
'nbfield']++;
1715 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1716 print_liste_field_titre($arrayfields[
'cf.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
1717 $totalarray[
'nbfield']++;
1719 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1720 print_liste_field_titre($arrayfields[
'cf.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_approve',
'', $param,
'', $sortfield, $sortorder,
'center ');
1721 $totalarray[
'nbfield']++;
1723 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1724 print_liste_field_titre($arrayfields[
'cf.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_public",
"", $param,
'', $sortfield, $sortorder,
'center ');
1725 $totalarray[
'nbfield']++;
1727 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1728 print_liste_field_titre($arrayfields[
'cf.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_private",
"", $param,
'', $sortfield, $sortorder,
'center ');
1729 $totalarray[
'nbfield']++;
1732 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1733 $totalarray[
'nbfield']++;
1739 $productstat_cache = array();
1741 $userstatic =
new User($db);
1743 $projectstatic =
new Project($db);
1746 $savnbfield = $totalarray[
'nbfield'];
1747 $totalarray = array(
'nbfield' => 0,
'val' => array(),
'pos' => array());
1748 $totalarray[
'val'][
'cf.total_ht'] = 0;
1749 $totalarray[
'val'][
'cf.total_ttc'] = 0;
1750 $totalarray[
'val'][
'cf.total_tva'] = 0;
1752 $imaxinloop = ($limit ? min($num, $limit) : $num);
1753 while ($i < $imaxinloop) {
1754 $obj = $db->fetch_object($resql);
1762 $objectstatic->id = $obj->rowid;
1763 $objectstatic->ref = $obj->ref;
1764 $objectstatic->ref_supplier = $obj->ref_supplier;
1765 $objectstatic->socid = $obj->socid;
1766 $objectstatic->total_ht = $obj->total_ht;
1767 $objectstatic->total_tva = $obj->total_tva;
1768 $objectstatic->total_ttc = $obj->total_ttc;
1769 $objectstatic->date_commande = $db->jdate($obj->date_commande);
1770 $objectstatic->delivery_date = $db->jdate($obj->delivery_date);
1771 $objectstatic->note_public = $obj->note_public;
1772 $objectstatic->note_private = $obj->note_private;
1773 $objectstatic->statut = $obj->fk_statut;
1775 if ($mode ==
'kanban') {
1777 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1778 print
'<div class="box-flex-container kanban">';
1781 $thirdpartytmp->id = $obj->socid;
1782 $thirdpartytmp->name = $obj->name;
1783 $thirdpartytmp->email = $obj->email;
1784 $thirdpartytmp->name_alias = $obj->alias;
1785 $thirdpartytmp->client = $obj->client;
1786 $thirdpartytmp->fournisseur = $obj->fournisseur;
1788 print $objectstatic->getKanbanView(
'', array(
'thirdparty' => $thirdpartytmp->getNomUrl(
'supplier', 0, 0, -1),
'selected' => in_array($objectstatic->id, $arrayofselected)));
1789 if ($i == ($imaxinloop - 1)) {
1794 print
'<tr class="oddeven '.((getDolGlobalInt(
'MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->billed == 1) ?
'opacitymedium' :
'').
'">';
1797 print
'<td class="nowrap center">';
1798 if ($massactionbutton || $massaction) {
1800 if (in_array($obj->rowid, $arrayofselected)) {
1803 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1807 $totalarray[
'nbfield']++;
1811 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1812 print
'<td class="nowrap">';
1815 print $objectstatic->getNomUrl(1,
'', 0, -1, 1);
1819 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1823 $totalarray[
'nbfield']++;
1827 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1828 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>'.
"\n";
1830 $totalarray[
'nbfield']++;
1834 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1835 $projectstatic->id = $obj->project_id;
1836 $projectstatic->ref = $obj->project_ref;
1837 $projectstatic->title = $obj->project_title;
1839 if ($obj->project_id > 0) {
1840 print $projectstatic->getNomUrl(1);
1844 $totalarray[
'nbfield']++;
1848 $userstatic->id = $obj->fk_user_author;
1849 $userstatic->lastname = $obj->lastname;
1850 $userstatic->firstname = $obj->firstname;
1851 $userstatic->login = $obj->login;
1852 $userstatic->photo = $obj->photo;
1853 $userstatic->email = $obj->user_email;
1854 $userstatic->status = $obj->user_status;
1855 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1856 print
'<td class="tdoverflowmax150">';
1857 if ($userstatic->id) {
1858 print $userstatic->getNomUrl(1);
1862 $totalarray[
'nbfield']++;
1866 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1867 print
'<td class="tdoverflowmax150">';
1868 $thirdpartytmp->id = $obj->socid;
1869 $thirdpartytmp->name = $obj->name;
1870 $thirdpartytmp->email = $obj->email;
1871 $thirdpartytmp->name_alias = $obj->alias;
1872 $thirdpartytmp->client = $obj->client;
1873 $thirdpartytmp->fournisseur = $obj->fournisseur;
1874 print $thirdpartytmp->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1877 $totalarray[
'nbfield']++;
1881 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1882 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->alias).
'">';
1886 $totalarray[
'nbfield']++;
1890 if (!empty($arrayfields[
's.town'][
'checked'])) {
1891 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
1895 $totalarray[
'nbfield']++;
1899 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1900 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).
'">';
1904 $totalarray[
'nbfield']++;
1908 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1909 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).
'">'.
dol_escape_htmltag($obj->state_name).
"</td>\n";
1911 $totalarray[
'nbfield']++;
1915 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1916 print
'<td class="center">';
1917 $tmparray =
getCountry($obj->fk_pays,
'all');
1918 print $tmparray[
'label'];
1921 $totalarray[
'nbfield']++;
1925 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1926 print
'<td class="center">';
1927 if (empty($typenArray)) {
1928 $typenArray = $formcompany->typent_array(1);
1930 print $typenArray[$obj->typent_code];
1933 $totalarray[
'nbfield']++;
1938 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1939 print
'<td class="center">';
1941 if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1942 if ($objectstatic->hasDelay()) {
1943 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1948 $totalarray[
'nbfield']++;
1952 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1953 print
'<td class="center">';
1955 if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1956 if ($objectstatic->hasDelay()) {
1957 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1962 $totalarray[
'nbfield']++;
1966 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1967 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1969 $totalarray[
'nbfield']++;
1972 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ht';
1974 $totalarray[
'val'][
'cf.total_ht'] += $obj->total_ht;
1977 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1978 print
'<td class="right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
1980 $totalarray[
'nbfield']++;
1983 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_tva';
1985 $totalarray[
'val'][
'cf.total_tva'] += $obj->total_tva;
1988 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1989 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1991 $totalarray[
'nbfield']++;
1994 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ttc';
1996 $totalarray[
'val'][
'cf.total_ttc'] += $obj->total_ttc;
2000 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
2001 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
2003 $totalarray[
'nbfield']++;
2008 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
2009 print
'<td class="nowrap">';
2010 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2013 $totalarray[
'nbfield']++;
2017 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
2018 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
2020 $totalarray[
'nbfield']++;
2024 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
2025 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva).
"</span></td>\n";
2027 $totalarray[
'nbfield']++;
2031 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
2032 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
2034 $totalarray[
'nbfield']++;
2039 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2041 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
2042 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2043 print $hookmanager->resPrint;
2045 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
2046 print
'<td class="center nowraponall">';
2047 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2050 $totalarray[
'nbfield']++;
2054 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
2055 print
'<td class="center nowraponall">';
2056 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
2059 $totalarray[
'nbfield']++;
2063 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
2064 print
'<td class="center">'.yn($obj->billed).
'</td>';
2066 $totalarray[
'nbfield']++;
2070 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
2071 print
'<td class="center nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).
'</td>';
2073 $totalarray[
'nbfield']++;
2078 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
2079 print
'<td class="center">';
2083 $totalarray[
'nbfield']++;
2087 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
2088 print
'<td class="center">';
2092 $totalarray[
'nbfield']++;
2096 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
2097 print
'<td class="sensiblehtmlcontent center">';
2101 $totalarray[
'nbfield']++;
2106 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
2107 print
'<td class="sensiblehtmlcontent center">';
2111 $totalarray[
'nbfield']++;
2117 print
'<td class="nowrap center">';
2118 if ($massactionbutton || $massaction) {
2120 if (in_array($obj->rowid, $arrayofselected)) {
2123 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2127 $totalarray[
'nbfield']++;
2133 $total += $obj->total_ht;
2134 $subtotal += $obj->total_ht;
2140 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2145 foreach ($arrayfields as $key => $val) {
2146 if (!empty($val[
'checked'])) {
2150 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2155 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2156 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2157 print $hookmanager->resPrint;
2159 print
'</table>'.
"\n";
2162 print
'</form>'.
"\n";
2164 $hidegeneratedfilelistifempty = 1;
2165 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2166 $hidegeneratedfilelistifempty = 0;
2170 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2171 $urlsource .= str_replace(
'&',
'&', $param);
2173 $filedir = $diroutputmassaction;
2174 $genallowed = $permissiontoread;
2175 $delallowed = $permissiontoadd;
2177 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
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.