33 require
'../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
46 $langs->loadLangs(array(
"orders",
"sendings",
'deliveries',
'companies',
'compta',
'bills',
'projects',
'suppliers',
'products'));
48 $action =
GETPOST(
'action',
'aZ09');
49 $massaction =
GETPOST(
'massaction',
'alpha');
50 $show_files =
GETPOST(
'show_files',
'int');
51 $confirm =
GETPOST(
'confirm',
'alpha');
52 $toselect =
GETPOST(
'toselect',
'array');
53 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierorderlist';
55 $search_orderyear =
GETPOST(
"search_orderyear",
"int");
56 $search_ordermonth =
GETPOST(
"search_ordermonth",
"int");
57 $search_orderday =
GETPOST(
"search_orderday",
"int");
58 $search_deliveryyear =
GETPOST(
"search_deliveryyear",
"int");
59 $search_deliverymonth =
GETPOST(
"search_deliverymonth",
"int");
60 $search_deliveryday =
GETPOST(
"search_deliveryday",
"int");
62 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
64 $search_product_category =
GETPOST(
'search_product_category',
'int');
65 $search_ref =
GETPOST(
'search_ref',
'alpha');
66 $search_refsupp =
GETPOST(
'search_refsupp',
'alpha');
67 $search_company =
GETPOST(
'search_company',
'alpha');
68 $search_town =
GETPOST(
'search_town',
'alpha');
69 $search_zip =
GETPOST(
'search_zip',
'alpha');
70 $search_state =
GETPOST(
"search_state",
'alpha');
71 $search_country =
GETPOST(
"search_country",
'int');
72 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
73 $search_user =
GETPOST(
'search_user',
'int');
74 $search_request_author =
GETPOST(
'search_request_author',
'alpha');
75 $search_ht =
GETPOST(
'search_ht',
'alpha');
76 $search_ttc =
GETPOST(
'search_ttc',
'alpha');
77 $optioncss =
GETPOST(
'optioncss',
'alpha');
78 $socid =
GETPOST(
'socid',
'int');
79 $search_sale =
GETPOST(
'search_sale',
'int');
80 $search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
81 $search_total_vat =
GETPOST(
'search_total_vat',
'alpha');
82 $search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
83 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
84 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
85 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
86 $search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
87 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
88 $optioncss =
GETPOST(
'optioncss',
'alpha');
89 $search_billed =
GETPOST(
'search_billed',
'int');
90 $search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
91 $search_btn =
GETPOST(
'button_search',
'alpha');
92 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
94 if (is_array(
GETPOST(
'search_status',
'intcomma'))) {
95 $search_status = join(
',',
GETPOST(
'search_status',
'intcomma'));
97 $search_status = (
GETPOST(
'search_status',
'intcomma') !=
'' ?
GETPOST(
'search_status',
'intcomma') :
GETPOST(
'statut',
'intcomma'));
101 $orderid =
GETPOST(
'orderid',
'int');
102 if ($user->socid) $socid = $user->socid;
103 $result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
105 $diroutputmassaction = $conf->fournisseur->commande->dir_output.
'/temp/massgeneration/'.$user->id;
107 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
108 $sortfield =
GETPOST(
"sortfield",
'alpha');
109 $sortorder =
GETPOST(
"sortorder",
'alpha');
111 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction ===
'0')) { $page = 0; }
112 $offset = $limit * $page;
113 $pageprev = $page - 1;
114 $pagenext = $page + 1;
115 if (!$sortfield) $sortfield =
'cf.ref';
116 if (!$sortorder) $sortorder =
'DESC';
118 if ($search_status ==
'') $search_status = -1;
122 $hookmanager->initHooks(array(
'supplierorderlist'));
126 $extrafields->fetch_name_optionals_label($object->table_element);
128 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
131 $fieldstosearchall = array(
133 'cf.ref_supplier'=>
'RefOrderSupplier',
134 'pd.description'=>
'Description',
135 's.nom'=>
"ThirdParty",
136 's.name_alias'=>
"AliasNameShort",
139 'cf.note_public'=>
'NotePublic',
141 if (empty($user->socid)) $fieldstosearchall[
"cf.note_private"] =
"NotePrivate";
143 $checkedtypetiers = 0;
144 $arrayfields = array(
145 'cf.ref'=>array(
'label'=>
"Ref",
'checked'=>1),
146 'cf.ref_supplier'=>array(
'label'=>
"RefOrderSupplierShort",
'checked'=>1,
'enabled'=>1),
147 'p.project_ref'=>array(
'label'=>
"ProjectRef",
'checked'=>0,
'enabled'=>1),
148 'u.login'=>array(
'label'=>
"AuthorRequest",
'checked'=>1),
149 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1),
150 's.town'=>array(
'label'=>
"Town",
'checked'=>1),
151 's.zip'=>array(
'label'=>
"Zip",
'checked'=>1),
152 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0),
153 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0),
154 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers),
155 'cf.date_commande'=>array(
'label'=>
"OrderDateShort",
'checked'=>1),
156 'cf.date_livraison'=>array(
'label'=>
"DateDeliveryPlanned",
'checked'=>1,
'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)),
157 'cf.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1),
158 'cf.total_vat'=>array(
'label'=>
"AmountVAT",
'checked'=>0),
159 'cf.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0),
160 'cf.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
161 'cf.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
162 'cf.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
163 'cf.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
164 'cf.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
165 'cf.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>500),
166 'cf.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>500),
167 'cf.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000),
168 'cf.billed'=>array(
'label'=>
"Billed",
'checked'=>1,
'position'=>1000,
'enabled'=>1)
171 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
183 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
184 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createsupplierbills') { $massaction =
''; }
186 $parameters = array(
'socid'=>$socid);
187 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
188 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
193 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
196 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
201 $search_product_category =
'';
203 $search_refsupp =
'';
204 $search_company =
'';
209 $search_country =
'';
210 $search_type_thirdparty =
'';
211 $search_request_author =
'';
212 $search_total_ht =
'';
213 $search_total_vat =
'';
214 $search_total_ttc =
'';
215 $search_multicurrency_code =
'';
216 $search_multicurrency_tx =
'';
217 $search_multicurrency_montant_ht =
'';
218 $search_multicurrency_montant_vat =
'';
219 $search_multicurrency_montant_ttc =
'';
220 $search_project_ref =
'';
222 $search_orderyear =
'';
223 $search_ordermonth =
'';
224 $search_orderday =
'';
225 $search_deliveryday =
'';
226 $search_deliverymonth =
'';
227 $search_deliveryyear =
'';
231 $search_array_options = array();
233 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
234 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha'))
240 $objectclass =
'CommandeFournisseur';
241 $objectlabel =
'SupplierOrders';
242 $permissiontoread = $user->rights->fournisseur->commande->lire;
243 $permissiontodelete = $user->rights->fournisseur->commande->supprimer;
244 $uploaddir = $conf->fournisseur->commande->dir_output;
245 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
248 if ($massaction ==
'confirm_createsupplierbills')
250 $orders =
GETPOST(
'toselect',
'array');
251 $createbills_onebythird =
GETPOST(
'createbills_onebythird',
'int');
252 $validate_invoices =
GETPOST(
'validate_invoices',
'int');
255 $TFactThird = array();
257 $nb_bills_created = 0;
261 foreach ($orders as $id_order) {
263 if ($cmd->fetch($id_order) <= 0)
continue;
266 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid];
268 $objecttmp->socid = $cmd->socid;
269 $objecttmp->type = $objecttmp::TYPE_STANDARD;
270 $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
271 $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
272 $objecttmp->fk_project = $cmd->fk_project;
273 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
274 if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client;
277 if (empty($datefacture))
282 $objecttmp->date = $datefacture;
283 $objecttmp->origin =
'order_supplier';
284 $objecttmp->origin_id = $id_order;
286 $res = $objecttmp->create($user);
288 if ($res > 0) $nb_bills_created++;
291 if ($objecttmp->id > 0)
293 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_element (";
295 $sql .=
", sourcetype";
296 $sql .=
", fk_target";
297 $sql .=
", targettype";
298 $sql .=
") VALUES (";
300 $sql .=
", '".$db->escape($objecttmp->origin).
"'";
301 $sql .=
", ".$objecttmp->id;
302 $sql .=
", '".$db->escape($objecttmp->element).
"'";
305 if (!$db->query($sql))
312 $lines = $cmd->lines;
313 if (empty($lines) && method_exists($cmd,
'fetch_lines'))
316 $lines = $cmd->lines;
320 $num = count($lines);
322 for ($i = 0; $i < $num; $i++)
324 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
325 if ($lines[$i]->subprice < 0)
329 $discount->fk_soc = $objecttmp->socid;
330 $discount->amount_ht = abs($lines[$i]->total_ht);
331 $discount->amount_tva = abs($lines[$i]->total_tva);
332 $discount->amount_ttc = abs($lines[$i]->total_ttc);
333 $discount->tva_tx = $lines[$i]->tva_tx;
334 $discount->fk_user = $user->id;
335 $discount->description = $desc;
336 $discountid = $discount->create($user);
339 $result = $objecttmp->insert_discount($discountid);
348 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
351 if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue;
352 if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel;
353 if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start;
356 if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue;
357 if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel;
358 if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end;
360 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
364 $result = $objecttmp->addline(
366 $lines[$i]->subprice,
368 $lines[$i]->localtax1_tx,
369 $lines[$i]->localtax2_tx,
371 $lines[$i]->fk_product,
372 $lines[$i]->remise_percent,
376 $lines[$i]->info_bits,
381 $lines[$i]->array_options,
383 $objecttmp->origin_id,
385 $lines[$i]->ref_supplier,
386 $lines[$i]->special_code,
398 if ($result > 0 && $lines[$i]->product_type == 9)
400 $fk_parent_line = $result;
407 $cmd->classifyBilled($user);
409 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp;
410 else $TFact[$objecttmp->id] = $objecttmp;
414 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
417 if (!$error && $validate_invoices) {
418 $massaction = $action =
'builddoc';
420 foreach ($TAllFact as &$objecttmp)
422 $objecttmp->validate($user);
430 $id = $objecttmp->id;
434 $upload_dir = $conf->fournisseur->facture->dir_output;
435 $permissiontoadd = $user->rights->fournisseur->facture->creer;
439 $massaction = $action =
'confirm_createsupplierbills';
445 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created), null,
'mesgs');
449 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
450 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
451 if ($sall) $param .=
'&sall='.urlencode($sall);
452 if ($socid > 0) $param .=
'&socid='.urlencode($socid);
453 if ($search_status !=
'') $param .=
'&search_status='.urlencode($search_status);
454 if ($search_orderday) $param .=
'&search_orderday='.urlencode($search_orderday);
455 if ($search_ordermonth) $param .=
'&search_ordermonth='.urlencode($search_ordermonth);
456 if ($search_orderyear) $param .=
'&search_orderyear='.urlencode($search_orderyear);
457 if ($search_deliveryday) $param .=
'&search_deliveryday='.urlencode($search_deliveryday);
458 if ($search_deliverymonth) $param .=
'&search_deliverymonth='.urlencode($search_deliverymonth);
459 if ($search_deliveryyear) $param .=
'&search_deliveryyear='.urlencode($search_deliveryyear);
460 if ($search_ref) $param .=
'&search_ref='.urlencode($search_ref);
461 if ($search_company) $param .=
'&search_company='.urlencode($search_company);
462 if ($search_ref_customer) $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
463 if ($search_user > 0) $param .=
'&search_user='.urlencode($search_user);
464 if ($search_sale > 0) $param .=
'&search_sale='.urlencode($search_sale);
465 if ($search_total_ht !=
'') $param .=
'&search_total_ht='.urlencode($search_total_ht);
466 if ($search_total_vat !=
'') $param .=
'&search_total_vat='.urlencode($search_total_vat);
467 if ($search_total_ttc !=
'') $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
468 if ($search_project_ref >= 0) $param .=
"&search_project_ref=".urlencode($search_project_ref);
469 if ($show_files) $param .=
'&show_files='.urlencode($show_files);
470 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
471 if ($billed !=
'') $param .=
'&billed='.urlencode($billed);
473 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
'?'.$param);
478 $_GET[
"origin"] = $_POST[
"origin"];
479 $_GET[
"originid"] = $_POST[
"originid"];
493 $form =
new Form($db);
501 $title = $langs->trans(
"ListOfSupplierOrders");
505 $fourn->fetch($socid);
506 $title .=
' - '.$fourn->name;
517 if ($search_billed > 0) $title .=
' - '.$langs->trans(
"Billed");
524 if ($sall || $search_product_category > 0 || $search_user > 0) $sql =
'SELECT DISTINCT';
525 $sql .=
' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,';
526 $sql .=
" typent.code as typent_code,";
527 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
528 $sql .=
" cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,";
529 $sql .=
' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva as multicurrency_total_vat, cf.multicurrency_total_ttc,';
530 $sql .=
' cf.date_creation as date_creation, cf.tms as date_update,';
531 $sql .=
' cf.note_public, cf.note_private,';
532 $sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
533 $sql .=
" u.firstname, u.lastname, u.photo, u.login, u.email as user_email";
535 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
536 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
' as options_'.$key :
'');
539 $parameters = array();
540 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
541 $sql .= $hookmanager->resPrint;
542 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
543 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
544 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
545 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
546 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
547 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cf.rowid = ef.fk_object)";
548 if ($sall || $search_product_category > 0) $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
549 if ($search_product_category > 0) $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=pd.fk_product';
550 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON cf.fk_user_author = u.rowid";
551 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = cf.fk_projet";
553 if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
554 if ($search_user > 0)
556 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
557 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
559 $parameters = array();
560 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
561 $sql .= $hookmanager->resPrint;
562 $sql .=
' WHERE cf.fk_soc = s.rowid';
563 $sql .=
' AND cf.entity IN ('.getEntity(
'supplier_order').
')';
564 if ($socid > 0) $sql .=
" AND s.rowid = ".$socid;
565 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
567 if ($search_refsupp) $sql .=
natural_search(
"cf.ref_supplier", $search_refsupp);
568 if ($sall) $sql .=
natural_search(array_keys($fieldstosearchall), $sall);
569 if ($search_company) $sql .=
natural_search(
's.nom', $search_company);
570 if ($search_request_author) $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_request_author);
571 if ($search_billed !=
'' && $search_billed >= 0) $sql .=
" AND cf.billed = ".$db->escape($search_billed);
572 if ($search_product_category > 0) $sql .=
" AND cp.fk_categorie = ".$search_product_category;
574 if (
GETPOST(
'statut',
'intcomma') !==
'')
575 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(
GETPOST(
'statut',
'intcomma')))).
")";
576 if ($search_status !=
'' && $search_status !=
'-1')
577 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
578 $sql .=
dolSqlDateFilter(
"cf.date_commande", $search_orderday, $search_ordermonth, $search_orderyear);
579 $sql .=
dolSqlDateFilter(
"cf.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear);
582 if ($search_state) $sql .=
natural_search(
"state.nom", $search_state);
583 if ($search_country) $sql .=
" AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).
')';
584 if ($search_type_thirdparty) $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
585 if ($search_company) $sql .=
natural_search(
's.nom', $search_company);
586 if ($search_sale > 0) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale);
587 if ($search_user > 0) $sql .=
" AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user);
588 if ($search_total_ht !=
'') $sql .=
natural_search(
'cf.total_ht', $search_total_ht, 1);
589 if ($search_total_vat !=
'') $sql .=
natural_search(
'cf.tva', $search_total_vat, 1);
590 if ($search_total_ttc !=
'') $sql .=
natural_search(
'cf.total_ttc', $search_total_ttc, 1);
591 if ($search_multicurrency_code !=
'') $sql .=
' AND cf.multicurrency_code = "'.$db->escape($search_multicurrency_code).
'"';
592 if ($search_multicurrency_tx !=
'') $sql .=
natural_search(
'cf.multicurrency_tx', $search_multicurrency_tx, 1);
593 if ($search_multicurrency_montant_ht !=
'') $sql .=
natural_search(
'cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
594 if ($search_multicurrency_montant_vat !=
'') $sql .=
natural_search(
'cf.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
595 if ($search_multicurrency_montant_ttc !=
'') $sql .=
natural_search(
'cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
596 if ($search_project_ref !=
'') $sql .=
natural_search(
"p.ref", $search_project_ref);
598 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
600 $parameters = array();
601 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
602 $sql .= $hookmanager->resPrint;
604 $sql .= $db->order($sortfield, $sortorder);
607 $nbtotalofrecords =
'';
608 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
610 $result = $db->query($sql);
611 $nbtotalofrecords = $db->num_rows($result);
612 if (($page * $limit) > $nbtotalofrecords)
619 $sql .= $db->plimit($limit + 1, $offset);
622 $resql = $db->query($sql);
625 $num = $db->num_rows(
$resql);
627 $arrayofselected = is_array($toselect) ? $toselect : array();
629 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
631 $obj = $db->fetch_object(
$resql);
633 header(
"Location: ".DOL_URL_ROOT.
'/fourn/commande/card.php?id='.$id);
640 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
641 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
642 if ($sall) $param .=
'&sall='.urlencode($sall);
643 if ($socid > 0) $param .=
'&socid='.urlencode($socid);
644 if ($sall) $param .=
"&search_all=".urlencode($sall);
645 if ($search_orderday) $param .=
'&search_orderday='.urlencode($search_orderday);
646 if ($search_ordermonth) $param .=
'&search_ordermonth='.urlencode($search_ordermonth);
647 if ($search_orderyear) $param .=
'&search_orderyear='.urlencode($search_orderyear);
648 if ($search_deliveryday) $param .=
'&search_deliveryday='.urlencode($search_deliveryday);
649 if ($search_deliverymonth) $param .=
'&search_deliverymonth='.urlencode($search_deliverymonth);
650 if ($search_deliveryyear) $param .=
'&search_deliveryyear='.urlencode($search_deliveryyear);
651 if ($search_ref) $param .=
'&search_ref='.urlencode($search_ref);
652 if ($search_company) $param .=
'&search_company='.urlencode($search_company);
653 if ($search_user > 0) $param .=
'&search_user='.urlencode($search_user);
654 if ($search_request_author) $param .=
'&search_request_author='.urlencode($search_request_author);
655 if ($search_sale > 0) $param .=
'&search_sale='.urlencode($search_sale);
656 if ($search_total_ht !=
'') $param .=
'&search_total_ht='.urlencode($search_total_ht);
657 if ($search_total_ttc !=
'') $param .=
"&search_total_ttc=".urlencode($search_total_ttc);
658 if ($search_multicurrency_code !=
'') $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
659 if ($search_multicurrency_tx !=
'') $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
660 if ($search_multicurrency_montant_ht !=
'') $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
661 if ($search_multicurrency_montant_vat !=
'') $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
662 if ($search_multicurrency_montant_ttc !=
'') $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
663 if ($search_refsupp) $param .=
"&search_refsupp=".urlencode($search_refsupp);
664 if ($search_status !=
'' && $search_status !=
'-1') $param .=
"&search_status=".urlencode($search_status);
665 if ($search_project_ref >= 0) $param .=
"&search_project_ref=".urlencode($search_project_ref);
666 if ($search_billed !=
'') $param .=
"&search_billed=".urlencode($search_billed);
667 if ($show_files) $param .=
'&show_files='.urlencode($show_files);
668 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
670 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
672 $parameters = array();
673 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
674 $param .= $hookmanager->resPrint;
677 $arrayofmassactions = array(
678 'generate_doc'=>$langs->trans(
"ReGeneratePDF"),
679 'builddoc'=>$langs->trans(
"PDFMerge"),
680 'presend'=>$langs->trans(
"SendByMail"),
682 if ($user->rights->fournisseur->facture->creer) $arrayofmassactions[
'createbills'] = $langs->trans(
"CreateInvoiceForThisSupplier");
683 if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions[
'predelete'] =
'<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans(
"Delete");
684 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) $arrayofmassactions = array();
685 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
687 $url = DOL_URL_ROOT.
'/fourn/commande/card.php?action=create';
688 if (!empty($socid)) $url .=
'&socid='.$socid;
689 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewOrder'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->fournisseur->commande->creer);
692 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
693 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
694 print '<input type="hidden" name="token" value="'.newToken().
'">';
695 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
696 print '<input type="hidden" name="action" value="list">';
697 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
698 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
699 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
700 print '<input type="hidden" name="socid" value="'.$socid.
'">';
702 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'supplier_order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
704 $topicmail =
"SendOrderRef";
705 $modelmail =
"order_supplier_send";
707 $trackid =
'sord'.$object->id;
708 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
710 if ($massaction ==
'createbills')
713 print '<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
715 print '<table class="noborder" width="100%" >';
717 print '<td class="titlefield">';
718 print $langs->trans(
'DateInvoice');
721 print $form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
726 print $langs->trans(
'CreateOneBillByThird');
729 print $form->selectyesno(
'createbills_onebythird',
'', 1);
734 print $langs->trans(
'ValidateInvoices');
737 print $form->selectyesno(
'validate_invoices', 1, 1);
743 print '<div class="center">';
744 print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
745 print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
752 foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
753 print '<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
759 if ($user->rights->societe->client->voir || $socid)
761 $langs->load(
"commercial");
762 $moreforfilter .=
'<div class="divsearchfield">';
763 $moreforfilter .= $langs->trans(
'ThirdPartiesOfSaleRepresentative').
': ';
764 $moreforfilter .= $formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, 1,
'maxwidth200');
765 $moreforfilter .=
'</div>';
768 if ($user->rights->user->user->lire)
770 $moreforfilter .=
'<div class="divsearchfield">';
771 $moreforfilter .= $langs->trans(
'LinkedToSpecificUsers').
': ';
772 $moreforfilter .= $form->select_dolusers($search_user,
'search_user', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
773 $moreforfilter .=
'</div>';
776 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire))
778 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
779 $moreforfilter .=
'<div class="divsearchfield">';
780 $moreforfilter .= $langs->trans(
'IncludingProductWithTag').
': ';
781 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null,
'parent', null, null, 1);
782 $moreforfilter .= $form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, 1, 0, 0,
'', 0, 0, 0, 0,
'maxwidth300', 1);
783 $moreforfilter .=
'</div>';
785 $parameters = array();
786 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
787 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
788 else $moreforfilter = $hookmanager->resPrint;
790 if (!empty($moreforfilter))
792 print '<div class="liste_titre liste_titre_bydiv centpercent">';
793 print $moreforfilter;
797 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
798 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
799 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
801 if (
GETPOST(
'autoselectall',
'int')) {
802 $selectedfields .=
'<script>';
803 $selectedfields .=
' $(document).ready(function() {';
804 $selectedfields .=
' console.log("Autoclick on checkforselects");';
805 $selectedfields .=
' $("#checkforselects").click();';
806 $selectedfields .=
' $("#massaction").val("createbills").change();';
807 $selectedfields .=
' });';
808 $selectedfields .=
'</script>';
811 print '<div class="div-table-responsive">';
812 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
814 print '<tr class="liste_titre_filter">';
816 if (!empty($arrayfields[
'cf.ref'][
'checked']))
818 print
'<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.
'"></td>';
821 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked']))
823 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.
'"></td>';
826 if (!empty($arrayfields[
'p.project_ref'][
'checked']))
828 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.
'"></td>';
831 if (!empty($arrayfields[
'u.login'][
'checked']))
833 print
'<td class="liste_titre">';
834 print
'<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.
'">';
838 if (!empty($arrayfields[
's.nom'][
'checked']))
840 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.
'"></td>';
843 if (!empty($arrayfields[
's.town'][
'checked'])) print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.
'"></td>';
845 if (!empty($arrayfields[
's.zip'][
'checked'])) print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.
'"></td>';
847 if (!empty($arrayfields[
'state.nom'][
'checked']))
849 print
'<td class="liste_titre">';
850 print
'<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
854 if (!empty($arrayfields[
'country.code_iso'][
'checked']))
856 print
'<td class="liste_titre center">';
857 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
861 if (!empty($arrayfields[
'typent.code'][
'checked']))
863 print
'<td class="liste_titre maxwidthonsmartphone center">';
864 print $form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0,
'', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
868 if (!empty($arrayfields[
'cf.date_commande'][
'checked']))
870 print
'<td class="liste_titre nowraponall center">';
871 if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print
'<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_orderday" value="'.$search_orderday.
'">';
872 print
'<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_ordermonth" value="'.$search_ordermonth.
'">';
873 $formother->select_year($search_orderyear ? $search_orderyear : -1,
'search_orderyear', 1, 20, 5);
877 if (!empty($arrayfields[
'cf.date_livraison'][
'checked']))
879 print
'<td class="liste_titre nowraponall center">';
880 if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print
'<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliveryday" value="'.$search_deliveryday.
'">';
881 print
'<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliverymonth" value="'.$search_deliverymonth.
'">';
882 $formother->select_year($search_deliveryyear ? $search_deliveryyear : -1,
'search_deliveryyear', 1, 20, 5);
885 if (!empty($arrayfields[
'cf.total_ht'][
'checked']))
888 print
'<td class="liste_titre right">';
889 print
'<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.
'">';
892 if (!empty($arrayfields[
'cf.total_vat'][
'checked']))
895 print
'<td class="liste_titre right">';
896 print
'<input class="flat" type="text" size="5" name="search_total_vat" value="'.$search_total_vat.
'">';
899 if (!empty($arrayfields[
'cf.total_ttc'][
'checked']))
902 print
'<td class="liste_titre right">';
903 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
906 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked']))
909 print
'<td class="liste_titre">';
910 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
913 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked']))
916 print
'<td class="liste_titre">';
917 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
920 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked']))
923 print
'<td class="liste_titre right">';
924 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
927 if (!empty($arrayfields[
'cf.multicurrency_total_vat'][
'checked']))
930 print
'<td class="liste_titre right">';
931 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
934 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked']))
937 print
'<td class="liste_titre right">';
938 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
942 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
945 $parameters = array(
'arrayfields'=>$arrayfields);
946 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
947 print $hookmanager->resPrint;
949 if (!empty($arrayfields[
'cf.datec'][
'checked']))
951 print
'<td class="liste_titre">';
955 if (!empty($arrayfields[
'cf.tms'][
'checked']))
957 print
'<td class="liste_titre">';
961 if (!empty($arrayfields[
'cf.fk_statut'][
'checked']))
963 print
'<td class="liste_titre right">';
964 $formorder->selectSupplierOrderStatus($search_status, 1,
'search_status');
968 if (!empty($arrayfields[
'cf.billed'][
'checked']))
970 print
'<td class="liste_titre center">';
971 print $form->selectyesno(
'search_billed', $search_billed, 1, 0, 1, 1);
975 print
'<td class="liste_titre middle">';
976 $searchpicto = $form->showFilterButtons();
983 print
'<tr class="liste_titre">';
984 if (!empty($arrayfields[
'cf.ref'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.ref'][
'label'],
$_SERVER[
"PHP_SELF"],
"cf.ref",
"", $param,
'', $sortfield, $sortorder);
985 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.ref_supplier'][
'label'],
$_SERVER[
"PHP_SELF"],
"cf.ref_supplier",
"", $param,
'', $sortfield, $sortorder,
'tdoverflowmax100imp ');
986 if (!empty($arrayfields[
'p.project_ref'][
'checked']))
print_liste_field_titre($arrayfields[
'p.project_ref'][
'label'],
$_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
987 if (!empty($arrayfields[
'u.login'][
'checked']))
print_liste_field_titre($arrayfields[
'u.login'][
'label'],
$_SERVER[
"PHP_SELF"],
"u.login",
"", $param,
'', $sortfield, $sortorder);
988 if (!empty($arrayfields[
's.nom'][
'checked']))
print_liste_field_titre($arrayfields[
's.nom'][
'label'],
$_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
989 if (!empty($arrayfields[
's.town'][
'checked']))
print_liste_field_titre($arrayfields[
's.town'][
'label'],
$_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
990 if (!empty($arrayfields[
's.zip'][
'checked']))
print_liste_field_titre($arrayfields[
's.zip'][
'label'],
$_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
991 if (!empty($arrayfields[
'state.nom'][
'checked']))
print_liste_field_titre($arrayfields[
'state.nom'][
'label'],
$_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
992 if (!empty($arrayfields[
'country.code_iso'][
'checked']))
print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'],
$_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
993 if (!empty($arrayfields[
'typent.code'][
'checked']))
print_liste_field_titre($arrayfields[
'typent.code'][
'label'],
$_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
994 if (!empty($arrayfields[
'cf.fk_author'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.fk_author'][
'label'],
$_SERVER[
"PHP_SELF"],
"cf.fk_author",
"", $param,
'', $sortfield, $sortorder);
995 if (!empty($arrayfields[
'cf.date_commande'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.date_commande'][
'label'],
$_SERVER[
"PHP_SELF"],
"cf.date_commande",
"", $param,
'', $sortfield, $sortorder,
'center ');
996 if (!empty($arrayfields[
'cf.date_livraison'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.date_livraison'][
'label'],
$_SERVER[
"PHP_SELF"],
'cf.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
997 if (!empty($arrayfields[
'cf.total_ht'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.total_ht'][
'label'],
$_SERVER[
"PHP_SELF"],
"cf.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
998 if (!empty($arrayfields[
'cf.total_vat'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.total_vat'][
'label'],
$_SERVER[
"PHP_SELF"],
"cf.tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
999 if (!empty($arrayfields[
'cf.total_ttc'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.total_ttc'][
'label'],
$_SERVER[
"PHP_SELF"],
"cf.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
1000 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.multicurrency_code'][
'label'],
$_SERVER[
'PHP_SELF'],
'cf.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1001 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.multicurrency_tx'][
'label'],
$_SERVER[
'PHP_SELF'],
'cf.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1002 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ht'][
'label'],
$_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1003 if (!empty($arrayfields[
'cf.multicurrency_total_vat'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.multicurrency_total_vat'][
'label'],
$_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1004 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ttc'][
'label'],
$_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1006 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1008 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1009 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1010 print $hookmanager->resPrint;
1011 if (!empty($arrayfields[
'cf.datec'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.datec'][
'label'],
$_SERVER[
"PHP_SELF"],
"cf.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1012 if (!empty($arrayfields[
'cf.tms'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.tms'][
'label'],
$_SERVER[
"PHP_SELF"],
"cf.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1013 if (!empty($arrayfields[
'cf.fk_statut'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.fk_statut'][
'label'],
$_SERVER[
"PHP_SELF"],
"cf.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
1014 if (!empty($arrayfields[
'cf.billed'][
'checked']))
print_liste_field_titre($arrayfields[
'cf.billed'][
'label'],
$_SERVER[
"PHP_SELF"],
'cf.billed',
'', $param,
'', $sortfield, $sortorder,
'center ');
1021 $productstat_cache = array();
1023 $userstatic =
new User($db);
1025 $projectstatic =
new Project($db);
1028 $totalarray = array();
1029 while ($i < min($num, $limit))
1031 $obj = $db->fetch_object(
$resql);
1039 $objectstatic->id = $obj->rowid;
1040 $objectstatic->ref = $obj->ref;
1041 $objectstatic->ref_supplier = $obj->ref_supplier;
1042 $objectstatic->total_ht = $obj->total_ht;
1043 $objectstatic->total_tva = $obj->total_tva;
1044 $objectstatic->total_ttc = $obj->total_ttc;
1045 $objectstatic->date_commande = $db->jdate($obj->date_commande);
1046 $objectstatic->delivery_date = $db->jdate($obj->date_livraison);
1047 $objectstatic->note_public = $obj->note_public;
1048 $objectstatic->note_private = $obj->note_private;
1049 $objectstatic->statut = $obj->fk_statut;
1051 print
'<tr class="oddeven">';
1054 if (!empty($arrayfields[
'cf.ref'][
'checked']))
1056 print
'<td class="nowrap">';
1059 print $objectstatic->getNomUrl(1,
'', 0, -1, 1);
1063 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1066 if (!$i) $totalarray[
'nbfield']++;
1069 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked']))
1071 print
'<td>'.$obj->ref_supplier.
'</td>'.
"\n";
1072 if (!$i) $totalarray[
'nbfield']++;
1075 if (!empty($arrayfields[
'p.project_ref'][
'checked']))
1077 $projectstatic->id = $obj->project_id;
1078 $projectstatic->ref = $obj->project_ref;
1079 $projectstatic->title = $obj->project_title;
1081 if ($obj->project_id > 0) print $projectstatic->getNomUrl(1);
1083 if (!$i) $totalarray[
'nbfield']++;
1086 $userstatic->id = $obj->fk_user_author;
1087 $userstatic->lastname = $obj->lastname;
1088 $userstatic->firstname = $obj->firstname;
1089 $userstatic->login = $obj->login;
1090 $userstatic->photo = $obj->photo;
1091 $userstatic->email = $obj->user_email;
1092 if (!empty($arrayfields[
'u.login'][
'checked']))
1094 print
'<td class="tdoverflowmax150">';
1095 if ($userstatic->id) print $userstatic->getNomUrl(1);
1097 if (!$i) $totalarray[
'nbfield']++;
1100 if (!empty($arrayfields[
's.nom'][
'checked']))
1102 print
'<td class="tdoverflowmax150">';
1103 $thirdpartytmp->id = $obj->socid;
1104 $thirdpartytmp->name = $obj->name;
1105 $thirdpartytmp->email = $obj->email;
1106 print $thirdpartytmp->getNomUrl(1,
'supplier');
1108 if (!$i) $totalarray[
'nbfield']++;
1111 if (!empty($arrayfields[
's.town'][
'checked']))
1116 if (!$i) $totalarray[
'nbfield']++;
1119 if (!empty($arrayfields[
's.zip'][
'checked']))
1124 if (!$i) $totalarray[
'nbfield']++;
1127 if (!empty($arrayfields[
'state.nom'][
'checked']))
1129 print
"<td>".$obj->state_name.
"</td>\n";
1130 if (!$i) $totalarray[
'nbfield']++;
1133 if (!empty($arrayfields[
'country.code_iso'][
'checked']))
1135 print
'<td class="center">';
1136 $tmparray =
getCountry($obj->fk_pays,
'all');
1137 print $tmparray[
'label'];
1139 if (!$i) $totalarray[
'nbfield']++;
1142 if (!empty($arrayfields[
'typent.code'][
'checked']))
1144 print
'<td class="center">';
1145 if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
1146 print $typenArray[$obj->typent_code];
1148 if (!$i) $totalarray[
'nbfield']++;
1152 if (!empty($arrayfields[
'cf.date_commande'][
'checked']))
1154 print
'<td class="center">';
1156 if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1157 if ($objectstatic->hasDelay()) {
1158 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1162 if (!$i) $totalarray[
'nbfield']++;
1165 if (!empty($arrayfields[
'cf.date_livraison'][
'checked']))
1167 print
'<td class="center">';
1169 if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1170 if ($objectstatic->hasDelay()) {
1171 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1175 if (!$i) $totalarray[
'nbfield']++;
1178 if (!empty($arrayfields[
'cf.total_ht'][
'checked']))
1180 print
'<td class="right">'.price($obj->total_ht).
"</td>\n";
1181 if (!$i) $totalarray[
'nbfield']++;
1182 if (!$i) $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ht';
1183 $totalarray[
'val'][
'cf.total_ht'] += $obj->total_ht;
1186 if (!empty($arrayfields[
'cf.total_vat'][
'checked']))
1188 print
'<td class="right">'.price($obj->total_tva).
"</td>\n";
1189 if (!$i) $totalarray[
'nbfield']++;
1190 if (!$i) $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_vat';
1191 $totalarray[
'val'][
'cf.total_vat'] += $obj->total_tva;
1194 if (!empty($arrayfields[
'cf.total_ttc'][
'checked']))
1196 print
'<td class="right">'.price($obj->total_ttc).
"</td>\n";
1197 if (!$i) $totalarray[
'nbfield']++;
1198 if (!$i) $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ttc';
1199 $totalarray[
'val'][
'cf.total_ttc'] += $obj->total_ttc;
1203 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked']))
1205 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1206 if (!$i) $totalarray[
'nbfield']++;
1210 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked']))
1212 print
'<td class="nowrap">';
1213 $form->form_multicurrency_rate(
$_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1215 if (!$i) $totalarray[
'nbfield']++;
1218 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked']))
1220 print
'<td class="right nowrap">'.price($obj->multicurrency_total_ht).
"</td>\n";
1221 if (!$i) $totalarray[
'nbfield']++;
1224 if (!empty($arrayfields[
'cf.multicurrency_total_vat'][
'checked']))
1226 print
'<td class="right nowrap">'.price($obj->multicurrency_total_vat).
"</td>\n";
1227 if (!$i) $totalarray[
'nbfield']++;
1230 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked']))
1232 print
'<td class="right nowrap">'.price($obj->multicurrency_total_ttc).
"</td>\n";
1233 if (!$i) $totalarray[
'nbfield']++;
1237 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1239 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1240 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1241 print $hookmanager->resPrint;
1243 if (!empty($arrayfields[
'cf.datec'][
'checked']))
1245 print
'<td class="center nowrap">';
1246 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1248 if (!$i) $totalarray[
'nbfield']++;
1251 if (!empty($arrayfields[
'cf.tms'][
'checked']))
1253 print
'<td class="center nowrap">';
1254 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1256 if (!$i) $totalarray[
'nbfield']++;
1259 if (!empty($arrayfields[
'cf.fk_statut'][
'checked']))
1261 print
'<td class="right nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).
'</td>';
1262 if (!$i) $totalarray[
'nbfield']++;
1265 if (!empty($arrayfields[
'cf.billed'][
'checked']))
1267 print
'<td class="center">'.yn($obj->billed).
'</td>';
1268 if (!$i) $totalarray[
'nbfield']++;
1272 print
'<td class="nowrap center">';
1273 if ($massactionbutton || $massaction)
1276 if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
1277 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1280 if (!$i) $totalarray[
'nbfield']++;
1284 $total += $obj->total_ht;
1285 $subtotal += $obj->total_ht;
1290 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1294 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
1295 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
1296 print $hookmanager->resPrint;
1298 print
'</table>'.
"\n";
1301 print
'</form>'.
"\n";
1303 $hidegeneratedfilelistifempty = 1;
1304 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
1307 $urlsource =
$_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1308 $urlsource .= str_replace(
'&',
'&', $param);
1310 $filedir = $diroutputmassaction;
1311 $genallowed = $user->rights->fournisseur->commande->lire;
1312 $delallowed = $user->rights->fournisseur->commande->creer;
1314 print $formfile->showdocuments(
'massfilesarea_supplier_order',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'', null, $hidegeneratedfilelistifempty);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
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_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Class to manage suppliers invoices.
Class to manage suppliers.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage projects.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
Class to manage predefined suppliers products.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage absolute discounts.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.