diff --git a/htdocs/api/index.php b/htdocs/api/index.php
index 1b50e00d193..3f0edace5c2 100644
--- a/htdocs/api/index.php
+++ b/htdocs/api/index.php
@@ -253,6 +253,8 @@ if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $
$modulenameforenabled = 'supplier_proposal';
} elseif ($module == 'ficheinter') {
$modulenameforenabled = 'intervention';
+ } elseif ($module == 'product' && !isModEnabled('product') && isModEnabled('service')) {
+ $modulenameforenabled = 'service';
}
dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass);
diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php
index 21ba3a490d2..7e7dbcaabbe 100644
--- a/htdocs/commande/list_det.php
+++ b/htdocs/commande/list_det.php
@@ -486,17 +486,14 @@ if ($search_status != '') {
$sql .= ' AND c.fk_statut = '.((int) $search_status); // draft, validated, in process or canceled
}
}
- if ($search_status == -2) { // To process
+ if ($search_status == -2) { // "validated + in progress"
//$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0';
- $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
+ $sql .= " AND c.fk_statut IN (1,2)";
}
- if ($search_status == -3) { // To bill
+ if ($search_status == -3) { // "validated + in progress + shipped"
//$sql.= ' AND c.fk_statut in (1,2,3)';
//$sql.= ' AND c.facture = 0'; // invoice not created
- $sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed
- }
- if ($search_status == -4) { // "validate and in progress"
- $sql .= ' AND (c.fk_statut IN (1,2))'; // validated, in process
+ $sql .= ' AND c.fk_statut IN (1,2,3)'; // validated, in process or closed
}
}
@@ -725,9 +722,6 @@ if ($resql) {
if ($search_status == -3) {
$title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('shipping') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
}
- if ($search_status == -4) {
- $title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort");
- }
$num = $db->num_rows($resql);
diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php
index dc65c082759..87f147a7f73 100644
--- a/htdocs/compta/facture/class/api_invoices.class.php
+++ b/htdocs/compta/facture/class/api_invoices.class.php
@@ -380,6 +380,7 @@ class Invoices extends DolibarrApi
*
* @throws RestException 400
* @throws RestException 401
+ * @throws RestException 403 Access not allowed for login
* @throws RestException 404
* @throws RestException 405
*/
@@ -396,6 +397,9 @@ class Invoices extends DolibarrApi
if (empty($orderid)) {
throw new RestException(400, 'Order ID is mandatory');
}
+ if (!DolibarrApi::_checkAccessToResource('commande', $orderid)) {
+ throw new RestException(403, 'Access not allowed on order for login '.DolibarrApiAccess::$user->login);
+ }
$order = new Commande($this->db);
$result = $order->fetch($orderid);
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index fdbb5ab31bd..2e81167777b 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -4204,7 +4204,7 @@ class Facture extends CommonInvoice
if (empty($fk_prev_id)) {
$fk_prev_id = 'null';
}
- if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '' || $situation_percent == null) {
+ if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '' || $situation_percent === null) {
// INVOICE_USE_SITUATION = 2 - Lines situation percent on new lines must be 0 (No cumulative)
if ($this->isSituationInvoice() && getDolGlobalInt('INVOICE_USE_SITUATION') == 2) {
$situation_percent = 0;
diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php
index 25face3bbc0..7043765ee46 100644
--- a/htdocs/compta/paiement/list.php
+++ b/htdocs/compta/paiement/list.php
@@ -843,6 +843,11 @@ while ($i < $imaxinloop) {
}
}
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, '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;
+
// Status
if (!empty($arrayfields['p.statut']['checked'])) {
print '
';
diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index bb7fd3a6d6a..06f65d14b8c 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -914,9 +914,9 @@ class FormSetupItem
$revertonoff = !empty($this->fieldParams['revertonoff']) ? 1 : 0;
$forcereload = !empty($this->fieldParams['forcereload']) ? 1 : 0;
- $out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload);
+ $out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, '', '', $this->cssClass);
} else {
- $out .= $this->form->selectyesno($this->confKey, $this->fieldValue, 1);
+ $out .= $this->form->selectyesno($this->confKey, $this->fieldValue, 1, false, 0, 0, $this->cssClass);
}
} elseif (preg_match('/emailtemplate:/', $this->type)) {
$out .= $this->generateInputFieldEmailTemplate();
@@ -1230,7 +1230,7 @@ class FormSetupItem
$revertonoff = empty($this->fieldParams['revertonoff']) ? 0 : 1;
$forcereload = empty($this->fieldParams['forcereload']) ? 0 : 1;
- $out .= ajax_constantonoff($this->confKey, array(), $this->entity, $revertonoff, 0, $forcereload);
+ $out .= ajax_constantonoff($this->confKey, array(), $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, '', '', $this->cssClass); // TODO possibility to add $input parameter
} else {
if ($this->fieldValue == 1) {
$out .= $langs->trans('yes');
diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php
index c02c012ab2c..c0919570c11 100644
--- a/htdocs/core/class/notify.class.php
+++ b/htdocs/core/class/notify.class.php
@@ -668,7 +668,8 @@ class Notify
$application = (preg_match('/^\+/', $applicationcustom) ? $application : '').$applicationcustom;
}
- $from = getDolGlobalString('NOTIFICATION_EMAIL_FROM');
+ $from = getDolGlobalString('NOTIFICATION_EMAIL_FROM', getDolGlobalString('MAIN_MAIL_EMAIL_FROM'));
+
$object_type = '';
$link = '';
$num = 0;
diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php
index 61ae4a59aec..48f765112a1 100644
--- a/htdocs/core/js/lib_head.js.php
+++ b/htdocs/core/js/lib_head.js.php
@@ -1578,14 +1578,20 @@ jQuery(document).ready(function() {
// Code to manage the js for combo list with dependencies (called by extrafields_view.tpl.php)
function showOptions(child_list, parent_list) {
- var val = $("select[name="+parent_list+"]").val();
- var parentVal = parent_list + ":" + val;
- if(val > 0) {
- $("select[name=\""+child_list+"\"] option[parent]").hide();
- $("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show();
+ var parentInput = $("select[name="+parent_list+"]");
+ if (parentInput.length === 0) { // when parent extra-field is in view mode and the child is edited directly on card (on line edit)
+ parentInput = $("input[name="+parent_list+"]");
+ }
+ if (parentInput.length > 0) {
+ var val = parentInput.val();
+ var parentVal = parent_list + ":" + val;
+ if (val > 0) {
+ $("select[name=\""+child_list+"\"] option[parent]").prop("disabled", true).hide(); // hide not work with select2 element so disabled it
+ $("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").prop('disabled', false).show(); // show not work with select2 element so enabled it
} else {
- $("select[name=\""+child_list+"\"] option").show();
+ $("select[name=\""+child_list+"\"] option").prop("disabled", false).show(); // show not work with select2 element so enabled it
}
+ }
}
function setListDependencies() {
console.log("setListDependencies");
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 3dd0254de36..1dbe7635da6 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -235,7 +235,7 @@ function societe_prepare_head(Societe $object)
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as n";
$sql .= " WHERE n.fk_soc = ".((int) $object->id);
if (!isModEnabled('stripe')) {
- $sql .= " AND n.stripe_card_ref IS NULL";
+ $sql .= " AND (n.stripe_card_ref IS NULL OR n.stripe_card_ref ='')";
} else {
$sql .= " AND (n.stripe_card_ref IS NULL OR (n.stripe_card_ref IS NOT NULL AND n.status = ".((int) $servicestatus)."))";
}
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index 209ab8aee13..cfe7c74b836 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -1052,7 +1052,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$sql .= " AND (sc.fk_user = ".((int) $user->id);
if (getDolGlobalInt('MAIN_SEE_SUBORDINATES')) {
$userschilds = $user->getAllChildIds();
- $sql .= " OR sc.fk_user IN (".$db->sanitize(implode(',', $userschilds)).")";
+ if (!empty($userschilds)) $sql .= " OR sc.fk_user IN (".$db->sanitize(implode(',', $userschilds)).")";
}
$sql .= ")";
$sql .= " AND sc.fk_soc = s.rowid";
@@ -1162,9 +1162,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$sql .= " AND (sc.fk_user = ".((int) $user->id);
if (getDolGlobalInt('MAIN_SEE_SUBORDINATES')) {
$userschilds = $user->getAllChildIds();
- foreach ($userschilds as $key => $value) {
- $sql .= ' OR sc.fk_user = '.((int) $value);
- }
+ if (!empty($userschilds)) $sql .= " OR sc.fk_user IN (".$db->sanitize(implode(',', $userschilds)).")";
}
$sql .= ')';
} else {
diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php
index 92090bfb8fa..53eb687e3f4 100644
--- a/htdocs/core/tpl/extrafields_view.tpl.php
+++ b/htdocs/core/tpl/extrafields_view.tpl.php
@@ -322,6 +322,7 @@ if (empty($reshook) && !empty($object->table_element) && isset($extrafields->att
//var_dump($tmpkeyextra.'-'.$value.'-'.$object->table_element);
print $extrafields->showOutputField($tmpkeyextra, $value, '', $object->table_element, null, $object);
+ print ''; // it's needed when to get parent value when extra-field list depend on parent extra-field list
}
print ' ';
diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php
index d8f9c426919..dd37af32adc 100644
--- a/htdocs/core/tpl/passwordforgotten.tpl.php
+++ b/htdocs/core/tpl/passwordforgotten.tpl.php
@@ -204,7 +204,7 @@ if (!empty($captcha)) {
}
// List of directories where we can find captcha handlers
- $dirModCaptcha = array_merge(array('main' => '/core/modules/security/captcha/'), is_array($conf->modules_parts['captcha']) ? $conf->modules_parts['captcha'] : array());
+ $dirModCaptcha = array_merge(array('main' => '/core/modules/security/captcha/'), ((isset($conf->modules_parts['captcha']) && is_array($conf->modules_parts['captcha'])) ? $conf->modules_parts['captcha'] : array()));
$fullpathclassfile = '';
foreach ($dirModCaptcha as $dir) {
$fullpathclassfile = dol_buildpath($dir."modCaptcha".ucfirst($captcha).'.class.php', 0, 2);
diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php
index fe46430413c..9710a0d1f6f 100644
--- a/htdocs/fourn/paiement/list.php
+++ b/htdocs/fourn/paiement/list.php
@@ -730,6 +730,11 @@ while ($i < $imaxinloop) {
}
}
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, '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;
+
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
@@ -747,6 +752,7 @@ while ($i < $imaxinloop) {
print ''."\n";
}
+
$i++;
}
diff --git a/htdocs/index.php b/htdocs/index.php
index d772f716b83..68f426092a7 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -130,7 +130,7 @@ if (getDolGlobalString('MAIN_MOTD')) {
*/
// Specific warning to propose to upgrade invoice situation to progressive mode
-if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
+if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1 && (float) DOL_VERSION >= 22.0) {
$langs->loadLangs(array("admin"));
print info_admin($langs->trans("WarningExperimentalFeatureInvoiceSituationNeedToUpgradeToProgressiveMode", 'https://partners.dolibarr.org'));
//print " ";
diff --git a/htdocs/knowledgemanagement/knowledgerecord_agenda.php b/htdocs/knowledgemanagement/knowledgerecord_agenda.php
index 63707b92f5b..9d8a11c55aa 100644
--- a/htdocs/knowledgemanagement/knowledgerecord_agenda.php
+++ b/htdocs/knowledgemanagement/knowledgerecord_agenda.php
@@ -98,7 +98,7 @@ if ($id > 0 || !empty($ref)) {
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
-restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
+restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php
diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php
index 9f710efff55..dc9ce22e7c1 100644
--- a/htdocs/knowledgemanagement/knowledgerecord_card.php
+++ b/htdocs/knowledgemanagement/knowledgerecord_card.php
@@ -97,7 +97,7 @@ $upload_dir = $conf->knowledgemanagement->multidir_output[isset($object->entity)
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
-restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
+restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
//if (empty($conf->knowledgemanagement->enabled)) accessforbidden();
//if (empty($permissiontoread)) accessforbidden();
diff --git a/htdocs/knowledgemanagement/knowledgerecord_contact.php b/htdocs/knowledgemanagement/knowledgerecord_contact.php
index 468f66660f4..342c1547c12 100644
--- a/htdocs/knowledgemanagement/knowledgerecord_contact.php
+++ b/htdocs/knowledgemanagement/knowledgerecord_contact.php
@@ -63,7 +63,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'inclu
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
-restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
+restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
$permission = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write');
diff --git a/htdocs/knowledgemanagement/knowledgerecord_document.php b/htdocs/knowledgemanagement/knowledgerecord_document.php
index 16d7fbde906..a22c031ff5f 100644
--- a/htdocs/knowledgemanagement/knowledgerecord_document.php
+++ b/htdocs/knowledgemanagement/knowledgerecord_document.php
@@ -88,7 +88,7 @@ if ($id > 0 || !empty($ref)) {
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
-restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
+restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
diff --git a/htdocs/knowledgemanagement/knowledgerecord_note.php b/htdocs/knowledgemanagement/knowledgerecord_note.php
index 5e00656e9a7..1f2aec596dd 100644
--- a/htdocs/knowledgemanagement/knowledgerecord_note.php
+++ b/htdocs/knowledgemanagement/knowledgerecord_note.php
@@ -68,7 +68,7 @@ $permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'wr
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
-restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
+restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
/*
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 8f97a7461a0..76db76bb441 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -3074,8 +3074,8 @@ class Product extends CommonObject
$this->duration = $obj->duration;
$matches = [];
- preg_match('/(\d+)(\w+)/', $obj->duration, $matches);
- $this->duration_value = !empty($matches[1]) ? (int) $matches[1] : 0;
+ preg_match('/([\d.]+)(\w+)/', $obj->duration, $matches);
+ $this->duration_value = !empty($matches[1]) ? (float) $matches[1] : 0;
$this->duration_unit = !empty($matches[2]) ? (string) $matches[2] : null;
$this->canvas = $obj->canvas;
$this->net_measure = $obj->net_measure;
diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php
index 7e3e3cac80c..9b1953018b4 100644
--- a/htdocs/product/stock/stockatdate.php
+++ b/htdocs/product/stock/stockatdate.php
@@ -296,7 +296,7 @@ if (!empty($search_fk_warehouse)) {
}
// Add fields from hooks
$parameters = array();
-$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
+$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
@@ -305,7 +305,7 @@ if (!empty($search_fk_warehouse)) {
}
// Add fields from hooks
$parameters = array();
-$reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook
+$reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if ($productid > 0) {
@@ -323,8 +323,24 @@ if ($search_ref) {
if ($search_nom) {
$sql .= natural_search('p.label', $search_nom);
}
-$sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.pmp, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
-$sql .= ' p.tms, p.duration, p.tobuy, p.stock';
+
+$sqlGroupBy = ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.pmp, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
+$sqlGroupBy .= ' p.tms, p.duration, p.tobuy, p.stock';
+
+$parameters = array('sqlGroupBy' => $sqlGroupBy);
+$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+
+if ($reshook == 0) {
+ // Allows the hook to add things (old behavior)
+ $sql .= $hookmanager->resPrint;
+ // Allows the hook to REPLACE the clause (new behavior)
+ if (!empty($hookmanager->resArray['sqlGroupBy'])) {
+ $sqlGroupBy = $hookmanager->resArray['sqlGroupBy'];
+ }
+}
+
+$sql .= $sqlGroupBy;
+
// Add where from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php
index ce5d2b0d0d1..4faa587a5f7 100644
--- a/htdocs/resource/list.php
+++ b/htdocs/resource/list.php
@@ -93,6 +93,8 @@ if (empty($sortfield)) {
$sortfield = "t.ref";
}
+$search_all = trim(GETPOST('search_all', 'alphanohtml'));
+
// Load variable for pagination
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
@@ -356,7 +358,7 @@ if (!$resql) {
$num = $db->num_rows($resql);
// Direct jump if only one record found
-if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && !$page) {
+if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".dol_buildpath('/resource/card.php', 1).'?id='.$id);
@@ -459,9 +461,10 @@ print ''."\n";
// Fields title search
print '';
+// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print '';
- $searchpicto = $form->showFilterButtons();
+ print ' ';
+ $searchpicto = $form->showFilterButtons('left');
print $searchpicto;
print ' ';
}
@@ -538,6 +541,7 @@ $totalarray['nbfield'] = 0;
// Fields title label
print ' ';
+// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
}
@@ -605,7 +609,22 @@ while ($i < $imaxinloop) {
$objectstatic->max_users = $obj->max_users;
$objectstatic->url = $obj->url;
- print ' ';
+ print ' ';
+ // Action column
+ if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
+ print '';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print ' ';
+ }
+ print ' ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index d77cfe6a153..e50fb6f4dfd 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -1320,10 +1320,13 @@ class Societe extends CommonObject
$array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'TVA_INTRA', 'ACCOUNTANCY_CODE_CUSTOMER', 'ACCOUNTANCY_CODE_SUPPLIER');
foreach ($array_to_check as $key) {
$keymin = strtolower($key);
+ $keyfield_db = $keymin;
if ($key == 'ACCOUNTANCY_CODE_CUSTOMER') {
$keymin = 'code_compta_client';
+ $keyfield_db = 'code_compta';
} elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER') {
$keymin = 'code_compta_fournisseur';
+ $keyfield_db = 'code_compta_fournisseur';
}
$i = (int) preg_replace('/[^0-9]/', '', $key);
$vallabel = $this->$keymin;
@@ -1385,7 +1388,7 @@ class Societe extends CommonObject
} elseif ($key == 'ACCOUNTANCY_CODE_CUSTOMER' && !empty($this->client)) {
// Check for unicity
if ($vallabel && getDolGlobalString('SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_UNIQUE')) {
- if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) {
+ if ($this->id_prof_exists($keyfield_db, $vallabel, ($this->id > 0 ? $this->id : 0))) {
$langs->loadLangs(array("errors", 'compta'));
$error++;
$this->errors[] = $langs->trans('CustomerAccountancyCodeShort') . " " . $langs->trans("ErrorProdIdAlreadyExist", $vallabel) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')';
@@ -1401,7 +1404,7 @@ class Societe extends CommonObject
} elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER' && !empty($this->fournisseur)) {
// Check for unicity
if ($vallabel && getDolGlobalString('SOCIETE_ACCOUNTANCY_CODE_SUPPLIER_UNIQUE')) {
- if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) {
+ if ($this->id_prof_exists($keyfield_db, $vallabel, ($this->id > 0 ? $this->id : 0))) {
$langs->loadLangs(array("errors", 'compta'));
$error++;
$this->errors[] = $langs->trans('SupplierAccountancyCodeShort') . " " . $langs->trans("ErrorProdIdAlreadyExist", $vallabel) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')';