36 require
'../../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
50 $langs->loadLangs(array(
"orders",
"sendings",
'deliveries',
'companies',
'compta',
'bills',
'projects',
'suppliers',
'products'));
53 $action =
GETPOST(
'action',
'aZ09');
54 $massaction =
GETPOST(
'massaction',
'alpha');
55 $show_files =
GETPOST(
'show_files',
'int');
56 $confirm =
GETPOST(
'confirm',
'alpha');
57 $toselect =
GETPOST(
'toselect',
'array');
58 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierorderlist';
61 $search_date_order_startday =
GETPOST(
'search_date_order_startday',
'int');
62 $search_date_order_startmonth =
GETPOST(
'search_date_order_startmonth',
'int');
63 $search_date_order_startyear =
GETPOST(
'search_date_order_startyear',
'int');
64 $search_date_order_endday =
GETPOST(
'search_date_order_endday',
'int');
65 $search_date_order_endmonth =
GETPOST(
'search_date_order_endmonth',
'int');
66 $search_date_order_endyear =
GETPOST(
'search_date_order_endyear',
'int');
67 $search_date_order_start =
dol_mktime(0, 0, 0, $search_date_order_startmonth, $search_date_order_startday, $search_date_order_startyear);
68 $search_date_order_end =
dol_mktime(23, 59, 59, $search_date_order_endmonth, $search_date_order_endday, $search_date_order_endyear);
70 $search_date_delivery_startday =
GETPOST(
'search_date_delivery_startday',
'int');
71 $search_date_delivery_startmonth =
GETPOST(
'search_date_delivery_startmonth',
'int');
72 $search_date_delivery_startyear =
GETPOST(
'search_date_delivery_startyear',
'int');
73 $search_date_delivery_endday =
GETPOST(
'search_date_delivery_endday',
'int');
74 $search_date_delivery_endmonth =
GETPOST(
'search_date_delivery_endmonth',
'int');
75 $search_date_delivery_endyear =
GETPOST(
'search_date_delivery_endyear',
'int');
76 $search_date_delivery_start =
dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear);
77 $search_date_delivery_end =
dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
79 $search_date_valid_startday =
GETPOST(
'search_date_valid_startday',
'int');
80 $search_date_valid_startmonth =
GETPOST(
'search_date_valid_startmonth',
'int');
81 $search_date_valid_startyear =
GETPOST(
'search_date_valid_startyear',
'int');
82 $search_date_valid_endday =
GETPOST(
'search_date_valid_endday',
'int');
83 $search_date_valid_endmonth =
GETPOST(
'search_date_valid_endmonth',
'int');
84 $search_date_valid_endyear =
GETPOST(
'search_date_valid_endyear',
'int');
85 $search_date_valid_start =
dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear);
86 $search_date_valid_end =
dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
88 $search_date_approve_startday =
GETPOST(
'search_date_approve_startday',
'int');
89 $search_date_approve_startmonth =
GETPOST(
'search_date_approve_startmonth',
'int');
90 $search_date_approve_startyear =
GETPOST(
'search_date_approve_startyear',
'int');
91 $search_date_approve_endday =
GETPOST(
'search_date_approve_endday',
'int');
92 $search_date_approve_endmonth =
GETPOST(
'search_date_approve_endmonth',
'int');
93 $search_date_approve_endyear =
GETPOST(
'search_date_approve_endyear',
'int');
94 $search_date_approve_start =
dol_mktime(0, 0, 0, $search_date_approve_startmonth, $search_date_approve_startday, $search_date_approve_startyear);
95 $search_date_approve_end =
dol_mktime(23, 59, 59, $search_date_approve_endmonth, $search_date_approve_endday, $search_date_approve_endyear);
97 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
99 $search_product_category =
GETPOST(
'search_product_category',
'int');
100 $search_ref =
GETPOST(
'search_ref',
'alpha');
101 $search_refsupp =
GETPOST(
'search_refsupp',
'alpha');
102 $search_company =
GETPOST(
'search_company',
'alpha');
103 $search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
104 $search_town =
GETPOST(
'search_town',
'alpha');
105 $search_zip =
GETPOST(
'search_zip',
'alpha');
106 $search_state =
GETPOST(
"search_state",
'alpha');
107 $search_country =
GETPOST(
"search_country",
'int');
108 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
109 $search_user =
GETPOST(
'search_user',
'int');
110 $search_request_author =
GETPOST(
'search_request_author',
'alpha');
111 $search_ht =
GETPOST(
'search_ht',
'alpha');
112 $search_ttc =
GETPOST(
'search_ttc',
'alpha');
113 $optioncss =
GETPOST(
'optioncss',
'alpha');
114 $socid =
GETPOST(
'socid',
'int');
115 $search_sale =
GETPOST(
'search_sale',
'int');
116 $search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
117 $search_total_tva =
GETPOST(
'search_total_tva',
'alpha');
118 $search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
119 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
120 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
121 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
122 $search_multicurrency_montant_tva =
GETPOST(
'search_multicurrency_montant_tva',
'alpha');
123 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
124 $optioncss =
GETPOST(
'optioncss',
'alpha');
125 $search_billed =
GETPOST(
'search_billed',
'int');
126 $search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
127 $search_btn =
GETPOST(
'button_search',
'alpha');
128 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
131 $search_status = join(
',',
GETPOST(
'search_status',
'array:intcomma'));
133 $search_status = (
GETPOST(
'search_status',
'intcomma') !=
'' ?
GETPOST(
'search_status',
'intcomma') :
GETPOST(
'statut',
'intcomma'));
137 $orderid =
GETPOST(
'orderid',
'int');
139 $socid = $user->socid;
141 $result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
143 $diroutputmassaction = $conf->fournisseur->commande->dir_output.
'/temp/massgeneration/'.$user->id;
145 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
146 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
147 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
149 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction ===
'0')) {
152 $offset = $limit * $page;
153 $pageprev = $page - 1;
154 $pagenext = $page + 1;
156 $sortfield =
'cf.ref';
164 $hookmanager->initHooks(array(
'supplierorderlist'));
168 $extrafields->fetch_name_optionals_label($object->table_element);
170 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
173 $fieldstosearchall = array();
174 foreach ($object->fields as $key => $val) {
175 if (!empty($val[
'searchall'])) {
176 $fieldstosearchall[
'cf.'.$key] = $val[
'label'];
179 $fieldstosearchall[
'pd.description'] =
'Description';
180 $fieldstosearchall[
's.nom'] =
"ThirdParty";
181 $fieldstosearchall[
's.name_alias'] =
"AliasNameShort";
182 $fieldstosearchall[
's.zip'] =
"Zip";
183 $fieldstosearchall[
's.town'] =
"Town";
184 if (empty($user->socid)) {
185 $fieldstosearchall[
"cf.note_private"] =
"NotePrivate";
188 $checkedtypetiers = 0;
191 $arrayfields = array(
192 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'position'=>47,
'checked'=>0),
193 's.town'=>array(
'label'=>
"Town",
'enabled'=>1,
'position'=>47,
'checked'=>1),
194 's.zip'=>array(
'label'=>
"Zip",
'enabled'=>1,
'position'=>47,
'checked'=>1),
195 'state.nom'=>array(
'label'=>
"StateShort",
'enabled'=>1,
'position'=>48),
196 'country.code_iso'=>array(
'label'=>
"Country",
'enabled'=>1,
'position'=>49),
197 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'enabled'=>$checkedtypetiers,
'position'=>50),
198 'u.login'=>array(
'label'=>
"AuthorRequest",
'enabled'=>1,
'position'=>51),
199 'cf.note_public'=>array(
'label'=>
'NotePublic',
'checked'=>0,
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES')),
'position'=>100),
200 'cf.note_private'=>array(
'label'=>
'NotePrivate',
'checked'=>0,
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'position'=>110),
202 foreach ($object->fields as $key => $val) {
204 if (!empty($val[
'visible'])) {
205 $visible = (int)
dol_eval($val[
'visible'], 1);
206 $arrayfields[
'cf.'.$key] = array(
207 'label'=>$val[
'label'],
208 'checked'=>(($visible < 0) ? 0 : 1),
209 'enabled'=>(abs($visible) != 3 &&
dol_eval($val[
'enabled'], 1)),
210 'position'=>$val[
'position'],
211 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
216 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
223 $permissiontoread = ($user->rights->fournisseur->commande->lire || $user->rights->supplier_order->lire);
224 $permissiontoadd = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer);
225 $permissiontodelete = ($user->rights->fournisseur->commande->supprimer || $user->rights->supplier_order->supprimer);
226 $permissiontovalidate = $permissiontoadd;
227 $permissiontoapprove = ($user->rights->fournisseur->commande->approuver || $user->rights->supplier_order->approuver);
234 if (
GETPOST(
'cancel',
'alpha')) {
235 $action =
'list'; $massaction =
'';
237 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createsupplierbills') {
241 $parameters = array(
'socid'=>$socid);
242 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
247 if (empty($reshook)) {
249 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
252 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
256 $search_product_category =
'';
258 $search_refsupp =
'';
259 $search_company =
'';
260 $search_company_alias =
'';
265 $search_country =
'';
266 $search_type_thirdparty =
'';
267 $search_request_author =
'';
268 $search_total_ht =
'';
269 $search_total_tva =
'';
270 $search_total_ttc =
'';
271 $search_multicurrency_code =
'';
272 $search_multicurrency_tx =
'';
273 $search_multicurrency_montant_ht =
'';
274 $search_multicurrency_montant_tva =
'';
275 $search_multicurrency_montant_ttc =
'';
276 $search_project_ref =
'';
278 $search_date_order_startday =
'';
279 $search_date_order_startmonth =
'';
280 $search_date_order_startyear =
'';
281 $search_date_order_endday =
'';
282 $search_date_order_endmonth =
'';
283 $search_date_order_endyear =
'';
284 $search_date_order_start =
'';
285 $search_date_order_end =
'';
286 $search_date_delivery_startday =
'';
287 $search_date_delivery_startmonth =
'';
288 $search_date_delivery_startyear =
'';
289 $search_date_delivery_endday =
'';
290 $search_date_delivery_endmonth =
'';
291 $search_date_delivery_endyear =
'';
292 $search_date_delivery_start =
'';
293 $search_date_delivery_end =
'';
294 $search_date_valid_startday =
'';
295 $search_date_valid_startmonth =
'';
296 $search_date_valid_startyear =
'';
297 $search_date_valid_endday =
'';
298 $search_date_valid_endmonth =
'';
299 $search_date_valid_endyear =
'';
300 $search_date_valid_start =
'';
301 $search_date_valid_end =
'';
302 $search_date_approve_startday =
'';
303 $search_date_approve_startmonth =
'';
304 $search_date_approve_startyear =
'';
305 $search_date_approve_endday =
'';
306 $search_date_approve_endmonth =
'';
307 $search_date_approve_endyear =
'';
308 $search_date_approve_start =
'';
309 $search_date_approve_end =
'';
313 $search_array_options = array();
315 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
316 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
321 $objectclass =
'CommandeFournisseur';
322 $objectlabel =
'SupplierOrders';
323 $uploaddir = $conf->fournisseur->commande->dir_output;
324 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
326 if ($action ==
'validate' && $permissiontovalidate) {
327 if (
GETPOST(
'confirm') ==
'yes') {
332 foreach ($toselect as $checked) {
333 if ($objecttmp->fetch($checked)) {
334 if ($objecttmp->statut == 0) {
335 $objecttmp->date_commande =
dol_now();
336 $result = $objecttmp->valid($user);
339 if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $permissiontoapprove && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $objecttmp->hasProductsOrServices(1))) {
340 $result = $objecttmp->approve($user);
341 setEventMessages($langs->trans(
"SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
343 setEventMessages($langs->trans(
"SupplierOrderValidated"), array($objecttmp->ref));
353 if (!$error) $db->commit();
354 else $db->rollback();
359 if ($massaction ==
'confirm_createsupplierbills') {
360 $orders =
GETPOST(
'toselect',
'array');
361 $createbills_onebythird =
GETPOST(
'createbills_onebythird',
'int');
362 $validate_invoices =
GETPOST(
'validate_invoices',
'int');
365 $TFactThird = array();
367 $nb_bills_created = 0;
375 foreach ($orders as $id_order) {
377 if ($cmd->fetch($id_order) <= 0) {
382 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
383 $objecttmp = $TFactThird[$cmd->socid];
385 $objecttmp->socid = $cmd->socid;
386 $objecttmp->type = $objecttmp::TYPE_STANDARD;
387 $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
388 $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
389 $objecttmp->fk_project = $cmd->fk_project;
390 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
391 $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
392 $default_ref_supplier+=1;
395 if (empty($datefacture)) {
399 $objecttmp->date = $datefacture;
400 $objecttmp->origin =
'order_supplier';
401 $objecttmp->origin_id = $id_order;
403 $res = $objecttmp->create($user);
407 $lastref = $objecttmp->ref;
408 $lastid = $objecttmp->id;
412 if ($objecttmp->id > 0) {
413 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"element_element (";
415 $sql .=
", sourcetype";
416 $sql .=
", fk_target";
417 $sql .=
", targettype";
418 $sql .=
") VALUES (";
420 $sql .=
", '".$db->escape($objecttmp->origin).
"'";
421 $sql .=
", ".((int) $objecttmp->id);
422 $sql .=
", '".$db->escape($objecttmp->element).
"'";
425 if (!$db->query($sql)) {
430 $lines = $cmd->lines;
431 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
433 $lines = $cmd->lines;
437 $num = count($lines);
439 for ($i = 0; $i < $num; $i++) {
440 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
441 if ($lines[$i]->subprice < 0) {
444 $discount->fk_soc = $objecttmp->socid;
445 $discount->amount_ht = abs($lines[$i]->total_ht);
446 $discount->amount_tva = abs($lines[$i]->total_tva);
447 $discount->amount_ttc = abs($lines[$i]->total_ttc);
448 $discount->tva_tx = $lines[$i]->tva_tx;
449 $discount->fk_user = $user->id;
450 $discount->description = $desc;
451 $discountid = $discount->create($user);
452 if ($discountid > 0) {
453 $result = $objecttmp->insert_discount($discountid);
462 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
465 if ($lines[$i]->date_debut_prevue) {
466 $date_start = $lines[$i]->date_debut_prevue;
468 if ($lines[$i]->date_debut_reel) {
469 $date_start = $lines[$i]->date_debut_reel;
471 if ($lines[$i]->date_start) {
472 $date_start = $lines[$i]->date_start;
476 if ($lines[$i]->date_fin_prevue) {
477 $date_end = $lines[$i]->date_fin_prevue;
479 if ($lines[$i]->date_fin_reel) {
480 $date_end = $lines[$i]->date_fin_reel;
482 if ($lines[$i]->date_end) {
483 $date_end = $lines[$i]->date_end;
486 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
489 $result = $objecttmp->addline(
491 $lines[$i]->subprice,
493 $lines[$i]->localtax1_tx,
494 $lines[$i]->localtax2_tx,
496 $lines[$i]->fk_product,
497 $lines[$i]->remise_percent,
501 $lines[$i]->info_bits,
506 $lines[$i]->array_options,
508 $objecttmp->origin_id,
510 $lines[$i]->ref_supplier,
511 $lines[$i]->special_code,
522 if ($result > 0 && $lines[$i]->product_type == 9) {
523 $fk_parent_line = $result;
530 $cmd->classifyBilled($user);
532 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
533 $TFactThird[$cmd->socid] = $objecttmp;
535 $TFact[$objecttmp->id] = $objecttmp;
540 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
543 if (!$error && $validate_invoices) {
544 $massaction = $action =
'builddoc';
546 foreach ($TAllFact as &$objecttmp) {
547 $objecttmp->validate($user);
554 $id = $objecttmp->id;
558 $upload_dir = $conf->fournisseur->facture->dir_output;
559 $permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
563 $massaction = $action =
'confirm_createsupplierbills';
569 if ($nb_bills_created == 1) {
570 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
571 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?id='.urlencode($lastid).
'">'.$lastref.
'</a>', $texttoshow);
574 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
579 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
580 $param .=
'&contextpage='.urlencode($contextpage);
582 if ($limit > 0 && $limit != $conf->liste_limit) {
583 $param .=
'&limit='.urlencode($limit);
586 $param .=
'&sall='.urlencode($sall);
589 $param .=
'&socid='.urlencode($socid);
591 if ($search_status !=
'') {
592 $param .=
'&search_status='.urlencode($search_status);
594 if ($search_date_order_startday) {
595 $param .=
'&search_date_order_startday='.urlencode($search_date_order_startday);
597 if ($search_date_order_startmonth) {
598 $param .=
'&search_date_order_startmonth='.urlencode($search_date_order_startmonth);
600 if ($search_date_order_startyear) {
601 $param .=
'&search_date_order_startyear='.urlencode($search_date_order_startyear);
603 if ($search_date_order_endday) {
604 $param .=
'&search_date_order_endday='.urlencode($search_date_order_endday);
606 if ($search_date_order_endmonth) {
607 $param .=
'&search_date_order_endmonth='.urlencode($search_date_order_endmonth);
609 if ($search_date_order_endyear) {
610 $param .=
'&search_date_order_endyear='.urlencode($search_date_order_endyear);
612 if ($search_date_delivery_startday) {
613 $param .=
'&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
615 if ($search_date_delivery_startmonth) {
616 $param .=
'&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
618 if ($search_date_delivery_startyear) {
619 $param .=
'&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
621 if ($search_date_delivery_endday) {
622 $param .=
'&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
624 if ($search_date_delivery_endmonth) {
625 $param .=
'&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
627 if ($search_date_delivery_endyear) {
628 $param .=
'&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
630 if ($search_date_valid_startday) {
631 $param .=
'&search_date_valid_startday='.urlencode($search_date_valid_startday);
633 if ($search_date_valid_startmonth) {
634 $param .=
'&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
636 if ($search_date_valid_startyear) {
637 $param .=
'&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
639 if ($search_date_valid_endday) {
640 $param .=
'&search_date_valid_endday='.urlencode($search_date_valid_endday);
642 if ($search_date_valid_endmonth) {
643 $param .=
'&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
645 if ($search_date_valid_endyear) {
646 $param .=
'&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
648 if ($search_date_approve_startday) {
649 $param .=
'&search_date_approve_startday='.urlencode($search_date_approve_startday);
651 if ($search_date_approve_startmonth) {
652 $param .=
'&search_date_approve_startmonth='.urlencode($search_date_approve_startmonth);
654 if ($search_date_approve_startyear) {
655 $param .=
'&search_date_approve_startyear='.urlencode($search_date_approve_startyear);
657 if ($search_date_approve_endday) {
658 $param .=
'&search_date_approve_endday='.urlencode($search_date_approve_endday);
660 if ($search_date_approve_endmonth) {
661 $param .=
'&search_date_approve_endmonth='.urlencode($search_date_approve_endmonth);
663 if ($search_date_approve_endyear) {
664 $param .=
'&search_date_approve_endyear='.urlencode($search_date_approve_endyear);
667 $param .=
'&search_ref='.urlencode($search_ref);
669 if ($search_company) {
670 $param .=
'&search_company='.urlencode($search_company);
672 if ($search_company_alias) {
673 $param .=
'&search_company_alias='.urlencode($search_company_alias);
676 if ($search_user > 0) {
677 $param .=
'&search_user='.urlencode($search_user);
679 if ($search_sale > 0) {
680 $param .=
'&search_sale='.urlencode($search_sale);
682 if ($search_total_ht !=
'') {
683 $param .=
'&search_total_ht='.urlencode($search_total_ht);
685 if ($search_total_tva !=
'') {
686 $param .=
'&search_total_tva='.urlencode($search_total_tva);
688 if ($search_total_ttc !=
'') {
689 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
691 if ($search_project_ref >= 0) {
692 $param .=
"&search_project_ref=".urlencode($search_project_ref);
695 $param .=
'&show_files='.urlencode($show_files);
697 if ($optioncss !=
'') {
698 $param .=
'&optioncss='.urlencode($optioncss);
701 $param .=
'&billed='.urlencode($billed);
704 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
709 $_GET[
"origin"] = $_POST[
"origin"];
710 $_GET[
"originid"] = $_POST[
"originid"];
732 $title = $langs->trans(
"SuppliersOrders");
735 $fourn->fetch($socid);
736 $title .=
' - '.$fourn->name;
747 if ($search_billed > 0) {
748 $title .=
' - '.$langs->trans(
"Billed");
754 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
755 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
759 $sql =
'SELECT DISTINCT';
761 $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,';
762 $sql .=
" typent.code as typent_code,";
763 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
764 $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 date_livraison,cf.date_valid, cf.date_approve,";
765 $sql .=
' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
766 $sql .=
' cf.date_creation as date_creation, cf.tms as date_update,';
767 $sql .=
' cf.note_public, cf.note_private,';
768 $sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
769 $sql .=
" u.firstname, u.lastname, u.photo, u.login, u.email as user_email, u.statut as user_status";
771 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
772 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
773 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
777 $parameters = array();
778 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
779 $sql .= $hookmanager->resPrint;
783 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
784 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
785 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
786 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
787 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
788 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
789 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cf.rowid = ef.fk_object)";
792 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
794 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON cf.fk_user_author = u.rowid";
795 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = cf.fk_projet";
797 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
798 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
800 $parameters = array();
801 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
802 $sql .= $hookmanager->resPrint;
803 $sql .=
' WHERE cf.fk_soc = s.rowid';
804 $sql .=
' AND cf.entity IN ('.getEntity(
'supplier_order').
')';
806 $sql .=
" AND s.rowid = ".((int) $socid);
808 if (empty($user->rights->societe->client->voir) && !$socid) {
809 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
814 if ($search_refsupp) {
820 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
821 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
823 if ($search_company) {
826 if ($search_company_alias) {
830 if ($search_request_author) {
831 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_request_author);
833 if ($search_billed !=
'' && $search_billed >= 0) {
834 $sql .=
" AND cf.billed = ".((int) $search_billed);
837 if (
GETPOST(
'statut',
'intcomma') !==
'') {
838 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(
GETPOST(
'statut',
'intcomma')))).
")";
840 if ($search_status !=
'' && $search_status !=
'-1') {
841 $sql .=
" AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
843 if ($search_date_order_start) {
844 $sql .=
" AND cf.date_commande >= '".$db->idate($search_date_order_start).
"'";
846 if ($search_date_order_end) {
847 $sql .=
" AND cf.date_commande <= '".$db->idate($search_date_order_end).
"'";
849 if ($search_date_delivery_start) {
850 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_delivery_start).
"'";
852 if ($search_date_delivery_end) {
853 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_delivery_end).
"'";
855 if ($search_date_valid_start) {
856 $sql .=
" AND cf.date_commande >= '".$db->idate($search_date_valid_start).
"'";
858 if ($search_date_valid_end) {
859 $sql .=
" AND cf.date_commande <= '".$db->idate($search_date_valid_end).
"'";
861 if ($search_date_approve_start) {
862 $sql .=
" AND cf.date_livraison >= '".$db->idate($search_date_approve_start).
"'";
864 if ($search_date_approve_end) {
865 $sql .=
" AND cf.date_livraison <= '".$db->idate($search_date_approve_end).
"'";
876 if ($search_country) {
877 $sql .=
" AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).
')';
879 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
880 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
882 if ($search_sale > 0) {
883 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
885 if ($search_user > 0) {
886 $sql .=
" AND EXISTS (";
887 $sql .=
" SELECT ec.rowid ";
888 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_contact as ec";
889 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
890 $sql .=
" WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
891 $sql .=
" AND tc.element = 'order_supplier' AND tc.source = 'internal'";
894 if ($search_total_ht !=
'') {
897 if ($search_total_tva !=
'') {
900 if ($search_total_ttc !=
'') {
903 if ($search_multicurrency_code !=
'') {
904 $sql .=
" AND cf.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
906 if ($search_multicurrency_tx !=
'') {
907 $sql .=
natural_search(
'cf.multicurrency_tx', $search_multicurrency_tx, 1);
909 if ($search_multicurrency_montant_ht !=
'') {
910 $sql .=
natural_search(
'cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
912 if ($search_multicurrency_montant_tva !=
'') {
913 $sql .=
natural_search(
'cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1);
915 if ($search_multicurrency_montant_ttc !=
'') {
916 $sql .=
natural_search(
'cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
918 if ($search_project_ref !=
'') {
922 $searchCategoryProductOperator = -1;
923 $searchCategoryProductList = array($search_product_category);
924 if (!empty($searchCategoryProductList)) {
925 $searchCategoryProductSqlList = array();
926 $listofcategoryid =
'';
927 foreach ($searchCategoryProductList as $searchCategoryProduct) {
928 if (intval($searchCategoryProduct) == -2) {
929 $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)";
930 } elseif (intval($searchCategoryProduct) > 0) {
931 if ($searchCategoryProductOperator == 0) {
932 $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).
")";
934 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
938 if ($listofcategoryid) {
939 $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).
"))";
941 if ($searchCategoryProductOperator == 1) {
942 if (!empty($searchCategoryProductSqlList)) {
943 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
946 if (!empty($searchCategoryProductSqlList)) {
947 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
952 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
954 $parameters = array();
955 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
956 $sql .= $hookmanager->resPrint;
960 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
962 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
963 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
964 $resql = $db->query($sqlforcount);
966 $objforcount = $db->fetch_object(
$resql);
979 $sql .= $db->order($sortfield, $sortorder);
981 $sql .= $db->plimit($limit + 1, $offset);
985 $resql = $db->query($sql);
987 $num = $db->num_rows(
$resql);
989 $arrayofselected = is_array($toselect) ? $toselect : array();
991 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
992 $obj = $db->fetch_object(
$resql);
994 header(
"Location: ".DOL_URL_ROOT.
'/fourn/commande/card.php?id='.$id);
1001 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1002 $param .=
'&contextpage='.urlencode($contextpage);
1004 if ($limit > 0 && $limit != $conf->liste_limit) {
1005 $param .=
'&limit='.urlencode($limit);
1008 $param .=
'&sall='.urlencode($sall);
1011 $param .=
'&socid='.urlencode($socid);
1014 $param .=
"&search_all=".urlencode($sall);
1016 if ($search_date_order_startday) {
1017 $param .=
'&search_date_order_startday='.urlencode($search_date_order_startday);
1019 if ($search_date_order_startmonth) {
1020 $param .=
'&search_date_order_startmonth='.urlencode($search_date_order_startmonth);
1022 if ($search_date_order_startyear) {
1023 $param .=
'&search_date_order_startyear='.urlencode($search_date_order_startyear);
1025 if ($search_date_order_endday) {
1026 $param .=
'&search_date_order_endday='.urlencode($search_date_order_endday);
1028 if ($search_date_order_endmonth) {
1029 $param .=
'&search_date_order_endmonth='.urlencode($search_date_order_endmonth);
1031 if ($search_date_order_endyear) {
1032 $param .=
'&search_date_order_endyear='.urlencode($search_date_order_endyear);
1034 if ($search_date_delivery_startday) {
1035 $param .=
'&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
1037 if ($search_date_delivery_startmonth) {
1038 $param .=
'&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
1040 if ($search_date_delivery_startyear) {
1041 $param .=
'&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
1043 if ($search_date_delivery_endday) {
1044 $param .=
'&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
1046 if ($search_date_delivery_endmonth) {
1047 $param .=
'&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
1049 if ($search_date_delivery_endyear) {
1050 $param .=
'&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
1052 if ($search_date_valid_startday) {
1053 $param .=
'&search_date_valid_startday='.urlencode($search_date_valid_startday);
1055 if ($search_date_valid_startmonth) {
1056 $param .=
'&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
1058 if ($search_date_valid_startyear) {
1059 $param .=
'&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
1061 if ($search_date_valid_endday) {
1062 $param .=
'&search_date_valid_endday='.urlencode($search_date_valid_endday);
1064 if ($search_date_valid_endmonth) {
1065 $param .=
'&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
1067 if ($search_date_valid_endyear) {
1068 $param .=
'&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
1070 if ($search_date_approve_startday) {
1071 $param .=
'&search_date_approve_startday='.urlencode($search_date_approve_startday);
1073 if ($search_date_approve_startmonth) {
1074 $param .=
'&search_date_approve_startmonth='.urlencode($search_date_approve_startmonth);
1076 if ($search_date_approve_startyear) {
1077 $param .=
'&search_date_approve_startyear='.urlencode($search_date_approve_startyear);
1079 if ($search_date_approve_endday) {
1080 $param .=
'&search_date_approve_endday='.urlencode($search_date_approve_endday);
1082 if ($search_date_approve_endmonth) {
1083 $param .=
'&search_date_approve_endmonth='.urlencode($search_date_approve_endmonth);
1085 if ($search_date_approve_endyear) {
1086 $param .=
'&search_date_approve_endyear='.urlencode($search_date_approve_endyear);
1089 $param .=
'&search_ref='.urlencode($search_ref);
1091 if ($search_company) {
1092 $param .=
'&search_company='.urlencode($search_company);
1094 if ($search_company_alias) {
1095 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1097 if ($search_user > 0) {
1098 $param .=
'&search_user='.urlencode($search_user);
1100 if ($search_request_author) {
1101 $param .=
'&search_request_author='.urlencode($search_request_author);
1103 if ($search_sale > 0) {
1104 $param .=
'&search_sale='.urlencode($search_sale);
1106 if ($search_total_ht !=
'') {
1107 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1109 if ($search_total_ttc !=
'') {
1110 $param .=
"&search_total_ttc=".urlencode($search_total_ttc);
1112 if ($search_multicurrency_code !=
'') {
1113 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1115 if ($search_multicurrency_tx !=
'') {
1116 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1118 if ($search_multicurrency_montant_ht !=
'') {
1119 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1121 if ($search_multicurrency_montant_tva !=
'') {
1122 $param .=
'&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva);
1124 if ($search_multicurrency_montant_ttc !=
'') {
1125 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1127 if ($search_refsupp) {
1128 $param .=
"&search_refsupp=".urlencode($search_refsupp);
1130 if ($search_status !=
'' && $search_status !=
'-1') {
1131 $param .=
"&search_status=".urlencode($search_status);
1133 if ($search_project_ref >= 0) {
1134 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1136 if ($search_billed !=
'') {
1137 $param .=
"&search_billed=".urlencode($search_billed);
1140 $param .=
'&show_files='.urlencode($show_files);
1142 if ($optioncss !=
'') {
1143 $param .=
'&optioncss='.urlencode($optioncss);
1145 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
1146 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1150 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1152 $parameters = array();
1153 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1154 $param .= $hookmanager->resPrint;
1157 $arrayofmassactions = array(
1158 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1159 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1160 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1163 if ($permissiontovalidate) {
1164 if ($permissiontoapprove && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) {
1165 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"ValidateAndApprove");
1167 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1171 if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
1172 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisSupplier");
1174 if ($permissiontodelete) {
1175 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1177 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1178 $arrayofmassactions = array();
1180 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1182 $url = DOL_URL_ROOT.
'/fourn/commande/card.php?action=create';
1184 $url .=
'&socid='.((int) $socid);
1185 $url .=
'&backtopage='.urlencode(DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.((
int) $socid));
1187 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewSupplierOrderShort'),
'',
'fa fa-plus-circle', $url,
'', $permissiontoadd);
1190 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1191 if ($optioncss !=
'') {
1192 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1194 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1195 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1196 print
'<input type="hidden" name="action" value="list">';
1197 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1198 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1199 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1200 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1202 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'supplier_order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1204 $topicmail =
"SendOrderRef";
1205 $modelmail =
"order_supplier_send";
1207 $trackid =
'sord'.$object->id;
1208 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1210 if ($massaction ==
'prevalidate') {
1211 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1214 if ($massaction ==
'createbills') {
1216 print
'<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
1218 print
'<table class="noborder" width="100%" >';
1220 print
'<td class="titlefield">';
1221 print $langs->trans(
'DateInvoice');
1224 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1229 print $langs->trans(
'CreateOneBillByThird');
1232 print
$form->selectyesno(
'createbills_onebythird',
'', 1);
1237 print $langs->trans(
'ValidateInvoices');
1240 print
$form->selectyesno(
'validate_invoices', 1, 1);
1246 print
'<div class="center">';
1247 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1248 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1254 foreach ($fieldstosearchall as $key => $val) {
1255 $fieldstosearchall[$key] = $langs->trans($val);
1257 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
1260 $moreforfilter =
'';
1263 if ($user->rights->user->user->lire) {
1264 $langs->load(
"commercial");
1265 $moreforfilter .=
'<div class="divsearchfield">';
1266 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1267 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1268 $moreforfilter .=
'</div>';
1271 if ($user->rights->user->user->lire) {
1272 $moreforfilter .=
'<div class="divsearchfield">';
1273 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1274 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1275 $moreforfilter .=
'</div>';
1278 if (
isModEnabled(
'categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
1279 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1280 $moreforfilter .=
'<div class="divsearchfield">';
1281 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1282 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1283 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0, 0,
'maxwidth300 widthcentpercentminusx', 1);
1284 $moreforfilter .=
'</div>';
1286 $parameters = array();
1287 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1288 if (empty($reshook)) {
1289 $moreforfilter .= $hookmanager->resPrint;
1291 $moreforfilter = $hookmanager->resPrint;
1294 if (!empty($moreforfilter)) {
1295 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1296 print $moreforfilter;
1300 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1301 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1302 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1304 if (
GETPOST(
'autoselectall',
'int')) {
1305 $selectedfields .=
'<script>';
1306 $selectedfields .=
' $(document).ready(function() {';
1307 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1308 $selectedfields .=
' $("#checkforselects").click();';
1309 $selectedfields .=
' $("#massaction").val("createbills").change();';
1310 $selectedfields .=
' });';
1311 $selectedfields .=
'</script>';
1314 print
'<div class="div-table-responsive">';
1315 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1317 print
'<tr class="liste_titre_filter">';
1320 print
'<td class="liste_titre middle">';
1321 $searchpicto =
$form->showFilterButtons(
'left');
1326 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1327 print
'<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.
'"></td>';
1330 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1331 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.
'"></td>';
1334 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1335 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.
'"></td>';
1338 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1339 print
'<td class="liste_titre">';
1340 print
'<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.
'">';
1344 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1345 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.
'"></td>';
1348 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1349 print
'<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company_alias" value="'.$search_company_alias.
'"></td>';
1352 if (!empty($arrayfields[
's.town'][
'checked'])) {
1353 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.
'"></td>';
1356 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1357 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.
'"></td>';
1360 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1361 print
'<td class="liste_titre">';
1362 print
'<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1366 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1367 print
'<td class="liste_titre center">';
1368 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1372 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1373 print
'<td class="liste_titre maxwidthonsmartphone center">';
1374 print
$form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
1378 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1379 print
'<td class="liste_titre center">';
1380 print
'<div class="nowrap">';
1381 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'));
1383 print
'<div class="nowrap">';
1384 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'));
1389 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1390 print
'<td class="liste_titre center">';
1391 print
'<div class="nowrap">';
1392 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'));
1394 print
'<div class="nowrap">';
1395 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'));
1399 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1401 print
'<td class="liste_titre right">';
1402 print
'<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.
'">';
1405 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1407 print
'<td class="liste_titre right">';
1408 print
'<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.
'">';
1411 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1413 print
'<td class="liste_titre right">';
1414 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1417 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1419 print
'<td class="liste_titre">';
1420 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1423 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1425 print
'<td class="liste_titre">';
1426 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1429 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1431 print
'<td class="liste_titre right">';
1432 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1435 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1437 print
'<td class="liste_titre right">';
1438 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).
'">';
1441 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1443 print
'<td class="liste_titre right">';
1444 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1448 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1451 $parameters = array(
'arrayfields'=>$arrayfields);
1452 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1453 print $hookmanager->resPrint;
1455 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1456 print
'<td class="liste_titre">';
1460 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1461 print
'<td class="liste_titre">';
1465 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1466 print
'<td class="liste_titre right">';
1467 $formorder->selectSupplierOrderStatus($search_status, 1,
'search_status');
1471 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1472 print
'<td class="liste_titre center">';
1473 print
$form->selectyesno(
'search_billed', $search_billed, 1,
false, 1, 1,
'maxwidth100 onrightofpage');
1477 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1478 print
'<td class="liste_titre center">';
1479 print
'<div class="nowrap">';
1480 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'));
1482 print
'<div class="nowrap">';
1483 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'));
1488 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1489 print
'<td class="liste_titre center">';
1490 print
'<div class="nowrap">';
1491 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'));
1493 print
'<div class="nowrap">';
1494 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'));
1499 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1500 print
'<td class="liste_titre">';
1504 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1505 print
'<td class="liste_titre">';
1510 print
'<td class="liste_titre middle">';
1511 $searchpicto =
$form->showFilterButtons();
1519 print
'<tr class="liste_titre">';
1521 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1523 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1524 print_liste_field_titre($arrayfields[
'cf.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref",
"", $param,
'', $sortfield, $sortorder);
1526 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1527 print_liste_field_titre($arrayfields[
'cf.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.ref_supplier",
"", $param,
'', $sortfield, $sortorder,
'tdoverflowmax100imp ');
1529 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1530 print_liste_field_titre($arrayfields[
'cf.fk_projet'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1532 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1533 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
"u.login",
"", $param,
'', $sortfield, $sortorder);
1535 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1536 print_liste_field_titre($arrayfields[
'cf.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
1538 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1539 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"s.name_alias",
"", $param,
'', $sortfield, $sortorder);
1541 if (!empty($arrayfields[
's.town'][
'checked'])) {
1542 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1544 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1545 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1547 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1548 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1550 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1551 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1553 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1554 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1556 if (!empty($arrayfields[
'cf.fk_author'][
'checked'])) {
1557 print_liste_field_titre($arrayfields[
'cf.fk_author'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_author",
"", $param,
'', $sortfield, $sortorder);
1559 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1560 print_liste_field_titre($arrayfields[
'cf.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_commande",
"", $param,
'', $sortfield, $sortorder,
'center ');
1562 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1563 print_liste_field_titre($arrayfields[
'cf.date_livraison'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1565 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1566 print_liste_field_titre($arrayfields[
'cf.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
1568 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1569 print_liste_field_titre($arrayfields[
'cf.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
1571 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1572 print_liste_field_titre($arrayfields[
'cf.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
1574 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1575 print_liste_field_titre($arrayfields[
'cf.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1577 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1578 print_liste_field_titre($arrayfields[
'cf.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1580 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1581 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1583 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1584 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1586 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1587 print_liste_field_titre($arrayfields[
'cf.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'cf.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1590 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1592 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1593 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1594 print $hookmanager->resPrint;
1595 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1596 print_liste_field_titre($arrayfields[
'cf.date_creation'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1598 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1599 print_liste_field_titre($arrayfields[
'cf.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1601 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1602 print_liste_field_titre($arrayfields[
'cf.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
1604 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1605 print_liste_field_titre($arrayfields[
'cf.billed'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.billed',
'', $param,
'', $sortfield, $sortorder,
'center ');
1607 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1608 print_liste_field_titre($arrayfields[
'cf.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
1610 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1611 print_liste_field_titre($arrayfields[
'cf.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
'cf.date_approve',
'', $param,
'', $sortfield, $sortorder,
'center ');
1613 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1614 print_liste_field_titre($arrayfields[
'cf.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_public",
"", $param,
'', $sortfield, $sortorder,
'center ');
1616 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1617 print_liste_field_titre($arrayfields[
'cf.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"cf.note_private",
"", $param,
'', $sortfield, $sortorder,
'center ');
1620 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1627 $productstat_cache = array();
1629 $userstatic =
new User($db);
1631 $projectstatic =
new Project($db);
1634 $totalarray = array(
'nbfield' => 0,
'val' => array(),
'pos' => array());
1635 $totalarray[
'val'][
'cf.total_ht'] = 0;
1636 $totalarray[
'val'][
'cf.total_ttc'] = 0;
1637 $totalarray[
'val'][
'cf.total_tva'] = 0;
1639 $imaxinloop = ($limit ? min($num, $limit) : $num);
1640 while ($i < $imaxinloop) {
1641 $obj = $db->fetch_object(
$resql);
1649 $objectstatic->id = $obj->rowid;
1650 $objectstatic->ref = $obj->ref;
1651 $objectstatic->socid = $obj->socid;
1652 $objectstatic->ref_supplier = $obj->ref_supplier;
1653 $objectstatic->socid = $obj->socid;
1654 $objectstatic->total_ht = $obj->total_ht;
1655 $objectstatic->total_tva = $obj->total_tva;
1656 $objectstatic->total_ttc = $obj->total_ttc;
1657 $objectstatic->date_commande = $db->jdate($obj->date_commande);
1658 $objectstatic->delivery_date = $db->jdate($obj->date_livraison);
1659 $objectstatic->note_public = $obj->note_public;
1660 $objectstatic->note_private = $obj->note_private;
1661 $objectstatic->statut = $obj->fk_statut;
1663 print
'<tr class="oddeven">';
1666 print
'<td class="nowrap center">';
1667 if ($massactionbutton || $massaction) {
1669 if (in_array($obj->rowid, $arrayofselected)) {
1672 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1677 if (!empty($arrayfields[
'cf.ref'][
'checked'])) {
1678 print
'<td class="nowrap">';
1681 print $objectstatic->getNomUrl(1,
'', 0, -1, 1);
1685 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1689 $totalarray[
'nbfield']++;
1693 if (!empty($arrayfields[
'cf.ref_supplier'][
'checked'])) {
1694 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>'.
"\n";
1696 $totalarray[
'nbfield']++;
1700 if (!empty($arrayfields[
'cf.fk_projet'][
'checked'])) {
1701 $projectstatic->id = $obj->project_id;
1702 $projectstatic->ref = $obj->project_ref;
1703 $projectstatic->title = $obj->project_title;
1705 if ($obj->project_id > 0) {
1706 print $projectstatic->getNomUrl(1);
1710 $totalarray[
'nbfield']++;
1714 $userstatic->id = $obj->fk_user_author;
1715 $userstatic->lastname = $obj->lastname;
1716 $userstatic->firstname = $obj->firstname;
1717 $userstatic->login = $obj->login;
1718 $userstatic->photo = $obj->photo;
1719 $userstatic->email = $obj->user_email;
1720 $userstatic->statut = $obj->user_status;
1721 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1722 print
'<td class="tdoverflowmax150">';
1723 if ($userstatic->id) {
1724 print $userstatic->getNomUrl(1);
1728 $totalarray[
'nbfield']++;
1732 if (!empty($arrayfields[
'cf.fk_soc'][
'checked'])) {
1733 print
'<td class="tdoverflowmax150">';
1734 $thirdpartytmp->id = $obj->socid;
1735 $thirdpartytmp->name = $obj->name;
1736 $thirdpartytmp->email = $obj->email;
1737 $thirdpartytmp->name_alias = $obj->alias;
1738 $thirdpartytmp->client = $obj->client;
1739 $thirdpartytmp->fournisseur = $obj->fournisseur;
1740 print $thirdpartytmp->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1743 $totalarray[
'nbfield']++;
1747 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1748 print
'<td class="tdoverflowmax150">';
1752 $totalarray[
'nbfield']++;
1756 if (!empty($arrayfields[
's.town'][
'checked'])) {
1761 $totalarray[
'nbfield']++;
1765 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1770 $totalarray[
'nbfield']++;
1774 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1775 print
"<td>".$obj->state_name.
"</td>\n";
1777 $totalarray[
'nbfield']++;
1781 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1782 print
'<td class="center">';
1783 $tmparray =
getCountry($obj->fk_pays,
'all');
1784 print $tmparray[
'label'];
1787 $totalarray[
'nbfield']++;
1791 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1792 print
'<td class="center">';
1793 if (empty($typenArray)) {
1794 $typenArray = $formcompany->typent_array(1);
1796 print $typenArray[$obj->typent_code];
1799 $totalarray[
'nbfield']++;
1804 if (!empty($arrayfields[
'cf.date_commande'][
'checked'])) {
1805 print
'<td class="center">';
1807 if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1808 if ($objectstatic->hasDelay()) {
1809 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1814 $totalarray[
'nbfield']++;
1818 if (!empty($arrayfields[
'cf.date_livraison'][
'checked'])) {
1819 print
'<td class="center">';
1821 if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) {
1822 if ($objectstatic->hasDelay()) {
1823 print
' '.img_picto($langs->trans(
"Late").
' : '.$objectstatic->showDelay(),
"warning");
1828 $totalarray[
'nbfield']++;
1832 if (!empty($arrayfields[
'cf.total_ht'][
'checked'])) {
1833 print
'<td class="right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1835 $totalarray[
'nbfield']++;
1838 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ht';
1840 $totalarray[
'val'][
'cf.total_ht'] += $obj->total_ht;
1843 if (!empty($arrayfields[
'cf.total_tva'][
'checked'])) {
1844 print
'<td class="right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
1846 $totalarray[
'nbfield']++;
1849 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_tva';
1851 $totalarray[
'val'][
'cf.total_tva'] += $obj->total_tva;
1854 if (!empty($arrayfields[
'cf.total_ttc'][
'checked'])) {
1855 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1857 $totalarray[
'nbfield']++;
1860 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cf.total_ttc';
1862 $totalarray[
'val'][
'cf.total_ttc'] += $obj->total_ttc;
1866 if (!empty($arrayfields[
'cf.multicurrency_code'][
'checked'])) {
1867 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1869 $totalarray[
'nbfield']++;
1874 if (!empty($arrayfields[
'cf.multicurrency_tx'][
'checked'])) {
1875 print
'<td class="nowrap">';
1876 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1879 $totalarray[
'nbfield']++;
1883 if (!empty($arrayfields[
'cf.multicurrency_total_ht'][
'checked'])) {
1884 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
1886 $totalarray[
'nbfield']++;
1890 if (!empty($arrayfields[
'cf.multicurrency_total_tva'][
'checked'])) {
1891 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva).
"</span></td>\n";
1893 $totalarray[
'nbfield']++;
1897 if (!empty($arrayfields[
'cf.multicurrency_total_ttc'][
'checked'])) {
1898 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
1900 $totalarray[
'nbfield']++;
1905 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1907 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1908 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1909 print $hookmanager->resPrint;
1911 if (!empty($arrayfields[
'cf.date_creation'][
'checked'])) {
1912 print
'<td class="center nowrap">';
1913 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1916 $totalarray[
'nbfield']++;
1920 if (!empty($arrayfields[
'cf.tms'][
'checked'])) {
1921 print
'<td class="center nowrap">';
1922 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1925 $totalarray[
'nbfield']++;
1929 if (!empty($arrayfields[
'cf.fk_statut'][
'checked'])) {
1930 print
'<td class="right nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).
'</td>';
1932 $totalarray[
'nbfield']++;
1936 if (!empty($arrayfields[
'cf.billed'][
'checked'])) {
1937 print
'<td class="center">'.yn($obj->billed).
'</td>';
1939 $totalarray[
'nbfield']++;
1944 if (!empty($arrayfields[
'cf.date_valid'][
'checked'])) {
1945 print
'<td class="center">';
1949 $totalarray[
'nbfield']++;
1953 if (!empty($arrayfields[
'cf.date_approve'][
'checked'])) {
1954 print
'<td class="center">';
1958 $totalarray[
'nbfield']++;
1962 if (!empty($arrayfields[
'cf.note_public'][
'checked'])) {
1963 print
'<td class="center">';
1967 $totalarray[
'nbfield']++;
1972 if (!empty($arrayfields[
'cf.note_private'][
'checked'])) {
1973 print
'<td class="center">';
1977 $totalarray[
'nbfield']++;
1983 print
'<td class="nowrap center">';
1984 if ($massactionbutton || $massaction) {
1986 if (in_array($obj->rowid, $arrayofselected)) {
1989 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1994 $totalarray[
'nbfield']++;
1999 $total += $obj->total_ht;
2000 $subtotal += $obj->total_ht;
2005 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2010 foreach ($arrayfields as $key => $val) {
2011 if (!empty($val[
'checked'])) {
2015 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2020 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
2021 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2022 print $hookmanager->resPrint;
2024 print
'</table>'.
"\n";
2027 print
'</form>'.
"\n";
2029 $hidegeneratedfilelistifempty = 1;
2030 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2031 $hidegeneratedfilelistifempty = 0;
2035 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2036 $urlsource .= str_replace(
'&',
'&', $param);
2038 $filedir = $diroutputmassaction;
2039 $genallowed = $permissiontoread;
2040 $delallowed = $permissiontoadd;
2042 print $formfile->showdocuments(
'massfilesarea_supplier_order',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage predefined suppliers products.
Class to manage absolute discounts.
Class to manage suppliers invoices.
Class to manage suppliers.
Class to manage projects.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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 dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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...
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
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.