43require
'../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
50if (isModEnabled(
'margin')) {
51 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
58if (isModEnabled(
'category')) {
59 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
60 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcategory.class.php';
72$langs->loadLangs(array(
'orders',
'sendings',
'deliveries',
'companies',
'compta',
'bills',
'stocks',
'products'));
75$action =
GETPOST(
'action',
'aZ09');
76$massaction =
GETPOST(
'massaction',
'alpha');
78$confirm =
GETPOST(
'confirm',
'alpha');
79$toselect =
GETPOST(
'toselect',
'array');
80$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'orderlist';
81$optioncss =
GETPOST(
'optioncss',
'alpha');
85 $userschilds = $user->getAllChildIds();
87 $userschilds = array();
91$search_datecloture_start =
GETPOSTINT(
'search_datecloture_start');
92if (empty($search_datecloture_start)) {
95$search_datecloture_end =
GETPOSTINT(
'search_datecloture_end');
96if (empty($search_datecloture_end)) {
106$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
107$searchCategoryOrderOperator = 0;
108if (GETPOSTISSET(
'formfilteraction')) {
109 $searchCategoryOrderOperator =
GETPOSTINT(
'search_category_order_operator');
113$searchCategoryOrderList =
GETPOST(
'search_category_order_list',
'array');
114$search_product_category =
GETPOST(
'search_product_category',
'intcomma');
115$search_id =
GETPOST(
'search_id',
'int');
116$search_ref =
GETPOST(
'search_ref',
'alpha') !=
'' ?
GETPOST(
'search_ref',
'alpha') :
GETPOST(
'sref',
'alpha');
117$search_ref_ext =
GETPOST(
'search_ref_ext',
'alpha');
118$search_ref_customer =
GETPOST(
'search_ref_customer',
'alpha');
119$search_company =
GETPOST(
'search_company',
'alpha');
120$search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
121$search_parent_name = trim(
GETPOST(
'search_parent_name',
'alphanohtml'));
122$search_town =
GETPOST(
'search_town',
'alpha');
123$search_zip =
GETPOST(
'search_zip',
'alpha');
124$search_state =
GETPOST(
'search_state',
'alpha');
125$search_country =
GETPOST(
'search_country',
'aZ09');
126$search_type_thirdparty =
GETPOST(
'search_type_thirdparty',
'intcomma');
127$search_user =
GETPOST(
'search_user',
'intcomma');
128$search_sale =
GETPOST(
'search_sale',
'intcomma');
129$search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
130$search_total_vat =
GETPOST(
'search_total_vat',
'alpha');
131$search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
132$search_warehouse =
GETPOST(
'search_warehouse',
'intcomma');
133$search_note_public =
GETPOST(
'search_note_public',
'alphanohtml');
134$search_note_private =
GETPOST(
'search_note_private',
'alphanohtml');
136$search_module_source =
GETPOST(
'search_module_source',
'alphanohtml');
137$search_pos_source =
GETPOST(
'search_pos_source',
'alphanohtml');
139$search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
140$search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
141$search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
142$search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
143$search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
145$search_login =
GETPOST(
'search_login',
'alpha');
146$search_categ_cus =
GETPOST(
"search_categ_cus",
'intcomma');
147$search_billed =
GETPOST(
'search_billed',
'intcomma');
148$search_status =
GETPOST(
'search_status',
'intcomma');
149$search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
150$search_project =
GETPOST(
'search_project',
'alpha');
151$search_shippable =
GETPOST(
'search_shippable',
'aZ09');
153$search_fk_cond_reglement =
GETPOST(
'search_fk_cond_reglement',
'intcomma');
154$search_fk_shipping_method =
GETPOST(
'search_fk_shipping_method',
'intcomma');
155$search_fk_mode_reglement =
GETPOST(
'search_fk_mode_reglement',
'intcomma');
156$search_fk_input_reason =
GETPOST(
'search_fk_input_reason',
'intcomma');
158$search_option =
GETPOST(
'search_option',
'alpha');
159if ($search_option ==
'late') {
160 $search_status =
'-2';
162$search_orderday =
'';
163$search_ordermonth =
'';
164$search_orderyear =
'';
165$search_deliveryday =
'';
166$search_deliverymonth =
'';
167$search_deliveryyear =
'';
169$search_import_key = trim(
GETPOST(
"search_import_key",
"alpha"));
171$diroutputmassaction =
$conf->order->multidir_output[
$conf->entity].
'/temp/massgeneration/'.$user->id;
175$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
176$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
178if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
182$offset = $limit * $page;
183$pageprev = $page - 1;
184$pagenext = $page + 1;
186 $sortfield =
'c.ref';
192$show_shippable_command =
GETPOST(
'show_shippable_command',
'aZ09');
196$hookmanager->initHooks(array(
'orderlist'));
200$extrafields->fetch_name_optionals_label(
$object->table_element);
201$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
204$fieldstosearchall = array(
206 'c.ref_client' =>
'RefCustomerOrder',
207 'pd.description' =>
'Description',
208 's.nom' =>
"ThirdParty",
209 's.name_alias' =>
"AliasNameShort",
212 'c.note_public' =>
'NotePublic',
214if (empty($user->socid)) {
215 $fieldstosearchall[
"c.note_private"] =
"NotePrivate";
219$showpos = (isModEnabled(
'cashdesk') || isModEnabled(
'takepos') ||
getDolGlobalInt(
'ORDER_SHOW_POS')) ?
'1' :
'0';
221$checkedtypetiers =
'0';
223 'c.rowid' => array(
'label' =>
"ID",
'checked' =>
'1',
'enabled' => (
string)
getDolGlobalInt(
'MAIN_SHOW_TECHNICAL_ID'),
'position' => 1),
224 'c.ref' => array(
'label' =>
"Ref",
'checked' =>
'1',
'position' => 5,
'searchall' => 1),
225 'c.ref_ext' => array(
'label' =>
"RefExt",
'checked' =>
'1',
'position' => 5,
'visible' => 0,
'searchall' => 1),
226 'c.ref_client' => array(
'label' =>
"RefCustomerOrder",
'checked' =>
'-1',
'position' => 10,
'searchall' => 1),
227 'p.ref' => array(
'label' =>
"ProjectRef",
'langfile' =>
'projects',
'checked' =>
'-1',
'enabled' => (!isModEnabled(
'project') ?
'0' :
'1'),
'position' => 20),
228 'p.title' => array(
'label' =>
"ProjectLabel",
'langfile' =>
'projects',
'checked' =>
'0',
'enabled' => (!isModEnabled(
'project') ?
'0' :
'1'),
'position' => 25),
229 's.nom' => array(
'label' =>
"ThirdParty",
'checked' =>
'1',
'position' => 30,
'searchall' => 1),
230 's.name_alias' => array(
'label' =>
"AliasNameShort",
'checked' =>
'-1',
'position' => 31,
'searchall' => 1),
231 's2.nom' => array(
'label' =>
'ParentCompany',
'position' => 32,
'checked' =>
'0'),
232 's.town' => array(
'label' =>
"Town",
'checked' =>
'-1',
'position' => 35,
'searchall' => 1),
233 's.zip' => array(
'label' =>
"Zip",
'checked' =>
'-1',
'position' => 40,
'searchall' => 1),
234 'state.nom' => array(
'label' =>
"StateShort",
'checked' =>
'0',
'position' => 45),
235 'country.code_iso' => array(
'label' =>
"Country",
'checked' =>
'0',
'position' => 50),
236 'typent.code' => array(
'label' =>
"ThirdPartyType",
'checked' => (string) $checkedtypetiers,
'position' => 55),
237 'c.date_commande' => array(
'label' =>
"OrderDateShort",
'checked' =>
'1',
'position' => 60,
'csslist' =>
'nowraponall'),
238 'c.delivery_date' => array(
'label' =>
"DateDeliveryPlanned",
'checked' =>
'1',
'enabled' => (string) (int) !
getDolGlobalString(
'ORDER_DISABLE_DELIVERY_DATE'),
'position' => 65,
'csslist' =>
'nowraponall'),
239 'c.fk_shipping_method' => array(
'label' =>
"SendingMethod",
'checked' =>
'-1',
'position' => 66 ,
'enabled' => (string) (int) isModEnabled(
"shipping")),
240 'c.fk_cond_reglement' => array(
'label' =>
"PaymentConditionsShort",
'checked' =>
'-1',
'position' => 67),
241 'c.fk_mode_reglement' => array(
'label' =>
"PaymentMode",
'checked' =>
'-1',
'position' => 68),
242 'c.fk_input_reason' => array(
'label' =>
"Origin",
'checked' =>
'-1',
'position' => 69),
243 'c.module_source' => array(
'label' =>
"POSModule",
'langfile' =>
'cashdesk',
'checked' => ($contextpage ==
'poslist' ?
'1' :
'0'),
'enabled' => $showpos,
'position' => 90),
244 'c.pos_source' => array(
'label' =>
"POSTerminal",
'langfile' =>
'cashdesk',
'checked' => ($contextpage ==
'poslist' ?
'1' :
'0'),
'enabled' => $showpos,
'position' => 91),
245 'c.total_ht' => array(
'label' =>
"AmountHT",
'checked' =>
'1',
'position' => 75),
246 'c.total_vat' => array(
'label' =>
"AmountVAT",
'checked' =>
'0',
'position' => 80),
247 'c.total_ttc' => array(
'label' =>
"AmountTTC",
'checked' =>
'0',
'position' => 85),
248 'c.multicurrency_code' => array(
'label' =>
'Currency',
'checked' =>
'0',
'enabled' => (!isModEnabled(
"multicurrency") ?
'0' :
'1'),
'position' => 92),
249 'c.multicurrency_tx' => array(
'label' =>
'CurrencyRate',
'checked' =>
'0',
'enabled' => (!isModEnabled(
"multicurrency") ?
'0' :
'1'),
'position' => 95),
250 'c.multicurrency_total_ht' => array(
'label' =>
'MulticurrencyAmountHT',
'checked' =>
'0',
'enabled' => (!isModEnabled(
"multicurrency") ?
'0' :
'1'),
'position' => 100),
251 'c.multicurrency_total_vat' => array(
'label' =>
'MulticurrencyAmountVAT',
'checked' =>
'0',
'enabled' => (!isModEnabled(
"multicurrency") ?
'0' :
'1'),
'position' => 105),
252 'c.multicurrency_total_ttc' => array(
'label' =>
'MulticurrencyAmountTTC',
'checked' =>
'0',
'enabled' => (!isModEnabled(
"multicurrency") ?
'0' :
'1'),
'position' => 110),
253 'u.login' => array(
'label' =>
"Author",
'checked' =>
'-1',
'position' => 115),
254 'sale_representative' => array(
'label' =>
"SaleRepresentativesOfThirdParty",
'checked' =>
'0',
'position' => 116),
255 'total_pa' => array(
'label' => (
getDolGlobalString(
'MARGIN_TYPE') ==
'1' ?
'BuyingPrice' :
'CostPrice'),
'checked' =>
'0',
'position' => 300,
'enabled' => (string) (int) (!isModEnabled(
'margin') || !$user->hasRight(
"margins",
"liretous") ? 0 : 1)),
256 'total_margin' => array(
'label' =>
'Margin',
'checked' =>
'0',
'position' => 301,
'enabled' => (string) (int) (!isModEnabled(
'margin') || !$user->hasRight(
"margins",
"liretous") ? 0 : 1)),
257 'total_margin_rate' => array(
'label' =>
'MarginRate',
'checked' =>
'0',
'position' => 302,
'enabled' => (string) (int) (!isModEnabled(
'margin') || !$user->hasRight(
"margins",
"liretous") || !
getDolGlobalString(
'DISPLAY_MARGIN_RATES') ? 0 : 1)),
258 'total_mark_rate' => array(
'label' =>
'MarkRate',
'checked' =>
'0',
'position' => 303,
'enabled' => (string) (int) (!isModEnabled(
'margin') || !$user->hasRight(
"margins",
"liretous") || !
getDolGlobalString(
'DISPLAY_MARK_RATES') ? 0 : 1)),
259 'c.datec' => array(
'label' =>
"DateCreation",
'checked' =>
'0',
'position' => 120),
260 'c.tms' => array(
'label' =>
"DateModificationShort",
'checked' =>
'0',
'position' => 125),
261 'c.date_cloture' => array(
'label' =>
"DateClosing",
'checked' =>
'0',
'position' => 130),
262 'c.note_public' => array(
'label' =>
'NotePublic',
'checked' =>
'0',
'enabled' => (string) (int) (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES')),
'position' => 135,
'searchall' => 1),
263 'c.note_private' => array(
'label' =>
'NotePrivate',
'checked' =>
'0',
'enabled' => (string) (int) (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'position' => 140),
264 'shippable' => array(
'label' =>
"Shippable",
'checked' =>
'1',
'enabled' => (string) (int) (isModEnabled(
"shipping")),
'position' => 990),
265 'c.facture' => array(
'label' =>
"Billed",
'checked' =>
'1',
'enabled' => (string) (int) (!
getDolGlobalString(
'WORKFLOW_BILL_ON_SHIPMENT')),
'position' => 995),
266 'c.import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' =>
'1',
'visible' => -2,
'position' => 999),
267 'c.fk_statut' => array(
'label' =>
"Status",
'checked' =>
'1',
'position' => 1000)
270 unset($arrayfields[
'c.note_private']);
272$parameters = array(
'fieldstosearchall' => $fieldstosearchall);
273$reshook = $hookmanager->executeHooks(
'completeFieldsToSearchAll', $parameters, $object, $action);
275 $fieldstosearchall = empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall'];
276} elseif ($reshook == 0) {
277 $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall']);
281include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
291 $socid = $user->socid;
294$permissiontoreadallthirdparty = $user->hasRight(
'societe',
'client',
'voir');
295$permissiontoread =
false;
296$permissiontovalidate =
false;
297$permissiontoclose =
false;
298$permissiontocancel =
false;
299$permissiontosendbymail =
false;
312if (
GETPOST(
'cancel',
'alpha')) {
316if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createbills') {
320$parameters = array(
'socid' => $socid,
'arrayfields' => &$arrayfields);
321$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
326if (empty($reshook)) {
328 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
331 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
334 $search_product_category =
'';
335 $searchCategoryOrderList = array();
338 $search_ref_ext =
'';
339 $search_ref_customer =
'';
340 $search_company =
'';
341 $search_company_alias =
'';
342 $search_parent_name =
'';
343 $search_module_source =
'';
344 $search_pos_source =
'';
349 $search_country =
'';
350 $search_type_thirdparty =
'';
351 $search_total_ht =
'';
352 $search_total_vat =
'';
353 $search_total_ttc =
'';
354 $search_warehouse =
'';
355 $search_note_public =
'';
356 $search_note_private =
'';
357 $search_multicurrency_code =
'';
358 $search_multicurrency_tx =
'';
359 $search_multicurrency_montant_ht =
'';
360 $search_multicurrency_montant_vat =
'';
361 $search_multicurrency_montant_ttc =
'';
363 $search_dateorder_start =
'';
364 $search_dateorder_end =
'';
365 $search_datedelivery_start =
'';
366 $search_datedelivery_end =
'';
367 $search_project_ref =
'';
368 $search_project =
'';
371 $search_datecloture_start =
'';
372 $search_datecloture_end =
'';
373 $search_fk_cond_reglement =
'';
374 $search_fk_shipping_method =
'';
375 $search_fk_mode_reglement =
'';
376 $search_fk_input_reason =
'';
378 $search_import_key =
'';
379 $search_categ_cus = 0;
383 $search_array_options = array();
385 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
386 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
391 $objectclass =
'Commande';
392 $objectlabel =
'Orders';
393 $permissiontoread = $user->hasRight(
"commande",
"lire");
394 $permissiontoadd = $user->hasRight(
"commande",
"creer");
395 $permissiontodelete = $user->hasRight(
"commande",
"supprimer");
397 $permissiontovalidate = $user->hasRight(
"commande",
"order_advance",
"validate");
398 $permissiontoclose = $user->hasRight(
"commande",
"order_advance",
"close");
399 $permissiontocancel = $user->hasRight(
"commande",
"order_advance",
"annuler");
400 $permissiontosendbymail = $user->hasRight(
"commande",
"order_advance",
"send");
402 $permissiontovalidate = $user->hasRight(
"commande",
"creer");
403 $permissiontoclose = $user->hasRight(
"commande",
"creer");
404 $permissiontocancel = $user->hasRight(
"commande",
"creer");
405 $permissiontosendbymail = $user->hasRight(
"commande",
"creer");
407 $uploaddir =
$conf->order->multidir_output[
$conf->entity];
408 $triggersendname =
'ORDER_SENTBYMAIL';
411 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
413 if ($massaction ==
'confirm_createbills') {
414 $orders =
GETPOST(
'toselect',
'array');
415 $createbills_onebythird =
GETPOSTINT(
'createbills_onebythird');
416 $validate_invoices =
GETPOSTINT(
'validate_invoices');
421 $TFactThird = array();
422 $TFactThirdNbLines = array();
424 $nb_bills_created = 0;
430 $nbOrders = is_array($orders) ? count($orders) : 1;
433 foreach ($orders as $id_order) {
435 if ($cmd->fetch($id_order) <= 0) {
438 $cmd->fetch_thirdparty();
441 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
444 $objecttmp = $TFactThird[$cmd->socid];
447 $objecttmp->socid = $cmd->socid;
448 $objecttmp->thirdparty = $cmd->thirdparty;
450 $objecttmp->type = $objecttmp::TYPE_STANDARD;
451 $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id;
452 $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id;
453 $objecttmp->demand_reason_id = !empty($cmd->demand_reason_id) ? $cmd->demand_reason_id : $cmd->thirdparty->demand_reason_id;
455 $objecttmp->fk_project = $cmd->fk_project;
456 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
457 if (empty($createbills_onebythird)) {
458 $objecttmp->ref_client = $cmd->ref_client;
461 if (empty($objecttmp->note_public) &&
getDolGlobalInt(
"MAXREFONDOC", 10)>0) {
462 $objecttmp->note_public = $langs->transnoentities(
"Orders");
466 if (empty($datefacture)) {
470 $objecttmp->date = $datefacture;
471 $objecttmp->origin =
'commande';
472 $objecttmp->origin_id = $id_order;
474 $objecttmp->array_options = $cmd->array_options;
476 $res = $objecttmp->create($user);
480 $lastref = $objecttmp->ref;
481 $lastid = $objecttmp->id;
483 $TFactThird[$cmd->socid] = $objecttmp;
484 $TFactThirdNbLines[$cmd->socid] = 0;
486 $langs->load(
"errors");
487 $errors[] = $cmd->ref.
' : '.$langs->trans($objecttmp->errors[0]);
492 if ($objecttmp->id > 0) {
493 $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order);
496 $errors[] = $cmd->ref.
' : '.$langs->trans($objecttmp->errors[0]);
501 $lines = $cmd->lines;
502 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
504 $lines = $cmd->lines;
508 $num = count($lines);
509 $array_options = array();
511 for ($i = 0; $i < $num; $i++) {
512 $desc = ($lines[$i]->desc ? $lines[$i]->desc :
'');
514 if (!empty($createbills_onebythird)) {
518 if ($lines[$i]->subprice < 0 && !
getDolGlobalString(
'INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN')) {
521 $discount->fk_soc = $objecttmp->socid;
522 $discount->socid = $objecttmp->socid;
523 $discount->amount_ht = abs($lines[$i]->total_ht);
524 $discount->amount_tva = abs($lines[$i]->total_tva);
525 $discount->amount_ttc = abs($lines[$i]->total_ttc);
526 $discount->tva_tx = $lines[$i]->tva_tx;
527 $discount->fk_user = $user->id;
528 $discount->description = $desc;
529 $discountid = $discount->create($user);
530 if ($discountid > 0) {
531 $result = $objecttmp->insert_discount($discountid);
540 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
543 if ($lines[$i]->date_debut_prevue) {
544 $date_start = $lines[$i]->date_debut_prevue;
546 if ($lines[$i]->date_debut_reel) {
547 $date_start = $lines[$i]->date_debut_reel;
549 if ($lines[$i]->date_start) {
550 $date_start = $lines[$i]->date_start;
554 if ($lines[$i]->date_fin_prevue) {
555 $date_end = $lines[$i]->date_fin_prevue;
557 if ($lines[$i]->date_fin_reel) {
558 $date_end = $lines[$i]->date_fin_reel;
560 if ($lines[$i]->date_end) {
561 $date_end = $lines[$i]->date_end;
564 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
569 if (method_exists($lines[$i],
'fetch_optionals')) {
570 $lines[$i]->fetch_optionals();
571 $array_options = $lines[$i]->array_options;
574 $objecttmp->context[
'createfromclone'] =
'createfromclone';
576 $rang = ($nbOrders > 1) ? -1 : $lines[$i]->rang;
578 if (!empty($createbills_onebythird)) {
579 $TFactThirdNbLines[$cmd->socid]++;
580 $rang = $TFactThirdNbLines[$cmd->socid];
583 $result = $objecttmp->addline(
585 $lines[$i]->subprice,
588 $lines[$i]->localtax1_tx,
589 $lines[$i]->localtax2_tx,
590 $lines[$i]->fk_product,
591 $lines[$i]->remise_percent,
595 $lines[$i]->info_bits,
596 $lines[$i]->fk_remise_except,
601 $lines[$i]->special_code,
605 $lines[$i]->fk_fournprice,
614 if (!empty($lines[$i]->extraparams)) {
616 $factureLine->id = $result;
617 $factureLine->extraparams = $lines[$i]->extraparams;
618 $factureLine->setExtraParameters();
625 $errors[] = $objecttmp->error;
629 if ($result > 0 && $lines[$i]->product_type == 9) {
630 $fk_parent_line = $result;
638 $objecttmp->note_public =
dol_concatdesc($objecttmp->note_public, $langs->transnoentities($cmd->ref).(empty($cmd->ref_client) ?
'' :
' ('.$cmd->ref_client.
')'));
639 $objecttmp->update($user);
644 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
645 $TFactThird[$cmd->socid] = $objecttmp;
647 $TFact[$objecttmp->id] = $objecttmp;
652 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
655 if (!$error && $validate_invoices) {
656 $massaction = $action =
'builddoc';
658 foreach ($TAllFact as &$objecttmp) {
659 $result = $objecttmp->validate($user);
666 $id = $objecttmp->id;
670 $upload_dir =
$conf->facture->dir_output;
671 $permissiontoadd = $user->hasRight(
'facture',
'creer');
676 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
680 $massaction = $action =
'confirm_createbills';
686 if ($nb_bills_created == 1) {
687 if (
getDolGlobalInt(
'MAIN_MASSACTION_CREATEBILLS_REDIRECT_IF_ONE') == 1) {
689 header(
'Location: '.DOL_URL_ROOT.
'/compta/facture/card.php?id='.urlencode((
string) $lastid));
692 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
693 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?id='.urlencode((
string) ($lastid)).
'">'.$lastref.
'</a>', $texttoshow);
696 if (
getDolGlobalInt(
'MAIN_MASSACTION_CREATEBILLS_REDIRECT_IF_MANY') == 1) {
698 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills');
701 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
707 $param .=
'&mode='.urlencode($mode);
709 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
710 $param .=
'&contextpage='.urlencode($contextpage);
712 if ($limit > 0 && $limit !=
$conf->liste_limit) {
713 $param .=
'&limit='.((int) $limit);
715 if ($optioncss !=
'') {
716 $param .=
'&optioncss='.urlencode($optioncss);
719 $param .=
'&search_all='.urlencode($search_all);
722 $param .=
'&show_files='.urlencode((
string) ($show_files));
725 $param .=
'&socid='.urlencode((
string) ($socid));
727 if ($search_status !=
'') {
728 $param .=
'&search_status='.urlencode($search_status);
730 if ($search_option) {
731 $param .=
"&search_option=".urlencode($search_option);
733 if ($search_orderday) {
734 $param .=
'&search_orderday='.urlencode($search_orderday);
736 if ($search_ordermonth) {
737 $param .=
'&search_ordermonth='.urlencode($search_ordermonth);
739 if ($search_orderyear) {
740 $param .=
'&search_orderyear='.urlencode($search_orderyear);
742 if ($search_deliveryday) {
743 $param .=
'&search_deliveryday='.urlencode($search_deliveryday);
745 if ($search_deliverymonth) {
746 $param .=
'&search_deliverymonth='.urlencode($search_deliverymonth);
748 if ($search_deliveryyear) {
749 $param .=
'&search_deliveryyear='.urlencode($search_deliveryyear);
752 $param .=
'&search_id='.urlencode((
string) $search_id);
755 $param .=
'&search_ref='.urlencode($search_ref);
757 if ($search_ref_ext) {
758 $param .=
'&search_ref_ext='.urlencode($search_ref_ext);
760 if ($search_company) {
761 $param .=
'&search_company='.urlencode($search_company);
763 if ($search_ref_customer) {
764 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
766 if ($search_user > 0) {
767 $param .=
'&search_user='.urlencode((
string) ($search_user));
769 if ($search_sale > 0) {
770 $param .=
'&search_sale='.urlencode((
string) ($search_sale));
772 if ($search_total_ht !=
'') {
773 $param .=
'&search_total_ht='.urlencode($search_total_ht);
775 if ($search_total_vat !=
'') {
776 $param .=
'&search_total_vat='.urlencode($search_total_vat);
778 if ($search_total_ttc !=
'') {
779 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
781 if ($search_project_ref >= 0) {
782 $param .=
"&search_project_ref=".urlencode($search_project_ref);
784 if ($search_project !=
'') {
785 $param .=
"&search_project=".urlencode($search_project);
787 if ($search_billed !=
'') {
788 $param .=
'&search_billed='.urlencode($search_billed);
791 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
797 $_GET[
"origin"] = $_POST[
"origin"];
798 $_GET[
"originid"] = $_POST[
"originid"];
799 if (!empty($errors)) {
809if ($action ==
'validate' && $permissiontoadd && $objectclass !==
null) {
810 if (
GETPOST(
'confirm') ==
'yes') {
812 $objecttmp =
new $objectclass($db);
815 foreach ($toselect as $checked) {
816 if ($objecttmp->fetch($checked)) {
817 if ($objecttmp->status == $objecttmp::STATUS_DRAFT) {
818 if (!empty($objecttmp->fk_warehouse)) {
819 $idwarehouse = $objecttmp->fk_warehouse;
823 if ($objecttmp->valid($user, $idwarehouse) > 0) {
824 setEventMessages($langs->trans(
'hasBeenValidated', $objecttmp->ref),
null,
'mesgs');
830 $langs->load(
"errors");
831 setEventMessages($langs->trans(
'ErrorIsNotADraft', $objecttmp->ref),
null,
'errors');
846if ($action ==
'shipped' && $permissiontoadd && $objectclass !==
null) {
847 if (
GETPOST(
'confirm') ==
'yes') {
849 $objecttmp =
new $objectclass($db);
852 foreach ($toselect as $checked) {
853 if ($objecttmp->fetch($checked)) {
854 if ($objecttmp->status == $objecttmp::STATUS_VALIDATED || $objecttmp->status == $objecttmp::STATUS_SHIPMENTONPROCESS || $objecttmp->status == $objecttmp::STATUS_CLOSED) {
855 $result = $objecttmp->cloture($user);
857 setEventMessages($langs->trans(
'StatusOrderDelivered', $objecttmp->ref),
null,
'mesgs');
858 } elseif ($result < 0) {
859 setEventMessages($langs->trans(
'ErrorOrderStatusCantBeSetToDelivered'),
null,
'errors');
863 $langs->load(
"errors");
864 setEventMessages($langs->trans(
'ErrorObjectHasWrongStatus', $objecttmp->ref),
null,
'errors');
881if (!$error && $massaction ===
'setbilled' && $permissiontoclose && $objectclass !==
null) {
884 $objecttmp =
new $objectclass($db);
886 foreach ($toselect as $toselectid) {
887 $result = $objecttmp->fetch($toselectid);
889 $result = $objecttmp->classifyBilled($user, 0);
917$form =
new Form($db);
921if (isModEnabled(
'margin')) {
924$companystatic =
new Societe($db);
925$company_url_list = array();
927$projectstatic =
new Project($db);
931$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
932$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
934$title = $langs->trans(
"Orders");
935$help_url =
"EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
941 $sql =
'SELECT DISTINCT';
943$sql .=
' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client,';
944$sql .=
" s.parent as fk_parent,";
945$sql .=
" s2.nom as name2,";
946$sql .=
" typent.code as typent_code,";
947$sql .=
" state.code_departement as state_code, state.nom as state_name,";
948$sql .=
" country.code as country_code,";
949$sql .=
' c.rowid, c.ref, c.ref_ext, c.total_ht, c.total_tva, c.total_ttc, c.ref_client, c.fk_user_author,';
950$sql .=
' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,';
951$sql .=
' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as delivery_date, c.fk_statut, c.facture as billed,';
952$sql .=
' c.date_creation as date_creation, c.tms as date_modification, c.date_cloture as date_cloture,';
953$sql .=
' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
954$sql .=
' c.fk_input_reason, c.import_key,';
955$sql .=
" c.module_source, c.pos_source,";
956$sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
957$sql .=
' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
960if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
961 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
962 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
967$parameters = array();
968$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
969$sql .= $hookmanager->resPrint;
970$sql = preg_replace(
'/,\s*$/',
'', $sql);
974$sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
975$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s2 ON s2.rowid = s.parent";
976$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
977$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
978$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
979$sql .=
', '.MAIN_DB_PREFIX.
'commande as c';
980if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
981 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_extrafields as ef on (c.rowid = ef.fk_object)";
984 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commandedet as pd ON c.rowid = pd.fk_commande';
986$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = c.fk_projet";
987$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON c.fk_user_author = u.rowid';
989$parameters = array();
990$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
991$sql .= $hookmanager->resPrint;
993$sql .=
' WHERE c.fk_soc = s.rowid';
994$sql .=
' AND c.entity IN ('.getEntity(
'commande').
')';
996 $sql .=
' AND s.rowid = '.((int) $socid);
999if (empty($user->socid) && !$permissiontoreadallthirdparty) {
1000 $sql .=
" AND (EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $user->id).
")";
1002 $sql .=
" OR EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user IN (".$db->sanitize(implode(
',', $userschilds)).
"))";
1007if ($search_id > 0) {
1013if ($search_ref_ext) {
1016if ($search_ref_customer) {
1019if ($search_billed !=
'' && $search_billed >= 0) {
1020 $sql .=
' AND c.facture = '.((int) $search_billed);
1022if ($search_status !=
'') {
1023 if ($search_status <= 3 && $search_status >= -1) {
1024 if ($search_status == 1 && !isModEnabled(
'shipping')) {
1025 $sql .=
' AND c.fk_statut IN (1,2)';
1027 $sql .=
' AND c.fk_statut = '.((int) $search_status);
1030 if ($search_status == -2) {
1032 $sql .=
" AND (c.fk_statut IN (1,2))";
1034 if ($search_status == -3) {
1037 $sql .=
' AND (c.fk_statut IN (1,2,3))';
1040if ($search_option ==
'late') {
1043 $sql .=
" AND ((c.date_livraison IS NOT NULL AND c.date_livraison < '".$db->idate(
dol_now() -
$conf->order->client->warning_delay).
"') OR (c.date_livraison IS NULL AND c.date_commande < '".$db->idate(
dol_now() -
$conf->order->client->warning_delay).
"'))";
1045 $sql .=
" AND c.date_commande < '".$db->idate(
dol_now() -
$conf->order->client->warning_delay).
"'";
1048if ($search_datecloture_start) {
1049 $sql .=
" AND c.date_cloture >= '".$db->idate($search_datecloture_start).
"'";
1051if ($search_datecloture_end) {
1052 $sql .=
" AND c.date_cloture <= '".$db->idate($search_datecloture_end).
"'";
1054if ($search_dateorder_start) {
1055 $sql .=
" AND c.date_commande >= '".$db->idate($search_dateorder_start).
"'";
1057if ($search_dateorder_end) {
1058 $sql .=
" AND c.date_commande <= '".$db->idate($search_dateorder_end).
"'";
1060if ($search_datedelivery_start) {
1061 $sql .=
" AND c.date_livraison >= '".$db->idate($search_datedelivery_start).
"'";
1063if ($search_datedelivery_end) {
1064 $sql .=
" AND c.date_livraison <= '".$db->idate($search_datedelivery_end).
"'";
1075if ($search_country) {
1076 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
1078if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
1079 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
1081if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
1082 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
1084 if ($search_company) {
1087 if ($search_company_alias) {
1091if ($search_parent_name) {
1094if ($search_total_ht !=
'') {
1097if ($search_total_vat !=
'') {
1100if ($search_total_ttc !=
'') {
1103if ($search_warehouse !=
'' && $search_warehouse > 0) {
1106if ($search_note_public !=
'') {
1109if ($search_note_private !=
'') {
1112if ($search_multicurrency_code !=
'') {
1113 $sql .=
" AND c.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
1115if ($search_multicurrency_tx !=
'') {
1116 $sql .=
natural_search(
'c.multicurrency_tx', $search_multicurrency_tx, 1);
1118if ($search_multicurrency_montant_ht !=
'') {
1119 $sql .=
natural_search(
'c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
1121if ($search_multicurrency_montant_vat !=
'') {
1122 $sql .=
natural_search(
'c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
1124if ($search_multicurrency_montant_ttc !=
'') {
1125 $sql .=
natural_search(
'c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
1128 $sql .=
natural_search(array(
"u.login",
"u.firstname",
"u.lastname"), $search_login);
1130if ($search_project_ref !=
'') {
1133if ($search_project !=
'') {
1136if ($search_fk_cond_reglement > 0) {
1137 $sql .=
" AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
1139if ($search_fk_shipping_method > 0) {
1140 $sql .=
" AND c.fk_shipping_method = ".((int) $search_fk_shipping_method);
1142if ($search_fk_mode_reglement > 0) {
1143 $sql .=
" AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
1145if ($search_fk_input_reason > 0) {
1146 $sql .=
" AND c.fk_input_reason = ".((int) $search_fk_input_reason);
1148if ($search_module_source) {
1149 $sql .=
natural_search(
"c.module_source", $search_module_source);
1151if ($search_pos_source) {
1154if ($search_import_key) {
1158if ($search_user > 0) {
1159 $sql .=
" AND EXISTS (";
1160 $sql .=
" SELECT ec.fk_c_type_contact, ec.element_id, ec.fk_socpeople";
1161 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact as ec";
1162 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1163 $sql .=
" ON ec.fk_c_type_contact = tc.rowid AND tc.element = 'commande' AND tc.source = 'internal'";
1164 $sql .=
" WHERE ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user).
")";
1167if ($search_sale && $search_sale !=
'-1') {
1168 if ($search_sale == -2) {
1169 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
1170 } elseif ($search_sale > 0) {
1171 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
1176if (!empty($searchCategoryOrderList)) {
1177 $searchCategoryOrderSqlList = array();
1178 $listofcategoryid =
'';
1179 foreach ($searchCategoryOrderList as $searchCategoryOrder) {
1180 if (intval($searchCategoryOrder) == -2) {
1181 $searchCategoryOrderSqlList[] =
"NOT EXISTS (SELECT ck.fk_order FROM ".MAIN_DB_PREFIX.
"categorie_order as ck WHERE c.rowid = ck.fk_order)";
1182 } elseif (intval($searchCategoryOrder) > 0) {
1183 if ($searchCategoryOrderOperator == 0) {
1184 $searchCategoryOrderSqlList[] =
" EXISTS (SELECT ck.fk_order FROM ".MAIN_DB_PREFIX.
"categorie_order as ck WHERE c.rowid = ck.fk_order AND ck.fk_categorie = ".((int) $searchCategoryOrder).
")";
1186 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryOrder);
1190 if ($listofcategoryid) {
1191 $searchCategoryOrderSqlList[] =
" EXISTS (SELECT ck.fk_order FROM ".MAIN_DB_PREFIX.
"categorie_order as ck WHERE c.rowid = ck.fk_order AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
1193 if ($searchCategoryOrderOperator == 1) {
1194 if (!empty($searchCategoryOrderSqlList)) {
1195 $sql .=
" AND (".implode(
' OR ', $searchCategoryOrderSqlList).
")";
1198 if (!empty($searchCategoryOrderSqlList)) {
1199 $sql .=
" AND (".implode(
' AND ', $searchCategoryOrderSqlList).
")";
1205$searchCategoryCustomerOperator =
GETPOSTINT(
'search_category_customer_operator');
1206$searchCategoryCustomerList = array($search_categ_cus);
1207if (!empty($searchCategoryCustomerList)) {
1208 $searchCategoryCustomerSqlList = array();
1209 $listofcategoryid =
'';
1210 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
1211 if (intval($searchCategoryCustomer) == -2) {
1212 $searchCategoryCustomerSqlList[] =
"NOT EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as cs WHERE s.rowid = cs.fk_soc)";
1213 } elseif (intval($searchCategoryCustomer) > 0) {
1214 if ($searchCategoryCustomerOperator == 0) {
1215 $searchCategoryCustomerSqlList[] =
" EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie = ".((int) $searchCategoryCustomer).
")";
1217 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryCustomer);
1221 if ($listofcategoryid) {
1222 $searchCategoryCustomerSqlList[] =
" EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
1224 if ($searchCategoryCustomerOperator == 1) {
1225 if (!empty($searchCategoryCustomerSqlList)) {
1226 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
1229 if (!empty($searchCategoryCustomerSqlList)) {
1230 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
1235$searchCategoryProductOperator =
GETPOSTINT(
'search_category_product_operator');
1236$searchCategoryProductList = array($search_product_category);
1237if (!empty($searchCategoryProductList)) {
1238 $searchCategoryProductSqlList = array();
1239 $listofcategoryid =
'';
1240 foreach ($searchCategoryProductList as $searchCategoryProduct) {
1241 if (intval($searchCategoryProduct) == -2) {
1242 $searchCategoryProductSqlList[] =
"NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product)";
1243 } elseif (intval($searchCategoryProduct) > 0) {
1244 if ($searchCategoryProductOperator == 0) {
1245 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
1247 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
1251 if ($listofcategoryid) {
1252 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
1254 if ($searchCategoryProductOperator == 1) {
1255 if (!empty($searchCategoryProductSqlList)) {
1256 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
1259 if (!empty($searchCategoryProductSqlList)) {
1260 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
1265include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1267$parameters = array();
1268$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1269$sql .= $hookmanager->resPrint;
1272 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
1276$parameters = array();
1277$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
1278$sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
1282$nbtotalofrecords =
'';
1285 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1286 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1287 $resql = $db->query($sqlforcount);
1289 $objforcount = $db->fetch_object($resql);
1290 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1295 if (($page * $limit) > $nbtotalofrecords) {
1303$sql .= $db->order($sortfield, $sortorder);
1305 $sql .= $db->plimit($limit + 1, $offset);
1309$resql = $db->query($sql);
1317 $soc->fetch($socid);
1318 $title = $langs->trans(
'CustomersOrders').
' - '.$soc->name;
1319 if (empty($search_company)) {
1320 $search_company = $soc->name;
1323 $title = $langs->trans(
'CustomersOrders');
1325if (strval($search_status) ==
'0') {
1326 $title .=
' - '.$langs->trans(
'StatusOrderDraftShort');
1328if ($search_status == 1) {
1329 $title .=
' - '.$langs->trans(
'StatusOrderValidatedShort');
1331if ($search_status == 2) {
1332 $title .=
' - '.$langs->trans(
'StatusOrderSentShort');
1334if ($search_status == 3) {
1335 $title .=
' - '.$langs->trans(
'StatusOrderToBillShort');
1337if ($search_status == -1) {
1338 $title .=
' - '.$langs->trans(
'StatusOrderCanceledShort');
1340if ($search_status == -2) {
1341 $title .=
' - '.$langs->trans(
'StatusOrderToProcessShort');
1343if ($search_status == -3) {
1344 $title .=
' - '.$langs->trans(
'StatusOrderValidated').
', '.(!isModEnabled(
'shipping') ?
'' : $langs->trans(
"StatusOrderSent").
', ').$langs->trans(
'StatusOrderToBill');
1346if ($search_status == -4) {
1347 $title .=
' - '.$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort");
1350$num = $db->num_rows($resql);
1352$arrayofselected = is_array($toselect) ? $toselect : array();
1354if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1355 $obj = $db->fetch_object($resql);
1357 header(
"Location: ".DOL_URL_ROOT.
'/commande/card.php?id='.
$id);
1364llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-order page-list');
1366$arrayofselected = is_array($toselect) ? $toselect : array();
1370 $param .=
'&mode='.urlencode($mode);
1372if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1373 $param .=
'&contextpage='.urlencode($contextpage);
1375if ($limit > 0 && $limit !=
$conf->liste_limit) {
1376 $param .=
'&limit='.((int) $limit);
1378if ($optioncss !=
'') {
1379 $param .=
'&optioncss='.urlencode($optioncss);
1382 $param .=
'&show_files='.urlencode((
string) ($show_files));
1385 $param .=
'&search_all='.urlencode($search_all);
1388 $param .=
'&socid='.((int) $socid);
1390if ($search_status !=
'') {
1391 $param .=
'&search_status='.urlencode($search_status);
1393if ($search_option) {
1394 $param .=
"&search_option=".urlencode($search_option);
1396if ($search_datecloture_start) {
1397 $param .=
'&search_datecloture_startday='.dol_print_date($search_datecloture_start,
'%d').
'&search_datecloture_startmonth='.
dol_print_date($search_datecloture_start,
'%m').
'&search_datecloture_startyear='.
dol_print_date($search_datecloture_start,
'%Y');
1399if ($search_datecloture_end) {
1400 $param .=
'&search_datecloture_endday='.dol_print_date($search_datecloture_end,
'%d').
'&search_datecloture_endmonth='.
dol_print_date($search_datecloture_end,
'%m').
'&search_datecloture_endyear='.
dol_print_date($search_datecloture_end,
'%Y');
1402if ($search_dateorder_start) {
1403 $param .=
'&search_dateorder_start_day='.dol_print_date($search_dateorder_start,
'%d').
'&search_dateorder_start_month='.
dol_print_date($search_dateorder_start,
'%m').
'&search_dateorder_start_year='.
dol_print_date($search_dateorder_start,
'%Y');
1405if ($search_dateorder_end) {
1406 $param .=
'&search_dateorder_end_day='.dol_print_date($search_dateorder_end,
'%d').
'&search_dateorder_end_month='.
dol_print_date($search_dateorder_end,
'%m').
'&search_dateorder_end_year='.
dol_print_date($search_dateorder_end,
'%Y');
1408if ($search_datedelivery_start) {
1409 $param .=
'&search_datedelivery_start_day='.dol_print_date($search_datedelivery_start,
'%d').
'&search_datedelivery_start_month='.
dol_print_date($search_datedelivery_start,
'%m').
'&search_datedelivery_start_year='.
dol_print_date($search_datedelivery_start,
'%Y');
1411if ($search_datedelivery_end) {
1412 $param .=
'&search_datedelivery_end_day='.dol_print_date($search_datedelivery_end,
'%d').
'&search_datedelivery_end_month='.
dol_print_date($search_datedelivery_end,
'%m').
'&search_datedelivery_end_year='.
dol_print_date($search_datedelivery_end,
'%Y');
1415 $param .=
'&search_id='.urlencode((
string) $search_id);
1418 $param .=
'&search_ref='.urlencode($search_ref);
1420if ($search_ref_ext) {
1421 $param .=
'&search_ref_ext='.urlencode($search_ref_ext);
1423if ($search_company) {
1424 $param .=
'&search_company='.urlencode($search_company);
1426if ($search_company_alias) {
1427 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1429if ($search_parent_name !=
'') {
1430 $param .=
'&search_parent_name='.urlencode($search_parent_name);
1432if ($search_ref_customer) {
1433 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
1435if ($search_user > 0) {
1436 $param .=
'&search_user='.urlencode((
string) ($search_user));
1438if ($search_sale > 0) {
1439 $param .=
'&search_sale='.urlencode((
string) ($search_sale));
1441if ($search_total_ht !=
'') {
1442 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1444if ($search_total_vat !=
'') {
1445 $param .=
'&search_total_vat='.urlencode($search_total_vat);
1447if ($search_total_ttc !=
'') {
1448 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
1450if ($search_warehouse !=
'') {
1451 $param .=
'&search_warehouse='.urlencode((
string) ($search_warehouse));
1454 $param .=
'&search_login='.urlencode($search_login);
1456if ($search_multicurrency_code !=
'') {
1457 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1459if ($search_multicurrency_tx !=
'') {
1460 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1462if ($search_multicurrency_montant_ht !=
'') {
1463 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1465if ($search_multicurrency_montant_vat !=
'') {
1466 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1468if ($search_multicurrency_montant_ttc !=
'') {
1469 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1471if ($search_project_ref >= 0) {
1472 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1474if ($search_project !=
'') {
1475 $param .=
"&search_project=".urlencode($search_project);
1477if ($search_town !=
'') {
1478 $param .=
'&search_town='.urlencode($search_town);
1480if ($search_zip !=
'') {
1481 $param .=
'&search_zip='.urlencode($search_zip);
1483if ($search_state !=
'') {
1484 $param .=
'&search_state='.urlencode($search_state);
1486if ($search_country !=
'') {
1487 $param .=
'&search_country='.urlencode((
string) ($search_country));
1489if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
1490 $param .=
'&search_type_thirdparty='.urlencode((
string) ($search_type_thirdparty));
1492if ($searchCategoryOrderOperator == 1) {
1493 $param .=
"&search_category_order_operator=".urlencode((
string) ($searchCategoryOrderOperator));
1495foreach ($searchCategoryOrderList as $searchCategoryOrder) {
1496 $param .=
"&search_category_order_list[]=".urlencode($searchCategoryOrder);
1498if ($search_product_category !=
'') {
1499 $param .=
'&search_product_category='.urlencode((
string) ($search_product_category));
1501if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
1502 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
1504if ($search_billed !=
'') {
1505 $param .=
'&search_billed='.urlencode($search_billed);
1507if ($search_fk_cond_reglement > 0) {
1508 $param .=
'&search_fk_cond_reglement='.urlencode((
string) ($search_fk_cond_reglement));
1510if ($search_fk_shipping_method > 0) {
1511 $param .=
'&search_fk_shipping_method='.urlencode((
string) ($search_fk_shipping_method));
1513if ($search_fk_mode_reglement > 0) {
1514 $param .=
'&search_fk_mode_reglement='.urlencode((
string) ($search_fk_mode_reglement));
1516if ($search_fk_input_reason > 0) {
1517 $param .=
'&search_fk_input_reason='.urlencode((
string) ($search_fk_input_reason));
1519if ($search_module_source) {
1520 $param .=
'&search_module_source='.urlencode($search_module_source);
1522if ($search_pos_source) {
1523 $param .=
'&search_pos_source='.urlencode($search_pos_source);
1525if ($search_import_key !=
'') {
1526 $param .=
'&search_import_key='.urlencode($search_import_key);
1530include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1533$parameters = array();
1534$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1535$param .= $hookmanager->resPrint;
1538$arrayofmassactions = array(
1539 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1540 'builddoc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1542if ($permissiontovalidate) {
1543 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1545if ($permissiontoclose) {
1546 $arrayofmassactions[
'preshipped'] =
img_picto(
'',
'dolly',
'class="pictofixedwidth"').$langs->trans(
"ClassifyShipped");
1548if (isModEnabled(
'invoice') && $user->hasRight(
"facture",
"creer")) {
1549 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisCustomer");
1551if ($permissiontoclose) {
1552 $arrayofmassactions[
'setbilled'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"ClassifyBilled");
1554if ($permissiontocancel) {
1555 $arrayofmassactions[
'cancelorders'] =
img_picto(
'',
'close_title',
'class="pictofixedwidth"').$langs->trans(
"CancelOrder");
1557if (!empty($permissiontodelete)) {
1558 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1560if ($permissiontosendbymail) {
1561 $arrayofmassactions[
'presend'] =
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail");
1563if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1564 $arrayofmassactions = array();
1566$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1568$url = DOL_URL_ROOT.
'/commande/card.php?action=create';
1569if (!empty($socid)) {
1570 $url .=
'&socid='.$socid;
1573$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss' =>
'reposition'));
1574$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
1576$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewOrder'),
'',
'fa fa-plus-circle', $url,
'', (
int) (($contextpage ==
'orderlist' || $contextpage ==
'billableorders') && $permissiontoadd));
1579print
'<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
1580if ($optioncss !=
'') {
1581 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1583print
'<input type="hidden" name="token" value="'.newToken().
'">';
1584print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1585print
'<input type="hidden" name="action" value="list">';
1586print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1587print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1588print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1589print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
1590print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1591print
'<input type="hidden" name="page_y" value="">';
1592print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1595print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1597$topicmail =
"SendOrderRef";
1598$modelmail =
"order_send";
1600$trackid =
'ord'.$object->id;
1601include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1603if ($massaction ==
'prevalidate') {
1604 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1606if ($massaction ==
'preshipped') {
1607 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"CloseOrder"), $langs->trans(
"ConfirmCloseOrder"),
"shipped",
null,
'', 0, 200, 500, 1);
1610if ($massaction ==
'createbills') {
1611 print
'<input type="hidden" name="massaction" value="confirm_createbills">';
1613 print
'<table class="noborder centpercent">';
1616 print $langs->trans(
'DateInvoice');
1619 print $form->selectDate(
'',
'', 0, 0, 0,
'', 1, 1);
1624 print $langs->trans(
'CreateOneBillByThird');
1627 print $form->selectyesno(
'createbills_onebythird',
getDolGlobalString(
'MAIN_ORDERLIST_CREATEBILLS_ONEBYTHIRD',
'no'), 1);
1632 print $langs->trans(
'ValidateInvoices');
1636 print $form->selectyesno(
'validate_invoices', 0, 1, 1);
1637 $langs->load(
"errors");
1638 print
' ('.$langs->trans(
"WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal").
')';
1640 print $form->selectyesno(
'validate_invoices', 0, 1);
1642 if (!empty(
$conf->workflow->enabled) &&
getDolGlobalString(
'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER')) {
1643 print
' <span class="opacitymedium">'.$langs->trans(
"IfValidateInvoiceIsNoOrderStayUnbilled").
'</span>';
1645 print
' <span class="opacitymedium">'.$langs->trans(
"OptionToSetOrderBilledNotEnabled").
'</span>';
1651 print
'<div class="center">';
1652 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1653 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1660 foreach ($fieldstosearchall as $key => $val) {
1661 $fieldstosearchall[$key] = $langs->trans($val);
1662 $setupstring .= $key.
"=".$val.
";";
1664 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
1665 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
1670if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'read')) {
1672 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_ORDER, $searchCategoryOrderList,
'minwidth300', $searchCategoryOrderOperator ? $searchCategoryOrderOperator : 0);
1676if ($user->hasRight(
"user",
"user",
"lire")) {
1677 $langs->load(
"commercial");
1678 $moreforfilter .=
'<div class="divsearchfield">';
1679 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1680 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1681 $moreforfilter .=
'</div>';
1684if ($user->hasRight(
"user",
"user",
"lire")) {
1685 $moreforfilter .=
'<div class="divsearchfield">';
1686 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1687 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
null, 0,
'',
'',
'0', 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1688 $moreforfilter .=
'</div>';
1692if (isModEnabled(
'category') && $user->hasRight(
"categorie",
"lire") && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
1693 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1694 $moreforfilter .=
'<div class="divsearchfield">';
1695 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1696 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 0, array(), 1);
1697 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0,
'',
'maxwidth300 widthcentpercentminusx', 1);
1698 $moreforfilter .=
'</div>';
1701if (isModEnabled(
'category') && $user->hasRight(
"categorie",
"lire")) {
1702 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1703 $moreforfilter .=
'<div class="divsearchfield">';
1704 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
1705 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle,
'maxwidth300 widthcentpercentminusx');
1706 $moreforfilter .=
'</div>';
1709if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
1710 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1712 $moreforfilter .=
'<div class="divsearchfield">';
1713 $tmptitle = $langs->trans(
'Warehouse');
1714 $moreforfilter .=
img_picto($tmptitle,
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'', 1, 0, 0, $tmptitle, 0, 0, array(),
'maxwidth250 widthcentpercentminusx');
1715 $moreforfilter .=
'</div>';
1718$parameters = array();
1719$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1720if (empty($reshook)) {
1721 $moreforfilter .= $hookmanager->resPrint;
1723 $moreforfilter = $hookmanager->resPrint;
1726if (!empty($moreforfilter)) {
1727 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1728 print $moreforfilter;
1732$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1733$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1734$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
1735$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1738 $selectedfields .=
'<script>';
1739 $selectedfields .=
' $(document).ready(function() {';
1740 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1741 $selectedfields .=
' $("#checkforselects").click();';
1742 $selectedfields .=
' $("#massaction").val("createbills").change();';
1743 $selectedfields .=
' });';
1744 $selectedfields .=
'</script>';
1747print
'<div class="div-table-responsive">';
1748print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1752print
'<tr class="liste_titre_filter">';
1755 print
'<td class="liste_titre center maxwidthsearch actioncolumn">';
1756 $searchpicto = $form->showFilterButtons(
'left');
1762if (!empty($arrayfields[
'c.rowid'][
'checked'])) {
1763 print
'<td class="liste_titre">';
1764 print
'<input class="flat" size="6" type="text" name="search_id" value="'.dol_escape_htmltag($search_id).
'">';
1769if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1770 print
'<td class="liste_titre">';
1771 print
'<input class="flat maxwidth50imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1775if (!empty($arrayfields[
'c.ref_ext'][
'checked'])) {
1776 print
'<td class="liste_titre">';
1777 print
'<input class="flat maxwidth50imp" type="text" name="search_ref_ext" value="'.dol_escape_htmltag($search_ref_ext).
'">';
1781if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1782 print
'<td class="liste_titre" align="left">';
1783 print
'<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
1787if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1788 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1791if (!empty($arrayfields[
'p.title'][
'checked'])) {
1792 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1795if (!empty($arrayfields[
's.nom'][
'checked'])) {
1796 print
'<td class="liste_titre">';
1797 print
'<input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag((
string) $search_company).
'"'.(!empty($user->socid) ?
" disabled" :
"").
'>';
1801if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1802 print
'<td class="liste_titre">';
1803 print
'<input class="flat maxwidth75imp" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'">';
1807if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1808 print
'<td class="liste_titre">';
1809 print
'<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).
'">';
1813if (!empty($arrayfields[
's.town'][
'checked'])) {
1814 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1817if (!empty($arrayfields[
's.zip'][
'checked'])) {
1818 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1821if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1822 print
'<td class="liste_titre">';
1823 print
'<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1827if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1828 print
'<td class="liste_titre" align="center">';
1829 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1833if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1834 print
'<td class="liste_titre maxwidthonsmartphone center">';
1835 print $form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0, (!
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT') ?
'ASC' :
$conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
1839if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1840 print
'<td class="liste_titre center">';
1841 print
'<div class="nowrapfordate">';
1842 print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1,
'search_dateorder_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1844 print
'<div class="nowrapfordate">';
1845 print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1,
'search_dateorder_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1849if (!empty($arrayfields[
'c.delivery_date'][
'checked'])) {
1850 print
'<td class="liste_titre center">';
1851 print
'<div class="nowrapfordate">';
1852 print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1,
'search_datedelivery_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1854 print
'<div class="nowrapfordate">';
1855 print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1,
'search_datedelivery_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1860if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1861 print
'<td class="liste_titre">';
1862 $form->selectShippingMethod($search_fk_shipping_method,
'search_fk_shipping_method',
'', 1,
'', 1);
1866if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1867 print
'<td class="liste_titre">';
1868 print $form->getSelectConditionsPaiements((
int) $search_fk_cond_reglement,
'search_fk_cond_reglement', 1, 1, 1);
1872if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1873 print
'<td class="liste_titre">';
1874 print $form->select_types_paiements($search_fk_mode_reglement,
'search_fk_mode_reglement',
'', 0, 1, 1, 0, -1,
'', 1);
1878if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1879 print
'<td class="liste_titre">';
1880 $form->selectInputReason($search_fk_input_reason,
'search_fk_input_reason',
'', 1,
'', 1);
1884if (!empty($arrayfields[
'c.module_source'][
'checked'])) {
1885 print
'<td class="liste_titre">';
1886 print
'<input class="flat maxwidth75" type="text" name="search_module_source" value="'.dol_escape_htmltag($search_module_source).
'">';
1890if (!empty($arrayfields[
'c.pos_source'][
'checked'])) {
1891 print
'<td class="liste_titre">';
1892 print
'<input class="flat maxwidth50" type="text" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).
'">';
1896if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
1897 print
'<td class="liste_titre right">';
1898 print
'<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
1902if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1903 print
'<td class="liste_titre right">';
1904 print
'<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).
'">';
1908if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
1909 print
'<td class="liste_titre right">';
1910 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1914if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1915 print
'<td class="liste_titre">';
1916 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1920if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1921 print
'<td class="liste_titre">';
1922 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1926if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1927 print
'<td class="liste_titre right">';
1928 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1932if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1933 print
'<td class="liste_titre right">';
1934 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1938if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1939 print
'<td class="liste_titre right">';
1940 print
'<input class="flat width75" type="text" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1944if (!empty($arrayfields[
'u.login'][
'checked'])) {
1945 print
'<td class="liste_titre">';
1946 print
'<input class="flat width75" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1950if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1951 print
'<td class="liste_titre"></td>';
1953if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1954 print
'<td class="liste_titre right">';
1957if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1958 print
'<td class="liste_titre right">';
1961if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1962 print
'<td class="liste_titre right">';
1965if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1966 print
'<td class="liste_titre right">';
1971if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1972 print
'<td class="liste_titre">';
1976if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1977 print
'<td class="liste_titre">';
1981if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1982 print
'<td class="liste_titre center">';
1983 print
'<div class="nowrapfordate">';
1984 print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1,
'search_datecloture_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1986 print
'<div class="nowrapfordate">';
1987 print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1,
'search_datecloture_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1992if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1993 print
'<td class="liste_titre">';
1994 print
'<input class="flat width75" type="text" name="search_note_public" value="'.dolPrintHTMLForAttribute($search_note_public).
'">';
1998if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1999 print
'<td class="liste_titre">';
2000 print
'<input class="flat width75" type="text" name="search_note_private" value="'.dolPrintHTMLForAttribute($search_note_private).
'">';
2004if (!empty($arrayfields[
'shippable'][
'checked'])) {
2005 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
2008 print
'<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ?
' checked' :
'').
'>';
2009 print $langs->trans(
'ShowShippableStatus');
2011 $show_shippable_command = 1;
2017include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
2020$parameters = array(
'arrayfields' => $arrayfields);
2021$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
2022print $hookmanager->resPrint;
2025if (!empty($arrayfields[
'c.facture'][
'checked'])) {
2026 print
'<td class="liste_titre maxwidthonsmartphone center">';
2027 print $form->selectyesno(
'search_billed', $search_billed, 1, 0, 1, 1);
2032if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
2033 print
'<td class="liste_titre maxwidthonsmartphone center">';
2034 print
'<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).
'">';
2039if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
2040 print
'<td class="liste_titre center parentonrightofpage">';
2041 $liststatus = array(
2045 -2 => $langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort"),
2046 -3 => $langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort").
'+'.$langs->trans(
"StatusOrderDelivered"),
2051 print $form->selectarray(
'search_status', $liststatus, $search_status, -5, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage', 1);
2056 print
'<td class="liste_titre center maxwidthsearch">';
2057 $searchpicto = $form->showFilterButtons();
2076print
'<tr class="liste_titre">';
2080 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
2083if (!empty($arrayfields[
'c.rowid'][
'checked'])) {
2084 print_liste_field_titre($arrayfields[
'c.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'c.rowid',
'', $param,
'', $sortfield, $sortorder,
'center ');
2087if (!empty($arrayfields[
'c.ref'][
'checked'])) {
2088 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref',
'', $param,
'', $sortfield, $sortorder);
2091if (!empty($arrayfields[
'c.ref_ext'][
'checked'])) {
2092 print_liste_field_titre($arrayfields[
'c.ref_ext'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref_ext',
'', $param,
'', $sortfield, $sortorder);
2095if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
2096 print_liste_field_titre($arrayfields[
'c.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref_client',
'', $param,
'', $sortfield, $sortorder);
2099if (!empty($arrayfields[
'p.ref'][
'checked'])) {
2100 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
2103if (!empty($arrayfields[
'p.title'][
'checked'])) {
2104 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
"PHP_SELF"],
"p.title",
"", $param,
'', $sortfield, $sortorder);
2107if (!empty($arrayfields[
's.nom'][
'checked'])) {
2108 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
's.nom',
'', $param,
'', $sortfield, $sortorder);
2111if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2113 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2116if (!empty($arrayfields[
's2.nom'][
'checked'])) {
2117 print_liste_field_titre($arrayfields[
's2.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's2.nom',
'', $param,
'', $sortfield, $sortorder);
2120if (!empty($arrayfields[
's.town'][
'checked'])) {
2121 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
2124if (!empty($arrayfields[
's.zip'][
'checked'])) {
2125 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
2128if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2129 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
2132if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2133 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
2136if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2137 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
2140if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
2141 print_liste_field_titre($arrayfields[
'c.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_commande',
'', $param,
'', $sortfield, $sortorder,
'center ');
2144if (!empty($arrayfields[
'c.delivery_date'][
'checked'])) {
2145 print_liste_field_titre($arrayfields[
'c.delivery_date'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
2148if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
2149 print_liste_field_titre($arrayfields[
'c.fk_shipping_method'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_shipping_method",
"", $param,
'', $sortfield, $sortorder);
2152if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
2153 print_liste_field_titre($arrayfields[
'c.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_cond_reglement",
"", $param,
'', $sortfield, $sortorder);
2156if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
2157 print_liste_field_titre($arrayfields[
'c.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_mode_reglement",
"", $param,
'', $sortfield, $sortorder);
2160if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
2161 print_liste_field_titre($arrayfields[
'c.fk_input_reason'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_input_reason",
"", $param,
'', $sortfield, $sortorder);
2164if (!empty($arrayfields[
'c.module_source'][
'checked'])) {
2165 print_liste_field_titre($arrayfields[
'c.module_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.module_source",
"", $param,
"", $sortfield, $sortorder);
2168if (!empty($arrayfields[
'c.pos_source'][
'checked'])) {
2169 print_liste_field_titre($arrayfields[
'c.pos_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.pos_source",
"", $param,
"", $sortfield, $sortorder);
2172if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
2173 print_liste_field_titre($arrayfields[
'c.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
2176if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
2177 print_liste_field_titre($arrayfields[
'c.total_vat'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
2180if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
2181 print_liste_field_titre($arrayfields[
'c.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
2184if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
2185 print_liste_field_titre($arrayfields[
'c.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
2188if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
2189 print_liste_field_titre($arrayfields[
'c.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
2192if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
2193 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
2196if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
2197 print_liste_field_titre($arrayfields[
'c.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
2200if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
2201 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
2204if (!empty($arrayfields[
'u.login'][
'checked'])) {
2205 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'', $sortfield, $sortorder);
2208if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2209 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
2212if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2213 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
2216if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2217 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
2220if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2221 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
2224if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2225 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
2229if (!empty($arrayfields[
'c.datec'][
'checked'])) {
2230 print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
2233if (!empty($arrayfields[
'c.tms'][
'checked'])) {
2234 print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"c.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
2237if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
2238 print_liste_field_titre($arrayfields[
'c.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
2241if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
2242 print_liste_field_titre($arrayfields[
'c.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_public",
"", $param,
'', $sortfield, $sortorder,
'');
2245if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
2246 print_liste_field_titre($arrayfields[
'c.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_private",
"", $param,
'', $sortfield, $sortorder,
'');
2249if (!empty($arrayfields[
'shippable'][
'checked'])) {
2250 print_liste_field_titre($arrayfields[
'shippable'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
2254include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
2257$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
2258$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2259print $hookmanager->resPrint;
2262if (!empty($arrayfields[
'c.facture'][
'checked'])) {
2263 print_liste_field_titre($arrayfields[
'c.facture'][
'label'], $_SERVER[
"PHP_SELF"],
'c.facture',
'', $param,
'', $sortfield, $sortorder,
'center ');
2267if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
2268 print_liste_field_titre($arrayfields[
'c.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"c.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
2272if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
2273 print_liste_field_titre($arrayfields[
'c.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
2278 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
2285$productstat_cache = array();
2286$productstat_cachevirtual = array();
2287$getNomUrl_cache = array();
2289$generic_commande =
new Commande($db);
2290$generic_product =
new Product($db);
2291$userstatic =
new User($db);
2293$with_margin_info =
false;
2294if (isModEnabled(
'margin') && (
2295 !empty($arrayfields[
'total_pa'][
'checked'])
2296 || !empty($arrayfields[
'total_margin'][
'checked'])
2297 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
2298 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
2301 $with_margin_info =
true;
2313$imaxinloop = ($limit ? min($num, $limit) : $num);
2314while ($i < $imaxinloop) {
2315 $obj = $db->fetch_object($resql);
2320 $typenArray = $formcompany->typent_array(1);
2328 $companystatic->id = $obj->socid;
2329 $companystatic->name = $obj->name;
2330 $companystatic->name_alias = $obj->alias;
2331 $companystatic->client = $obj->client;
2332 $companystatic->fournisseur = $obj->fournisseur;
2333 $companystatic->code_client = $obj->code_client;
2334 $companystatic->email = $obj->email;
2335 $companystatic->phone = $obj->phone;
2336 $companystatic->address = $obj->address;
2337 $companystatic->zip = $obj->zip;
2338 $companystatic->town = $obj->town;
2339 $companystatic->country_code = $obj->country_code;
2340 if (!isset($getNomUrl_cache[$obj->socid])) {
2341 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1,
'customer', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2344 $generic_commande->id = $obj->rowid;
2345 $generic_commande->ref = $obj->ref;
2346 $generic_commande->status = $obj->fk_statut;
2347 $generic_commande->statut = $obj->fk_statut;
2348 $generic_commande->status = $obj->fk_statut;
2349 $generic_commande->billed = $obj->billed;
2350 $generic_commande->date = $db->jdate($obj->date_commande);
2351 $generic_commande->delivery_date = $db->jdate($obj->delivery_date);
2352 $generic_commande->ref_client = $obj->ref_client;
2353 $generic_commande->total_ht = $obj->total_ht;
2354 $generic_commande->total_tva = $obj->total_tva;
2355 $generic_commande->total_ttc = $obj->total_ttc;
2356 $generic_commande->note_public = $obj->note_public;
2357 $generic_commande->note_private = $obj->note_private;
2359 $generic_commande->thirdparty = $companystatic;
2362 $projectstatic->id = $obj->project_id;
2363 $projectstatic->ref = $obj->project_ref;
2364 $projectstatic->title = $obj->project_label;
2366 $marginInfo = array();
2367 if ($with_margin_info) {
2368 $generic_commande->fetch_lines();
2369 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
2370 $total_ht += $obj->total_ht;
2371 $total_margin += $marginInfo[
'total_margin'];
2374 if ($mode ==
'kanban') {
2376 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
2377 print
'<div class="box-flex-container kanban">';
2382 if ($massactionbutton || $massaction) {
2384 if (in_array(
$object->id, $arrayofselected)) {
2388 print $generic_commande->getKanbanView(
'', array(
'selected' => $selected));
2389 if ($i == ($imaxinloop - 1)) {
2396 print
'<tr data-rowid="'.$object->id.
'" class="oddeven status'.$generic_commande->status.((getDolGlobalInt(
'MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->status > 1) ?
' opacitymedium' :
'').
'">';
2400 print
'<td class="nowrap center">';
2401 if ($massactionbutton || $massaction) {
2403 if (in_array($obj->rowid, $arrayofselected)) {
2406 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2415 if (!empty($arrayfields[
'c.rowid'][
'checked'])) {
2416 print
'<td class="center" data-key="id">'.$obj->rowid.
'</td>';
2423 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
2424 print
'<td class="nowraponall">';
2425 $getNomUrlOption = $search_status != 2 ? 0 : $obj->fk_statut;
2431 $getNomUrlOption =
'';
2433 print $generic_commande->getNomUrl(1, $getNomUrlOption, 0, 0, 0, 1, 1);
2437 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
2438 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
2447 if (!empty($arrayfields[
'c.ref_ext'][
'checked'])) {
2448 print
'<td class="nowrap tdoverflowmax75" title="'.dol_escape_htmltag($obj->ref_ext).
'">';
2457 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
2458 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_client).
'">';
2467 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
2468 print
'<td class="nocellnopadd nowraponall">';
2469 if ($obj->project_id > 0) {
2470 print $projectstatic->getNomUrl(1);
2479 if (!empty($arrayfields[
'p.title'][
'checked'])) {
2480 print
'<td class="nowraponall">';
2481 if ($obj->project_id > 0) {
2482 print $projectstatic->title;
2491 if (!empty($arrayfields[
's.nom'][
'checked'])) {
2492 print
'<td class="tdoverflowmax150">';
2494 print $companystatic->getNomUrl(1,
'customer', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2496 print $getNomUrl_cache[$obj->socid];
2501 if ($user->hasRight(
'facture',
'creer')) {
2502 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
2503 print
' <a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$companystatic->id.
'&search_billed=0&autoselectall=1">';
2504 print
img_picto($langs->trans(
"CreateInvoiceForThisCustomer").
' : '.$companystatic->name,
'object_bill',
'hideonsmartphone').
'</a>';
2515 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2516 print
'<td class="nocellnopadd tdoverflowmax100" title="'.dolPrintHTMLForTextArea($obj->alias).
'">';
2525 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
2526 print
'<td class="tdoverflowmax200">';
2527 if ($obj->fk_parent > 0) {
2528 if (!isset($company_url_list[$obj->fk_parent])) {
2529 $companyparent =
new Societe($db);
2530 $res = $companyparent->fetch($obj->fk_parent);
2532 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2535 if (isset($company_url_list[$obj->fk_parent])) {
2536 print $company_url_list[$obj->fk_parent];
2546 if (!empty($arrayfields[
's.town'][
'checked'])) {
2547 print
'<td class="tdoverflowmax100" title="'.dolPrintHTMLForTextArea($obj->town).
'">';
2556 if (!empty($arrayfields[
's.zip'][
'checked'])) {
2557 print
'<td class="tdoverflowmax100" title="'.dolPrintHTMLForTextArea($obj->zip).
'">';
2566 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2567 print
'<td class="tdoverflowmax100" title="'.dolPrintHTMLForTextArea($obj->state_name).
'">'.
dolPrintLabel($obj->state_name).
"</td>\n";
2574 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2575 print
'<td class="center tdoverflowmax100">';
2576 $tmparray =
getCountry($obj->fk_pays,
'all');
2577 print $tmparray[
'label'];
2585 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2586 if (!is_array($typenArray) || count($typenArray) == 0) {
2587 $typenArray = $formcompany->typent_array(1);
2589 if (!empty($obj->typent_code)) {
2590 print
'<td class="center tdoverflowmax100" title="'.dolPrintHTMLForAttribute($typenArray[$obj->typent_code]).
'">';
2591 print $typenArray[$obj->typent_code];
2593 print
'<td class="center tdoverflowmax100">';
2603 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
2604 print
'<td class="center nowraponall">';
2607 if ($generic_commande->hasDelay()) {
2608 print
img_picto($langs->trans(
"Late").
' : '.$generic_commande->showDelay(),
"warning");
2617 if (!empty($arrayfields[
'c.delivery_date'][
'checked'])) {
2618 print
'<td class="center nowraponall">';
2619 print
dol_print_date($db->jdate($obj->delivery_date),
'dayhour');
2627 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
2629 $form->formSelectShippingMethod(
'', $obj->fk_shipping_method,
'none', 1);
2637 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
2639 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', 1, $obj->deposit_percent);
2647 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
2649 $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1);
2657 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
2659 $form->formInputReason($_SERVER[
'PHP_SELF'], $obj->fk_input_reason,
'none', 0);
2667 if (!empty($arrayfields[
'c.module_source'][
'checked'])) {
2676 if (!empty($arrayfields[
'c.pos_source'][
'checked'])) {
2686 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
2687 print
'<td class="nowraponall right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
2694 if (isset($totalarray[
'val'][
'c.total_ht'])) {
2695 $totalarray[
'val'][
'c.total_ht'] += $obj->total_ht;
2697 $totalarray[
'val'][
'c.total_ht'] = $obj->total_ht;
2702 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
2703 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
2710 if (isset($totalarray[
'val'][
'c.total_tva'])) {
2711 $totalarray[
'val'][
'c.total_tva'] += $obj->total_tva;
2713 $totalarray[
'val'][
'c.total_tva'] = $obj->total_tva;
2718 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
2719 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
2726 if (isset($totalarray[
'val'][
'c.total_ttc'])) {
2727 $totalarray[
'val'][
'c.total_ttc'] += $obj->total_ttc;
2729 $totalarray[
'val'][
'c.total_ttc'] = $obj->total_ttc;
2734 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
2735 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
2742 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
2743 print
'<td class="nowrap">';
2744 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2752 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
2753 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
2759 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
2760 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
2766 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
2767 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
2773 $userstatic->id = $obj->fk_user_author;
2774 $userstatic->login = $obj->login;
2775 $userstatic->lastname = $obj->lastname;
2776 $userstatic->firstname = $obj->firstname;
2777 $userstatic->email = $obj->user_email;
2778 $userstatic->status = $obj->user_statut;
2779 $userstatic->entity = $obj->entity;
2780 $userstatic->photo = $obj->photo;
2781 $userstatic->office_phone = $obj->office_phone;
2782 $userstatic->office_fax = $obj->office_fax;
2783 $userstatic->user_mobile = $obj->user_mobile;
2784 $userstatic->job = $obj->job;
2785 $userstatic->gender = $obj->gender;
2788 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2789 print
'<td class="tdoverflowmax125">';
2790 if ($userstatic->id) {
2791 print $userstatic->getNomUrl(-1);
2802 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2804 if ($obj->socid > 0) {
2805 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2806 if ($listsalesrepresentatives < 0) {
2809 $nbofsalesrepresentative = count($listsalesrepresentatives);
2810 if ($nbofsalesrepresentative > 6) {
2812 print $nbofsalesrepresentative;
2813 } elseif ($nbofsalesrepresentative > 0) {
2815 foreach ($listsalesrepresentatives as $val) {
2816 $userstatic->id = $val[
'id'];
2817 $userstatic->lastname = $val[
'lastname'];
2818 $userstatic->firstname = $val[
'firstname'];
2819 $userstatic->email = $val[
'email'];
2820 $userstatic->status = $val[
'statut'];
2821 $userstatic->entity = $val[
'entity'];
2822 $userstatic->photo = $val[
'photo'];
2823 $userstatic->login = $val[
'login'];
2824 $userstatic->office_phone = $val[
'office_phone'];
2825 $userstatic->office_fax = $val[
'office_fax'];
2826 $userstatic->user_mobile = $val[
'user_mobile'];
2827 $userstatic->job = $val[
'job'];
2828 $userstatic->gender = $val[
'gender'];
2830 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2832 if ($j < $nbofsalesrepresentative) {
2849 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2850 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total']).
'</td>';
2857 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2858 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin']).
'</td>';
2866 if (!isset($totalarray[
'val'][
'total_margin'])) {
2870 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2874 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2875 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'], 0,
'', 0, 0, 2).
'%').
'</td>';
2882 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2883 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'], 0,
'', 0, 0, 2).
'%').
'</td>';
2890 if ($i >= $imaxinloop - 1) {
2891 if (!empty($total_ht)) {
2900 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
2901 print
'<td class="center nowraponall">';
2902 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuserrel');
2910 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
2911 print
'<td class="center nowraponall">';
2912 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuserrel');
2920 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
2921 print
'<td class="center nowraponall">';
2922 print
dol_print_date($db->jdate($obj->date_cloture),
'dayhour',
'tzuserrel');
2930 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
2931 print
'<td class="sensiblehtmlcontent maxwidth250imp classfortooltip" title="'.dolPrintHTMLForAttribute(
dolGetFirstLineOfText($obj->note_public, 20)).
'">';
2932 print
'<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(
dolGetFirstLineOfText($obj->note_public, 5)).
'</div>';
2940 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
2941 print
'<td class="sensiblehtmlcontent maxwidth250imp classfortooltip" title="'.dolPrintHTMLForAttribute(
dolGetFirstLineOfText($obj->note_private, 20)).
'">';
2942 print
'<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(
dolGetFirstLineOfText($obj->note_private, 5)).
'</div>';
2950 if (!empty($arrayfields[
'shippable'][
'checked'])) {
2951 print
'<td class="center">';
2952 if (!empty($show_shippable_command) && isModEnabled(
'stock')) {
2954 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
2955 $generic_commande->getLinesArray();
2956 $generic_commande->loadExpeditions();
2958 $numlines = count($generic_commande->lines);
2959 for ($lig = 0; $lig < $numlines; $lig++) {
2960 $orderLine = $generic_commande->lines[$lig];
2961 '@phan-var-force OrderLine $orderLine';
2962 if (isset($generic_commande->expeditions[$orderLine->id])) {
2963 $reliquat = $orderLine->qty - $generic_commande->expeditions[$orderLine->id];
2965 $reliquat = $orderLine->qty;
2967 if ($orderLine->product_type == 0 && $orderLine->fk_product > 0) {
2969 $generic_product->id = $orderLine->fk_product;
2972 if (empty($productstat_cache[$orderLine->fk_product])) {
2973 $generic_product->load_stock(
'nobatch,warehouseopen');
2974 $productstat_cache[$orderLine->fk_product][
'stock_reel'] = $generic_product->stock_reel;
2975 $productstat_cachevirtual[$orderLine->fk_product][
'stock_reel'] = $generic_product->stock_theorique;
2977 $generic_product->stock_reel = $productstat_cache[$orderLine->fk_product][
'stock_reel'];
2979 $generic_product->stock_theorique = $productstat_cachevirtual[$orderLine->fk_product][
'stock_reel'];
2982 if ($reliquat > $generic_product->stock_reel) {
2986 $text_info .= $reliquat.
' x '.$orderLine->product_ref.
' '.
dol_trunc($orderLine->product_label, 20);
2987 $text_info .=
' - '.$langs->trans(
"Stock").
': <span class="'.($generic_product->stock_reel > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_reel.
'</span>';
2988 $text_info .=
' - '.$langs->trans(
"VirtualStock").
': <span class="'.($generic_product->stock_theorique > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_theorique.
'</span>';
2989 $text_info .= ($reliquat != $orderLine->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($orderLine->qty - $reliquat).
')</span>' :
'');
2990 $text_info .=
'<br>';
2997 $stock_order_supplier = 0;
2999 if (isModEnabled(
'order')) {
3000 if (empty($productstat_cache[$orderLine->fk_product][
'stats_order_customer'])) {
3001 $generic_product->load_stats_commande(0,
'1,2');
3002 $productstat_cache[$orderLine->fk_product][
'stats_order_customer'] = $generic_product->stats_commande[
'qty'];
3005 $generic_product->stats_commande[
'qty'] = $productstat_cache[$orderLine->fk_product][
'stats_order_customer'];
3007 $stock_order = $generic_product->stats_commande[
'qty'];
3009 if (isModEnabled(
"supplier_order")) {
3010 if (empty($productstat_cache[$orderLine->fk_product][
'stats_order_supplier'])) {
3011 $generic_product->load_stats_commande_fournisseur(0,
'3');
3012 $productstat_cache[$orderLine->fk_product][
'stats_order_supplier'] = $generic_product->stats_commande_fournisseur[
'qty'];
3015 $generic_product->stats_commande_fournisseur[
'qty'] = $productstat_cache[$orderLine->fk_product][
'stats_order_supplier'];
3017 $stock_order_supplier = $generic_product->stats_commande_fournisseur[
'qty'];
3020 $text_info .= $reliquat.
' x '.$orderLine->ref.
' '.
dol_trunc($orderLine->product_label, 20);
3021 $text_stock_reel = $generic_product->stock_reel.
'/'.$stock_order;
3022 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $orderLine->qty)) {
3024 $text_warning .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
3026 if ($reliquat > $generic_product->stock_reel) {
3027 $text_info .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
3029 $text_info .=
'<span class="ok">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
3031 if (isModEnabled(
"supplier_order")) {
3032 $text_info .=
' '.$langs->trans(
'SupplierOrder').
' : '.$stock_order_supplier;
3034 $text_info .= ($reliquat != $orderLine->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($orderLine->qty - $reliquat).
')</span>' :
'');
3035 $text_info .=
'<br>';
3039 if ($notshippable == 0) {
3040 $text_icon =
img_picto(
'',
'dolly',
'', 0, 0, 0,
'',
'green paddingleft');
3041 $text_info = $text_icon.
' '.$langs->trans(
'Shippable').
'<br>'.$text_info;
3043 $text_icon =
img_picto(
'',
'dolly',
'', 0, 0, 0,
'',
'error paddingleft');
3044 $text_info = $text_icon.
' '.$langs->trans(
'NonShippable').
'<br>'.$text_info;
3049 print
'<a href="'.DOL_URL_ROOT.
'/expedition/shipment.php?id='.((int) $obj->rowid).
'">';
3050 print $form->textwithtooltip(
'', $text_info, 2, 1, $text_icon,
'', 2);
3054 print $form->textwithtooltip(
'', $langs->trans(
'NotEnoughForAllOrders').
'<br>'.$text_warning, 2, 1,
img_picto(
'',
'error'),
'', 2);
3064 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
3066 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
3067 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
3068 print $hookmanager->resPrint;
3071 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
3072 print
'<td class="center">';
3074 print
yn($obj->billed, $langs->trans(
"Billed"));
3083 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
3084 print
'<td class="nowrap center">'.dol_escape_htmltag($obj->import_key).
'</td>';
3091 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
3092 print
'<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).
'</td>';
3100 print
'<td class="nowrap center">';
3101 if ($massactionbutton || $massaction) {
3103 if (in_array($obj->rowid, $arrayofselected)) {
3106 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3116 $total += $obj->total_ht;
3117 $subtotal += $obj->total_ht;
3123include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
3128 foreach ($arrayfields as $key => $val) {
3129 if (!empty($val[
'checked'])) {
3133 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
3138$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
3139$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
3140print $hookmanager->resPrint;
3142print
'</table>'.
"\n";
3145print
'</form>'.
"\n";
3147if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
3148 $hidegeneratedfilelistifempty = 1;
3149 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
3150 $hidegeneratedfilelistifempty = 0;
3154 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
3155 $urlsource .= str_replace(
'&',
'&', $param);
3157 $filedir = $diroutputmassaction;
3158 $genallowed = $permissiontoread;
3159 $delallowed = $permissiontoadd;
3161 print $formfile->showdocuments(
'massfilesarea_orders',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_CLOSED
Closed (Sent, billed or not)
const STATUS_CANCELED
Canceled status.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage absolute discounts.
Class to manage invoices.
Class to manage invoice lines.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dolPrintLabel($s, $escapeonlyhtmltags=0)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.