--- /tmp/dsg/dolibarr/htdocs/compta/deplacement/class/github_deplacement.class.php
+++ /tmp/dsg/dolibarr/htdocs/compta/deplacement/class/client_deplacement.class.php
@@ -43,12 +43,12 @@
public $table_element = 'deplacement';
/**
- * @var string Name of subtable line
+ * @var int Name of subtable line
*/
public $table_element_line = '';
/**
- * @var string Fieldname with ID of parent key if this field has a parent
+ * @var int Field with ID of parent key if this field has a parent
*/
public $fk_element = '';
@@ -59,22 +59,22 @@
public $ismultientitymanaged = 0;
/**
- * Date creation record (datec)
- *
- * @var integer
- */
- public $datec;
-
- /**
- * Date (dated)
- *
- * @var integer
- */
+ * Date creation record (datec)
+ *
+ * @var integer
+ */
+ public $datec;
+
+ /**
+ * Date (dated)
+ *
+ * @var integer
+ */
public $dated;
/**
- * @var int ID
- */
+ * @var int ID
+ */
public $fk_user_author;
/**
@@ -82,20 +82,20 @@
*/
public $fk_user;
- /**
- * @var string km value formatted
- */
- public $km;
-
- /**
- * @var int Thirdparty id
- */
+ /**
+ * @var string km value formatted
+ */
+ public $km;
+
+ /**
+ * @var int Thirdparty id
+ */
public $socid;
- /**
- * @var int Status 0=draft, 1=validated, 2=Refunded
- */
- public $statut;
+ /**
+ * @var int Status 0=draft, 1=validated, 2=Refunded
+ */
+ public $statut;
public $extraparams = array();
public $statuts = array();
@@ -116,7 +116,7 @@
*/
const STATUS_REFUNDED = 2;
- /**
+ /**
* Constructor
*
* @param DoliDB $db Database handler
@@ -125,8 +125,8 @@
{
$this->db = $db;
- $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded');
- $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded');
+ $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded');
+ $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded');
}
/**
@@ -152,9 +152,9 @@
return -1;
}
- $now = dol_now();
-
- $this->db->begin();
+ $now = dol_now();
+
+ $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement (";
$sql .= "datec";
@@ -185,26 +185,30 @@
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."deplacement");
- // Call trigger
- $result = $this->call_trigger('DEPLACEMENT_CREATE', $user);
- if ($result < 0)
- {
- $this->db->rollback();
- return -2;
- }
- // End call triggers
+ // Call trigger
+ $result = $this->call_trigger('DEPLACEMENT_CREATE', $user);
+ if ($result < 0)
+ {
+ $this->db->rollback();
+ return -2;
+ }
+ // End call triggers
$result = $this->update($user);
if ($result > 0)
{
$this->db->commit();
return $this->id;
- } else {
+ }
+ else
+ {
$this->error = $this->db->error();
$this->db->rollback();
return $result;
}
- } else {
+ }
+ else
+ {
$this->error = $this->db->error()." sql=".$sql;
$this->db->rollback();
return -1;
@@ -226,12 +230,12 @@
// Check parameters
if (!is_numeric($this->km)) $this->km = 0;
- if (empty($this->date))
- {
- $this->error = 'ErrorBadParameter';
- return -1;
- }
- if (empty($this->type) || $this->type < 0)
+ if (empty($this->date))
+ {
+ $this->error = 'ErrorBadParameter';
+ return -1;
+ }
+ if (empty($this->type) || $this->type < 0)
{
$this->error = 'ErrorBadParameter';
return -1;
@@ -263,14 +267,16 @@
{
$this->db->commit();
return 1;
- } else {
+ }
+ else
+ {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
}
- /**
+ /**
* Load an object from database
*
* @param int $id Id of record to load
@@ -306,13 +312,15 @@
$this->extraparams = (array) json_decode($obj->extraparams, true);
return 1;
- } else {
+ }
+ else
+ {
$this->error = $this->db->error();
return -1;
}
}
- /**
+ /**
* Delete record
*
* @param int $id Id of record to delete
@@ -330,7 +338,9 @@
{
$this->db->commit();
return 1;
- } else {
+ }
+ else
+ {
$this->error = $this->db->error();
$this->db->rollback();
return -1;
@@ -349,7 +359,7 @@
return $this->LibStatut($this->statut, $mode);
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -359,31 +369,36 @@
*/
public function LibStatut($status, $mode = 0)
{
- // phpcs:enable
+ // phpcs:enable
global $langs;
if ($mode == 0)
{
return $langs->trans($this->statuts[$status]);
- } elseif ($mode == 1)
+ }
+ elseif ($mode == 1)
{
return $langs->trans($this->statuts_short[$status]);
- } elseif ($mode == 2)
+ }
+ elseif ($mode == 2)
{
if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]);
elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]);
elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]);
- } elseif ($mode == 3)
+ }
+ elseif ($mode == 3)
{
if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0');
elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4');
elseif ($status == 2 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6');
- } elseif ($mode == 4)
+ }
+ elseif ($mode == 4)
{
if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]);
elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]);
elseif ($status == 2 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]);
- } elseif ($mode == 5)
+ }
+ elseif ($mode == 5)
{
if ($status == 0 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut0');
elseif ($status == 1 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4');
@@ -402,15 +417,15 @@
global $langs;
$result = '';
- $label = $langs->trans("Show").': '.$this->ref;
-
- $link = '';
+ $label = $langs->trans("Show").': '.$this->ref;
+
+ $link = '';
$linkend = '';
$picto = 'trip';
- if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
+ if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
if ($withpicto && $withpicto != 2) $result .= ' ';
if ($withpicto != 2) $result .= $link.$this->ref.$linkend;
return $result;
@@ -425,31 +440,33 @@
*/
public function listOfTypes($active = 1)
{
- global $langs;
-
- $ret = array();
-
- $sql = "SELECT id, code, label";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees";
- $sql .= " WHERE active = ".$active;
-
- dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG);
- $result = $this->db->query($sql);
- if ($result)
- {
- $num = $this->db->num_rows($result);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($result);
- $ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label);
- $i++;
- }
- } else {
- dol_print_error($this->db);
- }
-
- return $ret;
+ global $langs;
+
+ $ret = array();
+
+ $sql = "SELECT id, code, label";
+ $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees";
+ $sql .= " WHERE active = ".$active;
+
+ dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG);
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $num = $this->db->num_rows($result);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($result);
+ $ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label);
+ $i++;
+ }
+ }
+ else
+ {
+ dol_print_error($this->db);
+ }
+
+ return $ret;
}
/**
@@ -490,7 +507,9 @@
$this->date_modification = $this->db->jdate($obj->tms);
}
$this->db->free($result);
- } else {
+ }
+ else
+ {
dol_print_error($this->db);
}
}
--- /tmp/dsg/dolibarr/htdocs/compta/deplacement/class/github_deplacementstats.class.php
+++ /tmp/dsg/dolibarr/htdocs/compta/deplacement/class/client_deplacementstats.class.php
@@ -30,24 +30,24 @@
*/
class DeplacementStats extends Stats
{
- /**
- * @var string Name of table without prefix where object is stored
- */
- public $table_element;
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element;
- public $socid;
- public $userid;
+ public $socid;
+ public $userid;
- public $from;
- public $field;
- public $where;
+ public $from;
+ public $field;
+ public $where;
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param int $socid Id third party
- * @param mixed $userid Id user for filter or array of user ids
+ * @param mixed $userid Id user for filter or array of user ids
* @return void
*/
public function __construct($db, $socid = 0, $userid = 0)
@@ -55,8 +55,8 @@
global $conf;
$this->db = $db;
- $this->socid = $socid;
- $this->userid = $userid;
+ $this->socid = $socid;
+ $this->userid = $userid;
$object = new Deplacement($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element;
@@ -69,7 +69,7 @@
$this->where .= " AND fk_soc = ".$this->socid;
}
if (is_array($this->userid) && count($this->userid) > 0) $this->where .= ' AND fk_user IN ('.join(',', $this->userid).')';
- elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid;
+ elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid;
}
@@ -93,7 +93,7 @@
* Renvoie le nombre de facture par mois pour une annee donnee
*
* @param string $year Year to scan
- * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
+ * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array Array of values
*/
public function getNbByMonth($year, $format = 0)
@@ -103,7 +103,7 @@
$sql .= " WHERE YEAR(dated) = ".$year;
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
- $sql .= $this->db->order('dm', 'DESC');
+ $sql .= $this->db->order('dm', 'DESC');
$res = $this->_getNbByMonth($year, $sql, $format);
//var_dump($res);print '
';
@@ -115,14 +115,14 @@
* Renvoie le montant de facture par mois pour une annee donnee
*
* @param int $year Year to scan
- * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
+ * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array Array of values
*/
public function getAmountByMonth($year, $format = 0)
{
$sql = "SELECT date_format(dated,'%m') as dm, sum(".$this->field.")";
$sql .= " FROM ".$this->from;
- $sql .= " WHERE date_format(dated,'%Y') = '".$this->db->escape($year)."'";
+ $sql .= " WHERE date_format(dated,'%Y') = '".$year."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
@@ -142,10 +142,10 @@
{
$sql = "SELECT date_format(dated,'%m') as dm, avg(".$this->field.")";
$sql .= " FROM ".$this->from;
- $sql .= " WHERE date_format(dated,'%Y') = '".$this->db->escape($year)."'";
+ $sql .= " WHERE date_format(dated,'%Y') = '".$year."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
- $sql .= $this->db->order('dm', 'DESC');
+ $sql .= $this->db->order('dm', 'DESC');
return $this->_getAverageByMonth($year, $sql);
}
@@ -155,14 +155,14 @@
*
* @return array Array of values
*/
- public function getAllByYear()
- {
- $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
- $sql .= " FROM ".$this->from;
- $sql .= " WHERE ".$this->where;
- $sql .= " GROUP BY year";
- $sql .= $this->db->order('year', 'DESC');
+ public function getAllByYear()
+ {
+ $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
+ $sql .= " FROM ".$this->from;
+ $sql .= " WHERE ".$this->where;
+ $sql .= " GROUP BY year";
+ $sql .= $this->db->order('year', 'DESC');
- return $this->_getAllByYear($sql);
- }
+ return $this->_getAllByYear($sql);
+ }
}