Merge remote-tracking branch 'upstream/develop' into free_email

This commit is contained in:
Frédéric FRANCE 2020-05-02 13:29:56 +02:00
commit 44f914fede
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
5 changed files with 122 additions and 78 deletions

View File

@ -23,13 +23,12 @@
<!-- Rules from Internal Standard -->
<rule ref="Internal.NoCodeFound">
<severity>0</severity>
</rule>
<rule ref="Internal.NoCodeFound" />
<!-- Rules from Generic Standard -->
<!-- We want to allow empty statement: It allows to put some code comments into the else for examples -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedIf"/>
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedElse"/>
@ -38,8 +37,7 @@
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedForeach"/>
</rule>
<!-- <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" /> -->
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall" />
<rule ref="Generic.CodeAnalysis.JumbledIncrementer" />

View File

@ -1,71 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- BEGIN PHP TEMPLATE LOGIN.TPL.PHP -->
<html>
<head>
<meta name="robots" content="noindex,nofollow" />
<meta name="author" content="Dolibarr Development Team">
<link rel="shortcut icon" type="image/x-icon" href="/dolibarrnew/theme/eldy/img/favicon.ico"/>
<title>Login Dolibarr 3.4.0-alpha</title>
<!-- Includes for JQuery (Ajax library) -->
<link rel="stylesheet" type="text/css" href="/dolibarrnew/includes/jquery/css/smoothness/jquery-ui.custom.css" />
<link rel="stylesheet" type="text/css" title="default" href="/dolibarrnew/custom/filemanager/css/filemanager.css.php"><!-- Added by module filemanager-->
<!-- Includes JS for JQuery -->
<script type="text/javascript" src="/dolibarrnew/includes/jquery/js/jquery.min.js"></script>
<script type="text/javascript" src="/dolibarrnew/core/js/dst.js"></script>
<link rel="stylesheet" type="text/css" href="/dolibarrnew/theme/eldy/style.css.php?lang=fr_FR" />
<!-- HTTP_USER_AGENT = Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22 -->
</head>
<body class="body">
<div class="center">
<div class="login_table center">
<!-- <tr><td colspan="2" valign="middle"> -->
<div id="login_line1" class="center">
<div id="login_left" style="display: inline-block; min-width: 250px; margin: 0 auto;"><div class="center">
<table class="none center" summary="Login pass" cellpadding="2">
<!-- Login -->
<tr>
<td valign="bottom"> &nbsp; <strong><label for="username">Login</label></strong>fds fs df sdf gdsfgsdf r &nbsp; </td>
<td valign="bottom" class="nowrap">
<input type="text" id="username" name="username" class="flat" size="15" maxlength="40" value="" tabindex="1" />
</td>
</tr>
<!-- Password -->
<tr><td class="tdtop nowrap"> &nbsp; <strong><label for="password">Mot de passe</label></strong> &nbsp; </td>
<td class="tdtop nowrap">
<input id="password" name="password" class="flat" type="password" size="15" maxlength="30" value="" tabindex="2" />
</td></tr>
</table>
</div>
</div> <!-- end div left -->
<!-- </td>
<td class="center" valign="middle">-->
<div id="login_right" style="display: inline-block; min-width: 250px; margin: 0 auto;">
<img alt="Logo" title="" src="/dolibarrnew/theme/dolibarr_logo.png" id="img_logo" />
</div>
</div> <!-- end div line1 -->
<!--</td>
</tr>-->
</div>
</div>
</body>
</html>
<!-- END PHP TEMPLATE -->

View File

@ -386,4 +386,77 @@ class CUnits // extends CommonObject
return 1;
}
}
/**
* Get unit from code
* @param string $code code of unit
* @param string $mode 0= id , short_label=Use short label as value, code=use code
* @return int <0 if KO, Id of code if OK
*/
public function getUnitFromCode($code, $mode = 'code')
{
if($mode == 'short_label'){
return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid');
}
elseif($mode == 'code'){
return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid');
}
return $code;
}
/**
* Unit converter
* @param double $value value to convert
* @param int $fk_unit current unit id of value
* @param int $fk_new_unit the id of unit to convert in
* @return double
*/
public function unitConverter($value, $fk_unit, $fk_new_unit = 0)
{
$value = doubleval(price2num($value));
$fk_unit = intval($fk_unit);
// Calcul en unité de base
$scaleUnitPow = $this->scaleOfUnitPow($fk_unit);
// convert to standard unit
$value = $value * $scaleUnitPow;
if($fk_new_unit !=0 ){
// Calcul en unité de base
$scaleUnitPow = $this->scaleOfUnitPow($fk_new_unit);
if(!empty($scaleUnitPow))
{
// convert to new unit
$value = $value / $scaleUnitPow;
}
}
return round($value, 2);
}
/**
* get scale of unit factor
* @param $id int id of unit in dictionary
* @return float|int
*/
public function scaleOfUnitPow($id)
{
$base = 10;
// TODO : add base col into unit dictionary table
$unit = $this->db->getRow('SELECT scale, unit_type from '.MAIN_DB_PREFIX.'c_units WHERE rowid = '.intval($id));
if($unit){
// TODO : if base exist in unit dictionary table remove this convertion exception and update convertion infos in database exemple time hour currently scale 3600 will become scale 2 base 60
if($unit->unit_type == 'time'){
return doubleval($unit->scale);
}
return pow($base, doubleval($unit->scale));
}
return 0;
}
}

View File

@ -297,4 +297,48 @@ abstract class DoliDB implements Database
{
return $this->lastqueryerror;
}
/**
* Return first result from query as object
* Note : This method executes a given SQL query and retrieves the first row of results as an object. It should only be used with SELECT queries
* Dont add LIMIT to your query, it will be added by this method
* @param string $sql the sql query string
* @return bool| object
*/
public function getRow($sql)
{
$sql .= ' LIMIT 1;';
$res = $this->query($sql);
if ($res)
{
return $this->fetch_object($res);
}
return false;
}
/**
* return all results from query as an array of objects
* Note : This method executes a given SQL query and retrieves all row of results as an array of objects. It should only be used with SELECT queries
* be carefull with this method use it only with some limit of results to avoid performences loss
* @param string $sql the sql query string
* @return bool| array
*/
public function getRows($sql)
{
$res = $this->query($sql);
if ($res)
{
$results = array();
if($this->num_rows($res) > 0){
while ($obj = $this->fetch_object($res)){
$results[] = $obj;
}
}
return $results;
}
return false;
}
}

View File

@ -62,5 +62,5 @@ InterLineId=Line id intervention
InterLineDate=Line date intervention
InterLineDuration=Line duration intervention
InterLineDesc=Line description intervention
RepeatableIntervention=Template of intevention
RepeatableIntervention=Template of intervention
ToCreateAPredefinedIntervention=To create a predefined or recurring intervention, create a common intervention and convert it into intervention template