fix conflict

This commit is contained in:
Christophe Battarel
2024-03-19 10:55:59 +01:00
2669 changed files with 86087 additions and 44178 deletions

View File

@@ -11,7 +11,8 @@
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016-2023 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2023 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2021 Anthony Berton <anthony.berton@bb2a.fr>
* Copyright (C) 2021-2024 Anthony Berton <anthony.berton@bb2a.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -56,29 +57,33 @@ $langs->loadLangs(array('orders', 'sendings', 'deliveries', 'companies', 'compta
// Get Parameters
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int');
$show_files = GETPOSTINT('show_files');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'orderlist';
$mode = GETPOST('mode', 'alpha');
// Search Parameters
$search_datecloture_start = GETPOST('search_datecloture_start', 'int');
if (empty($search_datecloture_start)) {
$search_datecloture_start = dol_mktime(0, 0, 0, GETPOST('search_datecloture_startmonth', 'int'), GETPOST('search_datecloture_startday', 'int'), GETPOST('search_datecloture_startyear', 'int'));
if (getDolGlobalInt('MAIN_SEE_SUBORDINATES')) {
$userschilds = $user->getAllChildIds();
}
$search_datecloture_end = GETPOST('search_datecloture_end', 'int');
if (empty($search_datecloture_end)) {
$search_datecloture_end = dol_mktime(23, 59, 59, GETPOST('search_datecloture_endmonth', 'int'), GETPOST('search_datecloture_endday', 'int'), GETPOST('search_datecloture_endyear', 'int'));
}
$search_dateorder_start = dol_mktime(0, 0, 0, GETPOST('search_dateorder_start_month', 'int'), GETPOST('search_dateorder_start_day', 'int'), GETPOST('search_dateorder_start_year', 'int'));
$search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_end_month', 'int'), GETPOST('search_dateorder_end_day', 'int'), GETPOST('search_dateorder_end_year', 'int'));
$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_start_month', 'int'), GETPOST('search_datedelivery_start_day', 'int'), GETPOST('search_datedelivery_start_year', 'int'));
$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_end_month', 'int'), GETPOST('search_datedelivery_end_day', 'int'), GETPOST('search_datedelivery_end_year', 'int'));
$socid = GETPOST('socid', 'int');
// Search Parameters
$search_datecloture_start = GETPOSTINT('search_datecloture_start');
if (empty($search_datecloture_start)) {
$search_datecloture_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datecloture_startmonth'), GETPOSTINT('search_datecloture_startday'), GETPOSTINT('search_datecloture_startyear'));
}
$search_datecloture_end = GETPOSTINT('search_datecloture_end');
if (empty($search_datecloture_end)) {
$search_datecloture_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datecloture_endmonth'), GETPOSTINT('search_datecloture_endday'), GETPOSTINT('search_datecloture_endyear'));
}
$search_dateorder_start = dol_mktime(0, 0, 0, GETPOSTINT('search_dateorder_start_month'), GETPOSTINT('search_dateorder_start_day'), GETPOSTINT('search_dateorder_start_year'));
$search_dateorder_end = dol_mktime(23, 59, 59, GETPOSTINT('search_dateorder_end_month'), GETPOSTINT('search_dateorder_end_day'), GETPOSTINT('search_dateorder_end_year'));
$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datedelivery_start_month'), GETPOSTINT('search_datedelivery_start_day'), GETPOSTINT('search_datedelivery_start_year'));
$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datedelivery_end_month'), GETPOSTINT('search_datedelivery_end_day'), GETPOSTINT('search_datedelivery_end_year'));
$socid = GETPOSTINT('socid');
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$search_product_category = GETPOST('search_product_category', 'int');
$search_product_category = GETPOSTINT('search_product_category');
$search_ref = GETPOST('search_ref', 'alpha') != '' ? GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha');
$search_ref_customer = GETPOST('search_ref_customer', 'alpha');
$search_company = GETPOST('search_company', 'alpha');
@@ -87,14 +92,14 @@ $search_parent_name = trim(GETPOST('search_parent_name', 'alphanohtml'));
$search_town = GETPOST('search_town', 'alpha');
$search_zip = GETPOST('search_zip', 'alpha');
$search_state = GETPOST('search_state', 'alpha');
$search_country = GETPOST('search_country', 'int');
$search_type_thirdparty = GETPOST('search_type_thirdparty', 'int');
$search_user = GETPOST('search_user', 'int');
$search_sale = GETPOST('search_sale', 'int');
$search_country = GETPOSTINT('search_country');
$search_type_thirdparty = GETPOSTINT('search_type_thirdparty');
$search_user = GETPOSTINT('search_user');
$search_sale = GETPOSTINT('search_sale');
$search_total_ht = GETPOST('search_total_ht', 'alpha');
$search_total_vat = GETPOST('search_total_vat', 'alpha');
$search_total_ttc = GETPOST('search_total_ttc', 'alpha');
$search_warehouse = GETPOST('search_warehouse', 'int');
$search_warehouse = GETPOSTINT('search_warehouse');
$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
@@ -103,26 +108,26 @@ $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat',
$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
$search_login = GETPOST('search_login', 'alpha');
$search_categ_cus = GETPOST("search_categ_cus", 'int');
$search_categ_cus = GETPOSTINT("search_categ_cus");
$optioncss = GETPOST('optioncss', 'alpha');
$search_billed = GETPOST('search_billed', 'int');
$search_status = GETPOST('search_status', 'int');
$search_status = GETPOST('search_status', 'intcomma');
$search_project_ref = GETPOST('search_project_ref', 'alpha');
$search_project = GETPOST('search_project', 'alpha');
$search_shippable = GETPOST('search_shippable', 'aZ09');
$search_fk_cond_reglement = GETPOST('search_fk_cond_reglement', 'int');
$search_fk_shipping_method = GETPOST('search_fk_shipping_method', 'int');
$search_fk_mode_reglement = GETPOST('search_fk_mode_reglement', 'int');
$search_fk_input_reason = GETPOST('search_fk_input_reason', 'int');
$search_fk_cond_reglement = GETPOSTINT('search_fk_cond_reglement');
$search_fk_shipping_method = GETPOSTINT('search_fk_shipping_method');
$search_fk_mode_reglement = GETPOSTINT('search_fk_mode_reglement');
$search_fk_input_reason = GETPOSTINT('search_fk_input_reason');
$diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id;
// Load variable for pagination
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
// If $page is not defined, or '' or -1 or if we click on clear filters
$page = 0;
@@ -150,14 +155,14 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
'c.ref'=>'Ref',
'c.ref_client'=>'RefCustomerOrder',
'pd.description'=>'Description',
's.nom'=>"ThirdParty",
's.name_alias'=>"AliasNameShort",
's.zip'=>"Zip",
's.town'=>"Town",
'c.note_public'=>'NotePublic',
'c.ref' => 'Ref',
'c.ref_client' => 'RefCustomerOrder',
'pd.description' => 'Description',
's.nom' => "ThirdParty",
's.name_alias' => "AliasNameShort",
's.zip' => "Zip",
's.town' => "Town",
'c.note_public' => 'NotePublic',
);
if (empty($user->socid)) {
$fieldstosearchall["c.note_private"] = "NotePrivate";
@@ -165,50 +170,50 @@ if (empty($user->socid)) {
$checkedtypetiers = 0;
$arrayfields = array(
'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5, 'searchall'=>1),
'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10, 'searchall'=>1),
'p.ref'=>array('label'=>"ProjectRef", 'checked'=>-1, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>20),
'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>25),
's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30, 'searchall'=>1),
's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1, 'position'=>31, 'searchall'=>1),
's2.nom'=>array('label'=>'ParentCompany', 'position'=>32, 'checked'=>0),
's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>35, 'searchall'=>1),
's.zip'=>array('label'=>"Zip", 'checked'=>-1, 'position'=>40, 'searchall'=>1),
'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45),
'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50),
'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55),
'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60, 'csslist'=>'nowraponall'),
'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>!getDolGlobalString('ORDER_DISABLE_DELIVERY_DATE'), 'position'=>65, 'csslist'=>'nowraponall'),
'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>-1, 'position'=>66 , 'enabled'=>isModEnabled("expedition")),
'c.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>-1, 'position'=>67),
'c.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>-1, 'position'=>68),
'c.fk_input_reason'=>array('label'=>"Channel", 'checked'=>-1, 'position'=>69),
'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75),
'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80),
'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85),
'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>90),
'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>95),
'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>100),
'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>105),
'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>110),
'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115),
'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116),
'c.ref' => array('label' => "Ref", 'checked' => 1, 'position' => 5, 'searchall' => 1),
'c.ref_client' => array('label' => "RefCustomerOrder", 'checked' => -1, 'position' => 10, 'searchall' => 1),
'p.ref' => array('label' => "ProjectRef", 'checked' => -1, 'enabled' => (!isModEnabled('project') ? 0 : 1), 'position' => 20),
'p.title' => array('label' => "ProjectLabel", 'checked' => 0, 'enabled' => (!isModEnabled('project') ? 0 : 1), 'position' => 25),
's.nom' => array('label' => "ThirdParty", 'checked' => 1, 'position' => 30, 'searchall' => 1),
's.name_alias' => array('label' => "AliasNameShort", 'checked' => -1, 'position' => 31, 'searchall' => 1),
's2.nom' => array('label' => 'ParentCompany', 'position' => 32, 'checked' => 0),
's.town' => array('label' => "Town", 'checked' => -1, 'position' => 35, 'searchall' => 1),
's.zip' => array('label' => "Zip", 'checked' => -1, 'position' => 40, 'searchall' => 1),
'state.nom' => array('label' => "StateShort", 'checked' => 0, 'position' => 45),
'country.code_iso' => array('label' => "Country", 'checked' => 0, 'position' => 50),
'typent.code' => array('label' => "ThirdPartyType", 'checked' => $checkedtypetiers, 'position' => 55),
'c.date_commande' => array('label' => "OrderDateShort", 'checked' => 1, 'position' => 60, 'csslist' => 'nowraponall'),
'c.date_delivery' => array('label' => "DateDeliveryPlanned", 'checked' => 1, 'enabled' => !getDolGlobalString('ORDER_DISABLE_DELIVERY_DATE'), 'position' => 65, 'csslist' => 'nowraponall'),
'c.fk_shipping_method' => array('label' => "SendingMethod", 'checked' => -1, 'position' => 66 , 'enabled' => isModEnabled("shipping")),
'c.fk_cond_reglement' => array('label' => "PaymentConditionsShort", 'checked' => -1, 'position' => 67),
'c.fk_mode_reglement' => array('label' => "PaymentMode", 'checked' => -1, 'position' => 68),
'c.fk_input_reason' => array('label' => "Channel", 'checked' => -1, 'position' => 69),
'c.total_ht' => array('label' => "AmountHT", 'checked' => 1, 'position' => 75),
'c.total_vat' => array('label' => "AmountVAT", 'checked' => 0, 'position' => 80),
'c.total_ttc' => array('label' => "AmountTTC", 'checked' => 0, 'position' => 85),
'c.multicurrency_code' => array('label' => 'Currency', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1), 'position' => 90),
'c.multicurrency_tx' => array('label' => 'CurrencyRate', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1), 'position' => 95),
'c.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1), 'position' => 100),
'c.multicurrency_total_vat' => array('label' => 'MulticurrencyAmountVAT', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1), 'position' => 105),
'c.multicurrency_total_ttc' => array('label' => 'MulticurrencyAmountTTC', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1), 'position' => 110),
'u.login' => array('label' => "Author", 'checked' => 1, 'position' => 115),
'sale_representative' => array('label' => "SaleRepresentativesOfThirdParty", 'checked' => 0, 'position' => 116),
'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") ? 0 : 1)),
'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") ? 0 : 1)),
'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") || !getDolGlobalString('DISPLAY_MARGIN_RATES') ? 0 : 1)),
'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") || !getDolGlobalString('DISPLAY_MARK_RATES') ? 0 : 1)),
'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120),
'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125),
'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130),
'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position'=>135, 'searchall'=>1),
'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position'=>140),
'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(isModEnabled("expedition")), 'position'=>990),
'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(!getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')), 'position'=>995),
'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999),
'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
'c.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 120),
'c.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 125),
'c.date_cloture' => array('label' => "DateClosing", 'checked' => 0, 'position' => 130),
'c.note_public' => array('label' => 'NotePublic', 'checked' => 0, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position' => 135, 'searchall' => 1),
'c.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position' => 140),
'shippable' => array('label' => "Shippable", 'checked' => 1,'enabled' => (isModEnabled("shipping")), 'position' => 990),
'c.facture' => array('label' => "Billed", 'checked' => 1, 'enabled' => (!getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')), 'position' => 995),
'c.import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 999),
'c.fk_statut' => array('label' => "Status", 'checked' => 1, 'position' => 1000)
);
$parameters = array('fieldstosearchall'=>$fieldstosearchall);
$parameters = array('fieldstosearchall' => $fieldstosearchall);
$reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
@@ -223,15 +228,16 @@ $object->fields = dol_sort_array($object->fields, 'position');
//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
$arrayfields = dol_sort_array($arrayfields, 'position');
if (!$user->hasRight('societe', 'client', 'voir')) {
$search_sale = $user->id;
}
// Security check
$id = (GETPOST('orderid') ? GETPOST('orderid', 'int') : GETPOST('id', 'int'));
$id = (GETPOST('orderid') ? GETPOSTINT('orderid') : GETPOSTINT('id'));
if ($user->socid) {
$socid = $user->socid;
}
$permissiontoreadallthirdparty = $user->hasRight('societe', 'client', 'voir');
$result = restrictedArea($user, 'commande', $id, '');
$error = 0;
@@ -249,7 +255,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa
$massaction = '';
}
$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields);
$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -327,14 +333,14 @@ if (empty($reshook)) {
}
$uploaddir = $conf->commande->multidir_output[$conf->entity];
$triggersendname = 'ORDER_SENTBYMAIL';
$year="";
$month="";
$year = "";
$month = "";
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($massaction == 'confirm_createbills') { // Create bills from orders.
$orders = GETPOST('toselect', 'array');
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
$validate_invoices = GETPOST('validate_invoices', 'int');
$createbills_onebythird = GETPOSTINT('createbills_onebythird');
$validate_invoices = GETPOSTINT('validate_invoices');
$errors = array();
@@ -343,7 +349,7 @@ if (empty($reshook)) {
$TFactThirdNbLines = array();
$nb_bills_created = 0;
$lastid= 0;
$lastid = 0;
$lastref = '';
$db->begin();
@@ -376,7 +382,7 @@ if (empty($reshook)) {
$objecttmp->ref_client = $cmd->ref_client;
}
$datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$datefacture = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
if (empty($datefacture)) {
$datefacture = dol_now();
}
@@ -587,7 +593,7 @@ if (empty($reshook)) {
if ($nb_bills_created == 1) {
$texttoshow = $langs->trans('BillXCreated', '{s1}');
$texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?id='.urlencode($lastid).'">'.$lastref.'</a>', $texttoshow);
$texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?id='.urlencode((string) ($lastid)).'">'.$lastref.'</a>', $texttoshow);
setEventMessages($texttoshow, null, 'mesgs');
} else {
setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
@@ -611,10 +617,10 @@ if (empty($reshook)) {
$param .= '&search_all='.urlencode($search_all);
}
if ($show_files) {
$param .= '&show_files='.urlencode($show_files);
$param .= '&show_files='.urlencode((string) ($show_files));
}
if ($socid > 0) {
$param .= '&socid='.urlencode($socid);
$param .= '&socid='.urlencode((string) ($socid));
}
if ($search_status != '') {
$param .= '&search_status='.urlencode($search_status);
@@ -647,10 +653,10 @@ if (empty($reshook)) {
$param .= '&search_ref_customer='.urlencode($search_ref_customer);
}
if ($search_user > 0) {
$param .= '&search_user='.urlencode($search_user);
$param .= '&search_user='.urlencode((string) ($search_user));
}
if ($search_sale > 0) {
$param .= '&search_sale='.urlencode($search_sale);
$param .= '&search_sale='.urlencode((string) ($search_sale));
}
if ($search_total_ht != '') {
$param .= '&search_total_ht='.urlencode($search_total_ht);
@@ -778,11 +784,7 @@ if (!$error && $massaction === 'setbilled' && $permissiontoclose) {
}
if (!$error) {
if ($nbok > 1) {
setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
} else {
setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
}
setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
$db->commit();
} else {
$db->rollback();
@@ -879,6 +881,16 @@ $sql .= ' AND c.entity IN ('.getEntity('commande').')';
if ($socid > 0) {
$sql .= ' AND s.rowid = '.((int) $socid);
}
// Restriction on sale representative
if (!$permissiontoreadallthirdparty) {
$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).")";
if (getDolGlobalInt('MAIN_SEE_SUBORDINATES') && $userschilds) {
$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))."))";
}
$sql .= ")";
}
if ($search_ref) {
$sql .= natural_search('c.ref', $search_ref);
}
@@ -893,7 +905,7 @@ if ($search_billed != '' && $search_billed >= 0) {
}
if ($search_status != '') {
if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination)
if ($search_status == 1 && !isModEnabled('expedition')) {
if ($search_status == 1 && !isModEnabled('shipping')) {
$sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status "sent" into "validated"
} else {
$sql .= ' AND c.fk_statut = '.((int) $search_status); // draft, validated, in process or canceled
@@ -1150,7 +1162,7 @@ if ($search_status == -2) {
$title .= ' - '.$langs->trans('StatusOrderToProcessShort');
}
if ($search_status == -3) {
$title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('expedition') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
$title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('shipping') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
}
if ($search_status == -4) {
$title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort");
@@ -1227,10 +1239,10 @@ if ($search_ref_customer) {
$param .= '&search_ref_customer='.urlencode($search_ref_customer);
}
if ($search_user > 0) {
$param .= '&search_user='.urlencode($search_user);
$param .= '&search_user='.urlencode((string) ($search_user));
}
if ($search_sale > 0) {
$param .= '&search_sale='.urlencode($search_sale);
$param .= '&search_sale='.urlencode((string) ($search_sale));
}
if ($search_total_ht != '') {
$param .= '&search_total_ht='.urlencode($search_total_ht);
@@ -1242,7 +1254,7 @@ if ($search_total_ttc != '') {
$param .= '&search_total_ttc='.urlencode($search_total_ttc);
}
if ($search_warehouse != '') {
$param .= '&search_warehouse='.urlencode($search_warehouse);
$param .= '&search_warehouse='.urlencode((string) ($search_warehouse));
}
if ($search_login) {
$param .= '&search_login='.urlencode($search_login);
@@ -1275,19 +1287,19 @@ if ($search_state != '') {
$param .= '&search_state='.urlencode($search_state);
}
if ($search_country != '') {
$param .= '&search_country='.urlencode($search_country);
$param .= '&search_country='.urlencode((string) ($search_country));
}
if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
$param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
$param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
}
if ($search_product_category != '') {
$param .= '&search_product_category='.urlencode($search_product_category);
$param .= '&search_product_category='.urlencode((string) ($search_product_category));
}
if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
$param .= '&search_categ_cus='.urlencode($search_categ_cus);
$param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus));
}
if ($show_files) {
$param .= '&show_files='.urlencode($show_files);
$param .= '&show_files='.urlencode((string) ($show_files));
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
@@ -1296,16 +1308,16 @@ if ($search_billed != '') {
$param .= '&search_billed='.urlencode($search_billed);
}
if ($search_fk_cond_reglement > 0) {
$param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement);
$param .= '&search_fk_cond_reglement='.urlencode((string) ($search_fk_cond_reglement));
}
if ($search_fk_shipping_method > 0) {
$param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method);
$param .= '&search_fk_shipping_method='.urlencode((string) ($search_fk_shipping_method));
}
if ($search_fk_mode_reglement > 0) {
$param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement);
$param .= '&search_fk_mode_reglement='.urlencode((string) ($search_fk_mode_reglement));
}
if ($search_fk_input_reason > 0) {
$param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason);
$param .= '&search_fk_input_reason='.urlencode((string) ($search_fk_input_reason));
}
// Add $param from extra fields
@@ -1318,8 +1330,8 @@ $param .= $hookmanager->resPrint;
// List of mass actions available
$arrayofmassactions = array(
'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
);
if ($permissiontovalidate) {
$arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
@@ -1327,7 +1339,7 @@ if ($permissiontovalidate) {
if ($permissiontoclose) {
$arrayofmassactions['preshipped'] = img_picto('', 'dollyrevert', 'class="pictofixedwidth"').$langs->trans("ClassifyShipped");
}
if (isModEnabled('facture') && $user->hasRight("facture", "creer")) {
if (isModEnabled('invoice') && $user->hasRight("facture", "creer")) {
$arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisCustomer");
}
if ($permissiontoclose) {
@@ -1352,8 +1364,8 @@ if (!empty($socid)) {
$url .= '&socid='.$socid;
}
$newcardbutton = '';
$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'));
$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'));
$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'));
$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'));
$newcardbutton .= dolGetButtonTitleSeparator();
$newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', ($contextpage == 'orderlist' || $contextpage == 'billableorders') && $permissiontoadd);
@@ -1398,7 +1410,7 @@ if ($massaction == 'createbills') {
print $langs->trans('DateInvoice');
print '</td>';
print '<td>';
print $form->selectDate('', '', '', '', '', '', 1, 1);
print $form->selectDate('', '', 0, 0, 0, '', 1, 1);
print '</td>';
print '</tr>';
print '<tr>';
@@ -1466,7 +1478,7 @@ if ($user->hasRight("user", "user", "lire")) {
}
// If the user can view other products/services than his own
if (isModEnabled('categorie') && $user->hasRight("categorie", "lire") && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) {
if (isModEnabled('category') && $user->hasRight("categorie", "lire") && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) {
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('IncludingProductWithTag');
@@ -1475,7 +1487,7 @@ if (isModEnabled('categorie') && $user->hasRight("categorie", "lire") && ($user-
$moreforfilter .= '</div>';
}
// If Categories are enabled & user has rights to see
if (isModEnabled('categorie') && $user->hasRight("categorie", "lire")) {
if (isModEnabled('category') && $user->hasRight("categorie", "lire")) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('CustomersProspectsCategoriesShort');
@@ -1509,10 +1521,10 @@ if (!empty($moreforfilter)) {
}
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) : ''); // This also change content of $arrayfields
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
if (GETPOST('autoselectall', 'int')) {
if (GETPOSTINT('autoselectall')) {
$selectedfields .= '<script>';
$selectedfields .= ' $(document).ready(function() {';
$selectedfields .= ' console.log("Autoclick on checkforselects");';
@@ -1724,7 +1736,7 @@ if (!empty($arrayfields['total_mark_rate']['checked'])) {
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields);
$parameters = array('arrayfields' => $arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
@@ -1794,6 +1806,7 @@ if (!empty($arrayfields['c.fk_statut']['checked'])) {
Commande::STATUS_CLOSED => $langs->trans("StatusOrderDelivered"),
Commande::STATUS_CANCELED => $langs->trans("StatusOrderCanceledShort")
);
// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1);
print '</td>';
}
@@ -1959,7 +1972,7 @@ if (!empty($arrayfields['total_mark_rate']['checked'])) {
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['c.datec']['checked'])) {
@@ -2022,20 +2035,20 @@ if (isModEnabled('margin') && (
|| !empty($arrayfields['total_margin_rate']['checked'])
|| !empty($arrayfields['total_mark_rate']['checked'])
)
) {
) {
$with_margin_info = true;
}
$total_ht = 0;
$total_margin = 0;
$total_ht = 0;
$total_margin = 0;
// Loop on record
// --------------------------------------------------------------------
$i = 0;
$savnbfield = $totalarray['nbfield'];
$totalarray = array();
$totalarray['nbfield'] = 0;
$imaxinloop = ($limit ? min($num, $limit) : $num);
// Loop on record
// --------------------------------------------------------------------
$i = 0;
$savnbfield = $totalarray['nbfield'];
$totalarray = array();
$totalarray['nbfield'] = 0;
$imaxinloop = ($limit ? min($num, $limit) : $num);
while ($i < $imaxinloop) {
$obj = $db->fetch_object($resql);
if (empty($obj)) {
@@ -2192,7 +2205,7 @@ while ($i < $imaxinloop) {
}
// If module invoices enabled and user with invoice creation permissions
if (isModEnabled('facture') && getDolGlobalString('ORDER_BILLING_ALL_CUSTOMER')) {
if (isModEnabled('invoice') && getDolGlobalString('ORDER_BILLING_ALL_CUSTOMER')) {
if ($user->hasRight('facture', 'creer')) {
if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$companystatic->id.'&search_billed=0&autoselectall=1">';
@@ -2538,7 +2551,7 @@ while ($i < $imaxinloop) {
// Total margin rate
if (!empty($arrayfields['total_margin_rate']['checked'])) {
print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').'</td>';
print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], 0, null, null, null, 2).'%').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
@@ -2546,7 +2559,7 @@ while ($i < $imaxinloop) {
// Total mark rate
if (!empty($arrayfields['total_mark_rate']['checked'])) {
print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'</td>';
print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], 0, null, null, null, 2).'%').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
@@ -2565,7 +2578,7 @@ while ($i < $imaxinloop) {
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
@@ -2665,7 +2678,7 @@ while ($i < $imaxinloop) {
$stock_order = 0;
$stock_order_supplier = 0;
if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { // What about other options ?
if (isModEnabled('commande')) {
if (isModEnabled('order')) {
if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) {
$generic_product->load_stats_commande(0, '1,2');
$productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
@@ -2727,7 +2740,7 @@ while ($i < $imaxinloop) {
// Billed
if (!empty($arrayfields['c.facture']['checked'])) {
print '<td class="center">'.yn($obj->billed).'</td>';
print '<td class="center">'.yn($obj->billed, 4).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
@@ -2789,7 +2802,7 @@ if ($num == 0) {
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;