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$billed =
GETPOST(
'billed',
'int');
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';
152if ($search_option ==
'recv_late') {
153 $search_status =
'3,4';
156$diroutputmassaction =
$conf->fournisseur->commande->dir_output.
'/temp/massgeneration/'.$user->id;
159$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
160$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
162if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
166$offset = $limit * $page;
167$pageprev = $page - 1;
168$pagenext = $page + 1;
170 $sortfield =
'cf.ref';
178$hookmanager->initHooks(array(
'supplierorderlist'));
182$extrafields->fetch_name_optionals_label(
$object->table_element);
184$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
187$fieldstosearchall = array();
188foreach (
$object->fields as $key => $val) {
189 if (!empty($val[
'searchall'])) {
190 $fieldstosearchall[
'cf.'.$key] = $val[
'label'];
193$fieldstosearchall[
'pd.description'] =
'Description';
194$fieldstosearchall[
's.nom'] =
"ThirdParty";
195$fieldstosearchall[
's.name_alias'] =
"AliasNameShort";
196$fieldstosearchall[
's.zip'] =
"Zip";
197$fieldstosearchall[
's.town'] =
"Town";
198if (empty($user->socid)) {
199 $fieldstosearchall[
"cf.note_private"] =
"NotePrivate";
202$enabledtypetiers = 0;
206 'u.login' => array(
'label' =>
"AuthorRequest",
'enabled' =>
'1',
'position' => 41),
207 's.name_alias' => array(
'label' =>
"AliasNameShort",
'position' => 51,
'checked' =>
'0'),
208 's.town' => array(
'label' =>
"Town",
'enabled' =>
'1',
'position' => 55,
'checked' =>
'0'),
209 's.zip' => array(
'label' =>
"Zip",
'enabled' =>
'1',
'position' => 56,
'checked' =>
'1'),
210 'state.nom' => array(
'label' =>
"StateShort",
'enabled' =>
'1',
'position' => 57),
211 'country.code_iso' => array(
'label' =>
"Country",
'enabled' =>
'1',
'position' => 58),
212 'typent.code' => array(
'label' =>
"ThirdPartyType",
'enabled' => $enabledtypetiers,
'position' => 59),
213 'cf.total_localtax1' => array(
'label' => $langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked' =>
'0',
'enabled' => (
string) (
int) ($mysoc->localtax1_assuj ==
"1"),
'position' => 140),
214 'cf.total_localtax2' => array(
'label' => $langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked' =>
'0',
'enabled' => (
string) (
int) ($mysoc->localtax2_assuj ==
"1"),
'position' => 145),
215 'cf.note_public' => array(
'label' =>
'NotePublic',
'checked' =>
'0',
'enabled' => (
string) (
int) (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES')),
'position' => 750),
216 'cf.note_private' => array(
'label' =>
'NotePrivate',
'checked' =>
'0',
'enabled' => (
string) (
int) (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'position' => 760),
218foreach (
$object->fields as $key => $val) {
220 if (!empty($val[
'visible'])) {
221 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
222 $arrayfields[
'cf.'.$key] = array(
223 'label' => $val[
'label'],
224 'checked' => (($visible < 0) ?
'0' :
'1'),
225 'enabled' => (string) (int) (abs($visible) != 3 && (bool)
dol_eval((string) $val[
'enabled'], 1)),
226 'position' => $val[
'position'],
227 'help' => isset($val[
'help']) ? $val[
'help'] :
''
232include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
240if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
241 $search_sale = $user->id;
247 $socid = $user->socid;
249$result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
251$permissiontoread = ($user->hasRight(
"fournisseur",
"commande",
"lire") || $user->hasRight(
"supplier_order",
"lire"));
252$permissiontoadd = ($user->hasRight(
"fournisseur",
"commande",
"creer") || $user->hasRight(
"supplier_order",
"creer"));
253$permissiontodelete = ($user->hasRight(
"fournisseur",
"commande",
"supprimer") || $user->hasRight(
"supplier_order",
"supprimer"));
254$permissiontovalidate = $permissiontoadd;
255$permissiontoapprove = ($user->hasRight(
"fournisseur",
"commande",
"approuver") || $user->hasRight(
"supplier_order",
"approuver"));
262if (
GETPOST(
'cancel',
'alpha')) {
266if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createsupplierbills') {
270$parameters = array(
'socid' => $socid,
'arrayfields' => &$arrayfields);
271$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
276if (empty($reshook)) {
278 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
281 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
285 $search_product_category =
'';
287 $search_refsupp =
'';
288 $search_company =
'';
289 $search_company_alias =
'';
294 $search_country =
'';
295 $search_type_thirdparty =
'';
296 $search_request_author =
'';
297 $search_total_ht =
'';
298 $search_total_tva =
'';
299 $search_total_ttc =
'';
300 $search_multicurrency_code =
'';
301 $search_multicurrency_tx =
'';
302 $search_multicurrency_montant_ht =
'';
303 $search_multicurrency_montant_tva =
'';
304 $search_multicurrency_montant_ttc =
'';
305 $search_project_ref =
'';
308 $search_date_order_startday =
'';
309 $search_date_order_startmonth =
'';
310 $search_date_order_startyear =
'';
311 $search_date_order_endday =
'';
312 $search_date_order_endmonth =
'';
313 $search_date_order_endyear =
'';
314 $search_date_order_start =
'';
315 $search_date_order_end =
'';
316 $search_date_delivery_startday =
'';
317 $search_date_delivery_startmonth =
'';
318 $search_date_delivery_startyear =
'';
319 $search_date_delivery_endday =
'';
320 $search_date_delivery_endmonth =
'';
321 $search_date_delivery_endyear =
'';
322 $search_date_delivery_start =
'';
323 $search_date_delivery_end =
'';
324 $search_date_valid_startday =
'';
325 $search_date_valid_startmonth =
'';
326 $search_date_valid_startyear =
'';
327 $search_date_valid_endday =
'';
328 $search_date_valid_endmonth =
'';
329 $search_date_valid_endyear =
'';
330 $search_date_valid_start =
'';
331 $search_date_valid_end =
'';
332 $search_date_approve_startday =
'';
333 $search_date_approve_startmonth =
'';
334 $search_date_approve_startyear =
'';
335 $search_date_approve_endday =
'';
336 $search_date_approve_endmonth =
'';
337 $search_date_approve_endyear =
'';
338 $search_date_approve_start =
'';
339 $search_date_approve_end =
'';
342 $search_array_options = array();
344 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
345 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
350 $objectclass =
'CommandeFournisseur';
351 $objectlabel =
'SupplierOrders';
352 $uploaddir =
$conf->fournisseur->commande->dir_output;
353 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
355 if ($action ==
'validate' && $permissiontovalidate) {
356 if (
GETPOST(
'confirm') ==
'yes') {
361 foreach ($toselect as $checked) {
362 if ($objecttmp->fetch($checked)) {
363 if ($objecttmp->statut == 0) {
364 $objecttmp->date_commande =
dol_now();
365 $result = $objecttmp->valid($user);
368 if (!
getDolGlobalString(
'SUPPLIER_ORDER_NO_DIRECT_APPROVE') && $permissiontoapprove && !(
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') && $objecttmp->hasProductsOrServices(1))) {
369 $result = $objecttmp->approve($user);
370 setEventMessages($langs->trans(
"SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
372 setEventMessages($langs->trans(
"SupplierOrderValidated"), array($objecttmp->ref));
391 if ($massaction ==
'confirm_createsupplierbills') {
392 $orders =
GETPOST(
'toselect',
'array');
393 $createbills_onebythird =
GETPOSTINT(
'createbills_onebythird');
394 $validate_invoices =
GETPOSTINT(
'validate_invoices');
398 $TFactThird = array();
400 $nb_bills_created = 0;
408 foreach ($orders as $id_order) {
410 if ($cmd->fetch($id_order) <= 0) {
415 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
417 $objecttmp = $TFactThird[$cmd->socid];
420 if (!empty($cmd->socid) > 0) {
422 $societe->fetch($cmd->socid);
423 $objecttmp->vat_reverse_charge = $societe->vat_reverse_charge;
424 $objecttmp->thirdparty = $societe;
426 $objecttmp->socid = $cmd->socid;
427 $objecttmp->type = $objecttmp::TYPE_STANDARD;
428 $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
429 $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
430 $objecttmp->fk_project = $cmd->fk_project;
431 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
432 $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
433 $default_ref_supplier += 1;
436 if (empty($datefacture)) {
440 $objecttmp->date = $datefacture;
441 $objecttmp->origin =
'order_supplier';
442 $objecttmp->origin_id = $id_order;
444 $res = $objecttmp->create($user);
448 $lastref = $objecttmp->ref;
449 $lastid = $objecttmp->id;
453 if ($objecttmp->id > 0) {
454 if (empty($objecttmp->note_public)) {
455 $objecttmp->note_public = $langs->transnoentities(
"Orders");
458 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_element (";
460 $sql .=
", sourcetype";
461 $sql .=
", fk_target";
462 $sql .=
", targettype";
463 $sql .=
") VALUES (";
465 $sql .=
", '".$db->escape($objecttmp->origin).
"'";
466 $sql .=
", ".((int) $objecttmp->id);
467 $sql .=
", '".$db->escape($objecttmp->element).
"'";
470 if (!$db->query($sql)) {
475 $lines = $cmd->lines;
476 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
478 $lines = $cmd->lines;
482 $num = count($lines);
484 for ($i = 0; $i < $num; $i++) {
485 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
486 if ($lines[$i]->subprice < 0) {
487 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
491 $discount->fk_soc = $objecttmp->socid;
492 $discount->socid = $objecttmp->socid;
493 $discount->amount_ht = abs($lines[$i]->total_ht);
494 $discount->amount_tva = abs($lines[$i]->total_tva);
495 $discount->amount_ttc = abs($lines[$i]->total_ttc);
496 $discount->tva_tx = $lines[$i]->tva_tx;
497 $discount->fk_user = $user->id;
498 $discount->description = $desc;
499 $discountid = $discount->create($user);
500 if ($discountid > 0) {
501 $result = $objecttmp->insert_discount($discountid);
510 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
513 if ($lines[$i]->date_debut_prevue) {
514 $date_start = $lines[$i]->date_debut_prevue;
516 if ($lines[$i]->date_debut_reel) {
517 $date_start = $lines[$i]->date_debut_reel;
519 if ($lines[$i]->date_start) {
520 $date_start = $lines[$i]->date_start;
524 if ($lines[$i]->date_fin_prevue) {
525 $date_end = $lines[$i]->date_fin_prevue;
527 if ($lines[$i]->date_fin_reel) {
528 $date_end = $lines[$i]->date_fin_reel;
530 if ($lines[$i]->date_end) {
531 $date_end = $lines[$i]->date_end;
534 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
538 $tva_tx = $lines[$i]->tva_tx;
540 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', (
string) $tva_tx)) {
541 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
544 $result = $objecttmp->addline(
546 $lines[$i]->subprice,
548 $lines[$i]->localtax1_tx,
549 $lines[$i]->localtax2_tx,
551 $lines[$i]->fk_product,
552 $lines[$i]->remise_percent,
556 $lines[$i]->info_bits,
562 $lines[$i]->array_options,
565 $lines[$i]->fk_commande,
567 $lines[$i]->ref_supplier,
568 $lines[$i]->special_code,
579 if ($result > 0 && $lines[$i]->product_type == 9) {
580 $fk_parent_line = $result;
588 $objecttmp->note_public =
dol_concatdesc($objecttmp->note_public, $langs->transnoentities($cmd->ref).(empty($cmd->ref_supplier) ?
'' :
' ('.$cmd->ref_supplier.
')'));
589 $objecttmp->update($user);
592 $cmd->classifyBilled($user);
594 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
595 $TFactThird[$cmd->socid] = $objecttmp;
597 $TFact[$objecttmp->id] = $objecttmp;
602 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
605 if (!$error && $validate_invoices) {
606 $massaction = $action =
'builddoc';
608 foreach ($TAllFact as &$objecttmp) {
609 $objecttmp->validate($user);
616 $id = $objecttmp->id;
620 $upload_dir =
$conf->fournisseur->facture->dir_output;
621 $permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
625 $massaction = $action =
'confirm_createsupplierbills';
631 if ($nb_bills_created == 1) {
632 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
633 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?id='.urlencode((
string) ($lastid)).
'">'.$lastref.
'</a>', $texttoshow);
636 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
642 $param .=
'&mode='.urlencode($mode);
644 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
645 $param .=
'&contextpage='.urlencode($contextpage);
647 if ($limit > 0 && $limit !=
$conf->liste_limit) {
648 $param .=
'&limit='.((int) $limit);
651 $param .=
'&search_all='.urlencode($search_all);
654 $param .=
'&socid='.urlencode((
string) ($socid));
656 if ($search_status !=
'') {
657 $param .=
'&search_status='.urlencode($search_status);
659 if ($search_option) {
660 $param .=
'&search_option='.urlencode($search_option);
662 if ($search_date_order_startday) {
663 $param .=
'&search_date_order_startday='.urlencode((
string) ($search_date_order_startday));
665 if ($search_date_order_startmonth) {
666 $param .=
'&search_date_order_startmonth='.urlencode((
string) ($search_date_order_startmonth));
668 if ($search_date_order_startyear) {
669 $param .=
'&search_date_order_startyear='.urlencode((
string) ($search_date_order_startyear));
671 if ($search_date_order_endday) {
672 $param .=
'&search_date_order_endday='.urlencode((
string) ($search_date_order_endday));
674 if ($search_date_order_endmonth) {
675 $param .=
'&search_date_order_endmonth='.urlencode((
string) ($search_date_order_endmonth));
677 if ($search_date_order_endyear) {
678 $param .=
'&search_date_order_endyear='.urlencode((
string) ($search_date_order_endyear));
680 if ($search_date_delivery_startday) {
681 $param .=
'&search_date_delivery_startday='.urlencode((
string) ($search_date_delivery_startday));
683 if ($search_date_delivery_startmonth) {
684 $param .=
'&search_date_delivery_startmonth='.urlencode((
string) ($search_date_delivery_startmonth));
686 if ($search_date_delivery_startyear) {
687 $param .=
'&search_date_delivery_startyear='.urlencode((
string) ($search_date_delivery_startyear));
689 if ($search_date_delivery_endday) {
690 $param .=
'&search_date_delivery_endday='.urlencode((
string) ($search_date_delivery_endday));
692 if ($search_date_delivery_endmonth) {
693 $param .=
'&search_date_delivery_endmonth='.urlencode((
string) ($search_date_delivery_endmonth));
695 if ($search_date_delivery_endyear) {
696 $param .=
'&search_date_delivery_endyear='.urlencode((
string) ($search_date_delivery_endyear));
698 if ($search_date_valid_startday) {
699 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
701 if ($search_date_valid_startmonth) {
702 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
704 if ($search_date_valid_startyear) {
705 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
707 if ($search_date_valid_endday) {
708 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
710 if ($search_date_valid_endmonth) {
711 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
713 if ($search_date_valid_endyear) {
714 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
716 if ($search_date_approve_startday) {
717 $param .=
'&search_date_approve_startday='.urlencode((
string) ($search_date_approve_startday));
719 if ($search_date_approve_startmonth) {
720 $param .=
'&search_date_approve_startmonth='.urlencode((
string) ($search_date_approve_startmonth));
722 if ($search_date_approve_startyear) {
723 $param .=
'&search_date_approve_startyear='.urlencode((
string) ($search_date_approve_startyear));
725 if ($search_date_approve_endday) {
726 $param .=
'&search_date_approve_endday='.urlencode((
string) ($search_date_approve_endday));
728 if ($search_date_approve_endmonth) {
729 $param .=
'&search_date_approve_endmonth='.urlencode((
string) ($search_date_approve_endmonth));
731 if ($search_date_approve_endyear) {
732 $param .=
'&search_date_approve_endyear='.urlencode((
string) ($search_date_approve_endyear));
735 $param .=
'&search_ref='.urlencode($search_ref);
737 if ($search_company) {
738 $param .=
'&search_company='.urlencode($search_company);
740 if ($search_company_alias) {
741 $param .=
'&search_company_alias='.urlencode($search_company_alias);
744 if ($search_user > 0) {
745 $param .=
'&search_user='.urlencode((
string) ($search_user));
747 if ($search_sale > 0) {
748 $param .=
'&search_sale='.urlencode($search_sale);
750 if ($search_total_ht !=
'') {
751 $param .=
'&search_total_ht='.urlencode($search_total_ht);
753 if ($search_total_tva !=
'') {
754 $param .=
'&search_total_tva='.urlencode($search_total_tva);
756 if ($search_total_ttc !=
'') {
757 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
759 if ($search_project_ref >= 0) {
760 $param .=
"&search_project_ref=".urlencode($search_project_ref);
763 $param .=
'&show_files='.urlencode((
string) ($show_files));
765 if ($optioncss !=
'') {
766 $param .=
'&optioncss='.urlencode($optioncss);
769 $param .=
'&billed='.((int) ($billed));
772 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
777 $_GET[
"origin"] = $_POST[
"origin"];
778 $_GET[
"originid"] = $_POST[
"originid"];
792$form =
new Form($db);
800$title = $langs->trans(
"SuppliersOrders");
803 $fourn->fetch($socid);
804 $title .=
' - '.$fourn->name;
808 $title .=
' - '.$langs->trans(
"Billed");
814$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
815$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
819 $sql =
'SELECT DISTINCT';
821$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,';
822$sql .=
" typent.code as typent_code,";
823$sql .=
" state.code_departement as state_code, state.nom as state_name,";
824$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,";
825$sql .=
' cf.localtax1 as total_localtax1, cf.localtax2 as total_localtax2,';
826$sql .=
' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
827$sql .=
' cf.date_creation as date_creation, cf.tms as date_modification,';
828$sql .=
' cf.note_public, cf.note_private,';
829$sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
830$sql .=
" u.firstname, u.lastname, u.photo, u.login, u.email as user_email, u.statut as user_status";
832if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
833 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
834 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
838$parameters = array();
839$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
840$sql .= $hookmanager->resPrint;
844$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
845$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
846$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
847$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
848$sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
849if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
850 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cf.rowid = ef.fk_object)";
853 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
855$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON cf.fk_user_author = u.rowid";
856$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = cf.fk_projet";
857$parameters = array();
858$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
859$sql .= $hookmanager->resPrint;
860$sql .=
' WHERE cf.fk_soc = s.rowid';
861$sql .=
' AND cf.entity IN ('.getEntity(
'supplier_order').
')';
863 $sql .=
" AND s.rowid = ".((int) $socid);
868if ($search_refsupp) {
872 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
874if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
875 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
877 if ($search_company) {
880 if ($search_company_alias) {
884if ($search_request_author) {
885 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_request_author);
887if ($billed !=
'' && $billed !=
'-1') {
888 $sql .=
" AND cf.billed = ".((int) $billed);
891if (
GETPOST(
'statut',
'intcomma') !==
'') {
892 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(
GETPOST(
'statut',
'intcomma')))).
")";
894if ($search_status !=
'' && $search_status !=
'-1') {
895 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
897if ($search_option ==
'late') {
898 $sql .=
" AND cf.date_commande < '".$db->idate(
dol_now() -
$conf->order->fournisseur->warning_delay).
"'";
900if ($search_date_order_start) {
901 $sql .=
" AND cf.date_commande >= '".$db->idate($search_date_order_start).
"'";
903if ($search_date_order_end) {
904 $sql .=
" AND cf.date_commande <= '".$db->idate($search_date_order_end).
"'";
906if ($search_date_delivery_start) {
907 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_delivery_start).
"'";
909if ($search_date_delivery_end) {
910 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_delivery_end).
"'";
912if ($search_date_valid_start) {
913 $sql .=
" AND cf.date_valid >= '".$db->idate($search_date_valid_start).
"'";
915if ($search_date_valid_end) {
916 $sql .=
" AND cf.date_valid <= '".$db->idate($search_date_valid_end).
"'";
918if ($search_date_approve_start) {
919 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_approve_start).
"'";
921if ($search_date_approve_end) {
922 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_approve_end).
"'";
933if ($search_country) {
934 $sql .=
" AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).
')';
936if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
937 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
942if ($search_user > 0) {
943 $sql .=
" AND EXISTS (";
944 $sql .=
" SELECT ec.rowid ";
945 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_contact as ec";
946 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
947 $sql .=
" WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
948 $sql .=
" AND tc.element = 'order_supplier' AND tc.source = 'internal'";
951if ($search_total_ht !=
'') {
954if ($search_total_tva !=
'') {
957if ($search_total_ttc !=
'') {
960if ($search_multicurrency_code !=
'') {
961 $sql .=
" AND cf.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
963if ($search_multicurrency_tx !=
'') {
964 $sql .=
natural_search(
'cf.multicurrency_tx', $search_multicurrency_tx, 1);
966if ($search_multicurrency_montant_ht !=
'') {
967 $sql .=
natural_search(
'cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
969if ($search_multicurrency_montant_tva !=
'') {
970 $sql .=
natural_search(
'cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1);
972if ($search_multicurrency_montant_ttc !=
'') {
973 $sql .=
natural_search(
'cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
975if ($search_project_ref !=
'') {
979if ($search_sale && $search_sale !=
'-1') {
980 if ($search_sale == -2) {
981 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = cf.fk_soc)";
982 } elseif ($search_sale > 0) {
983 $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).
")";
987$searchCategoryProductOperator =
GETPOSTINT(
'search_category_product_operator');
988$searchCategoryProductList = array($search_product_category);
989if (!empty($searchCategoryProductList)) {
990 $searchCategoryProductSqlList = array();
991 $listofcategoryid =
'';
992 foreach ($searchCategoryProductList as $searchCategoryProduct) {
993 if (intval($searchCategoryProduct) == -2) {
994 $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)";
995 } elseif (intval($searchCategoryProduct) > 0) {
996 if ($searchCategoryProductOperator == 0) {
997 $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).
")";
999 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
1003 if ($listofcategoryid) {
1004 $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).
"))";
1006 if ($searchCategoryProductOperator == 1) {
1007 if (!empty($searchCategoryProductSqlList)) {
1008 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
1011 if (!empty($searchCategoryProductSqlList)) {
1012 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
1017include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1019$parameters = array();
1020$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
1021$sql .= $hookmanager->resPrint;
1024$nbtotalofrecords =
'';
1027 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1028 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1029 $resql = $db->query($sqlforcount);
1031 $objforcount = $db->fetch_object($resql);
1032 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1037 if (($page * $limit) > $nbtotalofrecords) {
1044$sql .= $db->order($sortfield, $sortorder);
1046 $sql .= $db->plimit($limit + 1, $offset);
1050$resql = $db->query($sql);
1052 $num = $db->num_rows($resql);
1054 $arrayofselected = is_array($toselect) ? $toselect : array();
1056 if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1057 $obj = $db->fetch_object($resql);
1059 header(
"Location: ".DOL_URL_ROOT.
'/fourn/commande/card.php?id='.
$id);
1063 llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-supplier-order page-list');
1066 if (!empty($mode)) {
1067 $param .=
'&mode='.urlencode($mode);
1069 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1070 $param .=
'&contextpage='.urlencode($contextpage);
1072 if ($limit > 0 && $limit !=
$conf->liste_limit) {
1073 $param .=
'&limit='.((int) $limit);
1076 $param .=
'&search_all='.urlencode($search_all);
1079 $param .=
'&socid='.urlencode((
string) ($socid));
1082 $param .=
"&search_all=".urlencode($search_all);
1084 if ($search_date_order_startday) {
1085 $param .=
'&search_date_order_startday='.urlencode((
string) ($search_date_order_startday));
1087 if ($search_date_order_startmonth) {
1088 $param .=
'&search_date_order_startmonth='.urlencode((
string) ($search_date_order_startmonth));
1090 if ($search_date_order_startyear) {
1091 $param .=
'&search_date_order_startyear='.urlencode((
string) ($search_date_order_startyear));
1093 if ($search_date_order_endday) {
1094 $param .=
'&search_date_order_endday='.urlencode((
string) ($search_date_order_endday));
1096 if ($search_date_order_endmonth) {
1097 $param .=
'&search_date_order_endmonth='.urlencode((
string) ($search_date_order_endmonth));
1099 if ($search_date_order_endyear) {
1100 $param .=
'&search_date_order_endyear='.urlencode((
string) ($search_date_order_endyear));
1102 if ($search_date_delivery_startday) {
1103 $param .=
'&search_date_delivery_startday='.urlencode((
string) ($search_date_delivery_startday));
1105 if ($search_date_delivery_startmonth) {
1106 $param .=
'&search_date_delivery_startmonth='.urlencode((
string) ($search_date_delivery_startmonth));
1108 if ($search_date_delivery_startyear) {
1109 $param .=
'&search_date_delivery_startyear='.urlencode((
string) ($search_date_delivery_startyear));
1111 if ($search_date_delivery_endday) {
1112 $param .=
'&search_date_delivery_endday='.urlencode((
string) ($search_date_delivery_endday));
1114 if ($search_date_delivery_endmonth) {
1115 $param .=
'&search_date_delivery_endmonth='.urlencode((
string) ($search_date_delivery_endmonth));
1117 if ($search_date_delivery_endyear) {
1118 $param .=
'&search_date_delivery_endyear='.urlencode((
string) ($search_date_delivery_endyear));
1120 if ($search_date_valid_startday) {
1121 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
1123 if ($search_date_valid_startmonth) {
1124 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
1126 if ($search_date_valid_startyear) {
1127 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
1129 if ($search_date_valid_endday) {
1130 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
1132 if ($search_date_valid_endmonth) {
1133 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
1135 if ($search_date_valid_endyear) {
1136 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
1138 if ($search_date_approve_startday) {
1139 $param .=
'&search_date_approve_startday='.urlencode((
string) ($search_date_approve_startday));
1141 if ($search_date_approve_startmonth) {
1142 $param .=
'&search_date_approve_startmonth='.urlencode((
string) ($search_date_approve_startmonth));
1144 if ($search_date_approve_startyear) {
1145 $param .=
'&search_date_approve_startyear='.urlencode((
string) ($search_date_approve_startyear));
1147 if ($search_date_approve_endday) {
1148 $param .=
'&search_date_approve_endday='.urlencode((
string) ($search_date_approve_endday));
1150 if ($search_date_approve_endmonth) {
1151 $param .=
'&search_date_approve_endmonth='.urlencode((
string) ($search_date_approve_endmonth));
1153 if ($search_date_approve_endyear) {
1154 $param .=
'&search_date_approve_endyear='.urlencode((
string) ($search_date_approve_endyear));
1157 $param .=
'&search_ref='.urlencode($search_ref);
1159 if ($search_company) {
1160 $param .=
'&search_company='.urlencode($search_company);
1162 if ($search_company_alias) {
1163 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1165 if ($search_user > 0) {
1166 $param .=
'&search_user='.urlencode((
string) ($search_user));
1168 if ($search_request_author) {
1169 $param .=
'&search_request_author='.urlencode($search_request_author);
1171 if ($search_sale > 0) {
1172 $param .=
'&search_sale='.urlencode($search_sale);
1174 if ($search_total_ht !=
'') {
1175 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1177 if ($search_total_ttc !=
'') {
1178 $param .=
"&search_total_ttc=".urlencode($search_total_ttc);
1180 if ($search_multicurrency_code !=
'') {
1181 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1183 if ($search_multicurrency_tx !=
'') {
1184 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1186 if ($search_multicurrency_montant_ht !=
'') {
1187 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1189 if ($search_multicurrency_montant_tva !=
'') {
1190 $param .=
'&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva);
1192 if ($search_multicurrency_montant_ttc !=
'') {
1193 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1195 if ($search_refsupp) {
1196 $param .=
"&search_refsupp=".urlencode($search_refsupp);
1198 if ($search_status !=
'' && $search_status !=
'-1') {
1199 $param .=
"&search_status=".urlencode($search_status);
1201 if ($search_option) {
1202 $param .=
"&search_option=".urlencode($search_option);
1204 if ($search_project_ref >= 0) {
1205 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1207 if ($billed !=
'') {
1208 $param .=
"&billed=".((int) $billed);
1211 $param .=
'&show_files='.urlencode((
string) ($show_files));
1213 if ($optioncss !=
'') {
1214 $param .=
'&optioncss='.urlencode($optioncss);
1216 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
1217 $param .=
'&search_type_thirdparty='.urlencode((
string) ($search_type_thirdparty));
1221 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1223 $parameters = array(
'param' => &$param);
1224 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1225 $param .= $hookmanager->resPrint;
1228 $arrayofmassactions = array(
1229 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1230 'builddoc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1231 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1234 if ($permissiontovalidate) {
1235 if ($permissiontoapprove && !
getDolGlobalString(
'SUPPLIER_ORDER_NO_DIRECT_APPROVE')) {
1236 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"ValidateAndApprove");
1238 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1242 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
"supplier_invoice",
"creer")) {
1243 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'supplier_invoice',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisSupplier");
1245 if ($permissiontodelete) {
1246 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1248 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1249 $arrayofmassactions = array();
1251 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1253 $url = DOL_URL_ROOT.
'/fourn/commande/card.php?action=create';
1255 $url .=
'&socid='.((int) $socid);
1256 $url .=
'&backtopage='.urlencode(DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.((
int) $socid));
1258 $newcardbutton =
'';
1259 $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'));
1260 $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'));
1262 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewSupplierOrderShort'),
'',
'fa fa-plus-circle', $url,
'', (
int) $permissiontoadd);
1265 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1266 if ($optioncss !=
'') {
1267 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1269 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1270 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1271 print
'<input type="hidden" name="action" value="list">';
1272 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1273 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1274 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1275 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1276 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1278 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'supplier_order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1280 $topicmail =
"SendOrderRef";
1281 $modelmail =
"order_supplier_send";
1283 $trackid =
'sord'.$object->id;
1284 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1286 if ($massaction ==
'prevalidate') {
1287 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1290 if ($massaction ==
'createbills') {
1292 print
'<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
1294 print
'<table class="noborder centpercent">';
1296 print
'<td class="titlefield">';
1297 print $langs->trans(
'DateInvoice');
1300 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1305 print $langs->trans(
'CreateOneBillByThird');
1308 print $form->selectyesno(
'createbills_onebythird',
'', 1);
1313 print $langs->trans(
'ValidateInvoices');
1316 print $form->selectyesno(
'validate_invoices', 1, 1);
1321 print
'<div class="center">';
1322 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1323 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1330 foreach ($fieldstosearchall as $key => $val) {
1331 $fieldstosearchall[$key] = $langs->trans($val);
1333 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
1336 $moreforfilter =
'';
1339 if ($user->hasRight(
"user",
"user",
"lire")) {
1340 $langs->load(
"commercial");
1341 $moreforfilter .=
'<div class="divsearchfield">';
1342 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1343 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1344 $moreforfilter .=
'</div>';
1347 if ($user->hasRight(
"user",
"user",
"lire")) {
1348 $moreforfilter .=
'<div class="divsearchfield">';
1349 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1350 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
null, 0,
'',
'',
'0', 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1351 $moreforfilter .=
'</div>';
1354 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
1355 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1356 $moreforfilter .=
'<div class="divsearchfield">';
1357 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1358 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 0, 0, 1);
1359 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0,
'',
'maxwidth300 widthcentpercentminusx', 1);
1360 $moreforfilter .=
'</div>';
1363 $moreforfilter .=
'<div class="divsearchfield">';
1364 $moreforfilter .= $langs->trans(
'Alert').
' <input type="checkbox" name="search_option" value="'.(($search_status ==
'3,4') ?
'recv_late' :
'late').
'"'.((array_search($search_option, array(
'late',
'recv_late')) !== false) ?
' checked' :
'').
'>';
1365 $moreforfilter .=
'</div>';
1366 $parameters = array();
1367 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1368 if (empty($reshook)) {
1369 $moreforfilter .= $hookmanager->resPrint;
1371 $moreforfilter = $hookmanager->resPrint;
1374 if (!empty($moreforfilter)) {
1375 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1376 print $moreforfilter;
1380 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1381 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1382 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
1385 $selectedfields .=
'<script>';
1386 $selectedfields .=
' $(document).ready(function() {';
1387 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1388 $selectedfields .=
' $("#checkforselects").click();';
1389 $selectedfields .=
' $("#massaction").val("createbills").change();';
1390 $selectedfields .=
' });';
1391 $selectedfields .=
'</script>';
1394 print
'<div class="div-table-responsive">';
1395 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1397 print
'<tr class="liste_titre_filter">';
1400 print
'<td class="liste_titre middle">';
1401 $searchpicto = $form->showFilterButtons(
'left');
1406 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1407 print
'<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.
'"></td>';
1410 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1411 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.
'"></td>';
1414 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1415 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.
'"></td>';
1418 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1419 print
'<td class="liste_titre">';
1420 print
'<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.
'">';
1424 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1425 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.
'"></td>';
1428 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1429 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company_alias" value="'.$search_company_alias.
'"></td>';
1432 if (!empty($arrayfields[
's.town'][
'checked'])) {
1433 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.
'"></td>';
1436 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1437 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.
'"></td>';
1440 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1441 print
'<td class="liste_titre">';
1442 print
'<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1446 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1447 print
'<td class="liste_titre center">';
1448 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1452 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1453 print
'<td class="liste_titre maxwidthonsmartphone center">';
1454 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);
1458 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1459 print
'<td class="liste_titre center">';
1460 print
'<div class="nowrapfordate">';
1461 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'));
1463 print
'<div class="nowrapfordate">';
1464 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'));
1469 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1470 print
'<td class="liste_titre center">';
1471 print
'<div class="nowrapfordate">';
1472 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'));
1474 print
'<div class="nowrapfordate">';
1475 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'));
1479 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1481 print
'<td class="liste_titre right">';
1482 print
'<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.
'">';
1485 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1487 print
'<td class="liste_titre right">';
1488 print
'<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.
'">';
1491 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1493 print
'<td class="liste_titre right">';
1494 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1497 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1499 print
'<td class="liste_titre">';
1500 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1503 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1505 print
'<td class="liste_titre">';
1506 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1509 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1511 print
'<td class="liste_titre right">';
1512 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1515 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1517 print
'<td class="liste_titre right">';
1518 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).
'">';
1521 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1523 print
'<td class="liste_titre right">';
1524 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1528 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1531 $parameters = array(
'arrayfields' => $arrayfields);
1532 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1533 print $hookmanager->resPrint;
1535 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1536 print
'<td class="liste_titre">';
1540 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1541 print
'<td class="liste_titre">';
1545 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1546 print
'<td class="liste_titre center parentonrightofpage">';
1547 print $form->selectyesno(
'billed', $billed, 1,
false, 1, 1,
'search_status width100 onrightofpage');
1551 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1552 print
'<td class="liste_titre center parentonrightofpage">';
1553 $formorder->selectSupplierOrderStatus($search_status, 1,
'search_status',
'search_status width125 onrightofpage');
1557 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1558 print
'<td class="liste_titre center">';
1559 print
'<div class="nowrapfordate">';
1560 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'));
1562 print
'<div class="nowrapfordate">';
1563 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'));
1568 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1569 print
'<td class="liste_titre center">';
1570 print
'<div class="nowrapfordate">';
1571 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'));
1573 print
'<div class="nowrapfordate">';
1574 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'));
1579 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1580 print
'<td class="liste_titre">';
1584 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1585 print
'<td class="liste_titre">';
1590 print
'<td class="liste_titre center">';
1591 $searchpicto = $form->showFilterButtons();
1602 print
'<tr class="liste_titre">';
1604 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1607 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1608 print_liste_field_titre($arrayfields[
'cf.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref",
"", $param,
'', $sortfield, $sortorder);
1611 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1612 print_liste_field_titre($arrayfields[
'cf.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref_supplier",
"", $param,
'', $sortfield, $sortorder,
'tdoverflowmax100imp ');
1615 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1616 print_liste_field_titre($arrayfields[
'cf.fk_projet'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1619 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1620 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
"u.login",
"", $param,
'', $sortfield, $sortorder);
1623 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1624 print_liste_field_titre($arrayfields[
'cf.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
1627 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1629 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"s.name_alias",
"", $param,
'', $sortfield, $sortorder);
1632 if (!empty($arrayfields[
's.town'][
'checked'])) {
1633 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1636 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1637 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1640 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1641 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1644 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1645 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1648 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1649 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1652 if (!empty($arrayfields[
'cf.fk_author'][
'checked'])) {
1653 print_liste_field_titre($arrayfields[
'cf.fk_author'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_author",
"", $param,
'', $sortfield, $sortorder);
1656 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1657 print_liste_field_titre($arrayfields[
'cf.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_commande",
"", $param,
'', $sortfield, $sortorder,
'center ');
1660 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1661 print_liste_field_titre($arrayfields[
'cf.date_livraison'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1664 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1665 print_liste_field_titre($arrayfields[
'cf.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
1668 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1669 print_liste_field_titre($arrayfields[
'cf.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
1672 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1673 print_liste_field_titre($arrayfields[
'cf.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
1676 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1677 print_liste_field_titre($arrayfields[
'cf.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1680 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1681 print_liste_field_titre($arrayfields[
'cf.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1684 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1685 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1688 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1689 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1692 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1693 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1697 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1699 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1700 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1701 print $hookmanager->resPrint;
1702 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1703 print_liste_field_titre($arrayfields[
'cf.date_creation'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowraponall ');
1706 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1707 print_liste_field_titre($arrayfields[
'cf.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowraponall ');
1710 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1711 print_liste_field_titre($arrayfields[
'cf.billed'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.billed',
'', $param,
'', $sortfield, $sortorder,
'center ');
1714 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1715 print_liste_field_titre($arrayfields[
'cf.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1718 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1719 print_liste_field_titre($arrayfields[
'cf.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
1722 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1723 print_liste_field_titre($arrayfields[
'cf.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_approve',
'', $param,
'', $sortfield, $sortorder,
'center ');
1726 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1727 print_liste_field_titre($arrayfields[
'cf.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_public",
"", $param,
'', $sortfield, $sortorder,
'center ');
1730 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1731 print_liste_field_titre($arrayfields[
'cf.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_private",
"", $param,
'', $sortfield, $sortorder,
'center ');
1735 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1742 $productstat_cache = array();
1744 $userstatic =
new User($db);
1746 $projectstatic =
new Project($db);
1750 $totalarray = array(
'nbfield' => 0,
'val' => array(),
'pos' => array());
1755 $imaxinloop = ($limit ? min($num, $limit) : $num);
1756 while ($i < $imaxinloop) {
1757 $obj = $db->fetch_object($resql);
1765 $objectstatic->id = $obj->rowid;
1766 $objectstatic->ref = $obj->ref;
1767 $objectstatic->ref_supplier = $obj->ref_supplier;
1768 $objectstatic->socid = $obj->socid;
1769 $objectstatic->total_ht = $obj->total_ht;
1770 $objectstatic->total_tva = $obj->total_tva;
1771 $objectstatic->total_ttc = $obj->total_ttc;
1772 $objectstatic->date_commande = $db->jdate($obj->date_commande);
1773 $objectstatic->delivery_date = $db->jdate($obj->delivery_date);
1774 $objectstatic->note_public = $obj->note_public;
1775 $objectstatic->note_private = $obj->note_private;
1776 $objectstatic->statut = $obj->fk_statut;
1777 $objectstatic->status = $obj->fk_statut;
1779 if ($mode ==
'kanban') {
1781 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1782 print
'<div class="box-flex-container kanban">';
1785 $thirdpartytmp->id = $obj->socid;
1786 $thirdpartytmp->name = $obj->name;
1787 $thirdpartytmp->email = $obj->email;
1788 $thirdpartytmp->name_alias = $obj->alias;
1789 $thirdpartytmp->client = $obj->client;
1790 $thirdpartytmp->fournisseur = $obj->fournisseur;
1792 print $objectstatic->getKanbanView(
'', array(
'thirdparty' => $thirdpartytmp->getNomUrl(1,
'supplier', 0, 0, -1),
'selected' => in_array($objectstatic->id, $arrayofselected)));
1793 if ($i == ($imaxinloop - 1)) {
1798 print
'<tr class="oddeven '.((getDolGlobalInt(
'MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->billed == 1) ?
'opacitymedium' :
'').
'">';
1801 print
'<td class="nowraponall center">';
1802 if ($massactionbutton || $massaction) {
1804 if (in_array($obj->rowid, $arrayofselected)) {
1807 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1815 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1816 print
'<td class="nowraponall">';
1819 print $objectstatic->getNomUrl(1,
'', 0, -1, 1);
1823 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1831 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1832 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>'.
"\n";
1838 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1839 $projectstatic->id = $obj->project_id;
1840 $projectstatic->ref = $obj->project_ref;
1841 $projectstatic->title = $obj->project_title;
1842 print
'<td class="tdoverflowmax125">';
1843 if ($obj->project_id > 0) {
1844 print $projectstatic->getNomUrl(1);
1852 $userstatic->id = $obj->fk_user_author;
1853 $userstatic->lastname = $obj->lastname;
1854 $userstatic->firstname = $obj->firstname;
1855 $userstatic->login = $obj->login;
1856 $userstatic->photo = $obj->photo;
1857 $userstatic->email = $obj->user_email;
1858 $userstatic->status = $obj->user_status;
1859 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1860 print
'<td class="tdoverflowmax150">';
1861 if ($userstatic->id) {
1862 print $userstatic->getNomUrl(1);
1870 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1871 print
'<td class="tdoverflowmax150">';
1872 $thirdpartytmp->id = $obj->socid;
1873 $thirdpartytmp->name = $obj->name;
1874 $thirdpartytmp->email = $obj->email;
1875 $thirdpartytmp->name_alias = $obj->alias;
1876 $thirdpartytmp->client = $obj->client;
1877 $thirdpartytmp->fournisseur = $obj->fournisseur;
1878 print $thirdpartytmp->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1885 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1886 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->alias).
'">';
1894 if (!empty($arrayfields[
's.town'][
'checked'])) {
1895 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
1903 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1904 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).
'">';
1912 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1913 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).
'">'.
dol_escape_htmltag($obj->state_name).
"</td>\n";
1919 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1920 print
'<td class="center">';
1921 $tmparray =
getCountry($obj->fk_pays,
'all');
1922 print $tmparray[
'label'];
1929 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1930 print
'<td class="center">';
1931 if (empty($typenArray)) {
1932 $typenArray = $formcompany->typent_array(1);
1934 print $typenArray[$obj->typent_code];
1942 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1943 print
'<td class="center">';
1945 if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1946 if ($objectstatic->hasDelay()) {
1947 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1956 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1957 print
'<td class="center">';
1959 if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1960 if ($objectstatic->hasDelay()) {
1961 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1970 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1971 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1978 $totalarray[
'val'][
'cf.total_ht'] += $obj->total_ht;
1981 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1982 print
'<td class="right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
1989 $totalarray[
'val'][
'cf.total_tva'] += $obj->total_tva;
1992 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1993 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
2000 $totalarray[
'val'][
'cf.total_ttc'] += $obj->total_ttc;
2004 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
2005 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
2012 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
2013 print
'<td class="nowrap">';
2014 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2021 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
2022 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
2028 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
2029 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva).
"</span></td>\n";
2035 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
2036 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
2043 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2045 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
2046 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2047 print $hookmanager->resPrint;
2049 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
2050 print
'<td class="center nowraponall">';
2051 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2058 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
2059 print
'<td class="center nowraponall">';
2060 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
2067 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
2068 print
'<td class="center">';
2070 print
yn($obj->billed, $langs->trans(
"Billed"));
2078 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
2079 print
'<td class="center nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).
'</td>';
2086 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
2087 print
'<td class="center">';
2095 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
2096 print
'<td class="center">';
2104 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
2105 print
'<td class="sensiblehtmlcontent center">';
2106 print
'<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(
dolGetFirstLineOfText($obj->note_public, 5)).
'</div>';
2114 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
2115 print
'<td class="sensiblehtmlcontent center">';
2116 print
'<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(
dolGetFirstLineOfText($obj->note_private, 5)).
'</div>';
2125 print
'<td class="nowrap center">';
2126 if ($massactionbutton || $massaction) {
2128 if (in_array($obj->rowid, $arrayofselected)) {
2131 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2141 $total += $obj->total_ht;
2142 $subtotal += $obj->total_ht;
2148 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2153 foreach ($arrayfields as $key => $val) {
2154 if (!empty($val[
'checked'])) {
2158 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2163 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2164 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2165 print $hookmanager->resPrint;
2167 print
'</table>'.
"\n";
2170 print
'</form>'.
"\n";
2172 $hidegeneratedfilelistifempty = 1;
2173 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2174 $hidegeneratedfilelistifempty = 0;
2178 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2179 $urlsource .= str_replace(
'&',
'&', $param);
2181 $filedir = $diroutputmassaction;
2182 $genallowed = $permissiontoread;
2183 $delallowed = $permissiontoadd;
2185 print $formfile->showdocuments(
'massfilesarea_supplier_order',
'', $filedir, $urlsource, 0, (
int) $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
$id
Support class for third parties, contacts, members, users or resources.
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_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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, $allowothertags=array())
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.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
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...
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...
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
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.