Merge branch '16.0' of git@github.com:Dolibarr/dolibarr.git into fix_broken_feature_wrong_fk_parent_line

This commit is contained in:
Regis Houssin 2022-09-16 14:14:57 +02:00
commit 7eb3f16e62
35 changed files with 221 additions and 116 deletions

View File

@ -142,7 +142,7 @@ if (!function_exists("ldap_connect")) {
print dol_get_fiche_head($head, 'contacts', $langs->trans("LDAPSetup"), -1);
print $langs->trans("LDAPDescContact").'<br>';
print '<span class="opacitymedium">'.$langs->trans("LDAPDescContact").'</span><br>';
print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue&token='.newToken().'">';

View File

@ -116,7 +116,7 @@ if (!function_exists("ldap_connect")) {
print dol_get_fiche_head($head, 'groups', $langs->trans("LDAPSetup"), -1);
print $langs->trans("LDAPDescGroups").'<br>';
print '<span class="opacitymedium">'.$langs->trans("LDAPDescGroups").'</span><br>';
print '<br>';

View File

@ -190,7 +190,7 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
print dol_get_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1);
print $langs->trans("LDAPDescMembers").'<br>';
print '<span class="opacitymedium">'.$langs->trans("LDAPDescMembers").'</span><br>';
print '<br>';
print '<table class="noborder centpercent">';

View File

@ -108,7 +108,7 @@ if (!function_exists("ldap_connect")) {
print dol_get_fiche_head($head, 'memberstypes', $langs->trans("LDAPSetup"), -1);
print $langs->trans("LDAPDescMembersTypes").'<br>';
print '<span class="opacitymedium">'.$langs->trans("LDAPDescMembersTypes").'</span><br>';
print '<br>';

View File

@ -179,7 +179,7 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
print dol_get_fiche_head($head, 'users', $langs->trans("LDAPSetup"), -1);
print $langs->trans("LDAPDescUsers").'<br>';
print '<span class="opacitymedium">'.$langs->trans("LDAPDescUsers").'</span><br>';
print '<br>';

View File

@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("install", "other", "admin"));
$langs->loadLangs(array("install", "other", "admin", "products"));
if (!$user->admin) {
accessforbidden();

View File

@ -451,7 +451,8 @@ if (!empty($arrayfields['p.ref']['checked'])) {
if (!empty($arrayfields['cs.fk_user']['checked'])) {
// Employee
print '<td class="liste_titre">';
print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', '0', 0, '', 0, '', '', 0, 0, true);
print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth150', 0, 0, true);
print '</td>';
}
// Filter: Type
@ -592,7 +593,7 @@ while ($i < min($num, $limit)) {
if (isModEnabled('accounting')) {
$typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code;
}
print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($typelabelpopup).'">'.dol_escape_htmltag($typelabeltoshow).'</td>';
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($typelabelpopup).'">'.dol_escape_htmltag($typelabeltoshow).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
@ -600,7 +601,7 @@ while ($i < min($num, $limit)) {
// Date
if (!empty($arrayfields['cs.date_ech']['checked'])) {
print '<td class="center">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
@ -608,7 +609,7 @@ while ($i < min($num, $limit)) {
// Date end period
if (!empty($arrayfields['cs.periode']['checked'])) {
print '<td class="center">'.dol_print_date($db->jdate($obj->periode), 'day').'</td>';
print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->periode), 'day').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
@ -616,7 +617,7 @@ while ($i < min($num, $limit)) {
// Project ref
if (!empty($arrayfields['p.ref']['checked'])) {
print '<td class="nowrap">';
print '<td class="nowraponall">';
if ($obj->project_id > 0) {
print $projectstatic->getNomUrl(1);
}
@ -628,7 +629,7 @@ while ($i < min($num, $limit)) {
if (!empty($arrayfields['cs.fk_user']['checked'])) {
// Employee
print "<td>";
print '<td class="tdoverflowmax150">';
if (!empty($obj->fk_user)) {
if (!empty($TLoadedUsers[$obj->fk_user])) {
$ustatic = $TLoadedUsers[$obj->fk_user];
@ -647,7 +648,7 @@ while ($i < min($num, $limit)) {
// Type
if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
print '<td>';
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans("PaymentTypeShort".$obj->payment_code)).'">';
if (!empty($obj->payment_code)) {
print $langs->trans("PaymentTypeShort".$obj->payment_code);
}
@ -659,7 +660,7 @@ while ($i < min($num, $limit)) {
// Account
if (!empty($arrayfields['cs.fk_account']['checked'])) {
print '<td>';
print '<td class="toverflowmax150">';
if ($obj->fk_account > 0) {
$bankstatic->id = $obj->fk_account;
$bankstatic->ref = $obj->bref;
@ -682,7 +683,7 @@ while ($i < min($num, $limit)) {
// Amount
if (!empty($arrayfields['cs.amount']['checked'])) {
print '<td class="nowrap amount right">'.price($obj->amount).'</td>';
print '<td class="nowraponall amount right">'.price($obj->amount).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
@ -694,7 +695,7 @@ while ($i < min($num, $limit)) {
// Status
if (!empty($arrayfields['cs.paye']['checked'])) {
print '<td class="nowrap right">'.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
print '<td class="nowraponall right">'.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}

View File

@ -3554,7 +3554,7 @@ abstract class CommonObject
$forcedroundingmode = $roundingadjust;
if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) {
$forcedroundingmode = $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND;
$forcedroundingmode = getDolGlobalString('MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND');
} elseif ($forcedroundingmode == 'auto') {
$forcedroundingmode = '0';
}
@ -3679,14 +3679,17 @@ abstract class CommonObject
}
$sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - $diff).", total_ttc = ".price2num($obj->total_ttc - $diff)." WHERE rowid = ".((int) $obj->rowid);
dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
$resqlfix = $this->db->query($sqlfix);
$resqlfix = $this->db->query($sqlfix);
if (!$resqlfix) {
dol_print_error($this->db, 'Failed to update line');
}
$this->total_tva -= $diff;
$this->total_ttc -= $diff;
$total_tva_by_vats[$obj->vatrate] -= $diff;
$total_ttc_by_vats[$obj->vatrate] -= $diff;
$this->total_tva = (float) price2num($this->total_tva - $diff, '', 1);
$this->total_ttc = (float) price2num($this->total_ttc - $diff, '', 1);
$total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - $diff, '', 1);
$total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - $diff, '', 1);
}
}
@ -3713,6 +3716,13 @@ abstract class CommonObject
}
}
// Clean total
$this->total_ht = (float) price2num($this->total_ht);
$this->total_tva = (float) price2num($this->total_tva);
$this->total_localtax1 = (float) price2num($this->total_localtax1);
$this->total_localtax2 = (float) price2num($this->total_localtax2);
$this->total_ttc = (float) price2num($this->total_ttc);
$this->db->free($resql);
// Now update global field total_ht, total_ttc, total_tva, total_localtax1, total_localtax2, multicurrency_total_*
@ -3746,11 +3756,11 @@ abstract class CommonObject
if (empty($nodatabaseupdate)) {
$sql = "UPDATE ".$this->db->prefix().$this->table_element.' SET';
$sql .= " ".$fieldht." = ".((float) price2num($this->total_ht)).",";
$sql .= " ".$fieldtva." = ".((float) price2num($this->total_tva)).",";
$sql .= " ".$fieldlocaltax1." = ".((float) price2num($this->total_localtax1)).",";
$sql .= " ".$fieldlocaltax2." = ".((float) price2num($this->total_localtax2)).",";
$sql .= " ".$fieldttc." = ".((float) price2num($this->total_ttc));
$sql .= " ".$fieldht." = ".((float) price2num($this->total_ht, 'MT', 1)).",";
$sql .= " ".$fieldtva." = ".((float) price2num($this->total_tva, 'MT', 1)).",";
$sql .= " ".$fieldlocaltax1." = ".((float) price2num($this->total_localtax1, 'MT', 1)).",";
$sql .= " ".$fieldlocaltax2." = ".((float) price2num($this->total_localtax2, 'MT', 1)).",";
$sql .= " ".$fieldttc." = ".((float) price2num($this->total_ttc, 'MT', 1));
$sql .= ", multicurrency_total_ht = ".((float) price2num($this->multicurrency_total_ht, 'MT', 1));
$sql .= ", multicurrency_total_tva = ".((float) price2num($this->multicurrency_total_tva, 'MT', 1));
$sql .= ", multicurrency_total_ttc = ".((float) price2num($this->multicurrency_total_ttc, 'MT', 1));

View File

@ -5141,6 +5141,12 @@ class Form
},';
}
$jsforcursor = '';
if (empty($useajax)) {
$jsforcursor = '// The call to urljump can be slow, so we set the wait cursor'."\n";
$jsforcursor .= 'jQuery("html,body,#id-container").addClass("cursorwait");'."\n";
}
$formconfirm .= '
resizable: false,
height: "'.$height.'",
@ -5152,7 +5158,8 @@ class Form
var options = "&token='.urlencode(newToken()).'";
var inputok = '.json_encode($inputok).'; /* List of fields into form */
var pageyes = "'.dol_escape_js(!empty($pageyes) ? $pageyes : '').'";
if (inputok.length>0) {
if (inputok.length > 0) {
$.each(inputok, function(i, inputname) {
var more = "";
var inputvalue;
@ -5168,14 +5175,18 @@ class Form
});
}
var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "") + options;
if (pageyes.length > 0) { location.href = urljump; }
$(this).dialog("close");
if (pageyes.length > 0) {
'.$jsforcursor.'
location.href = urljump;
console.log("after location.href");
}
$(this).dialog("close");
},
"'.dol_escape_js($langs->transnoentities($labelbuttonno)).'": function() {
var options = "&token='.urlencode(newToken()).'";
var inputko = '.json_encode($inputko).'; /* List of fields into form */
var pageno="'.dol_escape_js(!empty($pageno) ? $pageno : '').'";
if (inputko.length>0) {
if (inputko.length > 0) {
$.each(inputko, function(i, inputname) {
var more = "";
if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
@ -5186,7 +5197,10 @@ class Form
}
var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "") + options;
//alert(urljump);
if (pageno.length > 0) { location.href = urljump; }
if (pageno.length > 0) {
location.href = urljump;
console.log("after location.href");
}
$(this).dialog("close");
}
}

View File

@ -263,6 +263,7 @@ class Ldap
if ($this->result) {
$this->bind = $this->result;
$connected = 2;
$this->connectedServer = $host;
break;
} else {
$this->error = ldap_errno($this->connection).' '.ldap_error($this->connection);
@ -275,6 +276,7 @@ class Ldap
if ($this->result) {
$this->bind = $this->result;
$connected = 2;
$this->connectedServer = $host;
break;
} else {
$this->error = ldap_errno($this->connection).' '.ldap_error($this->connection);
@ -287,6 +289,7 @@ class Ldap
if ($result) {
$this->bind = $this->result;
$connected = 1;
$this->connectedServer = $host;
break;
} else {
$this->error = ldap_errno($this->connection).' '.ldap_error($this->connection);
@ -297,10 +300,8 @@ class Ldap
if (!$connected) {
$this->unbind();
} else {
$this->connectedServer = $host;
}
}
} // End loop on each server
}
if ($connected) {

View File

@ -182,9 +182,18 @@ interface Database
*
* @param string $stringtoencode String to escape
* @return string String escaped
* @deprecated
*/
public function escapeunderscore($stringtoencode);
/**
* Escape a string to insert data into a like
*
* @param string $stringtoencode String to escape
* @return string String escaped
*/
public function escapeforlike($stringtoencode);
/**
* Sanitize a string for SQL forging
*

View File

@ -479,12 +479,24 @@ class DoliDBMysqli extends DoliDB
*
* @param string $stringtoencode String to escape
* @return string String escaped
* @deprecated
*/
public function escapeunderscore($stringtoencode)
{
return str_replace('_', '\_', (string) $stringtoencode);
}
/**
* Escape a string to insert data into a like
*
* @param string $stringtoencode String to escape
* @return string String escaped
*/
public function escapeforlike($stringtoencode)
{
return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode);
}
/**
* Return generic error code of last operation.
*

View File

@ -726,10 +726,22 @@ class DoliDBPgsql extends DoliDB
*
* @param string $stringtoencode String to escape
* @return string String escaped
* @deprecated
*/
public function escapeunderscore($stringtoencode)
{
return str_replace('_', '\_', $stringtoencode);
return str_replace('_', '\_', (string) $stringtoencode);
}
/**
* Escape a string to insert data into a like
*
* @param string $stringtoencode String to escape
* @return string String escaped
*/
public function escapeforlike($stringtoencode)
{
return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode);
}
/**

View File

@ -654,10 +654,22 @@ class DoliDBSqlite3 extends DoliDB
*
* @param string $stringtoencode String to escape
* @return string String escaped
* @deprecated
*/
public function escapeunderscore($stringtoencode)
{
return str_replace('_', '\_', $stringtoencode);
return str_replace('_', '\_', (string) $stringtoencode);
}
/**
* Escape a string to insert data into a like
*
* @param string $stringtoencode String to escape
* @return string String escaped
*/
public function escapeforlike($stringtoencode)
{
return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode);
}
/**

View File

@ -372,16 +372,16 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
// If rounding is not using base 10 (rare)
if (!empty($conf->global->MAIN_ROUNDING_RULE_TOT)) {
if ($price_base_type == 'HT') {
$result[0] = round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[0] = price2num(round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
$result[1] = price2num(round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
$result[9] = price2num(round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
$result[10] = price2num(round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
$result[2] = price2num($result[0] + $result[1] + $result[9] + $result[10], 'MT');
} else {
$result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[2] = round($result[2] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[1] = price2num(round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
$result[2] = price2num(round($result[2] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
$result[9] = price2num(round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
$result[10] = price2num(round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
$result[0] = price2num($result[2] - $result[1] - $result[9] - $result[10], 'MT');
}
}

View File

@ -947,11 +947,11 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
$sql .= " AND (";
$searchalgo = '';
if (preg_match('/meta/', $algo)) {
$searchalgo .= ($searchalgo ? ' OR ' : '')."wp.title LIKE '%".$db->escapeunderscore($db->escape($searchstring))."%' OR wp.description LIKE '%".$db->escapeunderscore($db->escape($searchstring))."%'";
$searchalgo .= ($searchalgo ? ' OR ' : '')."wp.keywords LIKE '".$db->escapeunderscore($db->escape($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escapeunderscore($db->escape($searchstring))."%'"; // TODO Use a better way to scan keywords
$searchalgo .= ($searchalgo ? ' OR ' : '')."wp.title LIKE '%".$db->escapeforlike($db->escape($searchstring))."%' OR wp.description LIKE '%".$db->escapeforlike($db->escape($searchstring))."%'";
$searchalgo .= ($searchalgo ? ' OR ' : '')."wp.keywords LIKE '".$db->escapeforlike($db->escape($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escapeforlike($db->escape($searchstring))."%'"; // TODO Use a better way to scan keywords
}
if (preg_match('/content/', $algo)) {
$searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escapeunderscore($db->escape($searchstring))."%'";
$searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escapeforlike($db->escape($searchstring))."%'";
}
$sql .= $searchalgo;
if (is_array($otherfilters) && !empty($otherfilters['category'])) {

View File

@ -233,12 +233,14 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
$usertmp = new User($db);
$usertmp->fetch('', $login);
$ret = $mc->checkRight($usertmp->id, $entitytotest);
if ($ret < 0) {
dol_syslog("functions_ldap::check_user_password_ldap Authentication KO entity '".$entitytotest."' not allowed for user id '".$usertmp->id."'", LOG_NOTICE);
$login = ''; // force authentication failure
if (is_object($mc)) {
$ret = $mc->checkRight($usertmp->id, $entitytotest);
if ($ret < 0) {
dol_syslog("functions_ldap::check_user_password_ldap Authentication KO entity '".$entitytotest."' not allowed for user id '".$usertmp->id."'", LOG_NOTICE);
$login = ''; // force authentication failure
}
unset($usertmp);
}
unset($usertmp);
}
}
if ($result == 1) {

View File

@ -1269,7 +1269,7 @@ class pdf_sponge extends ModelePDFFactures
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
global $langs;
$langs->loadLangs(array('payment', 'paybox'));
$langs->loadLangs(array('payment', 'paybox', 'stripe'));
$servicename = $langs->transnoentities('Online');
$paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, '', '', '');
$linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' <a href="'.$paiement_url.'">'.$outputlangs->transnoentities("ClickHere").'</a>';

View File

@ -835,8 +835,8 @@ class ImportCsv extends ModeleImports
$sqlSelect = "SELECT ".$fname." FROM ".$tablename;
$data = array_combine($listfields, $listvalues);
$where = array();
$filters = array();
$where = array(); // filters to forge SQL request
$filters = array(); // filters to forge output error message
foreach ($updatekeys as $key) {
$col = $objimport->array_import_updatekeys[0][$key];
$key = preg_replace('/^.*\./i', '', $key);
@ -846,8 +846,12 @@ class ImportCsv extends ModeleImports
$socialnetwork = $tmp[1];
$jsondata = $data[$key];
$json = json_decode($jsondata);
$where[] = $key." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'";
$filters[] = $col." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'";
$stringtosearch = json_encode($socialnetwork).':'.json_encode($json->$socialnetwork);
//var_dump($stringtosearch);
//var_dump($this->db->escape($stringtosearch)); // This provide a value for sql string (but not for a like)
$where[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'";
$filters[] = $col." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'";
//var_dump($where[1]); // This provide a value for sql string inside a like
} else {
$where[] = $key.' = '.$data[$key];
$filters[] = $col.' = '.$data[$key];

View File

@ -891,8 +891,12 @@ class ImportXlsx extends ModeleImports
$socialnetwork = $tmp[1];
$jsondata = $data[$key];
$json = json_decode($jsondata);
$where[] = $key." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'";
$filters[] = $col." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'";
$stringtosearch = json_encode($socialnetwork).':'.json_encode($json->$socialnetwork);
//var_dump($stringtosearch);
//var_dump($this->db->escape($stringtosearch)); // This provide a value for sql string (but not for a like)
$where[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'";
$filters[] = $col." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'";
//var_dump($where[1]); // This provide a value for sql string inside a like
} else {
$where[] = $key.' = '.$data[$key];
$filters[] = $col.' = '.$data[$key];

View File

@ -272,6 +272,24 @@ class modAccounting extends DolibarrModules
//--------
$r = 0;
// Chart of accounts
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = "Chartofaccounts"; // Translation key
$this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = array('aa'=>MAIN_DB_PREFIX.'accounting_account');
$this->import_tables_creator_array[$r] = array('aa'=>'fk_user_author'); // Fields to store import user id
$this->import_fields_array[$r] = array('aa.fk_pcg_version'=>"Chartofaccounts*", 'aa.account_number'=>"AccountAccounting*", 'aa.label'=>"Label*", 'aa.account_parent'=>"Accountparent", "aa.fk_accounting_category"=>"AccountingCategory", "aa.pcg_type"=>"Pcgtype*", 'aa.active'=>'Status*', 'aa.datec'=>"DateCreation");
$this->import_regex_array[$r] = array('aa.fk_pcg_version'=>'pcg_version@'.MAIN_DB_PREFIX.'accounting_system', 'aa.account_number'=>'^.{1,32}$', 'aa.label'=>'^.{1,255}$', 'aa.account_parent'=>'^.{0,32}$', 'aa.fk_accounting_category'=>'rowid@'.MAIN_DB_PREFIX.'c_accounting_category', 'aa.pcg_type'=>'^.{1,20}$', 'aa.active'=>'^0|1$', 'aa.datec'=>'^\d{4}-\d{2}-\d{2}$');
$this->import_convertvalue_array[$r] = array(
'aa.account_number'=>array('rule'=>'accountingaccount'),
'aa.account_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/accountancy/class/accountingaccount.class.php', 'class'=>'AccountingAccount', 'method'=>'fetch', 'element'=>'AccountingAccount'),
'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/accountancy/class/accountancycategory.class.php', 'class'=>'AccountancyCategory', 'method'=>'fetch', 'dict'=>'DictionaryAccountancyCategory'),
);
$this->import_examplevalues_array[$r] = array('aa.fk_pcg_version'=>"PCG99-ABREGE", 'aa.account_number'=>"707", 'aa.label'=>"Product sales", 'aa.account_parent'=>"ref:7 or id:1407", "aa.fk_accounting_category"=>"", "aa.pcg_type"=>"PROD", 'aa.active'=>'1', 'aa.datec'=>"2017-04-28");
$this->import_updatekeys_array[$r] = array('aa.fk_pcg_version'=>'Chartofaccounts', 'aa.account_number'=>'AccountAccounting');
// General ledger
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
@ -393,23 +411,5 @@ class modAccounting extends DolibarrModules
'b.multicurrency_amount'=>"90 (Necessary if devise is different than EUR)",
'b.multicurrency_code'=>"US (Necessary if devise is different than EUR)",
);
// Chart of accounts
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = "Chartofaccounts"; // Translation key
$this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = array('aa'=>MAIN_DB_PREFIX.'accounting_account');
$this->import_tables_creator_array[$r] = array('aa'=>'fk_user_author'); // Fields to store import user id
$this->import_fields_array[$r] = array('aa.fk_pcg_version'=>"Chartofaccounts*", 'aa.account_number'=>"AccountAccounting*", 'aa.label'=>"Label*", 'aa.account_parent'=>"Accountparent", "aa.fk_accounting_category"=>"AccountingCategory", "aa.pcg_type"=>"Pcgtype*", 'aa.active'=>'Status*', 'aa.datec'=>"DateCreation");
$this->import_regex_array[$r] = array('aa.fk_pcg_version'=>'pcg_version@'.MAIN_DB_PREFIX.'accounting_system', 'aa.account_number'=>'^.{1,32}$', 'aa.label'=>'^.{1,255}$', 'aa.account_parent'=>'^.{0,32}$', 'aa.fk_accounting_category'=>'rowid@'.MAIN_DB_PREFIX.'c_accounting_category', 'aa.pcg_type'=>'^.{1,20}$', 'aa.active'=>'^0|1$', 'aa.datec'=>'^\d{4}-\d{2}-\d{2}$');
$this->import_convertvalue_array[$r] = array(
'aa.account_number'=>array('rule'=>'accountingaccount'),
'aa.account_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/accountancy/class/accountingaccount.class.php', 'class'=>'AccountingAccount', 'method'=>'fetch', 'element'=>'AccountingAccount'),
'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/accountancy/class/accountancycategory.class.php', 'class'=>'AccountancyCategory', 'method'=>'fetch', 'dict'=>'DictionaryAccountancyCategory'),
);
$this->import_examplevalues_array[$r] = array('aa.fk_pcg_version'=>"PCG99-ABREGE", 'aa.account_number'=>"707", 'aa.label'=>"Product sales", 'aa.account_parent'=>"ref:7 or id:1407", "aa.fk_accounting_category"=>"", "aa.pcg_type"=>"PROD", 'aa.active'=>'1', 'aa.datec'=>"2017-04-28");
$this->import_updatekeys_array[$r] = array('aa.fk_pcg_version'=>'Chartofaccounts', 'aa.account_number'=>'AccountAccounting');
}
}

View File

@ -747,7 +747,7 @@ class modSociete extends DolibarrModules
's.fk_departement' => "StateCode",
's.fk_pays' => "CountryCode",
's.birthday' => "DateOfBirth",
's.poste' => "Role",
's.poste' => "PostOrFunction",
's.phone' => "Phone",
's.phone_perso' => "PhonePerso",
's.phone_mobile' => "PhoneMobile",

View File

@ -172,27 +172,32 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
"ErrorBadMaskBadRazMonth",
"ErrorCantUseRazWithYearOnOneDigit",
);
$cssforerror = (getDolGlobalString('SOCIETE_CODECLIENT_ADDON') == 'mod_codeclient_elephant' ? 'error' : 'opacitymedium');
if ($type != 1) {
$examplecust = $this->getNextValue($objsoc, 0);
if (!$examplecust) {
$examplecust = '<div class="error">'.$langs->trans('NotConfigured').'</div>';
if (!$examplecust && ($cssforerror == 'error' || $this->error != 'NotConfigured')) {
$langs->load("errors");
$examplecust = '<span class="'.$cssforerror.'">'.$langs->trans('ErrorBadMask').'</span>';
$error = 1;
}
if (in_array($examplecust, $errmsg)) {
$langs->load("errors");
$examplecust = '<div class="error">'.$langs->trans($examplecust).'</div>';
$examplecust = '<span class="'.$cssforerror.'">'.$langs->trans($examplecust).'</span>';
$error = 1;
}
}
if ($type != 0) {
$examplesup = $this->getNextValue($objsoc, 1);
if (!$examplesup) {
$examplesup = '<div class="error">'.$langs->trans('NotConfigured').'</div>';
if (!$examplesup && ($cssforerror == 'error' || $this->error != 'NotConfigured')) {
$langs->load("errors");
$examplesup = '<span class="'.$cssforerror.'">'.$langs->trans('ErrorBadMask').'</span>';
$error = 1;
}
if (in_array($examplesup, $errmsg)) {
$langs->load("errors");
$examplesup = '<div class="error">'.$langs->trans($examplesup).'</div>';
$examplesup = '<span class="'.$cssforerror.'">'.$langs->trans($examplesup).'</span>';
$error = 1;
}
}
@ -202,11 +207,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
} elseif ($type == 1) {
return $examplesup;
} else {
if ($error == 1) {
return $examplecust.' '.$examplesup;
} else {
return $examplecust.'<br>'.$examplesup;
}
return $examplecust.'<br>'.$examplesup;
}
}

View File

@ -255,12 +255,24 @@ class TraceableDB extends DoliDB
*
* @param string $stringtoencode String to escape
* @return string String escaped
* @deprecated
*/
public function escapeunderscore($stringtoencode)
{
return $this->db->escapeunderscore($stringtoencode);
}
/**
* Escape a string to insert data into a like
*
* @param string $stringtoencode String to escape
* @return string String escaped
*/
public function escapeforlike($stringtoencode)
{
return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Get last ID after an insert INSERT

View File

@ -2054,6 +2054,8 @@ class CommandeFournisseur extends CommonOrder
$now = dol_now();
$inventorycode = dol_print_date(dol_now(), 'dayhourlog');
if (($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY || $this->statut == self::STATUS_RECEIVED_COMPLETELY)) {
$this->db->begin();
@ -2087,12 +2089,14 @@ class CommandeFournisseur extends CommonOrder
// $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on)
$mouv->origin = &$this;
$mouv->setOrigin($this->element, $this->id);
// Method change if qty < 0
if (!empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN) && $qty < 0) {
$result = $mouv->livraison($user, $product, $entrepot, $qty*(-1), $price, $comment, $now, $eatby, $sellby, $batch);
} else {
$result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch);
$result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch, $inventorycode);
}
if ($result < 0) {
$this->error = $mouv->error;
$this->errors = $mouv->errors;

View File

@ -221,6 +221,7 @@ if ($action == 'denydispatchline' && $permissiontocontrol) {
if ($action == 'dispatch' && $permissiontoreceive) {
$error = 0;
$notrigger = 0;
$db->begin();

View File

@ -235,6 +235,7 @@ if ($action == 'add_import_model') {
$result = $objimport->create($user);
if ($result >= 0) {
setEventMessages($langs->trans("ImportModelSaved", $objimport->model_name), null, 'mesgs');
$import_name = '';
} else {
$langs->load("errors");
if ($objimport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
@ -1286,7 +1287,7 @@ if ($step == 4 && $datatoimport) {
print '</td></tr>';
// Lines for remark
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Remark").'</td></tr>';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Note").'</td></tr>';
print '<tr><td colspan="2"><div id="div-mandatory-target-fields-not-mapped"></div></td></tr>';
print '</table>';
@ -1470,8 +1471,8 @@ if ($step == 4 && $datatoimport) {
print '</tr>';
$nameofimportprofile = str_replace(' ', '-', $langs->trans("ImportProfile").' '.$titleofmodule.' '.dol_print_date(dol_now('gmt'), 'dayxcard'));
if (is_object($objimport) && !empty($objimport->model_name)) {
$nameofimportprofile = $objimport->model_name;
if (GETPOST('import_name')) { // If we have submited a form, we take value used fot the update try
$nameofimportprofile = $import_name;
}
print '<tr class="oddeven">';
@ -1966,9 +1967,9 @@ if ($step == 5 && $datatoimport) {
print '<div class="center">';
print '<span class="opacitymedium">'.$langs->trans("NowClickToRunTheImport", $langs->transnoentitiesnoconv("RunImportFile")).'</span><br>';
if (empty($nboferrors)) {
/*if (empty($nboferrors)) {
print $langs->trans("DataLoadedWithId", $importid).'<br>';
}
}*/
print '</div>';
print '<br>';

View File

@ -662,8 +662,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) {
$defaultstockmovementlabel = GETPOST('inventorylabel', 'alphanohtml') ? GETPOST('inventorylabel', 'alphanohtml') : $langs->trans("ProductionForRef", $object->ref);
//$defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $object->ref.'_'.dol_print_date(dol_now(), 'dayhourlog');
$defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $langs->trans("ProductionForRef", $object->ref);
$defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : dol_print_date(dol_now(), 'dayhourlog');
print '<div class="center'.(in_array($action, array('consumeorproduce', 'consumeandproduceall')) ? ' formconsumeproduce' : '').'">';
print '<div class="opacitymedium hideonsmartphone paddingbottom">'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'<br></div>';

View File

@ -345,6 +345,7 @@ class Project extends CommonObject
$this->fields['accept_booth_suggestions']['enabled'] = 0;
$this->fields['price_registration']['enabled'] = 0;
$this->fields['price_booth']['enabled'] = 0;
$this->fields['max_attendees']['enabled'] = 0;
}
}

View File

@ -1052,7 +1052,7 @@ while ($i < $imaxinloop) {
// Description
if (!empty($arrayfields['t.description']['checked'])) {
print '<td>';
print dol_escape_htmltag($object->description);
print dolGetFirstLineOfText($object->description, 5);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;

View File

@ -1445,24 +1445,19 @@ while ($i < min($num, $limit)) {
}
}
if (!empty($arrayfields['s.nom']['checked'])) {
$savalias = $obj->name_alias;
if (!empty($arrayfields['s.name_alias']['checked'])) {
$companystatic->name_alias = '';
}
print '<td'.(empty($conf->global->MAIN_SOCIETE_SHOW_COMPLETE_NAME) ? ' class="tdoverflowmax200"' : '').' data-key="ref">';
if ($contextpage == 'poslist') {
print $obj->name;
print dol_escape_htmltag($obj->name);
} else {
print $companystatic->getNomUrl(1, '', 100, 0, 1);
print $companystatic->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
}
print "</td>\n";
$companystatic->name_alias = $savalias;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['s.name_alias']['checked'])) {
print '<td class="tdoverflowmax200">';
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).'">';
print dol_escape_htmltag($companystatic->name_alias);
print "</td>\n";
if (!$i) {
@ -1471,7 +1466,7 @@ while ($i < min($num, $limit)) {
}
// Barcode
if (!empty($arrayfields['s.barcode']['checked'])) {
print '<td>'.dol_escape_htmltag($obj->barcode).'</td>';
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->barcode).'">'.dol_escape_htmltag($obj->barcode).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}

View File

@ -887,6 +887,9 @@ textarea.centpercent {
.cursornotallowed {
cursor: not-allowed;
}
.cursorwait {
cursor: wait;
}
.backgroundblank {
background-color: #fff;
}

View File

@ -1032,6 +1032,9 @@ textarea.centpercent {
.cursormove {
cursor: move;
}
.cursorwait {
cursor: wait;
}
.cursornotallowed {
cursor: not-allowed;
}

View File

@ -81,14 +81,14 @@ if (!$action) {
// Security check
$id = GETPOST("id", 'int');
if ($user->socid > 0) $socid = $user->socid;
$result = restrictedArea($user, 'ticket', $id, '');
$result = restrictedArea($user, 'ticket', $object->id, '');
// restrict access for externals users
if ($user->socid > 0 && ($object->fk_soc != $user->socid)) {
accessforbidden();
}
// or for unauthorized internals users
if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) {
if (!$user->socid && (!empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) {
accessforbidden();
}
@ -144,7 +144,7 @@ if ($socid > 0) {
print dol_get_fiche_end();
}
if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) {
if (!$user->socid && !empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) {
$object->next_prev_filter = "te.fk_user_assign = '".$user->id."'";
} elseif ($user->socid > 0) {
$object->next_prev_filter = "te.fk_soc = '".$user->socid."'";
@ -162,11 +162,15 @@ if ($object->fk_user_create > 0) {
$langs->load("users");
$fuser = new User($db);
$fuser->fetch($object->fk_user_create);
$morehtmlref .= $fuser->getNomUrl(0);
}
if (!empty($object->origin_email)) {
$morehtmlref .= $fuser->getNomUrl(-1);
} elseif (!empty($object->email_msgid)) {
$morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
$morehtmlref .= $object->origin_email.' <small>('.$langs->trans("TicketEmailOriginIssuer").')</small>';
$morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
$morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')</small>';
} elseif (!empty($object->origin_email)) {
$morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
$morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
$morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$langs->trans("CreatedByPublicPortal").')</small>';
}
// Thirdparty

View File

@ -50,7 +50,7 @@ if (!$sortfield) {
$sortfield = "a.datep,a.id";
}
if (!$sortorder) {
$sortorder = "desc";
$sortorder = "DESC";
}
$offset = $limit * $page;
$pageprev = $page - 1;