mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 09:38:23 +01:00
Move function colorIsLight into functions.lib.php
Fix scrutinizer bugs.
This commit is contained in:
@@ -1079,22 +1079,26 @@ class BookKeeping extends CommonObject
|
|||||||
* @param string $mode Mode
|
* @param string $mode Mode
|
||||||
* @return number <0 if KO, >0 if OK
|
* @return number <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function updateByMvt($piece_num='', $field='', $value='', $mode='') {
|
public function updateByMvt($piece_num='', $field='', $value='', $mode='')
|
||||||
|
{
|
||||||
|
$error=0;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab";
|
$sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab";
|
||||||
$sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$value."'");
|
$sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$value."'");
|
||||||
$sql .= ' WHERE ab.piece_num=' . $piece_num ;
|
$sql .= ' WHERE ab.piece_num=' . $piece_num ;
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if (! $resql) {
|
if (! $resql) {
|
||||||
$error ++;
|
$error++;
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
if ($error) {
|
if ($error) {
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
|
|
||||||
return - 1 * $error;
|
return -1 * $error;
|
||||||
} else {
|
} else {
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|
||||||
@@ -1521,11 +1525,16 @@ class BookKeeping extends CommonObject
|
|||||||
* @param string $piece_num Piece num
|
* @param string $piece_num Piece num
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function transformTransaction($direction=0,$piece_num='') {
|
public function transformTransaction($direction=0,$piece_num='')
|
||||||
|
{
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
if ($direction==0) {
|
|
||||||
|
if ($direction==0)
|
||||||
|
{
|
||||||
$next_piecenum=$this->getNextNumMvt();
|
$next_piecenum=$this->getNextNumMvt();
|
||||||
if ($result < 0) {
|
if ($next_piecenum < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element.'(doc_date, doc_type,';
|
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element.'(doc_date, doc_type,';
|
||||||
|
|||||||
@@ -1563,7 +1563,7 @@ class Adherent extends CommonObject
|
|||||||
* @param int $withpictoimg 0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small)
|
* @param int $withpictoimg 0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small)
|
||||||
* @param int $maxlen length max label
|
* @param int $maxlen length max label
|
||||||
* @param string $option Page for link ('card', 'category', 'subscription', ...)
|
* @param string $option Page for link ('card', 'category', 'subscription', ...)
|
||||||
* @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref
|
* @param string $mode ''=Show firstname+lastname as label (using default order), 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref
|
||||||
* @param string $morecss Add more css on link
|
* @param string $morecss Add more css on link
|
||||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||||
* @return string Chaine avec URL
|
* @return string Chaine avec URL
|
||||||
@@ -1574,6 +1574,8 @@ class Adherent extends CommonObject
|
|||||||
|
|
||||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0;
|
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0;
|
||||||
|
|
||||||
|
$notooltip=0;
|
||||||
|
|
||||||
$result=''; $label='';
|
$result=''; $label='';
|
||||||
$link=''; $linkstart=''; $linkend='';
|
$link=''; $linkstart=''; $linkend='';
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class AdherentType extends CommonObject
|
|||||||
$sql.= "libelle = '".$this->db->escape($this->label) ."',";
|
$sql.= "libelle = '".$this->db->escape($this->label) ."',";
|
||||||
$sql.= "subscription = '".$this->db->escape($this->subscription)."',";
|
$sql.= "subscription = '".$this->db->escape($this->subscription)."',";
|
||||||
$sql.= "note = '".$this->db->escape($this->note)."',";
|
$sql.= "note = '".$this->db->escape($this->note)."',";
|
||||||
$sql.= "vote = '".$this->db->escape($this->vote)."',";
|
$sql.= "vote = ".(integer) $this->db->escape($this->vote).",";
|
||||||
$sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
|
$sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
|
||||||
$sql.= " WHERE rowid =".$this->id;
|
$sql.= " WHERE rowid =".$this->id;
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ if ($action == 'add' && $user->rights->adherent->configurer)
|
|||||||
$object->subscription = (int) trim($subscription);
|
$object->subscription = (int) trim($subscription);
|
||||||
$object->note = trim($comment);
|
$object->note = trim($comment);
|
||||||
$object->mail_valid = trim($mail_valid);
|
$object->mail_valid = trim($mail_valid);
|
||||||
$object->vote = (boolean) trim($vote);
|
$object->vote = trim($vote);
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||||
@@ -160,7 +160,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
|
|||||||
$object->subscription = (int) trim($subscription);
|
$object->subscription = (int) trim($subscription);
|
||||||
$object->note = trim($comment);
|
$object->note = trim($comment);
|
||||||
$object->mail_valid = trim($mail_valid);
|
$object->mail_valid = trim($mail_valid);
|
||||||
$object->vote = (boolean) trim($vote);
|
$object->vote = trim($vote);
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||||
|
|||||||
@@ -1019,9 +1019,9 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
|||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
elseif ($context == 'add' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
|
elseif ($context == 'add' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
|
||||||
elseif ($context == 'edit' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
|
elseif ($context == 'edit' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
|
||||||
elseif ($context == 'hide' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
|
elseif ($context == 'hide' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$size=''; $class=''; $classtd='';
|
$size=''; $class=''; $classtd='';
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ class DolibarrApiAccess implements iAuthenticate
|
|||||||
|
|
||||||
// api key can be provided in url with parameter api_key=xxx or ni header with header DOLAPIKEY:xxx
|
// api key can be provided in url with parameter api_key=xxx or ni header with header DOLAPIKEY:xxx
|
||||||
$api_key = '';
|
$api_key = '';
|
||||||
if (isset($_GET['api_key']))
|
if (isset($_GET['api_key'])) // For backward compatibility
|
||||||
{
|
{
|
||||||
// TODO Add option to disable use of api key on url. Return errors if used.
|
// TODO Add option to disable use of api key on url. Return errors if used.
|
||||||
$api_key = $_GET['api_key']; // For backward compatibility
|
$api_key = $_GET['api_key'];
|
||||||
}
|
}
|
||||||
if (isset($_GET['DOLAPIKEY']))
|
if (isset($_GET['DOLAPIKEY']))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -256,9 +256,11 @@ class Documents extends DolibarrApi
|
|||||||
|
|
||||||
// Define $uploadir
|
// Define $uploadir
|
||||||
$object = null;
|
$object = null;
|
||||||
$entity = $user->entity;
|
$entity = DolibarrApiAccess::$user->entity;
|
||||||
if ($ref)
|
if ($ref)
|
||||||
{
|
{
|
||||||
|
$tmpreldir='';
|
||||||
|
|
||||||
if ($modulepart == 'facture' || $modulepart == 'invoice')
|
if ($modulepart == 'facture' || $modulepart == 'invoice')
|
||||||
{
|
{
|
||||||
$modulepart='facture';
|
$modulepart='facture';
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class Facturation
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define part of HT, VAT, TTC
|
// Define part of HT, VAT, TTC
|
||||||
$resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $use_npr, $product->type, $mysoc, $localtaxarray);
|
$resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray);
|
||||||
|
|
||||||
// Calcul du total ht sans remise
|
// Calcul du total ht sans remise
|
||||||
$total_ht = $resultarray[0];
|
$total_ht = $resultarray[0];
|
||||||
@@ -207,6 +207,9 @@ class Facturation
|
|||||||
|
|
||||||
$total_ht=0;
|
$total_ht=0;
|
||||||
$total_ttc=0;
|
$total_ttc=0;
|
||||||
|
$total_vat = 0;
|
||||||
|
$total_localtax1 = 0;
|
||||||
|
$total_localtax2 = 0;
|
||||||
|
|
||||||
$tab=array();
|
$tab=array();
|
||||||
$tab = $_SESSION['poscart'];
|
$tab = $_SESSION['poscart'];
|
||||||
@@ -309,7 +312,7 @@ class Facturation
|
|||||||
public function ref($aRef=null)
|
public function ref($aRef=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !$aRef )
|
if (is_null($aRef))
|
||||||
{
|
{
|
||||||
return $this->ref;
|
return $this->ref;
|
||||||
}
|
}
|
||||||
@@ -330,9 +333,9 @@ class Facturation
|
|||||||
* @param int $aQte Qty
|
* @param int $aQte Qty
|
||||||
* @return int Qty
|
* @return int Qty
|
||||||
*/
|
*/
|
||||||
public function qte( $aQte=null )
|
public function qte($aQte=null)
|
||||||
{
|
{
|
||||||
if ( !$aQte )
|
if (is_null($aQte))
|
||||||
{
|
{
|
||||||
return $this->qte;
|
return $this->qte;
|
||||||
}
|
}
|
||||||
@@ -357,7 +360,7 @@ class Facturation
|
|||||||
public function stock($aStock=null)
|
public function stock($aStock=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !$aStock )
|
if (is_null($aStock))
|
||||||
{
|
{
|
||||||
return $this->stock;
|
return $this->stock;
|
||||||
}
|
}
|
||||||
@@ -381,7 +384,7 @@ class Facturation
|
|||||||
public function remisePercent($aRemisePercent=null)
|
public function remisePercent($aRemisePercent=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !$aRemisePercent )
|
if (is_null($aRemisePercent))
|
||||||
{
|
{
|
||||||
return $this->remise_percent;
|
return $this->remise_percent;
|
||||||
}
|
}
|
||||||
@@ -405,7 +408,7 @@ class Facturation
|
|||||||
public function montantRemise($aMontantRemise=null)
|
public function montantRemise($aMontantRemise=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !$aMontantRemise ) {
|
if (is_null($aMontantRemise)) {
|
||||||
|
|
||||||
return $this->montant_remise;
|
return $this->montant_remise;
|
||||||
|
|
||||||
@@ -427,10 +430,10 @@ class Facturation
|
|||||||
* @param int $aPrix Price
|
* @param int $aPrix Price
|
||||||
* @return string Stock
|
* @return string Stock
|
||||||
*/
|
*/
|
||||||
public function prix ( $aPrix=null )
|
public function prix($aPrix=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !$aPrix ) {
|
if (is_null($aPrix)) {
|
||||||
|
|
||||||
return $this->prix;
|
return $this->prix;
|
||||||
|
|
||||||
@@ -454,7 +457,7 @@ class Facturation
|
|||||||
*/
|
*/
|
||||||
public function tva($aTva=null)
|
public function tva($aTva=null)
|
||||||
{
|
{
|
||||||
if ( !$aTva ) {
|
if (is_null($aTva)) {
|
||||||
|
|
||||||
return $this->tva;
|
return $this->tva;
|
||||||
|
|
||||||
@@ -478,7 +481,7 @@ class Facturation
|
|||||||
*/
|
*/
|
||||||
public function numInvoice($aNumFacture=null)
|
public function numInvoice($aNumFacture=null)
|
||||||
{
|
{
|
||||||
if ( !$aNumFacture ) {
|
if (is_null($aNumFacture)) {
|
||||||
|
|
||||||
return $this->num_facture;
|
return $this->num_facture;
|
||||||
|
|
||||||
@@ -499,10 +502,10 @@ class Facturation
|
|||||||
* @param int $aModeReglement Payment mode
|
* @param int $aModeReglement Payment mode
|
||||||
* @return int Payment mode
|
* @return int Payment mode
|
||||||
*/
|
*/
|
||||||
public function getSetPaymentMode( $aModeReglement=null )
|
public function getSetPaymentMode($aModeReglement=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !$aModeReglement ) {
|
if (is_null($aModeReglement)) {
|
||||||
|
|
||||||
return $this->mode_reglement;
|
return $this->mode_reglement;
|
||||||
|
|
||||||
@@ -524,10 +527,10 @@ class Facturation
|
|||||||
* @param int $aMontantEncaisse Amount
|
* @param int $aMontantEncaisse Amount
|
||||||
* @return int Amount
|
* @return int Amount
|
||||||
*/
|
*/
|
||||||
public function montantEncaisse( $aMontantEncaisse=null )
|
public function montantEncaisse($aMontantEncaisse=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !$aMontantEncaisse ) {
|
if (is_null($aMontantEncaisse)) {
|
||||||
|
|
||||||
return $this->montant_encaisse;
|
return $this->montant_encaisse;
|
||||||
|
|
||||||
@@ -549,10 +552,10 @@ class Facturation
|
|||||||
* @param int $aMontantRendu Amount
|
* @param int $aMontantRendu Amount
|
||||||
* @return int Amount
|
* @return int Amount
|
||||||
*/
|
*/
|
||||||
public function montantRendu( $aMontantRendu=null )
|
public function montantRendu($aMontantRendu=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !$aMontantRendu ) {
|
if (is_null($aMontantRendu)) {
|
||||||
|
|
||||||
return $this->montant_rendu;
|
return $this->montant_rendu;
|
||||||
} else if ( $aMontantRendu == 'RESET' ) {
|
} else if ( $aMontantRendu == 'RESET' ) {
|
||||||
@@ -573,9 +576,9 @@ class Facturation
|
|||||||
* @param date $aPaiementLe Date
|
* @param date $aPaiementLe Date
|
||||||
* @return date Date
|
* @return date Date
|
||||||
*/
|
*/
|
||||||
public function paiementLe( $aPaiementLe=null )
|
public function paiementLe($aPaiementLe=null)
|
||||||
{
|
{
|
||||||
if ( !$aPaiementLe ) {
|
if (is_null($aPaiementLe)) {
|
||||||
|
|
||||||
return $this->paiement_le;
|
return $this->paiement_le;
|
||||||
|
|
||||||
@@ -596,9 +599,9 @@ class Facturation
|
|||||||
* @param int $aTotalHt Total amount
|
* @param int $aTotalHt Total amount
|
||||||
* @return int Total amount
|
* @return int Total amount
|
||||||
*/
|
*/
|
||||||
public function prixTotalHt( $aTotalHt=null )
|
public function prixTotalHt($aTotalHt=null)
|
||||||
{
|
{
|
||||||
if ( !$aTotalHt ) {
|
if (is_null($aTotalHt)) {
|
||||||
|
|
||||||
return $this->prix_total_ht;
|
return $this->prix_total_ht;
|
||||||
|
|
||||||
@@ -619,9 +622,9 @@ class Facturation
|
|||||||
* @param int $aMontantTva Amount vat
|
* @param int $aMontantTva Amount vat
|
||||||
* @return int Amount vat
|
* @return int Amount vat
|
||||||
*/
|
*/
|
||||||
public function montantTva( $aMontantTva=null )
|
public function montantTva($aMontantTva=null)
|
||||||
{
|
{
|
||||||
if ( !$aMontantTva ) {
|
if (is_null($aMontantTva)) {
|
||||||
|
|
||||||
return $this->montant_tva;
|
return $this->montant_tva;
|
||||||
|
|
||||||
@@ -643,9 +646,9 @@ class Facturation
|
|||||||
* @param int $aTotalTtc Amount ttc
|
* @param int $aTotalTtc Amount ttc
|
||||||
* @return int Amount ttc
|
* @return int Amount ttc
|
||||||
*/
|
*/
|
||||||
public function prixTotalTtc( $aTotalTtc=null )
|
public function prixTotalTtc($aTotalTtc=null)
|
||||||
{
|
{
|
||||||
if ( !$aTotalTtc )
|
if (is_null($aTotalTtc))
|
||||||
{
|
{
|
||||||
return $this->prix_total_ttc;
|
return $this->prix_total_ttc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ class Categorie extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public $socid;
|
public $socid;
|
||||||
/**
|
/**
|
||||||
* @var int Category type
|
* @var string Category type
|
||||||
*
|
*
|
||||||
* @see Categorie::TYPE_PRODUCT
|
* @see Categorie::TYPE_PRODUCT
|
||||||
* @see Categorie::TYPE_SUPPLIER
|
* @see Categorie::TYPE_SUPPLIER
|
||||||
@@ -1327,6 +1327,7 @@ class Categorie extends CommonObject
|
|||||||
{
|
{
|
||||||
$w = array();
|
$w = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
$forced_color='';
|
||||||
foreach ($way as $cat)
|
foreach ($way as $cat)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
@@ -1340,12 +1341,7 @@ class Categorie extends CommonObject
|
|||||||
$forced_color='categtextwhite';
|
$forced_color='categtextwhite';
|
||||||
if ($cat->color)
|
if ($cat->color)
|
||||||
{
|
{
|
||||||
$hex=$cat->color;
|
if (colorIsLight($cat->color)) $forced_color='categtextblack';
|
||||||
$r = hexdec($hex[0].$hex[1]);
|
|
||||||
$g = hexdec($hex[2].$hex[3]);
|
|
||||||
$b = hexdec($hex[4].$hex[5]);
|
|
||||||
$bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
|
|
||||||
if ($bright >= 0.5) $forced_color='categtextblack'; // Higher than 60%
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1602,12 +1598,7 @@ class Categorie extends CommonObject
|
|||||||
$forced_color='categtextwhite';
|
$forced_color='categtextwhite';
|
||||||
if ($this->color)
|
if ($this->color)
|
||||||
{
|
{
|
||||||
$hex=$this->color;
|
if (colorIsLight($this->color)) $forced_color='categtextblack';
|
||||||
$r = hexdec($hex[0].$hex[1]);
|
|
||||||
$g = hexdec($hex[2].$hex[3]);
|
|
||||||
$b = hexdec($hex[4].$hex[5]);
|
|
||||||
$bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
|
|
||||||
if ($bright >= 0.5) $forced_color='categtextblack'; // Higher than 60%
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip '.$forced_color .'">';
|
$link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip '.$forced_color .'">';
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ abstract class DoliDB implements Database
|
|||||||
public $lastqueryerror;
|
public $lastqueryerror;
|
||||||
/** @var string Last error message */
|
/** @var string Last error message */
|
||||||
public $lasterror;
|
public $lasterror;
|
||||||
/** @var int Last error number */
|
/** @var string Last error number. For example: 'DB_ERROR_RECORD_ALREADY_EXISTS', '12345', ... */
|
||||||
public $lasterrno;
|
public $lasterrno;
|
||||||
|
|
||||||
/** @var bool Status */
|
/** @var bool Status */
|
||||||
@@ -238,16 +238,16 @@ abstract class DoliDB implements Database
|
|||||||
else $return.=', ';
|
else $return.=', ';
|
||||||
|
|
||||||
$return.=preg_replace('/[^0-9a-z_\.]/i','',$val);
|
$return.=preg_replace('/[^0-9a-z_\.]/i','',$val);
|
||||||
|
|
||||||
$tmpsortorder = trim($orders[$i]);
|
$tmpsortorder = trim($orders[$i]);
|
||||||
|
|
||||||
// Only ASC and DESC values are valid SQL
|
// Only ASC and DESC values are valid SQL
|
||||||
if (strtoupper($tmpsortorder) === 'ASC') {
|
if (strtoupper($tmpsortorder) === 'ASC') {
|
||||||
$return .= ' ASC';
|
$return .= ' ASC';
|
||||||
} elseif (strtoupper($tmpsortorder) === 'DESC') {
|
} elseif (strtoupper($tmpsortorder) === 'DESC') {
|
||||||
$return .= ' DESC';
|
$return .= ' DESC';
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
|||||||
@@ -6791,3 +6791,37 @@ function getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield='
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the color is light
|
||||||
|
*
|
||||||
|
* @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255')
|
||||||
|
* @return int -1 : Error with argument passed |0 : color is dark | 1 : color is light
|
||||||
|
*/
|
||||||
|
function colorIsLight($stringcolor)
|
||||||
|
{
|
||||||
|
$res = -1;
|
||||||
|
if (!empty($stringcolor))
|
||||||
|
{
|
||||||
|
$res = 0;
|
||||||
|
$tmp=explode(',', $stringcolor);
|
||||||
|
if (count($tmp) > 1) // This is a comma RGB ('255','255','255')
|
||||||
|
{
|
||||||
|
$r = $tmp[0];
|
||||||
|
$g = $tmp[1];
|
||||||
|
$b = $tmp[2];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$hexr=$stringcolor[0].$stringcolor[1];
|
||||||
|
$hexg=$stringcolor[2].$stringcolor[3];
|
||||||
|
$hexb=$stringcolor[4].$stringcolor[5];
|
||||||
|
$r = hexdec($hexr);
|
||||||
|
$g = hexdec($hexg);
|
||||||
|
$b = hexdec($hexb);
|
||||||
|
}
|
||||||
|
$bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
|
||||||
|
if ($bright > 0.6) $res = 1;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2153,40 +2153,6 @@ function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88))
|
|||||||
return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3]));
|
return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if the color is light
|
|
||||||
*
|
|
||||||
* @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255')
|
|
||||||
* @return int -1 : Error with argument passed |0 : color is dark | 1 : color is light
|
|
||||||
*/
|
|
||||||
function colorIsLight($stringcolor)
|
|
||||||
{
|
|
||||||
$res = -1;
|
|
||||||
if (!empty($stringcolor))
|
|
||||||
{
|
|
||||||
$res = 0;
|
|
||||||
$tmp=explode(',', $stringcolor);
|
|
||||||
if (count($tmp) > 1) // This is a comma RGB ('255','255','255')
|
|
||||||
{
|
|
||||||
$r = $tmp[0];
|
|
||||||
$g = $tmp[1];
|
|
||||||
$b = $tmp[2];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$hexr=$stringcolor[0].$stringcolor[1];
|
|
||||||
$hexg=$stringcolor[2].$stringcolor[3];
|
|
||||||
$hexb=$stringcolor[4].$stringcolor[5];
|
|
||||||
$r = hexdec($hexr);
|
|
||||||
$g = hexdec($hexg);
|
|
||||||
$b = hexdec($hexb);
|
|
||||||
}
|
|
||||||
$bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
|
|
||||||
if ($bright > 0.6) $res = 1;
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the Cartesian product algorithm to an array
|
* Applies the Cartesian product algorithm to an array
|
||||||
* Source: http://stackoverflow.com/a/15973172
|
* Source: http://stackoverflow.com/a/15973172
|
||||||
|
|||||||
Reference in New Issue
Block a user