37require
'../../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
52$langs->loadLangs(array(
"orders",
"sendings",
'deliveries',
'companies',
'compta',
'bills',
'projects',
'suppliers',
'products'));
55$action =
GETPOST(
'action',
'aZ09');
56$massaction =
GETPOST(
'massaction',
'alpha');
58$confirm =
GETPOST(
'confirm',
'alpha');
59$toselect =
GETPOST(
'toselect',
'array');
60$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierorderlist';
61$mode =
GETPOST(
'mode',
'alpha');
64$search_date_order_startday =
GETPOSTINT(
'search_date_order_startday');
65$search_date_order_startmonth =
GETPOSTINT(
'search_date_order_startmonth');
66$search_date_order_startyear =
GETPOSTINT(
'search_date_order_startyear');
67$search_date_order_endday =
GETPOSTINT(
'search_date_order_endday');
68$search_date_order_endmonth =
GETPOSTINT(
'search_date_order_endmonth');
69$search_date_order_endyear =
GETPOSTINT(
'search_date_order_endyear');
70$search_date_order_start =
dol_mktime(0, 0, 0, $search_date_order_startmonth, $search_date_order_startday, $search_date_order_startyear);
71$search_date_order_end =
dol_mktime(23, 59, 59, $search_date_order_endmonth, $search_date_order_endday, $search_date_order_endyear);
73$search_date_delivery_startday =
GETPOSTINT(
'search_date_delivery_startday');
74$search_date_delivery_startmonth =
GETPOSTINT(
'search_date_delivery_startmonth');
75$search_date_delivery_startyear =
GETPOSTINT(
'search_date_delivery_startyear');
76$search_date_delivery_endday =
GETPOSTINT(
'search_date_delivery_endday');
77$search_date_delivery_endmonth =
GETPOSTINT(
'search_date_delivery_endmonth');
78$search_date_delivery_endyear =
GETPOSTINT(
'search_date_delivery_endyear');
79$search_date_delivery_start =
dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear);
80$search_date_delivery_end =
dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
82$search_date_valid_startday =
GETPOSTINT(
'search_date_valid_startday');
83$search_date_valid_startmonth =
GETPOSTINT(
'search_date_valid_startmonth');
84$search_date_valid_startyear =
GETPOSTINT(
'search_date_valid_startyear');
85$search_date_valid_endday =
GETPOSTINT(
'search_date_valid_endday');
86$search_date_valid_endmonth =
GETPOSTINT(
'search_date_valid_endmonth');
87$search_date_valid_endyear =
GETPOSTINT(
'search_date_valid_endyear');
88$search_date_valid_start =
dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear);
89$search_date_valid_end =
dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
91$search_date_approve_startday =
GETPOSTINT(
'search_date_approve_startday');
92$search_date_approve_startmonth =
GETPOSTINT(
'search_date_approve_startmonth');
93$search_date_approve_startyear =
GETPOSTINT(
'search_date_approve_startyear');
94$search_date_approve_endday =
GETPOSTINT(
'search_date_approve_endday');
95$search_date_approve_endmonth =
GETPOSTINT(
'search_date_approve_endmonth');
96$search_date_approve_endyear =
GETPOSTINT(
'search_date_approve_endyear');
97$search_date_approve_start =
dol_mktime(0, 0, 0, $search_date_approve_startmonth, $search_date_approve_startday, $search_date_approve_startyear);
98$search_date_approve_end =
dol_mktime(23, 59, 59, $search_date_approve_endmonth, $search_date_approve_endday, $search_date_approve_endyear);
100$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
102$search_product_category =
GETPOSTINT(
'search_product_category');
103$search_ref =
GETPOST(
'search_ref',
'alpha');
104$search_refsupp =
GETPOST(
'search_refsupp',
'alpha');
105$search_company =
GETPOST(
'search_company',
'alpha');
106$search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
107$search_town =
GETPOST(
'search_town',
'alpha');
108$search_zip =
GETPOST(
'search_zip',
'alpha');
109$search_state =
GETPOST(
"search_state",
'alpha');
110$search_country =
GETPOST(
"search_country",
'aZ09');
111$search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'intcomma');
112$search_user =
GETPOST(
'search_user',
'intcomma');
113$search_request_author =
GETPOST(
'search_request_author',
'alpha');
114$optioncss =
GETPOST(
'optioncss',
'alpha');
116$search_sale =
GETPOST(
'search_sale',
'intcomma');
117$search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
118$search_total_tva =
GETPOST(
'search_total_tva',
'alpha');
119$search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
120$search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
121$search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
122$search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
123$search_multicurrency_montant_tva =
GETPOST(
'search_multicurrency_montant_tva',
'alpha');
124$search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
125$optioncss =
GETPOST(
'optioncss',
'alpha');
126$search_billed =
GETPOST(
'search_billed',
'intcomma');
127$search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
128$search_btn =
GETPOST(
'button_search',
'alpha');
129$search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
132 $search_status = implode(
',',
GETPOST(
'search_status',
'array:intcomma'));
134 $search_status = (
GETPOST(
'search_status',
'intcomma') !=
'' ?
GETPOST(
'search_status',
'intcomma') :
GETPOST(
'statut',
'intcomma'));
137$diroutputmassaction = $conf->fournisseur->commande->dir_output.
'/temp/massgeneration/'.$user->id;
140$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
141$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
143if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction ===
'0')) {
146$offset = $limit * $page;
147$pageprev = $page - 1;
148$pagenext = $page + 1;
150 $sortfield =
'cf.ref';
158$hookmanager->initHooks(array(
'supplierorderlist'));
162$extrafields->fetch_name_optionals_label(
$object->table_element);
164$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
167$fieldstosearchall = array();
168foreach (
$object->fields as $key => $val) {
169 if (!empty($val[
'searchall'])) {
170 $fieldstosearchall[
'cf.'.$key] = $val[
'label'];
173$fieldstosearchall[
'pd.description'] =
'Description';
174$fieldstosearchall[
's.nom'] =
"ThirdParty";
175$fieldstosearchall[
's.name_alias'] =
"AliasNameShort";
176$fieldstosearchall[
's.zip'] =
"Zip";
177$fieldstosearchall[
's.town'] =
"Town";
178if (empty($user->socid)) {
179 $fieldstosearchall[
"cf.note_private"] =
"NotePrivate";
182$checkedtypetiers = 0;
186 'u.login' => array(
'label' =>
"AuthorRequest",
'enabled' => 1,
'position' => 41),
187 's.name_alias' => array(
'label' =>
"AliasNameShort",
'position' => 51,
'checked' => 0),
188 's.town' => array(
'label' =>
"Town",
'enabled' => 1,
'position' => 55,
'checked' => 1),
189 's.zip' => array(
'label' =>
"Zip",
'enabled' => 1,
'position' => 56,
'checked' => 1),
190 'state.nom' => array(
'label' =>
"StateShort",
'enabled' => 1,
'position' => 57),
191 'country.code_iso' => array(
'label' =>
"Country",
'enabled' => 1,
'position' => 58),
192 'typent.code' => array(
'label' =>
"ThirdPartyType",
'enabled' => $checkedtypetiers,
'position' => 59),
193 'cf.total_localtax1' => array(
'label' => $langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked' => 0,
'enabled' => ($mysoc->localtax1_assuj ==
"1"),
'position' => 140),
194 'cf.total_localtax2' => array(
'label' => $langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked' => 0,
'enabled' => ($mysoc->localtax2_assuj ==
"1"),
'position' => 145),
195 'cf.note_public' => array(
'label' =>
'NotePublic',
'checked' => 0,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES')),
'position' => 750),
196 'cf.note_private' => array(
'label' =>
'NotePrivate',
'checked' => 0,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'position' => 760),
198foreach (
$object->fields as $key => $val) {
200 if (!empty($val[
'visible'])) {
201 $visible = (int)
dol_eval($val[
'visible'], 1);
202 $arrayfields[
'cf.'.$key] = array(
203 'label' => $val[
'label'],
204 'checked' => (($visible < 0) ? 0 : 1),
205 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
206 'position' => $val[
'position'],
207 'help' => isset($val[
'help']) ? $val[
'help'] :
''
212include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
216'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
221if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
222 $search_sale = $user->id;
228 $socid = $user->socid;
230$result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
232$permissiontoread = ($user->hasRight(
"fournisseur",
"commande",
"lire") || $user->hasRight(
"supplier_order",
"lire"));
233$permissiontoadd = ($user->hasRight(
"fournisseur",
"commande",
"creer") || $user->hasRight(
"supplier_order",
"creer"));
234$permissiontodelete = ($user->hasRight(
"fournisseur",
"commande",
"supprimer") || $user->hasRight(
"supplier_order",
"supprimer"));
235$permissiontovalidate = $permissiontoadd;
236$permissiontoapprove = ($user->hasRight(
"fournisseur",
"commande",
"approuver") || $user->hasRight(
"supplier_order",
"approuver"));
243if (
GETPOST(
'cancel',
'alpha')) {
247if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createsupplierbills') {
251$parameters = array(
'socid' => $socid,
'arrayfields' => &$arrayfields);
252$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
257if (empty($reshook)) {
259 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
262 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
266 $search_product_category =
'';
268 $search_refsupp =
'';
269 $search_company =
'';
270 $search_company_alias =
'';
275 $search_country =
'';
276 $search_type_thirdparty =
'';
277 $search_request_author =
'';
278 $search_total_ht =
'';
279 $search_total_tva =
'';
280 $search_total_ttc =
'';
281 $search_multicurrency_code =
'';
282 $search_multicurrency_tx =
'';
283 $search_multicurrency_montant_ht =
'';
284 $search_multicurrency_montant_tva =
'';
285 $search_multicurrency_montant_ttc =
'';
286 $search_project_ref =
'';
288 $search_date_order_startday =
'';
289 $search_date_order_startmonth =
'';
290 $search_date_order_startyear =
'';
291 $search_date_order_endday =
'';
292 $search_date_order_endmonth =
'';
293 $search_date_order_endyear =
'';
294 $search_date_order_start =
'';
295 $search_date_order_end =
'';
296 $search_date_delivery_startday =
'';
297 $search_date_delivery_startmonth =
'';
298 $search_date_delivery_startyear =
'';
299 $search_date_delivery_endday =
'';
300 $search_date_delivery_endmonth =
'';
301 $search_date_delivery_endyear =
'';
302 $search_date_delivery_start =
'';
303 $search_date_delivery_end =
'';
304 $search_date_valid_startday =
'';
305 $search_date_valid_startmonth =
'';
306 $search_date_valid_startyear =
'';
307 $search_date_valid_endday =
'';
308 $search_date_valid_endmonth =
'';
309 $search_date_valid_endyear =
'';
310 $search_date_valid_start =
'';
311 $search_date_valid_end =
'';
312 $search_date_approve_startday =
'';
313 $search_date_approve_startmonth =
'';
314 $search_date_approve_startyear =
'';
315 $search_date_approve_endday =
'';
316 $search_date_approve_endmonth =
'';
317 $search_date_approve_endyear =
'';
318 $search_date_approve_start =
'';
319 $search_date_approve_end =
'';
323 $search_array_options = array();
325 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
326 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
331 $objectclass =
'CommandeFournisseur';
332 $objectlabel =
'SupplierOrders';
333 $uploaddir = $conf->fournisseur->commande->dir_output;
334 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
336 if ($action ==
'validate' && $permissiontovalidate) {
337 if (
GETPOST(
'confirm') ==
'yes') {
342 foreach ($toselect as $checked) {
343 if ($objecttmp->fetch($checked)) {
344 if ($objecttmp->statut == 0) {
345 $objecttmp->date_commande =
dol_now();
346 $result = $objecttmp->valid($user);
349 if (!
getDolGlobalString(
'SUPPLIER_ORDER_NO_DIRECT_APPROVE') && $permissiontoapprove && !(
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') && $objecttmp->hasProductsOrServices(1))) {
350 $result = $objecttmp->approve($user);
351 setEventMessages($langs->trans(
"SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
353 setEventMessages($langs->trans(
"SupplierOrderValidated"), array($objecttmp->ref));
372 if ($massaction ==
'confirm_createsupplierbills') {
373 $orders =
GETPOST(
'toselect',
'array');
374 $createbills_onebythird =
GETPOSTINT(
'createbills_onebythird');
375 $validate_invoices =
GETPOSTINT(
'validate_invoices');
379 $TFactThird = array();
381 $nb_bills_created = 0;
389 foreach ($orders as $id_order) {
391 if ($cmd->fetch($id_order) <= 0) {
396 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
397 $objecttmp = $TFactThird[$cmd->socid];
400 if (!empty($cmd->socid) > 0) {
402 $societe->fetch($cmd->socid);
403 $objecttmp->vat_reverse_charge = $societe->vat_reverse_charge;
404 $objecttmp->thirdparty = $societe;
406 $objecttmp->socid = $cmd->socid;
407 $objecttmp->type = $objecttmp::TYPE_STANDARD;
408 $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
409 $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
410 $objecttmp->fk_project = $cmd->fk_project;
411 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
412 $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
413 $default_ref_supplier += 1;
416 if (empty($datefacture)) {
420 $objecttmp->date = $datefacture;
421 $objecttmp->origin =
'order_supplier';
422 $objecttmp->origin_id = $id_order;
424 $res = $objecttmp->create($user);
428 $lastref = $objecttmp->ref;
429 $lastid = $objecttmp->id;
433 if ($objecttmp->id > 0) {
434 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_element (";
436 $sql .=
", sourcetype";
437 $sql .=
", fk_target";
438 $sql .=
", targettype";
439 $sql .=
") VALUES (";
441 $sql .=
", '".$db->escape($objecttmp->origin).
"'";
442 $sql .=
", ".((int) $objecttmp->id);
443 $sql .=
", '".$db->escape($objecttmp->element).
"'";
446 if (!$db->query($sql)) {
451 $lines = $cmd->lines;
452 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
454 $lines = $cmd->lines;
458 $num = count($lines);
460 for ($i = 0; $i < $num; $i++) {
461 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
462 if ($lines[$i]->subprice < 0) {
463 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
467 $discount->fk_soc = $objecttmp->socid;
468 $discount->socid = $objecttmp->socid;
469 $discount->amount_ht = abs($lines[$i]->total_ht);
470 $discount->amount_tva = abs($lines[$i]->total_tva);
471 $discount->amount_ttc = abs($lines[$i]->total_ttc);
472 $discount->tva_tx = $lines[$i]->tva_tx;
473 $discount->fk_user = $user->id;
474 $discount->description = $desc;
475 $discountid = $discount->create($user);
476 if ($discountid > 0) {
477 $result = $objecttmp->insert_discount($discountid);
486 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
489 if ($lines[$i]->date_debut_prevue) {
490 $date_start = $lines[$i]->date_debut_prevue;
492 if ($lines[$i]->date_debut_reel) {
493 $date_start = $lines[$i]->date_debut_reel;
495 if ($lines[$i]->date_start) {
496 $date_start = $lines[$i]->date_start;
500 if ($lines[$i]->date_fin_prevue) {
501 $date_end = $lines[$i]->date_fin_prevue;
503 if ($lines[$i]->date_fin_reel) {
504 $date_end = $lines[$i]->date_fin_reel;
506 if ($lines[$i]->date_end) {
507 $date_end = $lines[$i]->date_end;
510 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
514 $tva_tx = $lines[$i]->tva_tx;
516 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', (
string) $tva_tx)) {
517 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
520 $result = $objecttmp->addline(
522 $lines[$i]->subprice,
524 $lines[$i]->localtax1_tx,
525 $lines[$i]->localtax2_tx,
527 $lines[$i]->fk_product,
528 $lines[$i]->remise_percent,
532 $lines[$i]->info_bits,
538 $lines[$i]->array_options,
541 $lines[$i]->fk_commande,
543 $lines[$i]->ref_supplier,
544 $lines[$i]->special_code,
555 if ($result > 0 && $lines[$i]->product_type == 9) {
556 $fk_parent_line = $result;
563 $cmd->classifyBilled($user);
565 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
566 $TFactThird[$cmd->socid] = $objecttmp;
568 $TFact[$objecttmp->id] = $objecttmp;
573 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
576 if (!$error && $validate_invoices) {
577 $massaction = $action =
'builddoc';
579 foreach ($TAllFact as &$objecttmp) {
580 $objecttmp->validate($user);
587 $id = $objecttmp->id;
591 $upload_dir = $conf->fournisseur->facture->dir_output;
592 $permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
596 $massaction = $action =
'confirm_createsupplierbills';
602 if ($nb_bills_created == 1) {
603 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
604 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?id='.urlencode((
string) ($lastid)).
'">'.$lastref.
'</a>', $texttoshow);
607 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
613 $param .=
'&mode='.urlencode($mode);
615 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
616 $param .=
'&contextpage='.urlencode($contextpage);
618 if ($limit > 0 && $limit != $conf->liste_limit) {
619 $param .=
'&limit='.((int) $limit);
622 $param .=
'&search_all='.urlencode($search_all);
625 $param .=
'&socid='.urlencode((
string) ($socid));
627 if ($search_status !=
'') {
628 $param .=
'&search_status='.urlencode($search_status);
630 if ($search_date_order_startday) {
631 $param .=
'&search_date_order_startday='.urlencode((
string) ($search_date_order_startday));
633 if ($search_date_order_startmonth) {
634 $param .=
'&search_date_order_startmonth='.urlencode((
string) ($search_date_order_startmonth));
636 if ($search_date_order_startyear) {
637 $param .=
'&search_date_order_startyear='.urlencode((
string) ($search_date_order_startyear));
639 if ($search_date_order_endday) {
640 $param .=
'&search_date_order_endday='.urlencode((
string) ($search_date_order_endday));
642 if ($search_date_order_endmonth) {
643 $param .=
'&search_date_order_endmonth='.urlencode((
string) ($search_date_order_endmonth));
645 if ($search_date_order_endyear) {
646 $param .=
'&search_date_order_endyear='.urlencode((
string) ($search_date_order_endyear));
648 if ($search_date_delivery_startday) {
649 $param .=
'&search_date_delivery_startday='.urlencode((
string) ($search_date_delivery_startday));
651 if ($search_date_delivery_startmonth) {
652 $param .=
'&search_date_delivery_startmonth='.urlencode((
string) ($search_date_delivery_startmonth));
654 if ($search_date_delivery_startyear) {
655 $param .=
'&search_date_delivery_startyear='.urlencode((
string) ($search_date_delivery_startyear));
657 if ($search_date_delivery_endday) {
658 $param .=
'&search_date_delivery_endday='.urlencode((
string) ($search_date_delivery_endday));
660 if ($search_date_delivery_endmonth) {
661 $param .=
'&search_date_delivery_endmonth='.urlencode((
string) ($search_date_delivery_endmonth));
663 if ($search_date_delivery_endyear) {
664 $param .=
'&search_date_delivery_endyear='.urlencode((
string) ($search_date_delivery_endyear));
666 if ($search_date_valid_startday) {
667 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
669 if ($search_date_valid_startmonth) {
670 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
672 if ($search_date_valid_startyear) {
673 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
675 if ($search_date_valid_endday) {
676 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
678 if ($search_date_valid_endmonth) {
679 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
681 if ($search_date_valid_endyear) {
682 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
684 if ($search_date_approve_startday) {
685 $param .=
'&search_date_approve_startday='.urlencode((
string) ($search_date_approve_startday));
687 if ($search_date_approve_startmonth) {
688 $param .=
'&search_date_approve_startmonth='.urlencode((
string) ($search_date_approve_startmonth));
690 if ($search_date_approve_startyear) {
691 $param .=
'&search_date_approve_startyear='.urlencode((
string) ($search_date_approve_startyear));
693 if ($search_date_approve_endday) {
694 $param .=
'&search_date_approve_endday='.urlencode((
string) ($search_date_approve_endday));
696 if ($search_date_approve_endmonth) {
697 $param .=
'&search_date_approve_endmonth='.urlencode((
string) ($search_date_approve_endmonth));
699 if ($search_date_approve_endyear) {
700 $param .=
'&search_date_approve_endyear='.urlencode((
string) ($search_date_approve_endyear));
703 $param .=
'&search_ref='.urlencode($search_ref);
705 if ($search_company) {
706 $param .=
'&search_company='.urlencode($search_company);
708 if ($search_company_alias) {
709 $param .=
'&search_company_alias='.urlencode($search_company_alias);
712 if ($search_user > 0) {
713 $param .=
'&search_user='.urlencode((
string) ($search_user));
715 if ($search_sale > 0) {
716 $param .=
'&search_sale='.urlencode($search_sale);
718 if ($search_total_ht !=
'') {
719 $param .=
'&search_total_ht='.urlencode($search_total_ht);
721 if ($search_total_tva !=
'') {
722 $param .=
'&search_total_tva='.urlencode($search_total_tva);
724 if ($search_total_ttc !=
'') {
725 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
727 if ($search_project_ref >= 0) {
728 $param .=
"&search_project_ref=".urlencode($search_project_ref);
731 $param .=
'&show_files='.urlencode((
string) ($show_files));
733 if ($optioncss !=
'') {
734 $param .=
'&optioncss='.urlencode($optioncss);
737 $param .=
'&billed='.urlencode($billed);
740 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
745 $_GET[
"origin"] = $_POST[
"origin"];
746 $_GET[
"originid"] = $_POST[
"originid"];
760$form =
new Form($db);
768$title = $langs->trans(
"SuppliersOrders");
771 $fourn->fetch($socid);
772 $title .=
' - '.$fourn->name;
783if ($search_billed > 0) {
784 $title .=
' - '.$langs->trans(
"Billed");
790$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
791$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
795 $sql =
'SELECT DISTINCT';
797$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,';
798$sql .=
" typent.code as typent_code,";
799$sql .=
" state.code_departement as state_code, state.nom as state_name,";
800$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,";
801$sql .=
' cf.localtax1 as total_localtax1, cf.localtax2 as total_localtax2,';
802$sql .=
' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
803$sql .=
' cf.date_creation as date_creation, cf.tms as date_modification,';
804$sql .=
' cf.note_public, cf.note_private,';
805$sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
806$sql .=
" u.firstname, u.lastname, u.photo, u.login, u.email as user_email, u.statut as user_status";
808if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
809 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
810 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
814$parameters = array();
815$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
816$sql .= $hookmanager->resPrint;
820$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
821$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
822$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
823$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
824$sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
825if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
826 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cf.rowid = ef.fk_object)";
829 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
831$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON cf.fk_user_author = u.rowid";
832$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = cf.fk_projet";
833$parameters = array();
834$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
835$sql .= $hookmanager->resPrint;
836$sql .=
' WHERE cf.fk_soc = s.rowid';
837$sql .=
' AND cf.entity IN ('.getEntity(
'supplier_order').
')';
839 $sql .=
" AND s.rowid = ".((int) $socid);
844if ($search_refsupp) {
848 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
850if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
851 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
853 if ($search_company) {
856 if ($search_company_alias) {
860if ($search_request_author) {
861 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_request_author);
863if ($search_billed !=
'' && $search_billed >= 0) {
864 $sql .=
" AND cf.billed = ".((int) $search_billed);
867if (
GETPOST(
'statut',
'intcomma') !==
'') {
868 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(
GETPOST(
'statut',
'intcomma')))).
")";
870if ($search_status !=
'' && $search_status !=
'-1') {
871 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
873if ($search_date_order_start) {
874 $sql .=
" AND cf.date_commande >= '".$db->idate($search_date_order_start).
"'";
876if ($search_date_order_end) {
877 $sql .=
" AND cf.date_commande <= '".$db->idate($search_date_order_end).
"'";
879if ($search_date_delivery_start) {
880 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_delivery_start).
"'";
882if ($search_date_delivery_end) {
883 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_delivery_end).
"'";
885if ($search_date_valid_start) {
886 $sql .=
" AND cf.date_valid >= '".$db->idate($search_date_valid_start).
"'";
888if ($search_date_valid_end) {
889 $sql .=
" AND cf.date_valid <= '".$db->idate($search_date_valid_end).
"'";
891if ($search_date_approve_start) {
892 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_approve_start).
"'";
894if ($search_date_approve_end) {
895 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_approve_end).
"'";
906if ($search_country) {
907 $sql .=
" AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).
')';
909if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
910 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
915if ($search_user > 0) {
916 $sql .=
" AND EXISTS (";
917 $sql .=
" SELECT ec.rowid ";
918 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_contact as ec";
919 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
920 $sql .=
" WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
921 $sql .=
" AND tc.element = 'order_supplier' AND tc.source = 'internal'";
924if ($search_total_ht !=
'') {
927if ($search_total_tva !=
'') {
930if ($search_total_ttc !=
'') {
933if ($search_multicurrency_code !=
'') {
934 $sql .=
" AND cf.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
936if ($search_multicurrency_tx !=
'') {
937 $sql .=
natural_search(
'cf.multicurrency_tx', $search_multicurrency_tx, 1);
939if ($search_multicurrency_montant_ht !=
'') {
940 $sql .=
natural_search(
'cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
942if ($search_multicurrency_montant_tva !=
'') {
943 $sql .=
natural_search(
'cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1);
945if ($search_multicurrency_montant_ttc !=
'') {
946 $sql .=
natural_search(
'cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
948if ($search_project_ref !=
'') {
952if ($search_sale && $search_sale !=
'-1') {
953 if ($search_sale == -2) {
954 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = cf.fk_soc)";
955 } elseif ($search_sale > 0) {
956 $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).
")";
960$searchCategoryProductOperator = -1;
961$searchCategoryProductList = array($search_product_category);
962if (!empty($searchCategoryProductList)) {
963 $searchCategoryProductSqlList = array();
964 $listofcategoryid =
'';
965 foreach ($searchCategoryProductList as $searchCategoryProduct) {
966 if (intval($searchCategoryProduct) == -2) {
967 $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)";
968 } elseif (intval($searchCategoryProduct) > 0) {
969 if ($searchCategoryProductOperator == 0) {
970 $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).
")";
972 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
976 if ($listofcategoryid) {
977 $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).
"))";
979 if ($searchCategoryProductOperator == 1) {
980 if (!empty($searchCategoryProductSqlList)) {
981 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
984 if (!empty($searchCategoryProductSqlList)) {
985 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
990include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
992$parameters = array();
993$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
994$sql .= $hookmanager->resPrint;
997$nbtotalofrecords =
'';
1000 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1001 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1002 $resql = $db->query($sqlforcount);
1004 $objforcount = $db->fetch_object($resql);
1005 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1010 if (($page * $limit) > $nbtotalofrecords) {
1017$sql .= $db->order($sortfield, $sortorder);
1019 $sql .= $db->plimit($limit + 1, $offset);
1023$resql = $db->query($sql);
1025 $num = $db->num_rows($resql);
1027 $arrayofselected = is_array($toselect) ? $toselect : array();
1029 if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1030 $obj = $db->fetch_object($resql);
1032 header(
"Location: ".DOL_URL_ROOT.
'/fourn/commande/card.php?id='.$id);
1036 llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-supplier-order page-list');
1039 if (!empty($mode)) {
1040 $param .=
'&mode='.urlencode($mode);
1042 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1043 $param .=
'&contextpage='.urlencode($contextpage);
1045 if ($limit > 0 && $limit != $conf->liste_limit) {
1046 $param .=
'&limit='.((int) $limit);
1049 $param .=
'&search_all='.urlencode($search_all);
1052 $param .=
'&socid='.urlencode((
string) ($socid));
1055 $param .=
"&search_all=".urlencode($search_all);
1057 if ($search_date_order_startday) {
1058 $param .=
'&search_date_order_startday='.urlencode((
string) ($search_date_order_startday));
1060 if ($search_date_order_startmonth) {
1061 $param .=
'&search_date_order_startmonth='.urlencode((
string) ($search_date_order_startmonth));
1063 if ($search_date_order_startyear) {
1064 $param .=
'&search_date_order_startyear='.urlencode((
string) ($search_date_order_startyear));
1066 if ($search_date_order_endday) {
1067 $param .=
'&search_date_order_endday='.urlencode((
string) ($search_date_order_endday));
1069 if ($search_date_order_endmonth) {
1070 $param .=
'&search_date_order_endmonth='.urlencode((
string) ($search_date_order_endmonth));
1072 if ($search_date_order_endyear) {
1073 $param .=
'&search_date_order_endyear='.urlencode((
string) ($search_date_order_endyear));
1075 if ($search_date_delivery_startday) {
1076 $param .=
'&search_date_delivery_startday='.urlencode((
string) ($search_date_delivery_startday));
1078 if ($search_date_delivery_startmonth) {
1079 $param .=
'&search_date_delivery_startmonth='.urlencode((
string) ($search_date_delivery_startmonth));
1081 if ($search_date_delivery_startyear) {
1082 $param .=
'&search_date_delivery_startyear='.urlencode((
string) ($search_date_delivery_startyear));
1084 if ($search_date_delivery_endday) {
1085 $param .=
'&search_date_delivery_endday='.urlencode((
string) ($search_date_delivery_endday));
1087 if ($search_date_delivery_endmonth) {
1088 $param .=
'&search_date_delivery_endmonth='.urlencode((
string) ($search_date_delivery_endmonth));
1090 if ($search_date_delivery_endyear) {
1091 $param .=
'&search_date_delivery_endyear='.urlencode((
string) ($search_date_delivery_endyear));
1093 if ($search_date_valid_startday) {
1094 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
1096 if ($search_date_valid_startmonth) {
1097 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
1099 if ($search_date_valid_startyear) {
1100 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
1102 if ($search_date_valid_endday) {
1103 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
1105 if ($search_date_valid_endmonth) {
1106 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
1108 if ($search_date_valid_endyear) {
1109 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
1111 if ($search_date_approve_startday) {
1112 $param .=
'&search_date_approve_startday='.urlencode((
string) ($search_date_approve_startday));
1114 if ($search_date_approve_startmonth) {
1115 $param .=
'&search_date_approve_startmonth='.urlencode((
string) ($search_date_approve_startmonth));
1117 if ($search_date_approve_startyear) {
1118 $param .=
'&search_date_approve_startyear='.urlencode((
string) ($search_date_approve_startyear));
1120 if ($search_date_approve_endday) {
1121 $param .=
'&search_date_approve_endday='.urlencode((
string) ($search_date_approve_endday));
1123 if ($search_date_approve_endmonth) {
1124 $param .=
'&search_date_approve_endmonth='.urlencode((
string) ($search_date_approve_endmonth));
1126 if ($search_date_approve_endyear) {
1127 $param .=
'&search_date_approve_endyear='.urlencode((
string) ($search_date_approve_endyear));
1130 $param .=
'&search_ref='.urlencode($search_ref);
1132 if ($search_company) {
1133 $param .=
'&search_company='.urlencode($search_company);
1135 if ($search_company_alias) {
1136 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1138 if ($search_user > 0) {
1139 $param .=
'&search_user='.urlencode((
string) ($search_user));
1141 if ($search_request_author) {
1142 $param .=
'&search_request_author='.urlencode($search_request_author);
1144 if ($search_sale > 0) {
1145 $param .=
'&search_sale='.urlencode($search_sale);
1147 if ($search_total_ht !=
'') {
1148 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1150 if ($search_total_ttc !=
'') {
1151 $param .=
"&search_total_ttc=".urlencode($search_total_ttc);
1153 if ($search_multicurrency_code !=
'') {
1154 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1156 if ($search_multicurrency_tx !=
'') {
1157 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1159 if ($search_multicurrency_montant_ht !=
'') {
1160 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1162 if ($search_multicurrency_montant_tva !=
'') {
1163 $param .=
'&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva);
1165 if ($search_multicurrency_montant_ttc !=
'') {
1166 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1168 if ($search_refsupp) {
1169 $param .=
"&search_refsupp=".urlencode($search_refsupp);
1171 if ($search_status !=
'' && $search_status !=
'-1') {
1172 $param .=
"&search_status=".urlencode($search_status);
1174 if ($search_project_ref >= 0) {
1175 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1177 if ($search_billed !=
'') {
1178 $param .=
"&search_billed=".urlencode($search_billed);
1181 $param .=
'&show_files='.urlencode((
string) ($show_files));
1183 if ($optioncss !=
'') {
1184 $param .=
'&optioncss='.urlencode($optioncss);
1186 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
1187 $param .=
'&search_type_thirdparty='.urlencode((
string) ($search_type_thirdparty));
1191 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1193 $parameters = array(
'param' => &$param);
1194 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1195 $param .= $hookmanager->resPrint;
1198 $arrayofmassactions = array(
1199 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1200 'builddoc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1201 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1204 if ($permissiontovalidate) {
1205 if ($permissiontoapprove && !
getDolGlobalString(
'SUPPLIER_ORDER_NO_DIRECT_APPROVE')) {
1206 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"ValidateAndApprove");
1208 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1212 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
"supplier_invoice",
"creer")) {
1213 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'supplier_invoice',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisSupplier");
1215 if ($permissiontodelete) {
1216 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1218 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1219 $arrayofmassactions = array();
1221 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1223 $url = DOL_URL_ROOT.
'/fourn/commande/card.php?action=create';
1225 $url .=
'&socid='.((int) $socid);
1226 $url .=
'&backtopage='.urlencode(DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.((
int) $socid));
1228 $newcardbutton =
'';
1229 $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'));
1230 $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'));
1232 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewSupplierOrderShort'),
'',
'fa fa-plus-circle', $url,
'', $permissiontoadd);
1235 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1236 if ($optioncss !=
'') {
1237 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1239 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1240 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1241 print
'<input type="hidden" name="action" value="list">';
1242 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1243 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1244 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1245 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1246 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1248 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'supplier_order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1250 $topicmail =
"SendOrderRef";
1251 $modelmail =
"order_supplier_send";
1253 $trackid =
'sord'.$object->id;
1254 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1256 if ($massaction ==
'prevalidate') {
1257 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1260 if ($massaction ==
'createbills') {
1262 print
'<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
1264 print
'<table class="noborder centpercent">';
1266 print
'<td class="titlefield">';
1267 print $langs->trans(
'DateInvoice');
1270 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1275 print $langs->trans(
'CreateOneBillByThird');
1278 print $form->selectyesno(
'createbills_onebythird',
'', 1);
1283 print $langs->trans(
'ValidateInvoices');
1286 print $form->selectyesno(
'validate_invoices', 1, 1);
1291 print
'<div class="center">';
1292 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1293 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1300 foreach ($fieldstosearchall as $key => $val) {
1301 $fieldstosearchall[$key] = $langs->trans($val);
1303 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
1306 $moreforfilter =
'';
1309 if ($user->hasRight(
"user",
"user",
"lire")) {
1310 $langs->load(
"commercial");
1311 $moreforfilter .=
'<div class="divsearchfield">';
1312 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1313 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1314 $moreforfilter .=
'</div>';
1317 if ($user->hasRight(
"user",
"user",
"lire")) {
1318 $moreforfilter .=
'<div class="divsearchfield">';
1319 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1320 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1321 $moreforfilter .=
'</div>';
1324 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
1325 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1326 $moreforfilter .=
'<div class="divsearchfield">';
1327 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1328 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1329 $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);
1330 $moreforfilter .=
'</div>';
1332 $parameters = array();
1333 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1334 if (empty($reshook)) {
1335 $moreforfilter .= $hookmanager->resPrint;
1337 $moreforfilter = $hookmanager->resPrint;
1340 if (!empty($moreforfilter)) {
1341 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1342 print $moreforfilter;
1346 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1347 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1348 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
1351 $selectedfields .=
'<script>';
1352 $selectedfields .=
' $(document).ready(function() {';
1353 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1354 $selectedfields .=
' $("#checkforselects").click();';
1355 $selectedfields .=
' $("#massaction").val("createbills").change();';
1356 $selectedfields .=
' });';
1357 $selectedfields .=
'</script>';
1360 print
'<div class="div-table-responsive">';
1361 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1363 print
'<tr class="liste_titre_filter">';
1366 print
'<td class="liste_titre middle">';
1367 $searchpicto = $form->showFilterButtons(
'left');
1372 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1373 print
'<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.
'"></td>';
1376 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1377 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.
'"></td>';
1380 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1381 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.
'"></td>';
1384 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1385 print
'<td class="liste_titre">';
1386 print
'<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.
'">';
1390 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1391 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.
'"></td>';
1394 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1395 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company_alias" value="'.$search_company_alias.
'"></td>';
1398 if (!empty($arrayfields[
's.town'][
'checked'])) {
1399 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.
'"></td>';
1402 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1403 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.
'"></td>';
1406 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1407 print
'<td class="liste_titre">';
1408 print
'<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1412 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1413 print
'<td class="liste_titre center">';
1414 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1418 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1419 print
'<td class="liste_titre maxwidthonsmartphone center">';
1420 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);
1424 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1425 print
'<td class="liste_titre center">';
1426 print
'<div class="nowrapfordate">';
1427 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'));
1429 print
'<div class="nowrapfordate">';
1430 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'));
1435 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1436 print
'<td class="liste_titre center">';
1437 print
'<div class="nowrapfordate">';
1438 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'));
1440 print
'<div class="nowrapfordate">';
1441 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'));
1445 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1447 print
'<td class="liste_titre right">';
1448 print
'<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.
'">';
1451 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1453 print
'<td class="liste_titre right">';
1454 print
'<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.
'">';
1457 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1459 print
'<td class="liste_titre right">';
1460 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1463 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1465 print
'<td class="liste_titre">';
1466 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1469 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1471 print
'<td class="liste_titre">';
1472 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1475 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1477 print
'<td class="liste_titre right">';
1478 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1481 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1483 print
'<td class="liste_titre right">';
1484 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).
'">';
1487 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1489 print
'<td class="liste_titre right">';
1490 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1494 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1497 $parameters = array(
'arrayfields' => $arrayfields);
1498 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1499 print $hookmanager->resPrint;
1501 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1502 print
'<td class="liste_titre">';
1506 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1507 print
'<td class="liste_titre">';
1511 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1512 print
'<td class="liste_titre center parentonrightofpage">';
1513 print $form->selectyesno(
'search_billed', $search_billed, 1,
false, 1, 1,
'search_status width100 onrightofpage');
1517 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1518 print
'<td class="liste_titre center parentonrightofpage">';
1519 $formorder->selectSupplierOrderStatus($search_status, 1,
'search_status',
'search_status width100 onrightofpage');
1523 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1524 print
'<td class="liste_titre center">';
1525 print
'<div class="nowrapfordate">';
1526 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'));
1528 print
'<div class="nowrapfordate">';
1529 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'));
1534 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1535 print
'<td class="liste_titre center">';
1536 print
'<div class="nowrapfordate">';
1537 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'));
1539 print
'<div class="nowrapfordate">';
1540 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'));
1545 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1546 print
'<td class="liste_titre">';
1550 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1551 print
'<td class="liste_titre">';
1556 print
'<td class="liste_titre center">';
1557 $searchpicto = $form->showFilterButtons();
1564 $totalarray = array();
1565 $totalarray[
'nbfield'] = 0;
1568 print
'<tr class="liste_titre">';
1570 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1571 $totalarray[
'nbfield']++;
1573 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1574 print_liste_field_titre($arrayfields[
'cf.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref",
"", $param,
'', $sortfield, $sortorder);
1575 $totalarray[
'nbfield']++;
1577 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1578 print_liste_field_titre($arrayfields[
'cf.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref_supplier",
"", $param,
'', $sortfield, $sortorder,
'tdoverflowmax100imp ');
1579 $totalarray[
'nbfield']++;
1581 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1582 print_liste_field_titre($arrayfields[
'cf.fk_projet'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1583 $totalarray[
'nbfield']++;
1585 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1586 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
"u.login",
"", $param,
'', $sortfield, $sortorder);
1587 $totalarray[
'nbfield']++;
1589 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1590 print_liste_field_titre($arrayfields[
'cf.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
1591 $totalarray[
'nbfield']++;
1593 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1594 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"s.name_alias",
"", $param,
'', $sortfield, $sortorder);
1595 $totalarray[
'nbfield']++;
1597 if (!empty($arrayfields[
's.town'][
'checked'])) {
1598 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1599 $totalarray[
'nbfield']++;
1601 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1602 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1603 $totalarray[
'nbfield']++;
1605 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1606 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1607 $totalarray[
'nbfield']++;
1609 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1610 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1611 $totalarray[
'nbfield']++;
1613 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1614 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1615 $totalarray[
'nbfield']++;
1617 if (!empty($arrayfields[
'cf.fk_author'][
'checked'])) {
1618 print_liste_field_titre($arrayfields[
'cf.fk_author'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_author",
"", $param,
'', $sortfield, $sortorder);
1619 $totalarray[
'nbfield']++;
1621 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1622 print_liste_field_titre($arrayfields[
'cf.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_commande",
"", $param,
'', $sortfield, $sortorder,
'center ');
1623 $totalarray[
'nbfield']++;
1625 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1626 print_liste_field_titre($arrayfields[
'cf.date_livraison'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1627 $totalarray[
'nbfield']++;
1629 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1630 print_liste_field_titre($arrayfields[
'cf.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
1631 $totalarray[
'nbfield']++;
1633 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1634 print_liste_field_titre($arrayfields[
'cf.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
1635 $totalarray[
'nbfield']++;
1637 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1638 print_liste_field_titre($arrayfields[
'cf.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
1639 $totalarray[
'nbfield']++;
1641 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1642 print_liste_field_titre($arrayfields[
'cf.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1643 $totalarray[
'nbfield']++;
1645 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1646 print_liste_field_titre($arrayfields[
'cf.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1647 $totalarray[
'nbfield']++;
1649 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1650 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1651 $totalarray[
'nbfield']++;
1653 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1654 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1655 $totalarray[
'nbfield']++;
1657 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1658 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1659 $totalarray[
'nbfield']++;
1662 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1664 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1665 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1666 print $hookmanager->resPrint;
1667 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1668 print_liste_field_titre($arrayfields[
'cf.date_creation'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowraponall ');
1669 $totalarray[
'nbfield']++;
1671 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1672 print_liste_field_titre($arrayfields[
'cf.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowraponall ');
1673 $totalarray[
'nbfield']++;
1675 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1676 print_liste_field_titre($arrayfields[
'cf.billed'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.billed',
'', $param,
'', $sortfield, $sortorder,
'center ');
1677 $totalarray[
'nbfield']++;
1679 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1680 print_liste_field_titre($arrayfields[
'cf.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1681 $totalarray[
'nbfield']++;
1683 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1684 print_liste_field_titre($arrayfields[
'cf.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
1685 $totalarray[
'nbfield']++;
1687 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1688 print_liste_field_titre($arrayfields[
'cf.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_approve',
'', $param,
'', $sortfield, $sortorder,
'center ');
1689 $totalarray[
'nbfield']++;
1691 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1692 print_liste_field_titre($arrayfields[
'cf.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_public",
"", $param,
'', $sortfield, $sortorder,
'center ');
1693 $totalarray[
'nbfield']++;
1695 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1696 print_liste_field_titre($arrayfields[
'cf.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_private",
"", $param,
'', $sortfield, $sortorder,
'center ');
1697 $totalarray[
'nbfield']++;
1700 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1701 $totalarray[
'nbfield']++;
1707 $productstat_cache = array();
1709 $userstatic =
new User($db);
1711 $projectstatic =
new Project($db);
1714 $savnbfield = $totalarray[
'nbfield'];
1715 $totalarray = array(
'nbfield' => 0,
'val' => array(),
'pos' => array());
1716 $totalarray[
'val'][
'cf.total_ht'] = 0;
1717 $totalarray[
'val'][
'cf.total_ttc'] = 0;
1718 $totalarray[
'val'][
'cf.total_tva'] = 0;
1720 $imaxinloop = ($limit ? min($num, $limit) : $num);
1721 while ($i < $imaxinloop) {
1722 $obj = $db->fetch_object($resql);
1730 $objectstatic->id = $obj->rowid;
1731 $objectstatic->ref = $obj->ref;
1732 $objectstatic->ref_supplier = $obj->ref_supplier;
1733 $objectstatic->socid = $obj->socid;
1734 $objectstatic->total_ht = $obj->total_ht;
1735 $objectstatic->total_tva = $obj->total_tva;
1736 $objectstatic->total_ttc = $obj->total_ttc;
1737 $objectstatic->date_commande = $db->jdate($obj->date_commande);
1738 $objectstatic->delivery_date = $db->jdate($obj->delivery_date);
1739 $objectstatic->note_public = $obj->note_public;
1740 $objectstatic->note_private = $obj->note_private;
1741 $objectstatic->statut = $obj->fk_statut;
1743 if ($mode ==
'kanban') {
1745 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1746 print
'<div class="box-flex-container kanban">';
1749 $thirdpartytmp->id = $obj->socid;
1750 $thirdpartytmp->name = $obj->name;
1751 $thirdpartytmp->email = $obj->email;
1752 $thirdpartytmp->name_alias = $obj->alias;
1753 $thirdpartytmp->client = $obj->client;
1754 $thirdpartytmp->fournisseur = $obj->fournisseur;
1756 print $objectstatic->getKanbanView(
'', array(
'thirdparty' => $thirdpartytmp->getNomUrl(
'supplier', 0, 0, -1),
'selected' => in_array($objectstatic->id, $arrayofselected)));
1757 if ($i == ($imaxinloop - 1)) {
1762 print
'<tr class="oddeven">';
1765 print
'<td class="nowrap center">';
1766 if ($massactionbutton || $massaction) {
1768 if (in_array($obj->rowid, $arrayofselected)) {
1771 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1775 $totalarray[
'nbfield']++;
1779 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1780 print
'<td class="nowrap">';
1783 print $objectstatic->getNomUrl(1,
'', 0, -1, 1);
1787 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1791 $totalarray[
'nbfield']++;
1795 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1796 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>'.
"\n";
1798 $totalarray[
'nbfield']++;
1802 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1803 $projectstatic->id = $obj->project_id;
1804 $projectstatic->ref = $obj->project_ref;
1805 $projectstatic->title = $obj->project_title;
1807 if ($obj->project_id > 0) {
1808 print $projectstatic->getNomUrl(1);
1812 $totalarray[
'nbfield']++;
1816 $userstatic->id = $obj->fk_user_author;
1817 $userstatic->lastname = $obj->lastname;
1818 $userstatic->firstname = $obj->firstname;
1819 $userstatic->login = $obj->login;
1820 $userstatic->photo = $obj->photo;
1821 $userstatic->email = $obj->user_email;
1822 $userstatic->status = $obj->user_status;
1823 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1824 print
'<td class="tdoverflowmax150">';
1825 if ($userstatic->id) {
1826 print $userstatic->getNomUrl(1);
1830 $totalarray[
'nbfield']++;
1834 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1835 print
'<td class="tdoverflowmax150">';
1836 $thirdpartytmp->id = $obj->socid;
1837 $thirdpartytmp->name = $obj->name;
1838 $thirdpartytmp->email = $obj->email;
1839 $thirdpartytmp->name_alias = $obj->alias;
1840 $thirdpartytmp->client = $obj->client;
1841 $thirdpartytmp->fournisseur = $obj->fournisseur;
1842 print $thirdpartytmp->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1845 $totalarray[
'nbfield']++;
1849 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1850 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->alias).
'">';
1854 $totalarray[
'nbfield']++;
1858 if (!empty($arrayfields[
's.town'][
'checked'])) {
1859 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
1863 $totalarray[
'nbfield']++;
1867 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1868 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).
'">';
1872 $totalarray[
'nbfield']++;
1876 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1877 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).
'">'.
dol_escape_htmltag($obj->state_name).
"</td>\n";
1879 $totalarray[
'nbfield']++;
1883 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1884 print
'<td class="center">';
1885 $tmparray =
getCountry($obj->fk_pays,
'all');
1886 print $tmparray[
'label'];
1889 $totalarray[
'nbfield']++;
1893 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1894 print
'<td class="center">';
1895 if (empty($typenArray)) {
1896 $typenArray = $formcompany->typent_array(1);
1898 print $typenArray[$obj->typent_code];
1901 $totalarray[
'nbfield']++;
1906 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1907 print
'<td class="center">';
1909 if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1910 if ($objectstatic->hasDelay()) {
1911 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1916 $totalarray[
'nbfield']++;
1920 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1921 print
'<td class="center">';
1923 if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1924 if ($objectstatic->hasDelay()) {
1925 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1930 $totalarray[
'nbfield']++;
1934 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1935 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1937 $totalarray[
'nbfield']++;
1940 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ht';
1942 $totalarray[
'val'][
'cf.total_ht'] += $obj->total_ht;
1945 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1946 print
'<td class="right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
1948 $totalarray[
'nbfield']++;
1951 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_tva';
1953 $totalarray[
'val'][
'cf.total_tva'] += $obj->total_tva;
1956 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1957 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1959 $totalarray[
'nbfield']++;
1962 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ttc';
1964 $totalarray[
'val'][
'cf.total_ttc'] += $obj->total_ttc;
1968 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1969 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1971 $totalarray[
'nbfield']++;
1976 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1977 print
'<td class="nowrap">';
1978 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1981 $totalarray[
'nbfield']++;
1985 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1986 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
1988 $totalarray[
'nbfield']++;
1992 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1993 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva).
"</span></td>\n";
1995 $totalarray[
'nbfield']++;
1999 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
2000 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
2002 $totalarray[
'nbfield']++;
2007 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2009 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
2010 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2011 print $hookmanager->resPrint;
2013 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
2014 print
'<td class="center nowraponall">';
2015 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2018 $totalarray[
'nbfield']++;
2022 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
2023 print
'<td class="center nowraponall">';
2024 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
2027 $totalarray[
'nbfield']++;
2031 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
2032 print
'<td class="center">'.yn($obj->billed).
'</td>';
2034 $totalarray[
'nbfield']++;
2038 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
2039 print
'<td class="center nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).
'</td>';
2041 $totalarray[
'nbfield']++;
2046 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
2047 print
'<td class="center">';
2051 $totalarray[
'nbfield']++;
2055 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
2056 print
'<td class="center">';
2060 $totalarray[
'nbfield']++;
2064 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
2065 print
'<td class="sensiblehtmlcontent center">';
2069 $totalarray[
'nbfield']++;
2074 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
2075 print
'<td class="sensiblehtmlcontent center">';
2079 $totalarray[
'nbfield']++;
2085 print
'<td class="nowrap center">';
2086 if ($massactionbutton || $massaction) {
2088 if (in_array($obj->rowid, $arrayofselected)) {
2091 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2095 $totalarray[
'nbfield']++;
2101 $total += $obj->total_ht;
2102 $subtotal += $obj->total_ht;
2108 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2113 foreach ($arrayfields as $key => $val) {
2114 if (!empty($val[
'checked'])) {
2118 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2123 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2124 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2125 print $hookmanager->resPrint;
2127 print
'</table>'.
"\n";
2130 print
'</form>'.
"\n";
2132 $hidegeneratedfilelistifempty = 1;
2133 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2134 $hidegeneratedfilelistifempty = 0;
2138 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2139 $urlsource .= str_replace(
'&',
'&', $param);
2141 $filedir = $diroutputmassaction;
2142 $genallowed = $permissiontoread;
2143 $delallowed = $permissiontoadd;
2145 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()
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...
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.