From 733d2be39c1d45acfc7bbf3b7e3ffe81e05e7310 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 2 Feb 2015 11:13:11 +0100 Subject: [PATCH 01/80] readd index.html file --- htdocs/contrat/class/index.html | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 htdocs/contrat/class/index.html diff --git a/htdocs/contrat/class/index.html b/htdocs/contrat/class/index.html new file mode 100644 index 00000000000..e69de29bb2d From 2f59a63e5ad6f063e3a18c77e3c2c4b79f40bde9 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 2 Feb 2015 18:03:18 +0100 Subject: [PATCH 02/80] Fix bug on contract create form propal and fix extrafield must be control before create object --- htdocs/contrat/card.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index b2b99a9dde3..248a9a46115 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -73,7 +73,7 @@ $object = new Contrat($db); $extrafields = new ExtraFields($db); // Load object -if ($id > 0 || ! empty($ref)) { +if ($id > 0 || ! empty($ref) && $action!='add') { $ret = $object->fetch($id, $ref); if ($ret > 0) $ret = $object->fetch_thirdparty(); @@ -203,6 +203,13 @@ if ($action == 'add' && $user->rights->contrat->creer) $error++; } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + $action = 'create'; + } + if (! $error) { $object->socid = $socid; @@ -352,10 +359,6 @@ if ($action == 'add' && $user->rights->contrat->creer) } else { - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - $result = $object->create($user); if ($result > 0) { From 7f5e4aa135da4b33b1571eaa91b7cff98617d5a5 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 11 Feb 2015 11:44:49 +0100 Subject: [PATCH 03/80] FIX : bug #1840 Email template modules in HTML are not render correctly --- htdocs/core/class/doleditor.class.php | 10 ++++++---- htdocs/core/class/html.formmail.class.php | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 6dc726b084e..0433d7799c4 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -43,6 +43,7 @@ class DolEditor var $height; var $width; var $readonly; + var $allowed_content; /** @@ -62,8 +63,9 @@ class DolEditor * @param int $rows Size of rows for textarea tool * @param int $cols Size of cols for textarea tool (textarea number of cols or %) * @param int $readonly 0=Read/Edit, 1=Read only + * @param int $allowed_content 0=filter input text, 1=render as it is */ - function __construct($htmlname,$content,$width='',$height=200,$toolbarname='Basic',$toolbarlocation='In',$toolbarstartexpanded=false,$uselocalbrowser=true,$okforextendededitor=true,$rows=0,$cols=0,$readonly=0) + function __construct($htmlname,$content,$width='',$height=200,$toolbarname='Basic',$toolbarlocation='In',$toolbarstartexpanded=false,$uselocalbrowser=true,$okforextendededitor=true,$rows=0,$cols=0,$readonly=0,$allowed_content=0) { global $conf,$langs; @@ -132,6 +134,7 @@ class DolEditor $this->cols = (preg_match('/%/',$cols)?$cols:max(40,$cols)); // If $cols is a percent, we keep it, otherwise, we take max $this->height = $height; $this->width = $width; + $this->allowed_content = $allowed_content; } } @@ -163,16 +166,14 @@ class DolEditor $out.= ''; - if ($this->tool == 'ckeditor') { if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); //$skin='kama'; $skin='moono'; // default with cdeditor 4 - + $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; - $out.= '' . "\n"; + foreach ($showextcals as $val) { - $htmlname = dol_string_nospecial($val['name']); - $htmlname = dol_string_nospecial($htmlname,'_',array("\.","#")); - $s.='' . "\n"; - $s.='
' . $val ['name'] . '  
'; + $htmlname = md5($val['name']); + + $s.='
' . $val ['name'] . '  
'; } } $s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; @@ -1174,7 +1179,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $numicals[dol_string_nospecial($event->icalname)]++; } $color=$event->icalcolor; - $cssclass=(! empty($event->icalname)?'family_'.dol_string_nospecial($event->icalname):'family_other unmovable'); + $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unmovable'); } else if ($event->type_code == 'BIRTHDAY') { From c9b3cab22b23b2765043d99afc7b766b69778427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Thu, 5 Mar 2015 10:22:22 +0100 Subject: [PATCH 20/80] Mytasks is not clickable --- htdocs/comm/action/index.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index a5b83217c80..5ba3a4d9b0b 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -348,7 +348,6 @@ if (! empty($conf->use_javascript_ajax)) $s=''; $s.='' . "\n"; From 0ef46b06f400487e7350e94fe8d6346ccbdf0df2 Mon Sep 17 00:00:00 2001 From: guillaume Date: Thu, 5 Mar 2015 10:52:37 +0100 Subject: [PATCH 21/80] Sqlite3-PDO restoration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FR: - Restauration de la version PDO dans sqlite.class.php et désactivation. - Ajout de la classe de base de données Sqlite3 dans sqlite3.class.php EN: - revert of the PDO version of sqlite.class.php and deactivation. - add database class Sqlite3 into sqlite3.class.php. --- htdocs/admin/system/database-tables.php | 3 +- htdocs/core/db/sqlite.class.php | 378 +---- htdocs/core/db/sqlite3.class.php | 1478 +++++++++++++++++ htdocs/install/etape2.php | 4 +- htdocs/install/fileconf.php | 7 +- .../functions/functions.sql | 0 htdocs/install/{sqlite => sqlite3}/index.html | 0 7 files changed, 1540 insertions(+), 330 deletions(-) create mode 100644 htdocs/core/db/sqlite3.class.php rename htdocs/install/{sqlite => sqlite3}/functions/functions.sql (100%) rename htdocs/install/{sqlite => sqlite3}/index.html (100%) diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index 3af715a09b8..5ac7292042e 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -66,7 +66,7 @@ else if ($conf->db->type == 'mssql') //$sqls[0] = ""; //$base=3; } -else if ($conf->db->type == 'sqlite') { +else if ($conf->db->type == 'sqlite3') { //$sql = "SELECT name, type FROM sqlite_master"; $base = 4; } @@ -176,6 +176,7 @@ else if ($base == 4) { + // Sqlite3 print ''; print ''; print ''; diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 77e9dcdba54..786bf435fcf 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -34,16 +34,17 @@ class DoliDBSqlite extends DoliDB //! Database type public $type='sqlite'; //! Database label - const LABEL='Sqlite3'; + const LABEL='PDO Sqlite'; //! Version min database const VERSIONMIN='3.0.0'; //! Resultset of last query private $_results; - const WEEK_MONDAY_FIRST=1; - const WEEK_YEAR = 2; - const WEEK_FIRST_WEEKDAY=4; - + /** + * Indique que les fonctions personnalisées sont définies + * @var boolean + */ + private static $customFunctionsDefined = false; /** * Constructor. @@ -101,15 +102,7 @@ class DoliDBSqlite extends DoliDB $this->database_selected = 1; $this->database_name = $name; - $this->addCustomFunction('IF'); - $this->addCustomFunction('MONTH'); - $this->addCustomFunction('CURTIME'); - $this->addCustomFunction('CURDATE'); - $this->addCustomFunction('WEEK', 1); - $this->addCustomFunction('WEEK', 2); - $this->addCustomFunction('WEEKDAY'); - $this->addCustomFunction('date_format'); - //$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } else { @@ -329,16 +322,14 @@ class DoliDBSqlite extends DoliDB if (empty($dir)) $dir=DOL_DATA_ROOT; // With sqlite, port must be in connect parameters //if (! $newport) $newport=3306; - $database_name = $dir.'/database_'.$name.'.sdb'; try { /*** connect to SQLite database ***/ - //$this->db = new PDO("sqlite:".$dir.'/database_'.$name.'.sdb'); - $this->db = new SQLite3($database_name); - //$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $this->db = new PDO("sqlite:".$dir.'/database_'.$name.'.sdb'); + $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } - catch(Exception $e) + catch(PDOException $e) { - $this->error= self::LABEL.' '.$e->getMessage().' current dir='.$database_name; + $this->error='PDO SQLITE '.$e->getMessage().' current dir='.$dir.'/database_'.$name.'.sdb'; return ''; } @@ -354,7 +345,9 @@ class DoliDBSqlite extends DoliDB */ function getVersion() { - return $this->db->version()['versionString']; + $resql=$this->query('SELECT sqlite_version() as sqliteversion'); + $row=$this->fetch_row($resql); + return $row[0]; } /** @@ -383,7 +376,6 @@ class DoliDBSqlite extends DoliDB { if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR); $this->connected=0; - $this->db->close(); $this->db=null; // Clean this->db return true; } @@ -419,10 +411,13 @@ class DoliDBSqlite extends DoliDB $constraintname=trim($reg[2]); $tablename=trim($reg[1]); - $descTable = $this->db->querySingle("SELECT sql FROM sqlite_master WHERE name='" . $tablename . "'"); + $res = $this->db->query("SELECT sql FROM sqlite_master WHERE name='" . $tablename . "'"); + $descTable = $res->fetchColumn(); + $res->closeCursor(); // 1- Renommer la table avec un nom temporaire - $this->query('ALTER TABLE ' . $tablename . ' RENAME TO tmp_' . $tablename); + $res = $this->query('ALTER TABLE ' . $tablename . ' RENAME TO tmp_' . $tablename); + $res->closeCursor(); // 2- Recréer la table avec la contrainte ajoutée @@ -434,13 +429,17 @@ class DoliDBSqlite extends DoliDB $descTable .= ')'; // Création proprement dite de la table - $this->query($descTable); + $res = $this->query($descTable); + $res->closeCursor(); // 3- Transférer les données - $this->query('INSERT INTO ' . $tablename . ' SELECT * FROM tmp_' . $tablename); + $res = $this->query('INSERT INTO ' . $tablename . ' SELECT * FROM tmp_' . $tablename); + $res->closeCursor(); + // 4- Supprimer la table temporaire - $this->query('DROP TABLE tmp_' . $tablename); + $res = $this->query('DROP TABLE tmp_' . $tablename); + $res->closeCursor(); // dummy statement $query="SELECT 0"; @@ -456,13 +455,10 @@ class DoliDBSqlite extends DoliDB try { //$ret = $this->db->exec($query); $ret = $this->db->query($query); // $ret is a PDO object - if ($ret) { - $ret->queryString = $query; - } } - catch(Exception $e) + catch(PDOException $e) { - $this->error=$this->db->lastErrorMsg(); + $this->error=$e->getMessage(); } if (! preg_match("/^COMMIT/i",$query) && ! preg_match("/^ROLLBACK/i",$query)) @@ -501,11 +497,7 @@ class DoliDBSqlite extends DoliDB { // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_object($resultset)) { $resultset=$this->_results; } - //return $resultset->fetch(PDO::FETCH_OBJ); - $ret = $resultset->fetchArray(SQLITE3_ASSOC); - if ($ret) { - return (object)$ret; - } + return $resultset->fetch(PDO::FETCH_OBJ); } @@ -519,11 +511,7 @@ class DoliDBSqlite extends DoliDB { // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } - //return $resultset->fetch(PDO::FETCH_ASSOC); - $ret = $resultset->fetchArray(SQLITE3_ASSOC); - if ($ret) { - return (array)$ret; - } + return $resultset->fetch(PDO::FETCH_ASSOC); } /** @@ -538,7 +526,7 @@ class DoliDBSqlite extends DoliDB if (! is_bool($resultset)) { if (! is_object($resultset)) { $resultset=$this->_results; } - return $resultset->fetchArray(SQLITE3_NUM); + return $resultset->fetch(PDO::FETCH_NUM); } else { @@ -559,9 +547,10 @@ class DoliDBSqlite extends DoliDB // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } if (preg_match("/^SELECT/i", $resultset->queryString)) { - return $this->db->querySingle("SELECT count(*) FROM (" . $resultset->queryString . ") q"); + $res = $this->db->query("SELECT count(*) FROM (" . $resultset->queryString . ") q"); + return $res->fetchColumn(); } - return 0; + return $resultset->rowCount(); } /** @@ -575,12 +564,9 @@ class DoliDBSqlite extends DoliDB { // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } - if (preg_match("/^SELECT/i", $resultset->queryString)) { - return $this->num_rows($resultset); - } // mysql necessite un link de base pour cette fonction contrairement // a pqsql qui prend un resultset - return $this->db->changes(); + return $resultset->rowCount(); } @@ -595,7 +581,7 @@ class DoliDBSqlite extends DoliDB // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } // Si resultset en est un, on libere la memoire - if ($resultset && is_object($resultset)) $resultset->finalize(); + if (is_object($resultset)) $resultset->closeCursor(); } /** @@ -606,7 +592,12 @@ class DoliDBSqlite extends DoliDB */ function escape($stringtoencode) { - return Sqlite3::escapeString($stringtoencode); + $ret = $this->db->quote($stringtoencode); + $l = strlen($ret); + if ($l >= 2) { + return substr($ret, 1, $l -2); + } + return ''; } /** @@ -654,8 +645,8 @@ class DoliDBSqlite extends DoliDB { return $errorcode_map[$this->db->errorCode()]; }*/ - $errno=$this->db->lastErrorCode(); - if ($errno=='HY000' || $errno == 0) + $errno=$this->db->errorCode(); + if ($errno=='HY000') { if (preg_match('/table.*already exists/i',$this->error)) return 'DB_ERROR_TABLE_ALREADY_EXISTS'; elseif (preg_match('/index.*already exists/i',$this->error)) return 'DB_ERROR_KEY_NAME_ALREADY_EXISTS'; @@ -666,9 +657,6 @@ class DoliDBSqlite extends DoliDB if (preg_match('/column.* not unique/i',$this->error)) return 'DB_ERROR_RECORD_ALREADY_EXISTS'; elseif (preg_match('/PRIMARY KEY must be unique/i',$this->error)) return 'DB_ERROR_RECORD_ALREADY_EXISTS'; } - if ($errno > 1) { - // TODO Voir la liste des messages d'erreur - } return ($errno?'DB_ERROR_'.$errno:'0'); } @@ -699,7 +687,7 @@ class DoliDBSqlite extends DoliDB */ function last_insert_id($tab,$fieldid='rowid') { - return $this->db->lastInsertRowId(); + return $this->db->lastInsertId(); } /** @@ -1183,39 +1171,15 @@ class DoliDBSqlite extends DoliDB function getServerParametersValues($filter='') { $result=array(); - static $pragmas; - if (! isset($pragmas)) { - // Définition de la liste des pragmas utilisés qui ne retournent qu'une seule valeur - // indépendante de la base de données. - // cf. http://www.sqlite.org/pragma.html - $pragmas = array( - 'application_id', 'auto_vacuum', 'automatic_index', 'busy_timeout', 'cache_size', - 'cache_spill', 'case_sensitive_like', 'checkpoint_fullsync', 'collation_list', - 'compile_options', 'data_version', /*'database_list',*/ - 'defer_foreign_keys', 'encoding', 'foreign_key_check', 'freelist_count', - 'full_column_names', 'fullsync', 'ingore_check_constraints', 'integrity_check', - 'journal_mode', 'journal_size_limit', 'legacy_file_format', 'locking_mode', - 'max_page_count', 'page_count', 'page_size', 'parser_trace', - 'query_only', 'quick_check', 'read_uncommitted', 'recursive_triggers', - 'reverse_unordered_selects', 'schema_version', 'user_version', - 'secure_delete', 'short_column_names', 'shrink_memory', 'soft_heap_limit', - 'synchronous', 'temp_store', /*'temp_store_directory',*/ 'threads', - 'vdbe_addoptrace', 'vdbe_debug', 'vdbe_listing', 'vdbe_trace', - 'wal_autocheckpoint', - ); - } - // TODO prendre en compte le filtre - foreach($pragmas as $var) { - $sql = "PRAGMA $var"; - $resql=$this->query($sql); - if ($resql) - { - $obj = $this->fetch_row($resql); - //dol_syslog(get_class($this)."::select_db getServerParametersValues $var=". print_r($obj, true), LOG_DEBUG); - $result[$var] = $obj[0]; - } - } + $sql='SHOW VARIABLES'; + if ($filter) $sql.=" LIKE '".$this->escape($filter)."'"; + $resql=$this->query($sql); + if ($resql) + { + while ($obj=$this->fetch_object($resql)) $result[$obj->Variable_name]=$obj->Value; + } + return $result; } @@ -1228,7 +1192,7 @@ class DoliDBSqlite extends DoliDB function getServerStatusValues($filter='') { $result=array(); - /* + $sql='SHOW STATUS'; if ($filter) $sql.=" LIKE '".$this->escape($filter)."'"; $resql=$this->query($sql); @@ -1236,243 +1200,9 @@ class DoliDBSqlite extends DoliDB { while ($obj=$this->fetch_object($resql)) $result[$obj->Variable_name]=$obj->Value; } - */ return $result; } - /** - * Permet le chargement d'une fonction personnalisee dans le moteur de base de donnees. - * Note: le nom de la fonction personnalisee est prefixee par 'db_'. La fonction doit être - * statique et publique. Le nombre de parametres est determine automatiquement. - * @param string $name Le nom de la fonction a definir dans Sqlite - */ - private function addCustomFunction($name, $arg_count = -1) { - if ($this->db) { - $localname = __CLASS__ . '::' . 'db_' . $name; - $reflectClass = new ReflectionClass(__CLASS__); - $reflectFunction = $reflectClass->getMethod('db_' . $name); - if ($arg_count < 0) { - $arg_count = $reflectFunction->getNumberOfParameters(); - } - if (!$this->db->createFunction($name, $localname , $arg_count)) { - $this->error = "unable to create custom function '$name'"; - } - } - } - - /** - * Cette fonction est l'equivalent de la fonction MONTH de MySql. - * @param string $date - * @return integer - */ - public static function db_MONTH($date) { - return date('n', strtotime($date)); - } - - /** - * calcule du numéro de semaine - * - * @param string date - * @param int mode - */ - public static function db_WEEK($date, $mode = 0) { - $arr = date_parse($date); - $calc_year = 0; - return self::calc_week($arr['year'], $arr['month'], $arr['day'], self::week_mode($mode), $calc_year); - } - - public static function db_CURDATE() { - return date('Y-m-d'); - } - - public static function db_CURTIME() { - return date('H:i:s'); - } - - public static function db_WEEKDAY($date) { - $arr = date_parse($date); - return self::calc_weekday(self::calc_daynr($arr['year'], $arr['month'], $arr['day']), 0); - - } - - /** - * Cette fonction est l'equivelent de la fonction date_format de MySQL. - * @staticvar string $mysql_replacement Les symboles formatage a remplacer - * @param string $date la date dans un format ISO - * @param string $format la chaine de formatage - * @return string La date formatee. - */ - public static function db_date_format($date, $format) { - static $mysql_replacement; - if (! isset($mysql_replacement)) { - $mysql_replacement = array( - '%' => '%', - 'a' => 'D', - 'b' => 'M', - 'c' => 'n', - 'D' => 'jS', - 'd' => 'd', - 'e' => 'j', - 'f' => 'u', - 'H' => 'H', - 'h' => 'h', - 'I' => 'h', - 'i' => 'i', - 'k' => 'H', - 'l' => 'g', - 'M' => 'F', - 'm' => 'm', - 'p' => 'A', - 'r' => 'h:i:s A', - 'S' => 's', - 's' => 's', - 'T' => 'H:i:s', - 'W' => 'l', - 'w' => 'w', - 'Y' => 'Y', - 'y' => 'y', - ); - } - - $fmt = ''; - $lg = strlen($format); - $state = 0; - $timestamp = strtotime($date); - $yday = date('z', $timestamp); - $month = (integer)date("n", $timestamp); - $year = (integer)date("Y", $timestamp); - $day = (integer)date("d", $timestamp); - for($idx = 0; $idx < $lg; ++$idx) { - $char = $format[$idx]; - if ($state == 0) { - if ($char == '%') { - $state = 1; - } else { - $fmt .= $char; - } - } - elseif ($state == 1) { - if (array_key_exists($char, $mysql_replacement)) { - $fmt .= $mysql_replacement[$char]; - } else { - $calc_year = 0; - switch ($char) { - case 'j': // day of the year 001 - $char = sprintf("%03d", $yday+1); - break; - case 'U': // mode 0: semaine 0 = premiere semaine complète qui commence un dimanche - $char = sprintf("%02d", self::calc_week($year, $month, $day, 4, $calc_year)); - break; - case 'u': // mode 1: semaine 0 = première semaine de 4 jours. Début le dimanche - $char = sprintf("%02d", self::calc_week($year, $month, $day, 1, $calc_year)); - break; - case 'V': // mode 2: semaine 1 = premiere semaine complète qui commence un dimanche - $char = sprintf("%02d", self::calc_week($year, $month, $day, 6, $calc_year)); - break; - case 'v': // mode 3: semaine 1 = premiere semaine de 4 jours. Début le lundi - $char = sprintf("%02d", self::calc_week($year, $month, $day, 3, $calc_year)); - break; - case 'X': - self::calc_week($year, $month, $day, 6, $calc_year); - $char = sprintf("%04d", $calc_year); - break; - case 'x': - self::calc_week($year, $month, $day, 3, $calc_year); - $char = sprintf("%04d", $calc_year); - break; - } - $fmt .= $char; - } - $state = 0; - } - } - return date($fmt, strtotime($date)); - } - - /** - * Equivalent de la fonction MySQL IF - * @param boolean $test Le resultat du test - * @param mixed $true_part Partie a retourner si vrai - * @param mixed $false_part Partie a retourner si faux - * @return mixed Partie selectionnee en fonction du test - */ - public static function db_IF($test, $true_part, $false_part) { - return ( $test ) ? $true_part : $false_part; - } - - // Adapté de mytime.c des sources de mariadb - // fonction calc_daynr - private static function calc_daynr($year, $month, $day) { - $y = $year; - if ($y == 0 && $month == 0) return 0; - $num = (365* $y + 31 * ($month - 1) + $day); - if ($month <= 2) { - $y--; } - else { - $num -= floor(($month * 4 + 23) / 10); - } - $temp = floor(($y / 100 + 1) * 3 / 4); - return $num + floor($y / 4) - $temp; - } - - private static function calc_weekday($daynr, $sunday_first_day_of_week) { - $ret = floor(($daynr + 5 + ($sunday_first_day_of_week ? 1 : 0)) % 7); - return $ret; - } - - private static function calc_days_in_year($year) - { - return (($year & 3) == 0 && ($year%100 || ($year%400 == 0 && $year)) ? 366 : 365); - } - - private static function week_mode($mode) { - $week_format= ($mode & 7); - if (!($week_format & self::WEEK_MONDAY_FIRST)) { - $week_format^= self::WEEK_FIRST_WEEKDAY; - } - return $week_format; - } - - - private static function calc_week($year, $month, $day, $week_behaviour, &$calc_year) { - $daynr=self::calc_daynr($year,$month,$day); - $first_daynr=self::calc_daynr($year,1,1); - $monday_first= ($week_behaviour & self::WEEK_MONDAY_FIRST) ? 1 : 0; - $week_year= ($week_behaviour & self::WEEK_YEAR) ? 1 : 0; - $first_weekday= ($week_behaviour & self::WEEK_FIRST_WEEKDAY) ? 1 : 0; - - $weekday=self::calc_weekday($first_daynr, !$monday_first); - $calc_year=$year; - - if ($month == 1 && $day <= 7-$weekday) - { - if (!$week_year && (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4))) - return 0; - $week_year= 1; - $calc_year--; - $first_daynr-= ($days=self::calc_days_in_year($calc_year)); - $weekday= ($weekday + 53*7- $days) % 7; - } - - if (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4)) { - $days= $daynr - ($first_daynr+ (7-$weekday)); - } - else { - $days= $daynr - ($first_daynr - $weekday); - } - - if ($week_year && $days >= 52*7) - { - $weekday= ($weekday + self::calc_days_in_year($calc_year)) % 7; - if ((!$first_weekday && $weekday < 4) || ($first_weekday && $weekday == 0)) - { - $calc_year++; - return 1; - } - } - return floor($days/7+1); - } - } diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php new file mode 100644 index 00000000000..f232acb199e --- /dev/null +++ b/htdocs/core/db/sqlite3.class.php @@ -0,0 +1,1478 @@ + + * Copyright (C) 2002-2005 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2005-2009 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/db/sqlite.class.php + * \brief Class file to manage Dolibarr database access for a Sqlite database + */ + +require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; + +/** + * Class to manage Dolibarr database access for a Sqlite database + */ +class DoliDBSqlite3 extends DoliDB +{ + //! Database type + public $type='sqlite3'; + //! Database label + const LABEL='Sqlite3'; + //! Version min database + const VERSIONMIN='3.0.0'; + //! Resultset of last query + private $_results; + + const WEEK_MONDAY_FIRST=1; + const WEEK_YEAR = 2; + const WEEK_FIRST_WEEKDAY=4; + + + /** + * Constructor. + * This create an opened connexion to a database server and eventually to a database + * + * @param string $type Type of database (mysql, pgsql...) + * @param string $host Address of database server + * @param string $user Nom de l'utilisateur autorise + * @param string $pass Mot de passe + * @param string $name Nom de la database + * @param int $port Port of database server + */ + function __construct($type, $host, $user, $pass, $name='', $port=0) + { + global $conf,$langs; + + // Note that having "static" property for "$forcecharset" and "$forcecollate" will make error here in strict mode, so they are not static + if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set; + if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation; + + $this->database_user=$user; + $this->database_host=$host; + $this->database_port=$port; + + $this->transaction_opened=0; + + //print "Name DB: $host,$user,$pass,$name
"; + + /*if (! function_exists("sqlite_query")) + { + $this->connected = 0; + $this->ok = 0; + $this->error="Sqlite PHP functions for using Sqlite driver are not available in this version of PHP. Try to use another driver."; + dol_syslog(get_class($this)."::DoliDBSqlite3 : Sqlite PHP functions for using Sqlite driver are not available in this version of PHP. Try to use another driver.",LOG_ERR); + return $this->ok; + }*/ + + /*if (! $host) + { + $this->connected = 0; + $this->ok = 0; + $this->error=$langs->trans("ErrorWrongHostParameter"); + dol_syslog(get_class($this)."::DoliDBSqlite3 : Erreur Connect, wrong host parameters",LOG_ERR); + return $this->ok; + }*/ + + // Essai connexion serveur + // We do not try to connect to database, only to server. Connect to database is done later in constrcutor + $this->db = $this->connect($host, $user, $pass, $name, $port); + + if ($this->db) + { + $this->connected = 1; + $this->ok = 1; + $this->database_selected = 1; + $this->database_name = $name; + + $this->addCustomFunction('IF'); + $this->addCustomFunction('MONTH'); + $this->addCustomFunction('CURTIME'); + $this->addCustomFunction('CURDATE'); + $this->addCustomFunction('WEEK', 1); + $this->addCustomFunction('WEEK', 2); + $this->addCustomFunction('WEEKDAY'); + $this->addCustomFunction('date_format'); + //$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } + else + { + // host, login ou password incorrect + $this->connected = 0; + $this->ok = 0; + $this->database_selected = 0; + $this->database_name = ''; + //$this->error=sqlite_connect_error(); + dol_syslog(get_class($this)."::DoliDBSqlite3 : Error Connect ".$this->error,LOG_ERR); + } + + return $this->ok; + } + + + /** + * Convert a SQL request in Mysql syntax to native syntax + * + * @param string $line SQL request line to convert + * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) + * @return string SQL request line converted + */ + static function convertSQLFromMysql($line,$type='ddl') + { + // Removed empty line if this is a comment line for SVN tagging + if (preg_match('/^--\s\$Id/i',$line)) { + return ''; + } + // Return line if this is a comment + if (preg_match('/^#/i',$line) || preg_match('/^$/i',$line) || preg_match('/^--/i',$line)) + { + return $line; + } + if ($line != "") + { + if ($type == 'auto') + { + if (preg_match('/ALTER TABLE/i',$line)) $type='dml'; + else if (preg_match('/CREATE TABLE/i',$line)) $type='dml'; + else if (preg_match('/DROP TABLE/i',$line)) $type='dml'; + } + + if ($type == 'dml') + { + $line=preg_replace('/\s/',' ',$line); // Replace tabulation with space + + // we are inside create table statement so lets process datatypes + if (preg_match('/(ISAM|innodb)/i',$line)) { // end of create table sequence + $line=preg_replace('/\)[\s\t]*type[\s\t]*=[\s\t]*(MyISAM|innodb);/i',');',$line); + $line=preg_replace('/\)[\s\t]*engine[\s\t]*=[\s\t]*(MyISAM|innodb);/i',');',$line); + $line=preg_replace('/,$/','',$line); + } + + // Process case: "CREATE TABLE llx_mytable(rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,code..." + if (preg_match('/[\s\t\(]*(\w*)[\s\t]+int.*auto_increment/i',$line,$reg)) { + $newline=preg_replace('/([\s\t\(]*)([a-zA-Z_0-9]*)[\s\t]+int.*auto_increment[^,]*/i','\\1 \\2 integer PRIMARY KEY AUTOINCREMENT',$line); + //$line = "-- ".$line." replaced by --\n".$newline; + $line=$newline; + } + + // tinyint type conversion + $line=str_replace('tinyint','smallint',$line); + + // nuke unsigned + $line=preg_replace('/(int\w+|smallint)\s+unsigned/i','\\1',$line); + + // blob -> text + $line=preg_replace('/\w*blob/i','text',$line); + + // tinytext/mediumtext -> text + $line=preg_replace('/tinytext/i','text',$line); + $line=preg_replace('/mediumtext/i','text',$line); + + // change not null datetime field to null valid ones + // (to support remapping of "zero time" to null + $line=preg_replace('/datetime not null/i','datetime',$line); + $line=preg_replace('/datetime/i','timestamp',$line); + + // double -> numeric + $line=preg_replace('/^double/i','numeric',$line); + $line=preg_replace('/(\s*)double/i','\\1numeric',$line); + // float -> numeric + $line=preg_replace('/^float/i','numeric',$line); + $line=preg_replace('/(\s*)float/i','\\1numeric',$line); + + // unique index(field1,field2) + if (preg_match('/unique index\s*\((\w+\s*,\s*\w+)\)/i',$line)) + { + $line=preg_replace('/unique index\s*\((\w+\s*,\s*\w+)\)/i','UNIQUE\(\\1\)',$line); + } + + // We remove end of requests "AFTER fieldxxx" + $line=preg_replace('/AFTER [a-z0-9_]+/i','',$line); + + // We remove start of requests "ALTER TABLE tablexxx" if this is a DROP INDEX + $line=preg_replace('/ALTER TABLE [a-z0-9_]+ DROP INDEX/i','DROP INDEX',$line); + + // Translate order to rename fields + if (preg_match('/ALTER TABLE ([a-z0-9_]+) CHANGE(?: COLUMN)? ([a-z0-9_]+) ([a-z0-9_]+)(.*)$/i',$line,$reg)) + { + $line = "-- ".$line." replaced by --\n"; + $line.= "ALTER TABLE ".$reg[1]." RENAME COLUMN ".$reg[2]." TO ".$reg[3]; + } + + // Translate order to modify field format + if (preg_match('/ALTER TABLE ([a-z0-9_]+) MODIFY(?: COLUMN)? ([a-z0-9_]+) (.*)$/i',$line,$reg)) + { + $line = "-- ".$line." replaced by --\n"; + $newreg3=$reg[3]; + $newreg3=preg_replace('/ DEFAULT NULL/i','',$newreg3); + $newreg3=preg_replace('/ NOT NULL/i','',$newreg3); + $newreg3=preg_replace('/ NULL/i','',$newreg3); + $newreg3=preg_replace('/ DEFAULT 0/i','',$newreg3); + $newreg3=preg_replace('/ DEFAULT \'[0-9a-zA-Z_@]*\'/i','',$newreg3); + $line.= "ALTER TABLE ".$reg[1]." ALTER COLUMN ".$reg[2]." TYPE ".$newreg3; + // TODO Add alter to set default value or null/not null if there is this in $reg[3] + } + + // alter table add primary key (field1, field2 ...) -> We create a unique index instead as dynamic creation of primary key is not supported + // ALTER TABLE llx_dolibarr_modules ADD PRIMARY KEY pk_dolibarr_modules (numero, entity); + if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+PRIMARY\s+KEY\s*(.*)\s*\((.*)$/i',$line,$reg)) + { + $line = "-- ".$line." replaced by --\n"; + $line.= "CREATE UNIQUE INDEX ".$reg[2]." ON ".$reg[1]."(".$reg[3]; + } + + // Translate order to drop foreign keys + // ALTER TABLE llx_dolibarr_modules DROP FOREIGN KEY fk_xxx; + if (preg_match('/ALTER\s+TABLE\s*(.*)\s*DROP\s+FOREIGN\s+KEY\s*(.*)$/i',$line,$reg)) + { + $line = "-- ".$line." replaced by --\n"; + $line.= "ALTER TABLE ".$reg[1]." DROP CONSTRAINT ".$reg[2]; + } + + // alter table add [unique] [index] (field1, field2 ...) + // ALTER TABLE llx_accountingaccount ADD INDEX idx_accountingaccount_fk_pcg_version (fk_pcg_version) + if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+(UNIQUE INDEX|INDEX|UNIQUE)\s+(.*)\s*\(([\w,\s]+)\)/i',$line,$reg)) + { + $fieldlist=$reg[4]; + $idxname=$reg[3]; + $tablename=$reg[1]; + $line = "-- ".$line." replaced by --\n"; + $line.= "CREATE ".(preg_match('/UNIQUE/',$reg[2])?'UNIQUE ':'')."INDEX ".$idxname." ON ".$tablename." (".$fieldlist.")"; + } + if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+CONSTRAINT\s+(.*)\s*FOREIGN\s+KEY\s*\(([\w,\s]+)\)\s*REFERENCES\s+(\w+)\s*\(([\w,\s]+)\)/i',$line, $reg)) { + // Pour l'instant les contraintes ne sont pas créées + dol_syslog(get_class().'::query line emptied'); + $line = 'SELECT 0;'; + + } + + //if (preg_match('/rowid\s+.*\s+PRIMARY\s+KEY,/i', $line)) { + //preg_replace('/(rowid\s+.*\s+PRIMARY\s+KEY\s*,)/i', '/* \\1 */', $line); + //} + } + + // Delete using criteria on other table must not declare twice the deleted table + // DELETE FROM tabletodelete USING tabletodelete, othertable -> DELETE FROM tabletodelete USING othertable + if (preg_match('/DELETE FROM ([a-z_]+) USING ([a-z_]+), ([a-z_]+)/i',$line,$reg)) + { + if ($reg[1] == $reg[2]) // If same table, we remove second one + { + $line=preg_replace('/DELETE FROM ([a-z_]+) USING ([a-z_]+), ([a-z_]+)/i','DELETE FROM \\1 USING \\3', $line); + } + } + + // Remove () in the tables in FROM if one table + $line=preg_replace('/FROM\s*\((([a-z_]+)\s+as\s+([a-z_]+)\s*)\)/i','FROM \\1',$line); + //print $line."\n"; + + // Remove () in the tables in FROM if two table + $line=preg_replace('/FROM\s*\(([a-z_]+\s+as\s+[a-z_]+)\s*,\s*([a-z_]+\s+as\s+[a-z_]+\s*)\)/i','FROM \\1, \\2',$line); + //print $line."\n"; + + // Remove () in the tables in FROM if two table + $line=preg_replace('/FROM\s*\(([a-z_]+\s+as\s+[a-z_]+)\s*,\s*([a-z_]+\s+as\s+[a-z_]+\s*),\s*([a-z_]+\s+as\s+[a-z_]+\s*)\)/i','FROM \\1, \\2, \\3',$line); + //print $line."\n"; + + //print "type=".$type." newline=".$line."
\n"; + } + + return $line; + } + + /** + * Select a database + * + * @param string $database Name of database + * @return boolean true if OK, false if KO + */ + function select_db($database) + { + dol_syslog(get_class($this)."::select_db database=".$database, LOG_DEBUG); + return sqlite_select_db($this->db,$database); + } + + + /** + * Connexion to server + * + * @param string $host database server host + * @param string $login login + * @param string $passwd password + * @param string $name name of database (not used for mysql, used for pgsql) + * @param string $port Port of database server + * @return resource Database access handler + * @see close + */ + function connect($host, $login, $passwd, $name, $port=0) + { + global $conf,$main_data_dir; + + dol_syslog(get_class($this)."::connect name=".$name,LOG_DEBUG); + + $dir=$main_data_dir; + if (empty($dir)) $dir=DOL_DATA_ROOT; + // With sqlite, port must be in connect parameters + //if (! $newport) $newport=3306; + $database_name = $dir.'/database_'.$name.'.sdb'; + try { + /*** connect to SQLite database ***/ + //$this->db = new PDO("sqlite:".$dir.'/database_'.$name.'.sdb'); + $this->db = new SQLite3($database_name); + //$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } + catch(Exception $e) + { + $this->error= self::LABEL.' '.$e->getMessage().' current dir='.$database_name; + return ''; + } + + //print "Resultat fonction connect: ".$this->db; + return $this->db; + } + + + /** + * Return version of database server + * + * @return string Version string + */ + function getVersion() + { + return $this->db->version()['versionString']; + } + + /** + * Return version of database client driver + * + * @return string Version string + */ + function getDriverInfo() + { + // FIXME: Dummy method + // TODO: Implement + + return ''; + } + + + /** + * Close database connexion + * + * @return boolean True if disconnect successfull, false otherwise + * @see connect + */ + function close() + { + if ($this->db) + { + if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR); + $this->connected=0; + $this->db->close(); + $this->db=null; // Clean this->db + return true; + } + return false; + } + + /** + * Execute a SQL request and return the resultset + * + * @param string $query SQL query string + * @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollbock to savepoint if error (this allow to have some request with errors inside global transactions). + * Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints. + * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) + * @return resource Resultset of answer + */ + function query($query,$usesavepoint=0,$type='auto') + { + $errmsg=''; + + $ret=''; + $query = trim($query); + $this->error = 0; + + // Convert MySQL syntax to SQLite syntax + if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+CONSTRAINT\s+(.*)\s*FOREIGN\s+KEY\s*\(([\w,\s]+)\)\s*REFERENCES\s+(\w+)\s*\(([\w,\s]+)\)/i',$query, $reg)) { + // Ajout d'une clef étrangère à la table + // procédure de remplacement de la table pour ajouter la contrainte + // Exemple : ALTER TABLE llx_adherent ADD CONSTRAINT adherent_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid) + // -> CREATE TABLE ( ... ,CONSTRAINT adherent_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid)) + $foreignFields = $reg[5]; + $foreignTable = $reg[4]; + $localfields = $reg[3]; + $constraintname=trim($reg[2]); + $tablename=trim($reg[1]); + + $descTable = $this->db->querySingle("SELECT sql FROM sqlite_master WHERE name='" . $tablename . "'"); + + // 1- Renommer la table avec un nom temporaire + $this->query('ALTER TABLE ' . $tablename . ' RENAME TO tmp_' . $tablename); + + // 2- Recréer la table avec la contrainte ajoutée + + // on bricole la requete pour ajouter la contrainte + $descTable = substr($descTable, 0, strlen($descTable) - 1); + $descTable .= ", CONSTRAINT " . $constraintname . " FOREIGN KEY (" . $localfields . ") REFERENCES " .$foreignTable . "(" . $foreignFields . ")"; + + // fermeture de l'instruction + $descTable .= ')'; + + // Création proprement dite de la table + $this->query($descTable); + + // 3- Transférer les données + $this->query('INSERT INTO ' . $tablename . ' SELECT * FROM tmp_' . $tablename); + + // 4- Supprimer la table temporaire + $this->query('DROP TABLE tmp_' . $tablename); + + // dummy statement + $query="SELECT 0"; + + } else { + $query=$this->convertSQLFromMysql($query,$type); + } + //print "After convertSQLFromMysql:\n".$query."
\n"; + + dol_syslog('sql='.$query, LOG_DEBUG); + + // Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE) + try { + //$ret = $this->db->exec($query); + $ret = $this->db->query($query); // $ret is a PDO object + if ($ret) { + $ret->queryString = $query; + } + } + catch(Exception $e) + { + $this->error=$this->db->lastErrorMsg(); + } + + if (! preg_match("/^COMMIT/i",$query) && ! preg_match("/^ROLLBACK/i",$query)) + { + // Si requete utilisateur, on la sauvegarde ainsi que son resultset + if (! is_object($ret) || $this->error) + { + $this->lastqueryerror = $query; + $this->lasterror = $this->error(); + $this->lasterrno = $this->errno(); + + dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); + + $errormsg = get_class($this)."::query SQL Error message: ".$this->lasterror; + + if (preg_match('/[0-9]/',$this->lasterrno)) { + $errormsg .= ' ('.$this->lasterrno.')'; + } + + dol_syslog($errormsg, LOG_ERR); + } + $this->lastquery=$query; + $this->_results = $ret; + } + + return $ret; + } + + /** + * Renvoie la ligne courante (comme un objet) pour le curseur resultset + * + * @param Resultset $resultset Curseur de la requete voulue + * @return Object Object result line or false if KO or end of cursor + */ + function fetch_object($resultset) + { + // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion + if (! is_object($resultset)) { $resultset=$this->_results; } + //return $resultset->fetch(PDO::FETCH_OBJ); + $ret = $resultset->fetchArray(SQLITE3_ASSOC); + if ($ret) { + return (object)$ret; + } + } + + + /** + * Return datas as an array + * + * @param Resultset $resultset Resultset of request + * @return array Array + */ + function fetch_array($resultset) + { + // If resultset not provided, we take the last used by connexion + if (! is_object($resultset)) { $resultset=$this->_results; } + //return $resultset->fetch(PDO::FETCH_ASSOC); + $ret = $resultset->fetchArray(SQLITE3_ASSOC); + if ($ret) { + return (array)$ret; + } + } + + /** + * Return datas as an array + * + * @param Resultset $resultset Resultset of request + * @return array Array + */ + function fetch_row($resultset) + { + // If resultset not provided, we take the last used by connexion + if (! is_bool($resultset)) + { + if (! is_object($resultset)) { $resultset=$this->_results; } + return $resultset->fetchArray(SQLITE3_NUM); + } + else + { + // si le curseur est un booleen on retourne la valeur 0 + return 0; + } + } + + /** + * Return number of lines for result of a SELECT + * + * @param Resultset $resultset Resulset of requests + * @return int Nb of lines + * @see affected_rows + */ + function num_rows($resultset) + { + // If resultset not provided, we take the last used by connexion + if (! is_object($resultset)) { $resultset=$this->_results; } + if (preg_match("/^SELECT/i", $resultset->queryString)) { + return $this->db->querySingle("SELECT count(*) FROM (" . $resultset->queryString . ") q"); + } + return 0; + } + + /** + * Return number of lines for result of a SELECT + * + * @param Resultset $resultset Resulset of requests + * @return int Nb of lines + * @see affected_rows + */ + function affected_rows($resultset) + { + // If resultset not provided, we take the last used by connexion + if (! is_object($resultset)) { $resultset=$this->_results; } + if (preg_match("/^SELECT/i", $resultset->queryString)) { + return $this->num_rows($resultset); + } + // mysql necessite un link de base pour cette fonction contrairement + // a pqsql qui prend un resultset + return $this->db->changes(); + } + + + /** + * Free last resultset used. + * + * @param resultset $resultset Curseur de la requete voulue + * @return void + */ + function free($resultset=0) + { + // If resultset not provided, we take the last used by connexion + if (! is_object($resultset)) { $resultset=$this->_results; } + // Si resultset en est un, on libere la memoire + if ($resultset && is_object($resultset)) $resultset->finalize(); + } + + /** + * Escape a string to insert data + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + function escape($stringtoencode) + { + return Sqlite3::escapeString($stringtoencode); + } + + /** + * Renvoie le code erreur generique de l'operation precedente. + * + * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) + */ + function errno() + { + if (! $this->connected) { + // Si il y a eu echec de connexion, $this->db n'est pas valide. + return 'DB_ERROR_FAILED_TO_CONNECT'; + } + else { + // Constants to convert error code to a generic Dolibarr error code + /*$errorcode_map = array( + 1004 => 'DB_ERROR_CANNOT_CREATE', + 1005 => 'DB_ERROR_CANNOT_CREATE', + 1006 => 'DB_ERROR_CANNOT_CREATE', + 1007 => 'DB_ERROR_ALREADY_EXISTS', + 1008 => 'DB_ERROR_CANNOT_DROP', + 1025 => 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP', + 1044 => 'DB_ERROR_ACCESSDENIED', + 1046 => 'DB_ERROR_NODBSELECTED', + 1048 => 'DB_ERROR_CONSTRAINT', + 'HY000' => 'DB_ERROR_TABLE_ALREADY_EXISTS', + 1051 => 'DB_ERROR_NOSUCHTABLE', + 1054 => 'DB_ERROR_NOSUCHFIELD', + 1060 => 'DB_ERROR_COLUMN_ALREADY_EXISTS', + 1061 => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS', + 1062 => 'DB_ERROR_RECORD_ALREADY_EXISTS', + 1064 => 'DB_ERROR_SYNTAX', + 1068 => 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS', + 1075 => 'DB_ERROR_CANT_DROP_PRIMARY_KEY', + 1091 => 'DB_ERROR_NOSUCHFIELD', + 1100 => 'DB_ERROR_NOT_LOCKED', + 1136 => 'DB_ERROR_VALUE_COUNT_ON_ROW', + 1146 => 'DB_ERROR_NOSUCHTABLE', + 1216 => 'DB_ERROR_NO_PARENT', + 1217 => 'DB_ERROR_CHILD_EXISTS', + 1451 => 'DB_ERROR_CHILD_EXISTS' + ); + + if (isset($errorcode_map[$this->db->errorCode()])) + { + return $errorcode_map[$this->db->errorCode()]; + }*/ + $errno=$this->db->lastErrorCode(); + if ($errno=='HY000' || $errno == 0) + { + if (preg_match('/table.*already exists/i',$this->error)) return 'DB_ERROR_TABLE_ALREADY_EXISTS'; + elseif (preg_match('/index.*already exists/i',$this->error)) return 'DB_ERROR_KEY_NAME_ALREADY_EXISTS'; + elseif (preg_match('/syntax error/i',$this->error)) return 'DB_ERROR_SYNTAX'; + } + if ($errno=='23000') + { + if (preg_match('/column.* not unique/i',$this->error)) return 'DB_ERROR_RECORD_ALREADY_EXISTS'; + elseif (preg_match('/PRIMARY KEY must be unique/i',$this->error)) return 'DB_ERROR_RECORD_ALREADY_EXISTS'; + } + if ($errno > 1) { + // TODO Voir la liste des messages d'erreur + } + + return ($errno?'DB_ERROR_'.$errno:'0'); + } + } + + /** + * Renvoie le texte de l'erreur mysql de l'operation precedente. + * + * @return string Error text + */ + function error() + { + if (! $this->connected) { + // Si il y a eu echec de connexion, $this->db n'est pas valide pour sqlite_error. + return 'Not connected. Check setup parameters in conf/conf.php file and your sqlite version'; + } + else { + return $this->error; + } + } + + /** + * Get last ID after an insert INSERT + * + * @param string $tab Table name concerned by insert. Ne sert pas sous MySql mais requis pour compatibilite avec Postgresql + * @param string $fieldid Field name + * @return int Id of row + */ + function last_insert_id($tab,$fieldid='rowid') + { + return $this->db->lastInsertRowId(); + } + + /** + * Encrypt sensitive data in database + * Warning: This function includes the escape, so it must use direct value + * + * @param string $fieldorvalue Field name or value to encrypt + * @param int $withQuotes Return string with quotes + * @return return XXX(field) or XXX('value') or field or 'value' + */ + function encrypt($fieldorvalue, $withQuotes=0) + { + global $conf; + + // Type of encryption (2: AES (recommended), 1: DES , 0: no encryption) + $cryptType = ($conf->db->dolibarr_main_db_encryption?$conf->db->dolibarr_main_db_encryption:0); + + //Encryption key + $cryptKey = (!empty($conf->db->dolibarr_main_db_cryptkey)?$conf->db->dolibarr_main_db_cryptkey:''); + + $return = ($withQuotes?"'":"").$this->escape($fieldorvalue).($withQuotes?"'":""); + + if ($cryptType && !empty($cryptKey)) + { + if ($cryptType == 2) + { + $return = 'AES_ENCRYPT('.$return.',\''.$cryptKey.'\')'; + } + else if ($cryptType == 1) + { + $return = 'DES_ENCRYPT('.$return.',\''.$cryptKey.'\')'; + } + } + + return $return; + } + + /** + * Decrypt sensitive data in database + * + * @param string $value Value to decrypt + * @return string Decrypted value if used + */ + function decrypt($value) + { + global $conf; + + // Type of encryption (2: AES (recommended), 1: DES , 0: no encryption) + $cryptType = ($conf->db->dolibarr_main_db_encryption?$conf->db->dolibarr_main_db_encryption:0); + + //Encryption key + $cryptKey = (!empty($conf->db->dolibarr_main_db_cryptkey)?$conf->db->dolibarr_main_db_cryptkey:''); + + $return = $value; + + if ($cryptType && !empty($cryptKey)) + { + if ($cryptType == 2) + { + $return = 'AES_DECRYPT('.$value.',\''.$cryptKey.'\')'; + } + else if ($cryptType == 1) + { + $return = 'DES_DECRYPT('.$value.',\''.$cryptKey.'\')'; + } + } + + return $return; + } + + + /** + * Return connexion ID + * + * @return string Id connexion + */ + function DDLGetConnectId() + { + return '?'; + } + + + /** + * Create a new database + * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated + * We force to create database with charset this->forcecharset and collate this->forcecollate + * + * @param string $database Database name to create + * @param string $charset Charset used to store data + * @param string $collation Charset used to sort data + * @param string $owner Username of database owner + * @return resource resource defined if OK, null if KO + */ + function DDLCreateDb($database,$charset='',$collation='',$owner='') + { + if (empty($charset)) $charset=$this->forcecharset; + if (empty($collation)) $collation=$this->forcecollate; + + // ALTER DATABASE dolibarr_db DEFAULT CHARACTER SET latin DEFAULT COLLATE latin1_swedish_ci + $sql = 'CREATE DATABASE '.$database; + $sql.= ' DEFAULT CHARACTER SET '.$charset.' DEFAULT COLLATE '.$collation; + + dol_syslog($sql,LOG_DEBUG); + $ret=$this->query($sql); + if (! $ret) + { + // We try again for compatibility with Mysql < 4.1.1 + $sql = 'CREATE DATABASE '.$database; + $ret=$this->query($sql); + dol_syslog($sql,LOG_DEBUG); + } + return $ret; + } + + /** + * List tables into a database + * + * @param string $database Name of database + * @param string $table Name of table filter ('xxx%') + * @return array List of tables in an array + */ + function DDLListTables($database, $table='') + { + $listtables=array(); + + $like = ''; + if ($table) $like = "LIKE '".$table."'"; + $sql="SHOW TABLES FROM ".$database." ".$like.";"; + //print $sql; + $result = $this->query($sql); + while($row = $this->fetch_row($result)) + { + $listtables[] = $row[0]; + } + return $listtables; + } + + /** + * List information of columns into a table. + * + * @param string $table Name of table + * @return array Tableau des informations des champs de la table + * TODO modify for sqlite + */ + function DDLInfoTable($table) + { + $infotables=array(); + + $sql="SHOW FULL COLUMNS FROM ".$table.";"; + + dol_syslog($sql,LOG_DEBUG); + $result = $this->query($sql); + while($row = $this->fetch_row($result)) + { + $infotables[] = $row; + } + return $infotables; + } + + /** + * Create a table into database + * + * @param string $table Nom de la table + * @param array $fields Tableau associatif [nom champ][tableau des descriptions] + * @param string $primary_key Nom du champ qui sera la clef primaire + * @param string $type Type de la table + * @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur + * @param array $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext + * @param string $keys Tableau des champs cles noms => valeur + * @return int <0 if KO, >=0 if OK + */ + function DDLCreateTable($table,$fields,$primary_key,$type,$unique_keys="",$fulltext_keys="",$keys="") + { + // cles recherchees dans le tableau des descriptions (fields) : type,value,attribute,null,default,extra + // ex. : $fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment'); + $sql = "create table ".$table."("; + $i=0; + foreach($fields as $field_name => $field_desc) + { + $sqlfields[$i] = $field_name." "; + $sqlfields[$i] .= $field_desc['type']; + if( preg_match("/^[^\s]/i",$field_desc['value'])) + $sqlfields[$i] .= "(".$field_desc['value'].")"; + else if( preg_match("/^[^\s]/i",$field_desc['attribute'])) + $sqlfields[$i] .= " ".$field_desc['attribute']; + else if( preg_match("/^[^\s]/i",$field_desc['default'])) + { + if(preg_match("/null/i",$field_desc['default'])) + $sqlfields[$i] .= " default ".$field_desc['default']; + else + $sqlfields[$i] .= " default '".$field_desc['default']."'"; + } + else if( preg_match("/^[^\s]/i",$field_desc['null'])) + $sqlfields[$i] .= " ".$field_desc['null']; + + else if( preg_match("/^[^\s]/i",$field_desc['extra'])) + $sqlfields[$i] .= " ".$field_desc['extra']; + $i++; + } + if($primary_key != "") + $pk = "primary key(".$primary_key.")"; + + if($unique_keys != "") + { + $i = 0; + foreach($unique_keys as $key => $value) + { + $sqluq[$i] = "UNIQUE KEY '".$key."' ('".$value."')"; + $i++; + } + } + if($keys != "") + { + $i = 0; + foreach($keys as $key => $value) + { + $sqlk[$i] = "KEY ".$key." (".$value.")"; + $i++; + } + } + $sql .= implode(',',$sqlfields); + if($primary_key != "") + $sql .= ",".$pk; + if($unique_keys != "") + $sql .= ",".implode(',',$sqluq); + if($keys != "") + $sql .= ",".implode(',',$sqlk); + $sql .=") type=".$type; + + dol_syslog($sql,LOG_DEBUG); + if(! $this -> query($sql)) + return -1; + else + return 1; + } + + /** + * Return a pointer of line with description of a table or field + * + * @param string $table Name of table + * @param string $field Optionnel : Name of field if we want description of field + * @return resource Resource + */ + function DDLDescTable($table,$field="") + { + $sql="DESC ".$table." ".$field; + + dol_syslog(get_class($this)."::DDLDescTable ".$sql,LOG_DEBUG); + $this->_results = $this->query($sql); + return $this->_results; + } + + /** + * Create a new field into table + * + * @param string $table Name of table + * @param string $field_name Name of field to add + * @param string $field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre] + * @param string $field_position Optionnel ex.: "after champtruc" + * @return int <0 if KO, >0 if OK + */ + function DDLAddField($table,$field_name,$field_desc,$field_position="") + { + // cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra + // ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment'); + $sql= "ALTER TABLE ".$table." ADD ".$field_name." "; + $sql.= $field_desc['type']; + if(preg_match("/^[^\s]/i",$field_desc['value'])) + if (! in_array($field_desc['type'],array('date','datetime'))) + { + $sql.= "(".$field_desc['value'].")"; + } + if(preg_match("/^[^\s]/i",$field_desc['attribute'])) + $sql.= " ".$field_desc['attribute']; + if(preg_match("/^[^\s]/i",$field_desc['null'])) + $sql.= " ".$field_desc['null']; + if(preg_match("/^[^\s]/i",$field_desc['default'])) + { + if(preg_match("/null/i",$field_desc['default'])) + $sql.= " default ".$field_desc['default']; + else + $sql.= " default '".$field_desc['default']."'"; + } + if(preg_match("/^[^\s]/i",$field_desc['extra'])) + $sql.= " ".$field_desc['extra']; + $sql.= " ".$field_position; + + dol_syslog(get_class($this)."::DDLAddField ".$sql,LOG_DEBUG); + if(! $this->query($sql)) + { + return -1; + } + else + { + return 1; + } + } + + /** + * Update format of a field into a table + * + * @param string $table Name of table + * @param string $field_name Name of field to modify + * @param string $field_desc Array with description of field format + * @return int <0 if KO, >0 if OK + */ + function DDLUpdateField($table,$field_name,$field_desc) + { + $sql = "ALTER TABLE ".$table; + $sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type']; + if ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int' || $field_desc['type'] == 'varchar') { + $sql.="(".$field_desc['value'].")"; + } + + dol_syslog(get_class($this)."::DDLUpdateField ".$sql,LOG_DEBUG); + if (! $this->query($sql)) + return -1; + else + return 1; + } + + /** + * Drop a field from table + * + * @param string $table Name of table + * @param string $field_name Name of field to drop + * @return int <0 if KO, >0 if OK + */ + function DDLDropField($table,$field_name) + { + $sql= "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; + dol_syslog(get_class($this)."::DDLDropField ".$sql,LOG_DEBUG); + if (! $this->query($sql)) + { + $this->error=$this->lasterror(); + return -1; + } + else return 1; + } + + + /** + * Create a user and privileges to connect to database (even if database does not exists yet) + * + * @param string $dolibarr_main_db_host Ip serveur + * @param string $dolibarr_main_db_user Nom user a creer + * @param string $dolibarr_main_db_pass Mot de passe user a creer + * @param string $dolibarr_main_db_name Database name where user must be granted + * @return int <0 if KO, >=0 if OK + */ + function DDLCreateUser($dolibarr_main_db_host,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_name) + { + $sql = "INSERT INTO user "; + $sql.= "(Host,User,password,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Index_Priv,Alter_priv,Lock_tables_priv)"; + $sql.= " VALUES ('".$this->escape($dolibarr_main_db_host)."','".$this->escape($dolibarr_main_db_user)."',password('".addslashes($dolibarr_main_db_pass)."')"; + $sql.= ",'Y','Y','Y','Y','Y','Y','Y','Y','Y')"; + + dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log + $resql=$this->query($sql); + if (! $resql) + { + return -1; + } + + $sql = "INSERT INTO db "; + $sql.= "(Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Index_Priv,Alter_priv,Lock_tables_priv)"; + $sql.= " VALUES ('".$this->escape($dolibarr_main_db_host)."','".$this->escape($dolibarr_main_db_name)."','".addslashes($dolibarr_main_db_user)."'"; + $sql.= ",'Y','Y','Y','Y','Y','Y','Y','Y','Y')"; + + dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); + $resql=$this->query($sql); + if (! $resql) + { + return -1; + } + + $sql="FLUSH Privileges"; + + dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); + $resql=$this->query($sql); + if (! $resql) + { + return -1; + } + + return 1; + } + + /** + * Return charset used to store data in database + * + * @return string Charset + */ + function getDefaultCharacterSetDatabase() + { + return 'UTF-8'; + } + + /** + * Return list of available charset that can be used to store data in database + * + * @return array List of Charset + */ + function getListOfCharacterSet() + { + $liste = array(); + $i=0; + $liste[$i]['charset'] = 'UTF-8'; + $liste[$i]['description'] = 'UTF-8'; + return $liste; + } + + /** + * Return collation used in database + * + * @return string Collation value + */ + function getDefaultCollationDatabase() + { + return 'UTF-8'; + } + + /** + * Return list of available collation that can be used for database + * + * @return array List of Collation + */ + function getListOfCollation() + { + $liste = array(); + $i=0; + $liste[$i]['charset'] = 'UTF-8'; + $liste[$i]['description'] = 'UTF-8'; + return $liste; + } + + /** + * Return full path of dump program + * + * @return string Full path of dump program + */ + function getPathOfDump() + { + $fullpathofdump='/pathtomysqldump/mysqldump'; + + $resql=$this->query('SHOW VARIABLES LIKE \'basedir\''); + if ($resql) + { + $liste=$this->fetch_array($resql); + $basedir=$liste['Value']; + $fullpathofdump=$basedir.(preg_match('/\/$/',$basedir)?'':'/').'bin/mysqldump'; + } + return $fullpathofdump; + } + + /** + * Return full path of restore program + * + * @return string Full path of restore program + */ + function getPathOfRestore() + { + $fullpathofimport='/pathtomysql/mysql'; + + $resql=$this->query('SHOW VARIABLES LIKE \'basedir\''); + if ($resql) + { + $liste=$this->fetch_array($resql); + $basedir=$liste['Value']; + $fullpathofimport=$basedir.(preg_match('/\/$/',$basedir)?'':'/').'bin/mysql'; + } + return $fullpathofimport; + } + + /** + * Return value of server parameters + * + * @param string $filter Filter list on a particular value + * @return array Array of key-values (key=>value) + */ + function getServerParametersValues($filter='') + { + $result=array(); + static $pragmas; + if (! isset($pragmas)) { + // Définition de la liste des pragmas utilisés qui ne retournent qu'une seule valeur + // indépendante de la base de données. + // cf. http://www.sqlite.org/pragma.html + $pragmas = array( + 'application_id', 'auto_vacuum', 'automatic_index', 'busy_timeout', 'cache_size', + 'cache_spill', 'case_sensitive_like', 'checkpoint_fullsync', 'collation_list', + 'compile_options', 'data_version', /*'database_list',*/ + 'defer_foreign_keys', 'encoding', 'foreign_key_check', 'freelist_count', + 'full_column_names', 'fullsync', 'ingore_check_constraints', 'integrity_check', + 'journal_mode', 'journal_size_limit', 'legacy_file_format', 'locking_mode', + 'max_page_count', 'page_count', 'page_size', 'parser_trace', + 'query_only', 'quick_check', 'read_uncommitted', 'recursive_triggers', + 'reverse_unordered_selects', 'schema_version', 'user_version', + 'secure_delete', 'short_column_names', 'shrink_memory', 'soft_heap_limit', + 'synchronous', 'temp_store', /*'temp_store_directory',*/ 'threads', + 'vdbe_addoptrace', 'vdbe_debug', 'vdbe_listing', 'vdbe_trace', + 'wal_autocheckpoint', + ); + } + + // TODO prendre en compte le filtre + foreach($pragmas as $var) { + $sql = "PRAGMA $var"; + $resql=$this->query($sql); + if ($resql) + { + $obj = $this->fetch_row($resql); + //dol_syslog(get_class($this)."::select_db getServerParametersValues $var=". print_r($obj, true), LOG_DEBUG); + $result[$var] = $obj[0]; + } + } + return $result; + } + + /** + * Return value of server status + * + * @param string $filter Filter list on a particular value + * @return array Array of key-values (key=>value) + */ + function getServerStatusValues($filter='') + { + $result=array(); + /* + $sql='SHOW STATUS'; + if ($filter) $sql.=" LIKE '".$this->escape($filter)."'"; + $resql=$this->query($sql); + if ($resql) + { + while ($obj=$this->fetch_object($resql)) $result[$obj->Variable_name]=$obj->Value; + } + */ + + return $result; + } + + /** + * Permet le chargement d'une fonction personnalisee dans le moteur de base de donnees. + * Note: le nom de la fonction personnalisee est prefixee par 'db_'. La fonction doit être + * statique et publique. Le nombre de parametres est determine automatiquement. + * @param string $name Le nom de la fonction a definir dans Sqlite + */ + private function addCustomFunction($name, $arg_count = -1) { + if ($this->db) { + $localname = __CLASS__ . '::' . 'db_' . $name; + $reflectClass = new ReflectionClass(__CLASS__); + $reflectFunction = $reflectClass->getMethod('db_' . $name); + if ($arg_count < 0) { + $arg_count = $reflectFunction->getNumberOfParameters(); + } + if (!$this->db->createFunction($name, $localname , $arg_count)) { + $this->error = "unable to create custom function '$name'"; + } + } + } + + /** + * Cette fonction est l'equivalent de la fonction MONTH de MySql. + * @param string $date + * @return integer + */ + public static function db_MONTH($date) { + return date('n', strtotime($date)); + } + + /** + * calcule du numéro de semaine + * + * @param string date + * @param int mode + */ + public static function db_WEEK($date, $mode = 0) { + $arr = date_parse($date); + $calc_year = 0; + return self::calc_week($arr['year'], $arr['month'], $arr['day'], self::week_mode($mode), $calc_year); + } + + public static function db_CURDATE() { + return date('Y-m-d'); + } + + public static function db_CURTIME() { + return date('H:i:s'); + } + + public static function db_WEEKDAY($date) { + $arr = date_parse($date); + return self::calc_weekday(self::calc_daynr($arr['year'], $arr['month'], $arr['day']), 0); + + } + + /** + * Cette fonction est l'equivelent de la fonction date_format de MySQL. + * @staticvar string $mysql_replacement Les symboles formatage a remplacer + * @param string $date la date dans un format ISO + * @param string $format la chaine de formatage + * @return string La date formatee. + */ + public static function db_date_format($date, $format) { + static $mysql_replacement; + if (! isset($mysql_replacement)) { + $mysql_replacement = array( + '%' => '%', + 'a' => 'D', + 'b' => 'M', + 'c' => 'n', + 'D' => 'jS', + 'd' => 'd', + 'e' => 'j', + 'f' => 'u', + 'H' => 'H', + 'h' => 'h', + 'I' => 'h', + 'i' => 'i', + 'k' => 'H', + 'l' => 'g', + 'M' => 'F', + 'm' => 'm', + 'p' => 'A', + 'r' => 'h:i:s A', + 'S' => 's', + 's' => 's', + 'T' => 'H:i:s', + 'W' => 'l', + 'w' => 'w', + 'Y' => 'Y', + 'y' => 'y', + ); + } + + $fmt = ''; + $lg = strlen($format); + $state = 0; + $timestamp = strtotime($date); + $yday = date('z', $timestamp); + $month = (integer)date("n", $timestamp); + $year = (integer)date("Y", $timestamp); + $day = (integer)date("d", $timestamp); + for($idx = 0; $idx < $lg; ++$idx) { + $char = $format[$idx]; + if ($state == 0) { + if ($char == '%') { + $state = 1; + } else { + $fmt .= $char; + } + } + elseif ($state == 1) { + if (array_key_exists($char, $mysql_replacement)) { + $fmt .= $mysql_replacement[$char]; + } else { + $calc_year = 0; + switch ($char) { + case 'j': // day of the year 001 + $char = sprintf("%03d", $yday+1); + break; + case 'U': // mode 0: semaine 0 = premiere semaine complète qui commence un dimanche + $char = sprintf("%02d", self::calc_week($year, $month, $day, 4, $calc_year)); + break; + case 'u': // mode 1: semaine 0 = première semaine de 4 jours. Début le dimanche + $char = sprintf("%02d", self::calc_week($year, $month, $day, 1, $calc_year)); + break; + case 'V': // mode 2: semaine 1 = premiere semaine complète qui commence un dimanche + $char = sprintf("%02d", self::calc_week($year, $month, $day, 6, $calc_year)); + break; + case 'v': // mode 3: semaine 1 = premiere semaine de 4 jours. Début le lundi + $char = sprintf("%02d", self::calc_week($year, $month, $day, 3, $calc_year)); + break; + case 'X': + self::calc_week($year, $month, $day, 6, $calc_year); + $char = sprintf("%04d", $calc_year); + break; + case 'x': + self::calc_week($year, $month, $day, 3, $calc_year); + $char = sprintf("%04d", $calc_year); + break; + } + $fmt .= $char; + } + $state = 0; + } + } + return date($fmt, strtotime($date)); + } + + /** + * Equivalent de la fonction MySQL IF + * @param boolean $test Le resultat du test + * @param mixed $true_part Partie a retourner si vrai + * @param mixed $false_part Partie a retourner si faux + * @return mixed Partie selectionnee en fonction du test + */ + public static function db_IF($test, $true_part, $false_part) { + return ( $test ) ? $true_part : $false_part; + } + + // Adapté de mytime.c des sources de mariadb + // fonction calc_daynr + private static function calc_daynr($year, $month, $day) { + $y = $year; + if ($y == 0 && $month == 0) return 0; + $num = (365* $y + 31 * ($month - 1) + $day); + if ($month <= 2) { + $y--; } + else { + $num -= floor(($month * 4 + 23) / 10); + } + $temp = floor(($y / 100 + 1) * 3 / 4); + return $num + floor($y / 4) - $temp; + } + + private static function calc_weekday($daynr, $sunday_first_day_of_week) { + $ret = floor(($daynr + 5 + ($sunday_first_day_of_week ? 1 : 0)) % 7); + return $ret; + } + + private static function calc_days_in_year($year) + { + return (($year & 3) == 0 && ($year%100 || ($year%400 == 0 && $year)) ? 366 : 365); + } + + private static function week_mode($mode) { + $week_format= ($mode & 7); + if (!($week_format & self::WEEK_MONDAY_FIRST)) { + $week_format^= self::WEEK_FIRST_WEEKDAY; + } + return $week_format; + } + + + private static function calc_week($year, $month, $day, $week_behaviour, &$calc_year) { + $daynr=self::calc_daynr($year,$month,$day); + $first_daynr=self::calc_daynr($year,1,1); + $monday_first= ($week_behaviour & self::WEEK_MONDAY_FIRST) ? 1 : 0; + $week_year= ($week_behaviour & self::WEEK_YEAR) ? 1 : 0; + $first_weekday= ($week_behaviour & self::WEEK_FIRST_WEEKDAY) ? 1 : 0; + + $weekday=self::calc_weekday($first_daynr, !$monday_first); + $calc_year=$year; + + if ($month == 1 && $day <= 7-$weekday) + { + if (!$week_year && (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4))) + return 0; + $week_year= 1; + $calc_year--; + $first_daynr-= ($days=self::calc_days_in_year($calc_year)); + $weekday= ($weekday + 53*7- $days) % 7; + } + + if (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4)) { + $days= $daynr - ($first_daynr+ (7-$weekday)); + } + else { + $days= $daynr - ($first_daynr - $weekday); + } + + if ($week_year && $days >= 52*7) + { + $weekday= ($weekday + self::calc_days_in_year($calc_year)) % 7; + if ((!$first_weekday && $weekday < 4) || ($first_weekday && $weekday == 0)) + { + $calc_year++; + return 1; + } + } + return floor($days/7+1); + } + +} + diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php index d934f79f0af..612c3c64148 100644 --- a/htdocs/install/etape2.php +++ b/htdocs/install/etape2.php @@ -51,7 +51,7 @@ if ($dolibarr_main_db_type == "mysql") $choix=1; if ($dolibarr_main_db_type == "mysqli") $choix=1; if ($dolibarr_main_db_type == "pgsql") $choix=2; if ($dolibarr_main_db_type == "mssql") $choix=3; -if ($dolibarr_main_db_type == "sqlite") $choix=4; +if ($dolibarr_main_db_type == "sqlite3") $choix=4; //if (empty($choix)) dol_print_error('','Database type '.$dolibarr_main_db_type.' not supported into etape2.php page'); @@ -413,7 +413,7 @@ if ($action == "set") if ($choix==1) $dir = "mysql/functions/"; elseif ($choix==2) $dir = "pgsql/functions/"; elseif ($choix==3) $dir = "mssql/functions/"; - elseif ($choix==4) { $dir = "sqlite/functions/"; } + elseif ($choix==4) { $dir = "sqlite3/functions/"; } // Creation donnees $file = "functions.sql"; diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 49b80eb1b6b..ec3e208374b 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -306,7 +306,7 @@ if (! empty($force_install_message)) $class='DoliDB'.ucfirst($type); include_once $dir."/".$file; - //if ($type == 'sqlite') continue; // We hide sqlite because support can't be complete unti sqlit does not manage foreign key creation after table creation + if ($type == 'sqlite') continue; // We hide sqlite because support can't be complete unti sqlit does not manage foreign key creation after table creation // Version min of database $versionbasemin=explode('.',$class::VERSIONMIN); @@ -320,7 +320,7 @@ if (! empty($force_install_message)) if ($type=='mysqli') { $testfunction='mysqli_connect'; $testclass=''; } if ($type=='pgsql') { $testfunction='pg_connect'; $testclass=''; } if ($type=='mssql') { $testfunction='mssql_connect'; $testclass=''; } - if ($type=='sqlite') { $testfunction=''; $testclass='PDO'; } + if ($type=='sqlite3') { $testfunction=''; $testclass='SQLite3'; } $option.=''; @@ -479,7 +480,7 @@ if (! empty($force_install_message)) jQuery(document).ready(function() { jQuery("#db_type").change(function() { - if (jQuery("#db_type").val()=='sqlite') { jQuery(".hidesqlite").hide(); } + if (jQuery("#db_type").val()=='sqlite' || jQuery("#db_type").val()=='sqlite3') { jQuery(".hidesqlite").hide(); } else { jQuery(".hidesqlite").show(); } }); diff --git a/htdocs/install/sqlite/functions/functions.sql b/htdocs/install/sqlite3/functions/functions.sql similarity index 100% rename from htdocs/install/sqlite/functions/functions.sql rename to htdocs/install/sqlite3/functions/functions.sql diff --git a/htdocs/install/sqlite/index.html b/htdocs/install/sqlite3/index.html similarity index 100% rename from htdocs/install/sqlite/index.html rename to htdocs/install/sqlite3/index.html From 22045603b744134fa4c75066b97ff1adca623d37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 13:51:29 +0100 Subject: [PATCH 22/80] Fix bad update of denormalized field --- htdocs/projet/class/task.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 017e2b782ec..b01a9644cb1 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -807,7 +807,7 @@ class Task extends CommonObject if ($ret >= 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = duration_effective + '".price2num($this->timespent_duration)."'"; + $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; if (isset($this->progress)) $sql.= ", progress = " . $this->progress; // Do not overwrite value if not provided $sql.= " WHERE rowid = ".$this->id; @@ -980,7 +980,7 @@ class Task extends CommonObject $newDuration = $this->timespent_duration - $this->timespent_old_duration; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = duration_effective + '".$newDuration."'"; + $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; $sql.= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); From dd2594692e9d6cab9ce6c3c329e606abf1ad43fb Mon Sep 17 00:00:00 2001 From: Guillaume de Lestanville Date: Thu, 5 Mar 2015 17:35:37 +0100 Subject: [PATCH 23/80] Updating compatibility with Sqlite3 - Replace USING syntax by IN SELECT syntax - Fix error on database creation - Removing test on username parameter when installing. --- htdocs/admin/system/database-tables.php | 2 +- htdocs/core/db/sqlite3.class.php | 974 +++++++++--------- htdocs/core/modules/DolibarrModules.class.php | 587 +++++------ htdocs/install/etape1.php | 7 +- index.php | 2 - 5 files changed, 794 insertions(+), 778 deletions(-) delete mode 100644 index.php diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index 5ac7292042e..e75cec3f513 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -180,7 +180,7 @@ else print '
'.$langs->trans("TableName").'
'; print ''; print ''; - print ''; + print ''; print "\n"; $sql = "SELECT name, type FROM sqlite_master where type='table' and name not like 'sqlite%' ORDER BY name"; diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index f232acb199e..c52578fa579 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -37,18 +37,18 @@ class DoliDBSqlite3 extends DoliDB const LABEL='Sqlite3'; //! Version min database const VERSIONMIN='3.0.0'; - //! Resultset of last query - private $_results; + //! Resultset of last query + private $_results; - const WEEK_MONDAY_FIRST=1; - const WEEK_YEAR = 2; - const WEEK_FIRST_WEEKDAY=4; + const WEEK_MONDAY_FIRST=1; + const WEEK_YEAR = 2; + const WEEK_FIRST_WEEKDAY=4; /** * Constructor. * This create an opened connexion to a database server and eventually to a database - * + * * @param string $type Type of database (mysql, pgsql...) * @param string $host Address of database server * @param string $user Nom de l'utilisateur autorise @@ -101,14 +101,14 @@ class DoliDBSqlite3 extends DoliDB $this->database_selected = 1; $this->database_name = $name; - $this->addCustomFunction('IF'); - $this->addCustomFunction('MONTH'); - $this->addCustomFunction('CURTIME'); - $this->addCustomFunction('CURDATE'); - $this->addCustomFunction('WEEK', 1); - $this->addCustomFunction('WEEK', 2); - $this->addCustomFunction('WEEKDAY'); - $this->addCustomFunction('date_format'); + $this->addCustomFunction('IF'); + $this->addCustomFunction('MONTH'); + $this->addCustomFunction('CURTIME'); + $this->addCustomFunction('CURDATE'); + $this->addCustomFunction('WEEK', 1); + $this->addCustomFunction('WEEK', 2); + $this->addCustomFunction('WEEKDAY'); + $this->addCustomFunction('date_format'); //$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } else @@ -135,83 +135,83 @@ class DoliDBSqlite3 extends DoliDB */ static function convertSQLFromMysql($line,$type='ddl') { - // Removed empty line if this is a comment line for SVN tagging - if (preg_match('/^--\s\$Id/i',$line)) { - return ''; - } - // Return line if this is a comment - if (preg_match('/^#/i',$line) || preg_match('/^$/i',$line) || preg_match('/^--/i',$line)) - { - return $line; - } - if ($line != "") - { - if ($type == 'auto') - { + // Removed empty line if this is a comment line for SVN tagging + if (preg_match('/^--\s\$Id/i',$line)) { + return ''; + } + // Return line if this is a comment + if (preg_match('/^#/i',$line) || preg_match('/^$/i',$line) || preg_match('/^--/i',$line)) + { + return $line; + } + if ($line != "") + { + if ($type == 'auto') + { if (preg_match('/ALTER TABLE/i',$line)) $type='dml'; else if (preg_match('/CREATE TABLE/i',$line)) $type='dml'; else if (preg_match('/DROP TABLE/i',$line)) $type='dml'; - } + } - if ($type == 'dml') - { + if ($type == 'dml') + { $line=preg_replace('/\s/',' ',$line); // Replace tabulation with space - // we are inside create table statement so lets process datatypes - if (preg_match('/(ISAM|innodb)/i',$line)) { // end of create table sequence - $line=preg_replace('/\)[\s\t]*type[\s\t]*=[\s\t]*(MyISAM|innodb);/i',');',$line); - $line=preg_replace('/\)[\s\t]*engine[\s\t]*=[\s\t]*(MyISAM|innodb);/i',');',$line); - $line=preg_replace('/,$/','',$line); - } + // we are inside create table statement so lets process datatypes + if (preg_match('/(ISAM|innodb)/i',$line)) { // end of create table sequence + $line=preg_replace('/\)[\s\t]*type[\s\t]*=[\s\t]*(MyISAM|innodb);/i',');',$line); + $line=preg_replace('/\)[\s\t]*engine[\s\t]*=[\s\t]*(MyISAM|innodb);/i',');',$line); + $line=preg_replace('/,$/','',$line); + } - // Process case: "CREATE TABLE llx_mytable(rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,code..." - if (preg_match('/[\s\t\(]*(\w*)[\s\t]+int.*auto_increment/i',$line,$reg)) { - $newline=preg_replace('/([\s\t\(]*)([a-zA-Z_0-9]*)[\s\t]+int.*auto_increment[^,]*/i','\\1 \\2 integer PRIMARY KEY AUTOINCREMENT',$line); + // Process case: "CREATE TABLE llx_mytable(rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,code..." + if (preg_match('/[\s\t\(]*(\w*)[\s\t]+int.*auto_increment/i',$line,$reg)) { + $newline=preg_replace('/([\s\t\(]*)([a-zA-Z_0-9]*)[\s\t]+int.*auto_increment[^,]*/i','\\1 \\2 integer PRIMARY KEY AUTOINCREMENT',$line); //$line = "-- ".$line." replaced by --\n".$newline; $line=$newline; - } + } - // tinyint type conversion - $line=str_replace('tinyint','smallint',$line); + // tinyint type conversion + $line=str_replace('tinyint','smallint',$line); - // nuke unsigned - $line=preg_replace('/(int\w+|smallint)\s+unsigned/i','\\1',$line); + // nuke unsigned + $line=preg_replace('/(int\w+|smallint)\s+unsigned/i','\\1',$line); - // blob -> text - $line=preg_replace('/\w*blob/i','text',$line); + // blob -> text + $line=preg_replace('/\w*blob/i','text',$line); - // tinytext/mediumtext -> text - $line=preg_replace('/tinytext/i','text',$line); - $line=preg_replace('/mediumtext/i','text',$line); + // tinytext/mediumtext -> text + $line=preg_replace('/tinytext/i','text',$line); + $line=preg_replace('/mediumtext/i','text',$line); - // change not null datetime field to null valid ones - // (to support remapping of "zero time" to null - $line=preg_replace('/datetime not null/i','datetime',$line); - $line=preg_replace('/datetime/i','timestamp',$line); + // change not null datetime field to null valid ones + // (to support remapping of "zero time" to null + $line=preg_replace('/datetime not null/i','datetime',$line); + $line=preg_replace('/datetime/i','timestamp',$line); - // double -> numeric - $line=preg_replace('/^double/i','numeric',$line); - $line=preg_replace('/(\s*)double/i','\\1numeric',$line); - // float -> numeric - $line=preg_replace('/^float/i','numeric',$line); - $line=preg_replace('/(\s*)float/i','\\1numeric',$line); + // double -> numeric + $line=preg_replace('/^double/i','numeric',$line); + $line=preg_replace('/(\s*)double/i','\\1numeric',$line); + // float -> numeric + $line=preg_replace('/^float/i','numeric',$line); + $line=preg_replace('/(\s*)float/i','\\1numeric',$line); - // unique index(field1,field2) - if (preg_match('/unique index\s*\((\w+\s*,\s*\w+)\)/i',$line)) - { - $line=preg_replace('/unique index\s*\((\w+\s*,\s*\w+)\)/i','UNIQUE\(\\1\)',$line); - } + // unique index(field1,field2) + if (preg_match('/unique index\s*\((\w+\s*,\s*\w+)\)/i',$line)) + { + $line=preg_replace('/unique index\s*\((\w+\s*,\s*\w+)\)/i','UNIQUE\(\\1\)',$line); + } - // We remove end of requests "AFTER fieldxxx" - $line=preg_replace('/AFTER [a-z0-9_]+/i','',$line); + // We remove end of requests "AFTER fieldxxx" + $line=preg_replace('/AFTER [a-z0-9_]+/i','',$line); - // We remove start of requests "ALTER TABLE tablexxx" if this is a DROP INDEX - $line=preg_replace('/ALTER TABLE [a-z0-9_]+ DROP INDEX/i','DROP INDEX',$line); + // We remove start of requests "ALTER TABLE tablexxx" if this is a DROP INDEX + $line=preg_replace('/ALTER TABLE [a-z0-9_]+ DROP INDEX/i','DROP INDEX',$line); // Translate order to rename fields if (preg_match('/ALTER TABLE ([a-z0-9_]+) CHANGE(?: COLUMN)? ([a-z0-9_]+) ([a-z0-9_]+)(.*)$/i',$line,$reg)) { - $line = "-- ".$line." replaced by --\n"; + $line = "-- ".$line." replaced by --\n"; $line.= "ALTER TABLE ".$reg[1]." RENAME COLUMN ".$reg[2]." TO ".$reg[3]; } @@ -230,12 +230,12 @@ class DoliDBSqlite3 extends DoliDB } // alter table add primary key (field1, field2 ...) -> We create a unique index instead as dynamic creation of primary key is not supported - // ALTER TABLE llx_dolibarr_modules ADD PRIMARY KEY pk_dolibarr_modules (numero, entity); - if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+PRIMARY\s+KEY\s*(.*)\s*\((.*)$/i',$line,$reg)) - { - $line = "-- ".$line." replaced by --\n"; - $line.= "CREATE UNIQUE INDEX ".$reg[2]." ON ".$reg[1]."(".$reg[3]; - } + // ALTER TABLE llx_dolibarr_modules ADD PRIMARY KEY pk_dolibarr_modules (numero, entity); + if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+PRIMARY\s+KEY\s*(.*)\s*\((.*)$/i',$line,$reg)) + { + $line = "-- ".$line." replaced by --\n"; + $line.= "CREATE UNIQUE INDEX ".$reg[2]." ON ".$reg[1]."(".$reg[3]; + } // Translate order to drop foreign keys // ALTER TABLE llx_dolibarr_modules DROP FOREIGN KEY fk_xxx; @@ -245,62 +245,62 @@ class DoliDBSqlite3 extends DoliDB $line.= "ALTER TABLE ".$reg[1]." DROP CONSTRAINT ".$reg[2]; } - // alter table add [unique] [index] (field1, field2 ...) - // ALTER TABLE llx_accountingaccount ADD INDEX idx_accountingaccount_fk_pcg_version (fk_pcg_version) - if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+(UNIQUE INDEX|INDEX|UNIQUE)\s+(.*)\s*\(([\w,\s]+)\)/i',$line,$reg)) - { - $fieldlist=$reg[4]; - $idxname=$reg[3]; - $tablename=$reg[1]; - $line = "-- ".$line." replaced by --\n"; - $line.= "CREATE ".(preg_match('/UNIQUE/',$reg[2])?'UNIQUE ':'')."INDEX ".$idxname." ON ".$tablename." (".$fieldlist.")"; - } - if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+CONSTRAINT\s+(.*)\s*FOREIGN\s+KEY\s*\(([\w,\s]+)\)\s*REFERENCES\s+(\w+)\s*\(([\w,\s]+)\)/i',$line, $reg)) { - // Pour l'instant les contraintes ne sont pas créées - dol_syslog(get_class().'::query line emptied'); - $line = 'SELECT 0;'; + // alter table add [unique] [index] (field1, field2 ...) + // ALTER TABLE llx_accountingaccount ADD INDEX idx_accountingaccount_fk_pcg_version (fk_pcg_version) + if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+(UNIQUE INDEX|INDEX|UNIQUE)\s+(.*)\s*\(([\w,\s]+)\)/i',$line,$reg)) + { + $fieldlist=$reg[4]; + $idxname=$reg[3]; + $tablename=$reg[1]; + $line = "-- ".$line." replaced by --\n"; + $line.= "CREATE ".(preg_match('/UNIQUE/',$reg[2])?'UNIQUE ':'')."INDEX ".$idxname." ON ".$tablename." (".$fieldlist.")"; + } + if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+CONSTRAINT\s+(.*)\s*FOREIGN\s+KEY\s*\(([\w,\s]+)\)\s*REFERENCES\s+(\w+)\s*\(([\w,\s]+)\)/i',$line, $reg)) { + // Pour l'instant les contraintes ne sont pas créées + dol_syslog(get_class().'::query line emptied'); + $line = 'SELECT 0;'; - } + } - //if (preg_match('/rowid\s+.*\s+PRIMARY\s+KEY,/i', $line)) { - //preg_replace('/(rowid\s+.*\s+PRIMARY\s+KEY\s*,)/i', '/* \\1 */', $line); - //} + //if (preg_match('/rowid\s+.*\s+PRIMARY\s+KEY,/i', $line)) { + //preg_replace('/(rowid\s+.*\s+PRIMARY\s+KEY\s*,)/i', '/* \\1 */', $line); + //} } - // Delete using criteria on other table must not declare twice the deleted table - // DELETE FROM tabletodelete USING tabletodelete, othertable -> DELETE FROM tabletodelete USING othertable - if (preg_match('/DELETE FROM ([a-z_]+) USING ([a-z_]+), ([a-z_]+)/i',$line,$reg)) - { + // Delete using criteria on other table must not declare twice the deleted table + // DELETE FROM tabletodelete USING tabletodelete, othertable -> DELETE FROM tabletodelete USING othertable + if (preg_match('/DELETE FROM ([a-z_]+) USING ([a-z_]+), ([a-z_]+)/i',$line,$reg)) + { if ($reg[1] == $reg[2]) // If same table, we remove second one - { - $line=preg_replace('/DELETE FROM ([a-z_]+) USING ([a-z_]+), ([a-z_]+)/i','DELETE FROM \\1 USING \\3', $line); - } - } + { + $line=preg_replace('/DELETE FROM ([a-z_]+) USING ([a-z_]+), ([a-z_]+)/i','DELETE FROM \\1 USING \\3', $line); + } + } - // Remove () in the tables in FROM if one table - $line=preg_replace('/FROM\s*\((([a-z_]+)\s+as\s+([a-z_]+)\s*)\)/i','FROM \\1',$line); - //print $line."\n"; + // Remove () in the tables in FROM if one table + $line=preg_replace('/FROM\s*\((([a-z_]+)\s+as\s+([a-z_]+)\s*)\)/i','FROM \\1',$line); + //print $line."\n"; - // Remove () in the tables in FROM if two table - $line=preg_replace('/FROM\s*\(([a-z_]+\s+as\s+[a-z_]+)\s*,\s*([a-z_]+\s+as\s+[a-z_]+\s*)\)/i','FROM \\1, \\2',$line); - //print $line."\n"; + // Remove () in the tables in FROM if two table + $line=preg_replace('/FROM\s*\(([a-z_]+\s+as\s+[a-z_]+)\s*,\s*([a-z_]+\s+as\s+[a-z_]+\s*)\)/i','FROM \\1, \\2',$line); + //print $line."\n"; - // Remove () in the tables in FROM if two table - $line=preg_replace('/FROM\s*\(([a-z_]+\s+as\s+[a-z_]+)\s*,\s*([a-z_]+\s+as\s+[a-z_]+\s*),\s*([a-z_]+\s+as\s+[a-z_]+\s*)\)/i','FROM \\1, \\2, \\3',$line); - //print $line."\n"; + // Remove () in the tables in FROM if two table + $line=preg_replace('/FROM\s*\(([a-z_]+\s+as\s+[a-z_]+)\s*,\s*([a-z_]+\s+as\s+[a-z_]+\s*),\s*([a-z_]+\s+as\s+[a-z_]+\s*)\)/i','FROM \\1, \\2, \\3',$line); + //print $line."\n"; - //print "type=".$type." newline=".$line."
\n"; - } + //print "type=".$type." newline=".$line."
\n"; + } - return $line; + return $line; } - /** + /** * Select a database - * + * * @param string $database Name of database * @return boolean true if OK, false if KO - */ + */ function select_db($database) { dol_syslog(get_class($this)."::select_db database=".$database, LOG_DEBUG); @@ -310,7 +310,7 @@ class DoliDBSqlite3 extends DoliDB /** * Connexion to server - * + * * @param string $host database server host * @param string $login login * @param string $passwd password @@ -329,7 +329,7 @@ class DoliDBSqlite3 extends DoliDB if (empty($dir)) $dir=DOL_DATA_ROOT; // With sqlite, port must be in connect parameters //if (! $newport) $newport=3306; - $database_name = $dir.'/database_'.$name.'.sdb'; + $database_name = $dir.'/database_'.$name.'.sdb'; try { /*** connect to SQLite database ***/ //$this->db = new PDO("sqlite:".$dir.'/database_'.$name.'.sdb'); @@ -349,12 +349,12 @@ class DoliDBSqlite3 extends DoliDB /** * Return version of database server - * + * * @return string Version string */ function getVersion() { - return $this->db->version()['versionString']; + return $this->db->version()['versionString']; } /** @@ -364,10 +364,10 @@ class DoliDBSqlite3 extends DoliDB */ function getDriverInfo() { - // FIXME: Dummy method - // TODO: Implement + // FIXME: Dummy method + // TODO: Implement - return ''; + return ''; } @@ -381,9 +381,9 @@ class DoliDBSqlite3 extends DoliDB { if ($this->db) { - if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR); + if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR); $this->connected=0; - $this->db->close(); + $this->db->close(); $this->db=null; // Clean this->db return true; } @@ -391,7 +391,7 @@ class DoliDBSqlite3 extends DoliDB } /** - * Execute a SQL request and return the resultset + * Execute a SQL request and return the resultset * * @param string $query SQL query string * @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollbock to savepoint if error (this allow to have some request with errors inside global transactions). @@ -407,58 +407,58 @@ class DoliDBSqlite3 extends DoliDB $query = trim($query); $this->error = 0; - // Convert MySQL syntax to SQLite syntax - if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+CONSTRAINT\s+(.*)\s*FOREIGN\s+KEY\s*\(([\w,\s]+)\)\s*REFERENCES\s+(\w+)\s*\(([\w,\s]+)\)/i',$query, $reg)) { - // Ajout d'une clef étrangère à la table - // procédure de remplacement de la table pour ajouter la contrainte - // Exemple : ALTER TABLE llx_adherent ADD CONSTRAINT adherent_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid) - // -> CREATE TABLE ( ... ,CONSTRAINT adherent_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid)) - $foreignFields = $reg[5]; - $foreignTable = $reg[4]; - $localfields = $reg[3]; - $constraintname=trim($reg[2]); - $tablename=trim($reg[1]); + // Convert MySQL syntax to SQLite syntax + if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+CONSTRAINT\s+(.*)\s*FOREIGN\s+KEY\s*\(([\w,\s]+)\)\s*REFERENCES\s+(\w+)\s*\(([\w,\s]+)\)/i',$query, $reg)) { + // Ajout d'une clef étrangère à la table + // procédure de remplacement de la table pour ajouter la contrainte + // Exemple : ALTER TABLE llx_adherent ADD CONSTRAINT adherent_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid) + // -> CREATE TABLE ( ... ,CONSTRAINT adherent_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid)) + $foreignFields = $reg[5]; + $foreignTable = $reg[4]; + $localfields = $reg[3]; + $constraintname=trim($reg[2]); + $tablename=trim($reg[1]); - $descTable = $this->db->querySingle("SELECT sql FROM sqlite_master WHERE name='" . $tablename . "'"); + $descTable = $this->db->querySingle("SELECT sql FROM sqlite_master WHERE name='" . $tablename . "'"); - // 1- Renommer la table avec un nom temporaire - $this->query('ALTER TABLE ' . $tablename . ' RENAME TO tmp_' . $tablename); + // 1- Renommer la table avec un nom temporaire + $this->query('ALTER TABLE ' . $tablename . ' RENAME TO tmp_' . $tablename); - // 2- Recréer la table avec la contrainte ajoutée + // 2- Recréer la table avec la contrainte ajoutée - // on bricole la requete pour ajouter la contrainte - $descTable = substr($descTable, 0, strlen($descTable) - 1); - $descTable .= ", CONSTRAINT " . $constraintname . " FOREIGN KEY (" . $localfields . ") REFERENCES " .$foreignTable . "(" . $foreignFields . ")"; + // on bricole la requete pour ajouter la contrainte + $descTable = substr($descTable, 0, strlen($descTable) - 1); + $descTable .= ", CONSTRAINT " . $constraintname . " FOREIGN KEY (" . $localfields . ") REFERENCES " .$foreignTable . "(" . $foreignFields . ")"; - // fermeture de l'instruction - $descTable .= ')'; + // fermeture de l'instruction + $descTable .= ')'; - // Création proprement dite de la table - $this->query($descTable); + // Création proprement dite de la table + $this->query($descTable); - // 3- Transférer les données - $this->query('INSERT INTO ' . $tablename . ' SELECT * FROM tmp_' . $tablename); + // 3- Transférer les données + $this->query('INSERT INTO ' . $tablename . ' SELECT * FROM tmp_' . $tablename); - // 4- Supprimer la table temporaire - $this->query('DROP TABLE tmp_' . $tablename); + // 4- Supprimer la table temporaire + $this->query('DROP TABLE tmp_' . $tablename); - // dummy statement - $query="SELECT 0"; + // dummy statement + $query="SELECT 0"; - } else { - $query=$this->convertSQLFromMysql($query,$type); - } - //print "After convertSQLFromMysql:\n".$query."
\n"; + } else { + $query=$this->convertSQLFromMysql($query,$type); + } + //print "After convertSQLFromMysql:\n".$query."
\n"; - dol_syslog('sql='.$query, LOG_DEBUG); + dol_syslog('sql='.$query, LOG_DEBUG); - // Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE) + // Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE) try { //$ret = $this->db->exec($query); - $ret = $this->db->query($query); // $ret is a PDO object - if ($ret) { - $ret->queryString = $query; - } + $ret = $this->db->query($query); // $ret is a Sqlite3Result + if ($ret) { + $ret->queryString = $query; + } } catch(Exception $e) { @@ -474,15 +474,15 @@ class DoliDBSqlite3 extends DoliDB $this->lasterror = $this->error(); $this->lasterrno = $this->errno(); - dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); + dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); - $errormsg = get_class($this)."::query SQL Error message: ".$this->lasterror; + $errormsg = get_class($this)."::query SQL Error message: ".$this->lasterror; - if (preg_match('/[0-9]/',$this->lasterrno)) { + if (preg_match('/[0-9]/',$this->lasterrno)) { $errormsg .= ' ('.$this->lasterrno.')'; } - dol_syslog($errormsg, LOG_ERR); + dol_syslog($errormsg, LOG_ERR); } $this->lastquery=$query; $this->_results = $ret; @@ -502,10 +502,10 @@ class DoliDBSqlite3 extends DoliDB // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_object($resultset)) { $resultset=$this->_results; } //return $resultset->fetch(PDO::FETCH_OBJ); - $ret = $resultset->fetchArray(SQLITE3_ASSOC); - if ($ret) { - return (object)$ret; - } + $ret = $resultset->fetchArray(SQLITE3_ASSOC); + if ($ret) { + return (object)$ret; + } } @@ -520,10 +520,10 @@ class DoliDBSqlite3 extends DoliDB // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } //return $resultset->fetch(PDO::FETCH_ASSOC); - $ret = $resultset->fetchArray(SQLITE3_ASSOC); - if ($ret) { - return (array)$ret; - } + $ret = $resultset->fetchArray(SQLITE3_ASSOC); + if ($ret) { + return (array)$ret; + } } /** @@ -558,10 +558,10 @@ class DoliDBSqlite3 extends DoliDB { // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } - if (preg_match("/^SELECT/i", $resultset->queryString)) { - return $this->db->querySingle("SELECT count(*) FROM (" . $resultset->queryString . ") q"); - } - return 0; + if (preg_match("/^SELECT/i", $resultset->queryString)) { + return $this->db->querySingle("SELECT count(*) FROM (" . $resultset->queryString . ") q"); + } + return 0; } /** @@ -575,21 +575,21 @@ class DoliDBSqlite3 extends DoliDB { // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } - if (preg_match("/^SELECT/i", $resultset->queryString)) { - return $this->num_rows($resultset); - } + if (preg_match("/^SELECT/i", $resultset->queryString)) { + return $this->num_rows($resultset); + } // mysql necessite un link de base pour cette fonction contrairement // a pqsql qui prend un resultset return $this->db->changes(); } - /** + /** * Free last resultset used. - * + * * @param resultset $resultset Curseur de la requete voulue * @return void - */ + */ function free($resultset=0) { // If resultset not provided, we take the last used by connexion @@ -598,15 +598,15 @@ class DoliDBSqlite3 extends DoliDB if ($resultset && is_object($resultset)) $resultset->finalize(); } - /** + /** * Escape a string to insert data - * + * * @param string $stringtoencode String to escape * @return string String escaped - */ + */ function escape($stringtoencode) { - return Sqlite3::escapeString($stringtoencode); + return Sqlite3::escapeString($stringtoencode); } /** @@ -656,19 +656,19 @@ class DoliDBSqlite3 extends DoliDB }*/ $errno=$this->db->lastErrorCode(); if ($errno=='HY000' || $errno == 0) - { + { if (preg_match('/table.*already exists/i',$this->error)) return 'DB_ERROR_TABLE_ALREADY_EXISTS'; elseif (preg_match('/index.*already exists/i',$this->error)) return 'DB_ERROR_KEY_NAME_ALREADY_EXISTS'; elseif (preg_match('/syntax error/i',$this->error)) return 'DB_ERROR_SYNTAX'; - } - if ($errno=='23000') - { + } + if ($errno=='23000') + { if (preg_match('/column.* not unique/i',$this->error)) return 'DB_ERROR_RECORD_ALREADY_EXISTS'; elseif (preg_match('/PRIMARY KEY must be unique/i',$this->error)) return 'DB_ERROR_RECORD_ALREADY_EXISTS'; - } - if ($errno > 1) { - // TODO Voir la liste des messages d'erreur - } + } + if ($errno > 1) { + // TODO Voir la liste des messages d'erreur + } return ($errno?'DB_ERROR_'.$errno:'0'); } @@ -691,8 +691,8 @@ class DoliDBSqlite3 extends DoliDB } /** - * Get last ID after an insert INSERT - * + * Get last ID after an insert INSERT + * * @param string $tab Table name concerned by insert. Ne sert pas sous MySql mais requis pour compatibilite avec Postgresql * @param string $fieldid Field name * @return int Id of row @@ -772,13 +772,13 @@ class DoliDBSqlite3 extends DoliDB /** - * Return connexion ID - * + * Return connexion ID + * * @return string Id connexion */ function DDLGetConnectId() { - return '?'; + return '?'; } @@ -786,7 +786,7 @@ class DoliDBSqlite3 extends DoliDB * Create a new database * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated * We force to create database with charset this->forcecharset and collate this->forcecollate - * + * * @param string $database Database name to create * @param string $charset Charset used to store data * @param string $collation Charset used to sort data @@ -815,8 +815,8 @@ class DoliDBSqlite3 extends DoliDB } /** - * List tables into a database - * + * List tables into a database + * * @param string $database Name of database * @param string $table Name of table filter ('xxx%') * @return array List of tables in an array @@ -839,7 +839,7 @@ class DoliDBSqlite3 extends DoliDB /** * List information of columns into a table. - * + * * @param string $table Name of table * @return array Tableau des informations des champs de la table * TODO modify for sqlite @@ -861,7 +861,7 @@ class DoliDBSqlite3 extends DoliDB /** * Create a table into database - * + * * @param string $table Nom de la table * @param array $fields Tableau associatif [nom champ][tableau des descriptions] * @param string $primary_key Nom du champ qui sera la clef primaire @@ -938,7 +938,7 @@ class DoliDBSqlite3 extends DoliDB /** * Return a pointer of line with description of a table or field - * + * * @param string $table Name of table * @param string $field Optionnel : Name of field if we want description of field * @return resource Resource @@ -954,7 +954,7 @@ class DoliDBSqlite3 extends DoliDB /** * Create a new field into table - * + * * @param string $table Name of table * @param string $field_name Name of field to add * @param string $field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre] @@ -1000,7 +1000,7 @@ class DoliDBSqlite3 extends DoliDB /** * Update format of a field into a table - * + * * @param string $table Name of table * @param string $field_name Name of field to modify * @param string $field_desc Array with description of field format @@ -1011,7 +1011,7 @@ class DoliDBSqlite3 extends DoliDB $sql = "ALTER TABLE ".$table; $sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type']; if ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int' || $field_desc['type'] == 'varchar') { - $sql.="(".$field_desc['value'].")"; + $sql.="(".$field_desc['value'].")"; } dol_syslog(get_class($this)."::DDLUpdateField ".$sql,LOG_DEBUG); @@ -1023,7 +1023,7 @@ class DoliDBSqlite3 extends DoliDB /** * Drop a field from table - * + * * @param string $table Name of table * @param string $field_name Name of field to drop * @return int <0 if KO, >0 if OK @@ -1043,7 +1043,7 @@ class DoliDBSqlite3 extends DoliDB /** * Create a user and privileges to connect to database (even if database does not exists yet) - * + * * @param string $dolibarr_main_db_host Ip serveur * @param string $dolibarr_main_db_user Nom user a creer * @param string $dolibarr_main_db_pass Mot de passe user a creer @@ -1088,21 +1088,21 @@ class DoliDBSqlite3 extends DoliDB return 1; } - /** + /** * Return charset used to store data in database - * + * * @return string Charset - */ + */ function getDefaultCharacterSetDatabase() { return 'UTF-8'; } - /** + /** * Return list of available charset that can be used to store data in database - * + * * @return array List of Charset - */ + */ function getListOfCharacterSet() { $liste = array(); @@ -1112,21 +1112,21 @@ class DoliDBSqlite3 extends DoliDB return $liste; } - /** + /** * Return collation used in database - * + * * @return string Collation value - */ + */ function getDefaultCollationDatabase() { return 'UTF-8'; } - /** + /** * Return list of available collation that can be used for database - * + * * @return array List of Collation - */ + */ function getListOfCollation() { $liste = array(); @@ -1136,12 +1136,12 @@ class DoliDBSqlite3 extends DoliDB return $liste; } - /** + /** * Return full path of dump program - * + * * @return string Full path of dump program - */ - function getPathOfDump() + */ + function getPathOfDump() { $fullpathofdump='/pathtomysqldump/mysqldump'; @@ -1155,11 +1155,11 @@ class DoliDBSqlite3 extends DoliDB return $fullpathofdump; } - /** + /** * Return full path of restore program - * + * * @return string Full path of restore program - */ + */ function getPathOfRestore() { $fullpathofimport='/pathtomysql/mysql'; @@ -1174,61 +1174,65 @@ class DoliDBSqlite3 extends DoliDB return $fullpathofimport; } - /** - * Return value of server parameters - * + /** + * Return value of server parameters + * * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) - */ + */ function getServerParametersValues($filter='') { $result=array(); - static $pragmas; - if (! isset($pragmas)) { - // Définition de la liste des pragmas utilisés qui ne retournent qu'une seule valeur - // indépendante de la base de données. - // cf. http://www.sqlite.org/pragma.html - $pragmas = array( - 'application_id', 'auto_vacuum', 'automatic_index', 'busy_timeout', 'cache_size', - 'cache_spill', 'case_sensitive_like', 'checkpoint_fullsync', 'collation_list', + static $pragmas; + if (! isset($pragmas)) { + // Définition de la liste des pragmas utilisés qui ne retournent qu'une seule valeur + // indépendante de la base de données. + // cf. http://www.sqlite.org/pragma.html + $pragmas = array( + 'application_id', 'auto_vacuum', 'automatic_index', 'busy_timeout', 'cache_size', + 'cache_spill', 'case_sensitive_like', 'checkpoint_fullsync', 'collation_list', 'compile_options', 'data_version', /*'database_list',*/ - 'defer_foreign_keys', 'encoding', 'foreign_key_check', 'freelist_count', - 'full_column_names', 'fullsync', 'ingore_check_constraints', 'integrity_check', - 'journal_mode', 'journal_size_limit', 'legacy_file_format', 'locking_mode', - 'max_page_count', 'page_count', 'page_size', 'parser_trace', - 'query_only', 'quick_check', 'read_uncommitted', 'recursive_triggers', - 'reverse_unordered_selects', 'schema_version', 'user_version', - 'secure_delete', 'short_column_names', 'shrink_memory', 'soft_heap_limit', - 'synchronous', 'temp_store', /*'temp_store_directory',*/ 'threads', - 'vdbe_addoptrace', 'vdbe_debug', 'vdbe_listing', 'vdbe_trace', - 'wal_autocheckpoint', - ); - } + 'defer_foreign_keys', 'encoding', 'foreign_key_check', 'freelist_count', + 'full_column_names', 'fullsync', 'ingore_check_constraints', 'integrity_check', + 'journal_mode', 'journal_size_limit', 'legacy_file_format', 'locking_mode', + 'max_page_count', 'page_count', 'page_size', 'parser_trace', + 'query_only', 'quick_check', 'read_uncommitted', 'recursive_triggers', + 'reverse_unordered_selects', 'schema_version', 'user_version', + 'secure_delete', 'short_column_names', 'shrink_memory', 'soft_heap_limit', + 'synchronous', 'temp_store', /*'temp_store_directory',*/ 'threads', + 'vdbe_addoptrace', 'vdbe_debug', 'vdbe_listing', 'vdbe_trace', + 'wal_autocheckpoint', + ); + } - // TODO prendre en compte le filtre - foreach($pragmas as $var) { - $sql = "PRAGMA $var"; - $resql=$this->query($sql); - if ($resql) - { - $obj = $this->fetch_row($resql); - //dol_syslog(get_class($this)."::select_db getServerParametersValues $var=". print_r($obj, true), LOG_DEBUG); - $result[$var] = $obj[0]; - } - } + // TODO prendre en compte le filtre + foreach($pragmas as $var) { + $sql = "PRAGMA $var"; + $resql=$this->query($sql); + if ($resql) + { + $obj = $this->fetch_row($resql); + //dol_syslog(get_class($this)."::select_db getServerParametersValues $var=". print_r($obj, true), LOG_DEBUG); + $result[$var] = $obj[0]; + } + else { + // TODO Récupérer le message + $result[$var] = 'FAIL'; + } + } return $result; } - /** - * Return value of server status - * + /** + * Return value of server status + * * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) - */ + */ function getServerStatusValues($filter='') { $result=array(); - /* + /* $sql='SHOW STATUS'; if ($filter) $sql.=" LIKE '".$this->escape($filter)."'"; $resql=$this->query($sql); @@ -1236,243 +1240,243 @@ class DoliDBSqlite3 extends DoliDB { while ($obj=$this->fetch_object($resql)) $result[$obj->Variable_name]=$obj->Value; } - */ + */ return $result; } - /** - * Permet le chargement d'une fonction personnalisee dans le moteur de base de donnees. - * Note: le nom de la fonction personnalisee est prefixee par 'db_'. La fonction doit être - * statique et publique. Le nombre de parametres est determine automatiquement. - * @param string $name Le nom de la fonction a definir dans Sqlite - */ - private function addCustomFunction($name, $arg_count = -1) { - if ($this->db) { - $localname = __CLASS__ . '::' . 'db_' . $name; - $reflectClass = new ReflectionClass(__CLASS__); - $reflectFunction = $reflectClass->getMethod('db_' . $name); - if ($arg_count < 0) { - $arg_count = $reflectFunction->getNumberOfParameters(); - } - if (!$this->db->createFunction($name, $localname , $arg_count)) { - $this->error = "unable to create custom function '$name'"; - } - } - } + /** + * Permet le chargement d'une fonction personnalisee dans le moteur de base de donnees. + * Note: le nom de la fonction personnalisee est prefixee par 'db_'. La fonction doit être + * statique et publique. Le nombre de parametres est determine automatiquement. + * @param string $name Le nom de la fonction a definir dans Sqlite + */ + private function addCustomFunction($name, $arg_count = -1) { + if ($this->db) { + $localname = __CLASS__ . '::' . 'db_' . $name; + $reflectClass = new ReflectionClass(__CLASS__); + $reflectFunction = $reflectClass->getMethod('db_' . $name); + if ($arg_count < 0) { + $arg_count = $reflectFunction->getNumberOfParameters(); + } + if (!$this->db->createFunction($name, $localname , $arg_count)) { + $this->error = "unable to create custom function '$name'"; + } + } + } - /** - * Cette fonction est l'equivalent de la fonction MONTH de MySql. - * @param string $date - * @return integer - */ - public static function db_MONTH($date) { - return date('n', strtotime($date)); - } + /** + * Cette fonction est l'equivalent de la fonction MONTH de MySql. + * @param string $date + * @return integer + */ + public static function db_MONTH($date) { + return date('n', strtotime($date)); + } - /** - * calcule du numéro de semaine - * - * @param string date - * @param int mode - */ - public static function db_WEEK($date, $mode = 0) { - $arr = date_parse($date); - $calc_year = 0; - return self::calc_week($arr['year'], $arr['month'], $arr['day'], self::week_mode($mode), $calc_year); - } + /** + * calcule du numéro de semaine + * + * @param string date + * @param int mode + */ + public static function db_WEEK($date, $mode = 0) { + $arr = date_parse($date); + $calc_year = 0; + return self::calc_week($arr['year'], $arr['month'], $arr['day'], self::week_mode($mode), $calc_year); + } - public static function db_CURDATE() { - return date('Y-m-d'); - } + public static function db_CURDATE() { + return date('Y-m-d'); + } - public static function db_CURTIME() { - return date('H:i:s'); - } + public static function db_CURTIME() { + return date('H:i:s'); + } - public static function db_WEEKDAY($date) { - $arr = date_parse($date); - return self::calc_weekday(self::calc_daynr($arr['year'], $arr['month'], $arr['day']), 0); + public static function db_WEEKDAY($date) { + $arr = date_parse($date); + return self::calc_weekday(self::calc_daynr($arr['year'], $arr['month'], $arr['day']), 0); - } + } - /** - * Cette fonction est l'equivelent de la fonction date_format de MySQL. + /** + * Cette fonction est l'equivelent de la fonction date_format de MySQL. * @staticvar string $mysql_replacement Les symboles formatage a remplacer - * @param string $date la date dans un format ISO - * @param string $format la chaine de formatage - * @return string La date formatee. - */ - public static function db_date_format($date, $format) { - static $mysql_replacement; - if (! isset($mysql_replacement)) { - $mysql_replacement = array( - '%' => '%', - 'a' => 'D', - 'b' => 'M', - 'c' => 'n', - 'D' => 'jS', - 'd' => 'd', - 'e' => 'j', - 'f' => 'u', - 'H' => 'H', - 'h' => 'h', - 'I' => 'h', - 'i' => 'i', - 'k' => 'H', - 'l' => 'g', - 'M' => 'F', - 'm' => 'm', - 'p' => 'A', - 'r' => 'h:i:s A', - 'S' => 's', - 's' => 's', - 'T' => 'H:i:s', - 'W' => 'l', - 'w' => 'w', - 'Y' => 'Y', - 'y' => 'y', - ); - } + * @param string $date la date dans un format ISO + * @param string $format la chaine de formatage + * @return string La date formatee. + */ + public static function db_date_format($date, $format) { + static $mysql_replacement; + if (! isset($mysql_replacement)) { + $mysql_replacement = array( + '%' => '%', + 'a' => 'D', + 'b' => 'M', + 'c' => 'n', + 'D' => 'jS', + 'd' => 'd', + 'e' => 'j', + 'f' => 'u', + 'H' => 'H', + 'h' => 'h', + 'I' => 'h', + 'i' => 'i', + 'k' => 'H', + 'l' => 'g', + 'M' => 'F', + 'm' => 'm', + 'p' => 'A', + 'r' => 'h:i:s A', + 'S' => 's', + 's' => 's', + 'T' => 'H:i:s', + 'W' => 'l', + 'w' => 'w', + 'Y' => 'Y', + 'y' => 'y', + ); + } - $fmt = ''; - $lg = strlen($format); - $state = 0; - $timestamp = strtotime($date); - $yday = date('z', $timestamp); - $month = (integer)date("n", $timestamp); - $year = (integer)date("Y", $timestamp); - $day = (integer)date("d", $timestamp); - for($idx = 0; $idx < $lg; ++$idx) { - $char = $format[$idx]; - if ($state == 0) { - if ($char == '%') { - $state = 1; - } else { - $fmt .= $char; - } - } - elseif ($state == 1) { - if (array_key_exists($char, $mysql_replacement)) { - $fmt .= $mysql_replacement[$char]; - } else { - $calc_year = 0; - switch ($char) { + $fmt = ''; + $lg = strlen($format); + $state = 0; + $timestamp = strtotime($date); + $yday = date('z', $timestamp); + $month = (integer)date("n", $timestamp); + $year = (integer)date("Y", $timestamp); + $day = (integer)date("d", $timestamp); + for($idx = 0; $idx < $lg; ++$idx) { + $char = $format[$idx]; + if ($state == 0) { + if ($char == '%') { + $state = 1; + } else { + $fmt .= $char; + } + } + elseif ($state == 1) { + if (array_key_exists($char, $mysql_replacement)) { + $fmt .= $mysql_replacement[$char]; + } else { + $calc_year = 0; + switch ($char) { case 'j': // day of the year 001 - $char = sprintf("%03d", $yday+1); - break; - case 'U': // mode 0: semaine 0 = premiere semaine complète qui commence un dimanche - $char = sprintf("%02d", self::calc_week($year, $month, $day, 4, $calc_year)); - break; - case 'u': // mode 1: semaine 0 = première semaine de 4 jours. Début le dimanche - $char = sprintf("%02d", self::calc_week($year, $month, $day, 1, $calc_year)); - break; - case 'V': // mode 2: semaine 1 = premiere semaine complète qui commence un dimanche - $char = sprintf("%02d", self::calc_week($year, $month, $day, 6, $calc_year)); - break; - case 'v': // mode 3: semaine 1 = premiere semaine de 4 jours. Début le lundi - $char = sprintf("%02d", self::calc_week($year, $month, $day, 3, $calc_year)); - break; - case 'X': - self::calc_week($year, $month, $day, 6, $calc_year); - $char = sprintf("%04d", $calc_year); - break; - case 'x': - self::calc_week($year, $month, $day, 3, $calc_year); - $char = sprintf("%04d", $calc_year); - break; - } - $fmt .= $char; - } - $state = 0; - } - } - return date($fmt, strtotime($date)); - } + $char = sprintf("%03d", $yday+1); + break; + case 'U': // mode 0: semaine 0 = premiere semaine complète qui commence un dimanche + $char = sprintf("%02d", self::calc_week($year, $month, $day, 4, $calc_year)); + break; + case 'u': // mode 1: semaine 0 = première semaine de 4 jours. Début le dimanche + $char = sprintf("%02d", self::calc_week($year, $month, $day, 1, $calc_year)); + break; + case 'V': // mode 2: semaine 1 = premiere semaine complète qui commence un dimanche + $char = sprintf("%02d", self::calc_week($year, $month, $day, 6, $calc_year)); + break; + case 'v': // mode 3: semaine 1 = premiere semaine de 4 jours. Début le lundi + $char = sprintf("%02d", self::calc_week($year, $month, $day, 3, $calc_year)); + break; + case 'X': + self::calc_week($year, $month, $day, 6, $calc_year); + $char = sprintf("%04d", $calc_year); + break; + case 'x': + self::calc_week($year, $month, $day, 3, $calc_year); + $char = sprintf("%04d", $calc_year); + break; + } + $fmt .= $char; + } + $state = 0; + } + } + return date($fmt, strtotime($date)); + } - /** - * Equivalent de la fonction MySQL IF - * @param boolean $test Le resultat du test - * @param mixed $true_part Partie a retourner si vrai - * @param mixed $false_part Partie a retourner si faux - * @return mixed Partie selectionnee en fonction du test - */ - public static function db_IF($test, $true_part, $false_part) { - return ( $test ) ? $true_part : $false_part; - } + /** + * Equivalent de la fonction MySQL IF + * @param boolean $test Le resultat du test + * @param mixed $true_part Partie a retourner si vrai + * @param mixed $false_part Partie a retourner si faux + * @return mixed Partie selectionnee en fonction du test + */ + public static function db_IF($test, $true_part, $false_part) { + return ( $test ) ? $true_part : $false_part; + } - // Adapté de mytime.c des sources de mariadb - // fonction calc_daynr - private static function calc_daynr($year, $month, $day) { - $y = $year; - if ($y == 0 && $month == 0) return 0; - $num = (365* $y + 31 * ($month - 1) + $day); - if ($month <= 2) { - $y--; } - else { - $num -= floor(($month * 4 + 23) / 10); - } - $temp = floor(($y / 100 + 1) * 3 / 4); - return $num + floor($y / 4) - $temp; - } + // Adapté de mytime.c des sources de mariadb + // fonction calc_daynr + private static function calc_daynr($year, $month, $day) { + $y = $year; + if ($y == 0 && $month == 0) return 0; + $num = (365* $y + 31 * ($month - 1) + $day); + if ($month <= 2) { + $y--; } + else { + $num -= floor(($month * 4 + 23) / 10); + } + $temp = floor(($y / 100 + 1) * 3 / 4); + return $num + floor($y / 4) - $temp; + } - private static function calc_weekday($daynr, $sunday_first_day_of_week) { - $ret = floor(($daynr + 5 + ($sunday_first_day_of_week ? 1 : 0)) % 7); - return $ret; - } + private static function calc_weekday($daynr, $sunday_first_day_of_week) { + $ret = floor(($daynr + 5 + ($sunday_first_day_of_week ? 1 : 0)) % 7); + return $ret; + } - private static function calc_days_in_year($year) - { - return (($year & 3) == 0 && ($year%100 || ($year%400 == 0 && $year)) ? 366 : 365); - } + private static function calc_days_in_year($year) + { + return (($year & 3) == 0 && ($year%100 || ($year%400 == 0 && $year)) ? 366 : 365); + } - private static function week_mode($mode) { - $week_format= ($mode & 7); - if (!($week_format & self::WEEK_MONDAY_FIRST)) { - $week_format^= self::WEEK_FIRST_WEEKDAY; - } - return $week_format; - } + private static function week_mode($mode) { + $week_format= ($mode & 7); + if (!($week_format & self::WEEK_MONDAY_FIRST)) { + $week_format^= self::WEEK_FIRST_WEEKDAY; + } + return $week_format; + } - private static function calc_week($year, $month, $day, $week_behaviour, &$calc_year) { - $daynr=self::calc_daynr($year,$month,$day); - $first_daynr=self::calc_daynr($year,1,1); - $monday_first= ($week_behaviour & self::WEEK_MONDAY_FIRST) ? 1 : 0; - $week_year= ($week_behaviour & self::WEEK_YEAR) ? 1 : 0; - $first_weekday= ($week_behaviour & self::WEEK_FIRST_WEEKDAY) ? 1 : 0; + private static function calc_week($year, $month, $day, $week_behaviour, &$calc_year) { + $daynr=self::calc_daynr($year,$month,$day); + $first_daynr=self::calc_daynr($year,1,1); + $monday_first= ($week_behaviour & self::WEEK_MONDAY_FIRST) ? 1 : 0; + $week_year= ($week_behaviour & self::WEEK_YEAR) ? 1 : 0; + $first_weekday= ($week_behaviour & self::WEEK_FIRST_WEEKDAY) ? 1 : 0; - $weekday=self::calc_weekday($first_daynr, !$monday_first); - $calc_year=$year; + $weekday=self::calc_weekday($first_daynr, !$monday_first); + $calc_year=$year; - if ($month == 1 && $day <= 7-$weekday) - { - if (!$week_year && (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4))) - return 0; - $week_year= 1; - $calc_year--; - $first_daynr-= ($days=self::calc_days_in_year($calc_year)); - $weekday= ($weekday + 53*7- $days) % 7; - } + if ($month == 1 && $day <= 7-$weekday) + { + if (!$week_year && (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4))) + return 0; + $week_year= 1; + $calc_year--; + $first_daynr-= ($days=self::calc_days_in_year($calc_year)); + $weekday= ($weekday + 53*7- $days) % 7; + } - if (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4)) { - $days= $daynr - ($first_daynr+ (7-$weekday)); - } - else { - $days= $daynr - ($first_daynr - $weekday); - } + if (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4)) { + $days= $daynr - ($first_daynr+ (7-$weekday)); + } + else { + $days= $daynr - ($first_daynr - $weekday); + } - if ($week_year && $days >= 52*7) - { - $weekday= ($weekday + self::calc_days_in_year($calc_year)) % 7; - if ((!$first_weekday && $weekday < 4) || ($first_weekday && $weekday == 0)) - { - $calc_year++; - return 1; - } - } - return floor($days/7+1); - } + if ($week_year && $days >= 52*7) + { + $weekday= ($weekday + self::calc_days_in_year($calc_year)) % 7; + if ((!$first_weekday && $weekday < 4) || ($first_weekday && $weekday == 0)) + { + $calc_year++; + return 1; + } + } + return floor($days/7+1); + } } diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 0b0ceb5460c..017d1eb8662 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -39,166 +39,166 @@ abstract class DolibarrModules */ public $db; - /** - * @var string Relative path to module style sheet - * @deprecated - */ - public $style_sheet = ''; + /** + * @var string Relative path to module style sheet + * @deprecated + */ + public $style_sheet = ''; - /** - * @var array Paths to create when module is activated - */ - public $dirs = array(); + /** + * @var array Paths to create when module is activated + */ + public $dirs = array(); - /** - * @var array Module boxes - */ - public $boxes = array(); + /** + * @var array Module boxes + */ + public $boxes = array(); - /** - * @var array Module constants - */ - public $const = array(); + /** + * @var array Module constants + */ + public $const = array(); - /** - * @var array Module access rights - */ - public $rights; + /** + * @var array Module access rights + */ + public $rights; - /** - * @var string Module access rights family - */ - public $rights_class; + /** + * @var string Module access rights family + */ + public $rights_class; - /** - * @var array Module menu entries - */ - public $menu = array(); + /** + * @var array Module menu entries + */ + public $menu = array(); - /** - * @var array Module parts - * array( - * // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers) - * 'triggers' => 0, - * // Set this to 1 if module has its own login method directory (/mymodule/core/login) + /** + * @var array Module parts + * array( + * // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers) + * 'triggers' => 0, + * // Set this to 1 if module has its own login method directory (/mymodule/core/login) * 'login' => 0, - * // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions) + * // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions) * 'substitutions' => 0, - * // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus) + * // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus) * 'menus' => 0, - * // Set this to 1 if module has its own theme directory (/mymodule/theme) + * // Set this to 1 if module has its own theme directory (/mymodule/theme) * 'theme' => 0, - * // Set this to 1 if module overwrite template dir (/mymodule/core/tpl) - * 'tpl' => 0, - * // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode) + * // Set this to 1 if module overwrite template dir (/mymodule/core/tpl) + * 'tpl' => 0, + * // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode) * 'barcode' => 0, - * // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx) + * // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx) * 'models' => 0, - * // Set this to relative path of css file if module has its own css file + * // Set this to relative path of css file if module has its own css file * 'css' => '/mymodule/css/mymodule.css.php', - * // Set this to relative path of js file if module must load a js on all pages + * // Set this to relative path of js file if module must load a js on all pages * 'js' => '/mymodule/js/mymodule.js', - * // Set here all hooks context managed by module + * // Set here all hooks context managed by module * 'hooks' => array('hookcontext1','hookcontext2'), - * // Set here all workflow context managed by module + * // Set here all workflow context managed by module * 'workflow' => array( - * 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array( - * 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', - * 'picto'=>'yourpicto@mymodule' - * ) - * ) - * ) - */ - public $module_parts = array(); + * 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array( + * 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', + * 'picto'=>'yourpicto@mymodule' + * ) + * ) + * ) + */ + public $module_parts = array(); - /** - * @var string Module documents ? - * @deprecated Seems unused anywhere - */ - public $docs; + /** + * @var string Module documents ? + * @deprecated Seems unused anywhere + */ + public $docs; - /** - * @var string ? - * @deprecated Seems unused anywhere - */ - public $dbversion = "-"; + /** + * @var string ? + * @deprecated Seems unused anywhere + */ + public $dbversion = "-"; - /** - * @var string Error message - */ - public $error; + /** + * @var string Error message + */ + public $error; - /** - * @var int Module unique ID - */ - public $numero; + /** + * @var int Module unique ID + */ + public $numero; - /** - * @var string Module name - */ - public $name; + /** + * @var string Module name + */ + public $name; - /** - * @var string Module version - */ - public $version; + /** + * @var string Module version + */ + public $version; - /** - * @var string Module description - */ - public $description; + /** + * @var string Module description + */ + public $description; - /** - * @var string[] Module language files - */ - public $langfiles; + /** + * @var string[] Module language files + */ + public $langfiles; - /** - * @var string Module export code - */ - public $export_code; + /** + * @var string Module export code + */ + public $export_code; - /** - * @var string Module export label - */ - public $export_label; + /** + * @var string Module export label + */ + public $export_label; - /** - * @var string Module import code - */ - public $import_code; + /** + * @var string Module import code + */ + public $import_code; - /** - * @var string Module import label - */ - public $import_label; + /** + * @var string Module import label + */ + public $import_label; - /** - * @var string Module constant name - */ - public $const_name; + /** + * @var string Module constant name + */ + public $const_name; - /** - * @var bool Module can't be disabled - */ - public $always_enabled; + /** + * @var bool Module can't be disabled + */ + public $always_enabled; - /** - * @var bool Module is enabled globally (Multicompany support) - */ - public $core_enabled; + /** + * @var bool Module is enabled globally (Multicompany support) + */ + public $core_enabled; - /** - * Enables a module. - * Inserts all informations into database - * + /** + * Enables a module. + * Inserts all informations into database + * * @param array $array_sql SQL requests to be executed when enabling module - * @param string $options String with options when disabling module: - * 'noboxes' = Do not insert boxes - * 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation - * - * @return int 1 if OK, 0 if KO - */ + * @param string $options String with options when disabling module: + * 'noboxes' = Do not insert boxes + * 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation + * + * @return int 1 if OK, 0 if KO + */ function _init($array_sql, $options='') { global $conf; @@ -232,12 +232,12 @@ abstract class DolibarrModules // Execute addons requests $num=count($array_sql); - for ($i = 0; $i < $num; $i++) + for ($i = 0; $i < $num; $i++) { if (! $err) { $val=$array_sql[$i]; - $sql=$val; + $sql=$val; $ignoreerror=0; if (is_array($val)) { @@ -367,12 +367,12 @@ abstract class DolibarrModules // If module name translation using it's unique id does not exists, we take use its name to find translation if (is_array($this->langfiles)) { - foreach($this->langfiles as $val) - { - if ($val) $langs->load($val); - } + foreach($this->langfiles as $val) + { + if ($val) $langs->load($val); + } } - return $langs->trans($this->name); + return $langs->trans($this->name); } } @@ -389,20 +389,20 @@ abstract class DolibarrModules if ($langs->trans("Module".$this->numero."Desc") != ("Module".$this->numero."Desc")) { - // If module description translation exists + // If module description translation exists return $langs->trans("Module".$this->numero."Desc"); } else - { + { // If module description translation using it's unique id does not exists, we take use its name to find translation if (is_array($this->langfiles)) { - foreach($this->langfiles as $val) - { - if ($val) $langs->load($val); - } + foreach($this->langfiles as $val) + { + if ($val) $langs->load($val); + } } - return $langs->trans($this->description); + return $langs->trans($this->description); } } @@ -429,7 +429,7 @@ abstract class DolibarrModules else $ret=$langs->trans("VersionUnknown"); if (preg_match('/_deprecated/',$this->version)) $ret.=' ('.$langs->trans("Deprecated").')'; - return $ret; + return $ret; } @@ -582,9 +582,9 @@ abstract class DolibarrModules global $conf; $error=0; - $dirfound=0; + $dirfound=0; - if (empty($reldir)) return 1; + if (empty($reldir)) return 1; include_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; @@ -599,10 +599,10 @@ abstract class DolibarrModules $handle=@opendir($dir); // Dir may not exists if (is_resource($handle)) { - $dirfound++; + $dirfound++; - // Run llx_mytable.sql files - while (($file = readdir($handle))!==false) + // Run llx_mytable.sql files + while (($file = readdir($handle))!==false) { if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data') { @@ -613,8 +613,8 @@ abstract class DolibarrModules rewinddir($handle); - // Run llx_mytable.key.sql files (Must be done after llx_mytable.sql) - while (($file = readdir($handle))!==false) + // Run llx_mytable.key.sql files (Must be done after llx_mytable.sql) + while (($file = readdir($handle))!==false) { if (preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data') { @@ -626,7 +626,7 @@ abstract class DolibarrModules rewinddir($handle); // Run data_xxx.sql files (Must be done after llx_mytable.key.sql) - while (($file = readdir($handle))!==false) + while (($file = readdir($handle))!==false) { if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'data') { @@ -638,7 +638,7 @@ abstract class DolibarrModules rewinddir($handle); // Run update_xxx.sql files - while (($file = readdir($handle))!==false) + while (($file = readdir($handle))!==false) { if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,6) == 'update') { @@ -671,9 +671,9 @@ abstract class DolibarrModules */ function insert_boxes($option='') { - require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php'; - global $conf; + global $conf; $err=0; @@ -681,8 +681,8 @@ abstract class DolibarrModules { $pos_name = InfoBox::getListOfPagesForBoxes(); - foreach ($this->boxes as $key => $value) - { + foreach ($this->boxes as $key => $value) + { $file = isset($this->boxes[$key]['file'])?$this->boxes[$key]['file']:''; $note = isset($this->boxes[$key]['note'])?$this->boxes[$key]['note']:''; $enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton'])?$this->boxes[$key]['enabledbydefaulton']:'Home'; @@ -724,15 +724,15 @@ abstract class DolibarrModules foreach ($pos_name as $key2 => $val2) { - //print 'key2='.$key2.'-val2='.$val2."
\n"; + //print 'key2='.$key2.'-val2='.$val2."
\n"; if ($enabledbydefaulton && $val2 != $enabledbydefaulton) continue; // Not enabled by default onto this page. - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id,position,box_order,fk_user,entity)"; - $sql.= " VALUES (".$lastid.", ".$key2.", '0', 0, ".$conf->entity.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id,position,box_order,fk_user,entity)"; + $sql.= " VALUES (".$lastid.", ".$key2.", '0', 0, ".$conf->entity.")"; - dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2."", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) $err++; + dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2."", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) $err++; } } @@ -741,7 +741,7 @@ abstract class DolibarrModules $this->db->commit(); } else - { + { $this->error=$this->db->lasterror(); $this->db->rollback(); } @@ -781,11 +781,22 @@ abstract class DolibarrModules if (empty($file)) $file = isset($this->boxes[$key][1])?$this->boxes[$key][1]:''; // For backward compatibility - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; - $sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def"; - $sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid"; - $sql.= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."'"; - $sql.= " AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity; + if ($this->db->type == 'sqlite3') { + // sqlite doesn't support "USING" syntax. + // TODO: remove this dependency. + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes "; + $sql .= "WHERE ".MAIN_DB_PREFIX."boxes.box_id IN ("; + $sql .= "SELECT ".MAIN_DB_PREFIX."boxes_def.rowid "; + $sql .= "FROM ".MAIN_DB_PREFIX."boxes_def "; + $sql .= "WHERE ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."') "; + $sql .= "AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity; + } else { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; + $sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def"; + $sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid"; + $sql.= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."'"; + $sql.= " AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity; + } dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG); $resql=$this->db->query($sql); @@ -1027,54 +1038,54 @@ abstract class DolibarrModules if (empty($r_type)) $r_type='w'; - // Search if perm already present - $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def"; - $sql.= " WHERE id = ".$r_id." AND entity = ".$entity; - $resqlselect=$this->db->query($sql); + // Search if perm already present + $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def"; + $sql.= " WHERE id = ".$r_id." AND entity = ".$entity; + $resqlselect=$this->db->query($sql); - $obj = $this->db->fetch_object($resqlselect); + $obj = $this->db->fetch_object($resqlselect); if ($obj->nb == 0) { - if (dol_strlen($r_perms) ) - { - if (dol_strlen($r_subperms) ) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; - $sql.= " (id, entity, libelle, module, type, bydefault, perms, subperms)"; - $sql.= " VALUES "; - $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')"; - } - else - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; - $sql.= " (id, entity, libelle, module, type, bydefault, perms)"; - $sql.= " VALUES "; - $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')"; - } - } - else - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; - $sql .= " (id, entity, libelle, module, type, bydefault)"; - $sql .= " VALUES "; - $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")"; - } + if (dol_strlen($r_perms) ) + { + if (dol_strlen($r_subperms) ) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; + $sql.= " (id, entity, libelle, module, type, bydefault, perms, subperms)"; + $sql.= " VALUES "; + $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')"; + } + else + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; + $sql.= " (id, entity, libelle, module, type, bydefault, perms)"; + $sql.= " VALUES "; + $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')"; + } + } + else + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; + $sql .= " (id, entity, libelle, module, type, bydefault)"; + $sql .= " VALUES "; + $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")"; + } - $resqlinsert=$this->db->query($sql,1); + $resqlinsert=$this->db->query($sql,1); - if (! $resqlinsert) - { - if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") - { - $this->error=$this->db->lasterror(); - $err++; - break; - } - else dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO); + if (! $resqlinsert) + { + if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") + { + $this->error=$this->db->lasterror(); + $err++; + break; + } + else dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO); - } + } - $this->db->free($resqlinsert); + $this->db->free($resqlinsert); } $this->db->free($resqlselect); @@ -1082,9 +1093,9 @@ abstract class DolibarrModules // If we want to init permissions on admin users if ($reinitadminperms) { - if (! class_exists('User')) { - require DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; - } + if (! class_exists('User')) { + require DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; + } $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1"; dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG); $resqlseladmin=$this->db->query($sql,1); @@ -1099,7 +1110,7 @@ abstract class DolibarrModules $tmpuser=new User($this->db); $tmpuser->fetch($obj2->rowid); if (!empty($tmpuser->id)) { - $tmpuser->addrights($r_id); + $tmpuser->addrights($r_id); } $i++; } @@ -1158,7 +1169,7 @@ abstract class DolibarrModules */ function insert_menus() { - global $user; + global $user; require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php'; @@ -1415,68 +1426,68 @@ abstract class DolibarrModules */ function insert_module_parts() { - global $conf; + global $conf; - $error=0; - $entity=$conf->entity; + $error=0; + $entity=$conf->entity; - if (is_array($this->module_parts) && ! empty($this->module_parts)) - { - foreach($this->module_parts as $key => $value) - { + if (is_array($this->module_parts) && ! empty($this->module_parts)) + { + foreach($this->module_parts as $key => $value) + { if (is_array($value) && count($value) == 0) continue; // Discard empty arrays - $newvalue = $value; + $newvalue = $value; - // Serialize array parameters - if (is_array($value)) - { - // Can defined other parameters - if (is_array($value['data']) && ! empty($value['data'])) - { - $newvalue = json_encode($value['data']); - if (isset($value['entity'])) $entity = $value['entity']; - } - else - { - $newvalue = json_encode($value); - } - } + // Serialize array parameters + if (is_array($value)) + { + // Can defined other parameters + if (is_array($value['data']) && ! empty($value['data'])) + { + $newvalue = json_encode($value['data']); + if (isset($value['entity'])) $entity = $value['entity']; + } + else + { + $newvalue = json_encode($value); + } + } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const ("; - $sql.= "name"; - $sql.= ", type"; - $sql.= ", value"; - $sql.= ", note"; - $sql.= ", visible"; - $sql.= ", entity"; - $sql.= ")"; - $sql.= " VALUES ("; - $sql.= $this->db->encrypt($this->const_name."_".strtoupper($key), 1); - $sql.= ", 'chaine'"; - $sql.= ", ".$this->db->encrypt($newvalue, 1); - $sql.= ", null"; - $sql.= ", '0'"; - $sql.= ", ".$entity; - $sql.= ")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const ("; + $sql.= "name"; + $sql.= ", type"; + $sql.= ", value"; + $sql.= ", note"; + $sql.= ", visible"; + $sql.= ", entity"; + $sql.= ")"; + $sql.= " VALUES ("; + $sql.= $this->db->encrypt($this->const_name."_".strtoupper($key), 1); + $sql.= ", 'chaine'"; + $sql.= ", ".$this->db->encrypt($newvalue, 1); + $sql.= ", null"; + $sql.= ", '0'"; + $sql.= ", ".$entity; + $sql.= ")"; - dol_syslog(get_class($this)."::insert_const_".$key."", LOG_DEBUG); - $resql=$this->db->query($sql,1); - if (! $resql) - { - if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $error++; - $this->error=$this->db->lasterror(); - } - else - { - dol_syslog(get_class($this)."::insert_const_".$key." Record already exists.", LOG_WARNING); - } - } - } - } - return $error; + dol_syslog(get_class($this)."::insert_const_".$key."", LOG_DEBUG); + $resql=$this->db->query($sql,1); + if (! $resql) + { + if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $error++; + $this->error=$this->db->lasterror(); + } + else + { + dol_syslog(get_class($this)."::insert_const_".$key." Record already exists.", LOG_WARNING); + } + } + } + } + return $error; } /** @@ -1486,31 +1497,31 @@ abstract class DolibarrModules */ function delete_module_parts() { - global $conf; + global $conf; - $err=0; - $entity=$conf->entity; + $err=0; + $entity=$conf->entity; - if (is_array($this->module_parts) && ! empty($this->module_parts)) - { - foreach($this->module_parts as $key => $value) - { - // If entity is defined - if (is_array($value) && isset($value['entity'])) $entity = $value['entity']; + if (is_array($this->module_parts) && ! empty($this->module_parts)) + { + foreach($this->module_parts as $key => $value) + { + // If entity is defined + if (is_array($value) && isset($value['entity'])) $entity = $value['entity']; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; - $sql.= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->const_name."_".strtoupper($key)."'"; - $sql.= " AND entity = ".$entity; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; + $sql.= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->const_name."_".strtoupper($key)."'"; + $sql.= " AND entity = ".$entity; - dol_syslog(get_class($this)."::delete_const_".$key."", LOG_DEBUG); - if (! $this->db->query($sql)) - { - $this->error=$this->db->lasterror(); - $err++; - } - } - } - return $err; + dol_syslog(get_class($this)."::delete_const_".$key."", LOG_DEBUG); + if (! $this->db->query($sql)) + { + $this->error=$this->db->lasterror(); + $err++; + } + } + } + return $err; } } diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 50d5ee27b55..7b39fa06cf7 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -86,12 +86,15 @@ if (! is_writable($conffile)) // Check parameters +$is_sqlite = false; if (empty($db_type)) { print '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseType")).'
'; $error++; +} else { + $is_sqlite = ($db_type === 'sqlite' || $db_type === 'sqlite3' ); } -if (empty($db_host)) +if (empty($db_host) && ! $is_sqlite) { print '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Server")).'
'; $error++; @@ -101,7 +104,7 @@ if (empty($db_name)) print '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseName")).'
'; $error++; } -if (empty($db_user)) +if (empty($db_user) && ! $is_sqlite) { print '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Login")).'
'; $error++; diff --git a/index.php b/index.php deleted file mode 100644 index e4341bb53ec..00000000000 --- a/index.php +++ /dev/null @@ -1,2 +0,0 @@ - Date: Thu, 5 Mar 2015 21:47:50 +0100 Subject: [PATCH 24/80] Work on new timesheet page --- htdocs/core/lib/project.lib.php | 16 ++++--- htdocs/projet/activity/perday.php | 69 ++++++++++++++++-------------- htdocs/projet/class/task.class.php | 13 +++++- 3 files changed, 58 insertions(+), 40 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index e028c3cbbd8..f744508d9bf 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -555,10 +555,12 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$ for ($k = 0 ; $k < $level ; $k++) print "   "; $taskstatic->id=$lines[$i]->id; $taskstatic->ref=$lines[$i]->label; + $taskstatic->date_start=$lines[$i]->date_start; + $taskstatic->date_end=$lines[$i]->date_end; print $taskstatic->getNomUrl(0); - print "
"; - for ($k = 0 ; $k < $level ; $k++) print "   "; - print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); + //print "
"; + //for ($k = 0 ; $k < $level ; $k++) print "   "; + //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); print "\n"; // Planned Workload @@ -714,10 +716,12 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t for ($k = 0 ; $k < $level ; $k++) print "   "; $taskstatic->id=$lines[$i]->id; $taskstatic->ref=$lines[$i]->label; + $taskstatic->date_start=$lines[$i]->date_start; + $taskstatic->date_end=$lines[$i]->date_end; print $taskstatic->getNomUrl(0); - print "
"; - for ($k = 0 ; $k < $level ; $k++) print "   "; - print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); + //print "
"; + //for ($k = 0 ; $k < $level ; $k++) print "   "; + //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); print "\n"; // Planned Workload diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 9ca8f95ac45..abec2e8cf7c 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -108,10 +108,45 @@ llxHeader("",$title,"",'','','',array('/core/js/timesheet.js')); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num); -print ''; +$startdayarray=dol_get_first_day_week($day, $month, $year); + +$prev = $startdayarray; +$prev_year = $prev['prev_year']; +$prev_month = $prev['prev_month']; +$prev_day = $prev['prev_day']; +$first_day = $prev['first_day']; +$first_month= $prev['first_month']; +$first_year = $prev['first_year']; +$week = $prev['week']; + +$day = (int) $day; +$next = dol_get_next_week($first_day, $week, $first_month, $first_year); +$next_year = $next['year']; +$next_month = $next['month']; +$next_day = $next['day']; + +// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) +$firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year); +$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); + +$tmpday = $first_day; + +// Show navigation bar +$nav ="".img_previous($langs->trans("Previous"))."\n"; +$nav.=" ".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week; +$nav.=" \n"; +$nav.="".img_next($langs->trans("Next"))."\n"; +$nav.="   (".$langs->trans("Today").")"; +$picto='calendarweek'; + + +print ''; print ''; print ''; print ''; +print ''; +print ''; +print ''; $head=project_timesheet_prepare_head($mode); dol_fiche_head($head, 'inputperday', '', 0, 'task'); @@ -146,36 +181,6 @@ print "\n"; */ -$startdayarray=dol_get_first_day_week($day, $month, $year); - -$prev = $startdayarray; -$prev_year = $prev['prev_year']; -$prev_month = $prev['prev_month']; -$prev_day = $prev['prev_day']; -$first_day = $prev['first_day']; -$first_month= $prev['first_month']; -$first_year = $prev['first_year']; -$week = $prev['week']; - -$day = (int) $day; -$next = dol_get_next_week($first_day, $week, $first_month, $first_year); -$next_year = $next['year']; -$next_month = $next['month']; -$next_day = $next['day']; - -// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) -$firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year); -$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); - -$tmpday = $first_day; - -// Show navigation bar -$nav ="".img_previous($langs->trans("Previous"))."\n"; -$nav.=" ".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week; -$nav.=" \n"; -$nav.="".img_next($langs->trans("Next"))."\n"; -$nav.="   (".$langs->trans("Today").")"; -$picto='calendarweek'; print '
'.$nav.'
'; @@ -230,7 +235,7 @@ print ''; -print ''; +print ''; print ''; print ''."\n\n"; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index f9e07ab6e9d..c322e0be3cc 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -506,9 +506,18 @@ class Task extends CommonObject global $langs; $result=''; - $label=$langs->trans("ShowTask").': '.$this->ref.($this->label?' - '.$this->label:''); + $label = '' . $langs->trans("ShowTask") . ''; + if (! empty($this->ref)) + $label .= '
' . $langs->trans('Ref') . ': ' . $this->ref; + if (! empty($this->title)) + $label .= '
' . $langs->trans('LabelTask') . ': ' . $this->label; + if ($this->date_start || $this->date_end) + { + $label .= "
".get_date_range($this->date_start,$this->date_end,'',$langs,0); + } + $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; - $lien = ''; + $lien = ' 46f56dc7dfff82250816df2bd2db313c 67798229e915f5841274ee70487feec4 -8d61cfa815ca3bb981582bcc7db0a6bd +e9fb1ad286fe67ee78fa8ce60a7be71c d41d8cd98f00b204e9800998ecf8427e @@ -19,7 +19,7 @@ 91885edae345ea489237442ebe3c8304 -706b9f915c400211b1c85c6ca6c11060 +6734d43389eded6e6ec04df0d0ac6a0c 4f72962320b42bab18deef783febd12b 6fe0eb8de0e5c45c09845bb8242fcb1c dacb01d46e370bb3bcc9574cd082f464 @@ -95,18 +95,18 @@ 68f0a32904f0ff877cb2c2820b38dc9b -083d2c1c63007a5a3487ec43bdd926d1 +00b0eb68f7ef07e9d614ae942f84e9a8 08194ccdf2c8801e9ce4acd3fc6a8829 -66a88729f0af41a466b40b1430f229f7 +422a9396b9040de1212afd253cc738aa 772b9a692d9998d6e7d8fd6e28ccb042 1f2562ebcb87267a49e9c8ec11f92d90 1e47fc4e62453875065109ef46259108 e8f85ee5f1ce535b1a6933f18ed09ba0 e047fd0ab0886550203c49269e7ad1ca 5f6244d1e0c7f706ccaed8c71240fc35 -4f7695bf300da817cbee7feffaa21508 +0b882db2159085006ffd37c772f7d8bf 10b05107d83798c17e2de027dfa923e6 fb72e6073af1b2f0763f9edfb4394d6c 942423fa65f36d20685e565e76434771 @@ -135,6 +135,7 @@ 90662aecd9eb51bf87b91f76d452381e 35b24d3c1592ad0e60c99c81a94be6b9 773f9a324037de24ba20edfa4f69099d +b791736af07760c81845b8fa160c6e39 858f4d351d6a865bccffef7fa262d99b 42b9d3d703feb637b4babe11190adb52 7f6bef974f62fb589b0c2d193750d714 @@ -142,7 +143,7 @@ 1ea47e3f2a830596d139ec65f559a508 2067170df6bc861d12d11a277986747a c1be7df4483ccc0e3b2ee08f977d911b -5f00bbdd645ef9bbf53ea25feeeac3f3 +15c0b5e011ee5e983f3f5c96db67d760 4489937620fe0ce4998a18b327a79cfa b447c8a39fa7d8217dfa5519af90e911 967aa7e79415181dfb2963777a90720d @@ -154,15 +155,15 @@ 41afb11aefb73a16398bd906a0201864 ef51c84433eab6197f43d0559f22fd4b -01cacadfbda4293ab21e779e06146085 +b2ee036efc506d6afd50dd7ac7ccc811 e79892f863bfba42a2658e43a2e8546b 978cfbff83d963db5c848161fc3ab286 69a64091740dccdfd8bd2f61df53fba3 dcce80148d3ea055836f7f38ab71f0c1 89a36b8dd5d33e53b92b491bc3edddfe 8b3806e68b169d4cd2c1320a5ab6fe8f -5abcc5736ddd1748f943313023e76de6 -937159f009bc845bd67dda6fc8c86b77 +3d6c42d646e2503f6a71b3618358f697 +46395deac9909d4a668bba6b94ee4c8a a08eb617d4122bc3972c2c04da32cb70 bf729609f42e090aed2a970401930e6d 2a6afbab650385179de02fe9205455d7 @@ -174,8 +175,8 @@ 2cf90126aba2b06f593f838a592ed66a 69be8c3d12533054535cbebb7d7efd07 0c89a620fdc2487c3cf242fa34acbfd6 -77a59143907052032b136e6883a0e1c2 -381ef356a676703edf225c3a56071002 +b3d4f333045789b87703c3c385194b0a +a5605b39b6125fc36ea7a6b083e30578 19e39ed2f2ac92ccec072d8d3d741104 0b3730d08a8d573f9195b07f58ccf09f 448ed84f8c692dae865030fdadfabb3e @@ -183,10 +184,10 @@ edcd9c936456f8945c9e05797b68a0c3 6ff462498bec936a81e4762d3fdbf31f 849d81f9f23ca9b07ea52367b4a666f5 -e549c764f41502093e349cd471306f3c +9af36af76afed9fe2efe0337be9ddf71 80f1b4396367b316403e0a81ae68c9ac cbafb5e0cfab93c9964b37d5c90b049c -f075b322db82ca5a1082e18033cea0f6 +c535a4a7b059b3963f5a5ddff9056faf a1ce81dd3436a5f87396dbc8213500d7 7b09d4f614806db46728a2fcf577f388 5343a79284c9127377a8827395d5b204 @@ -199,11 +200,11 @@ 0987559b12f37ae2490c1a5f5dd83076 32769f39902632408013c5860b088804 b3bf4266b0325db6ed8d9cd310cd2ef6 -a377699a88d8e920c8860ebb24aeacf2 -e62424215546778bde995edfa9692ca0 +4acbc9a5abb1a5d5afb9eaac8e18d34d +7e14eae5d5e6edcad2751240257a81f4 4bdf86d2111c1a361549dbb6523edb65 -105fea1b3cecab53fca1d10fde1a8823 -2887d01ae3349dff6c04d5902a5d6e5e +bc0db72496553e902eec64ef13a66b08 +8d97de9a3fac4e667f273bb41f920d93 6a605a7186f129ee54393898a6d9f4b0 5813003639fb8751dc574567dbf90989 114d8997f2920c105be850fc6ca8cdc1 @@ -253,7 +254,7 @@ 22cb27adf9a761ca0cb76e0e54b71890 3d9cc4ec66df38298e16365e009dfe66 26c66f78f5db62e9af07cb11280afc24 -368d57ca80f31c58192581ec7ca7f649 +9bba5c89e5dd034e4d6ddd1b19a8abd7 5c25310c78417e37fd75c8769e3c172f @@ -5349,64 +5350,108 @@ 3a316818411b5a80ef878dc5c8483950 -f4d6dda9a7e9a13fae9a0b5666a1af85 -26adcdd9610a48fcda8eddfd22fab072 -27f0f0c023d8775a7d970a0550caa3ef +3c06688411baa451d053f64eeccb1834 +bcb93bbeb8cf2831e49ff5541d277a1f +d306e9ad7b8b67464493c3281417afdc 6bb88a8a3d69511d1bf9e7af12ab5f47 -443543014f50021a6aab6e3dc45ed587 -a8231d248b1a221019ad16fdd605a9fd +2652ce7b4dcf00a1b07d8b1debedf867 +a1775d6ba3d8b76629dcdc2c1006048b +a874a391c41c223a007297af0fc82d71 0f6007361d5e4c8f34a2e83d402567b1 -b49ce165ab6bb7d90fd020bb3958ff1f -8ee3baf3211d960fc39e28c4e2a793c8 +a75033315ee90464410b47cc27ce9ff0 +bc1d75d2d4988d2ad9cac651bc44b8b3 +36cc4107f0d39d89b8031042c4159468 +8fd8e9a11cca513a4da0f25ff1a24149 +5af577705b43ce01285f2721a4850ac4 +2937220203e5a52762f5c9a4527e1988 +baadbf936466cfc106ae73e5f15dba89 +4fd59032d7c3a59fd45028bafa245721 191b3c2e856e750c06c0ba7987f902fb eb85dc872664c0769e9fab1b7540b4d5 -cc2cb448f60c5ecf61f6879aec325801 -d4836ebb5fa4e49eb36ba797c9f117e2 +17dfe118f580bc2a08e21e8104ef68eb +ad485022027867116de0bf6c25b1854a +5aeb1084e3a6ae5ef7ecc2bfc7a15592 +8702f5d6fbad08bf74378506ef376f83 +7596c070ac1bc839022e0a7aba2156ef +bcc98729a04598aecb86c451b91433ea +368af9ad30db4935e51b2109b9d4e9ca e0a7f23376f50de631db93814aff2e35 7ad3c70ef87d3657f918d3ee3649f31f -b2664e1ae97756c12114cb3371848ba2 +52b7639c5c4e35f33bb3c69cbfa0588d +a2a228f499608ddddeb2ba54834a5b7f c940b153fb6c5b3498efa181881b5b6c -fcc615d2a469180dd6a29ee6c04e866f -5a3660e46c91205c9203901c6b47cf8e +f9f9da534cce6a9124cc6b919329944b +287cb7bb6e6966708534cb9ed48d48ac +4775a411c20fe8fb13e9fb3a46629dc3 +9b2ce8f93949146d63dfef4d4784ad4c +18638db567f8b6fd7b1c6641ebf2c958 +463334491415afc3e56661e87196b4f8 +016527b52b6af2d6784fffeb23a2349b 2a315fa2593161154c319788f0ef2127 -544195d15ad41278307f99c79129ed72 -f163ef4cda9bb39f8abfcfcf2b683e0d +8b75ae7921f26b4f4b11d18ed921248e +7db990cc030127f1b64a4d3492f8f3e2 +afdcd64e0d7d78942401354d7f5f180d +51f6fe162641de3714866950d5eff4e8 +0a9d5e42c711a284436fa6f267e8ab85 +2c5e8a67d1a805aae9842bbad59a873f c22fdc8941f2956e0930b20105870468 +1f2386bedbebd633223278c1fd25109a +e0d060c7f70126e74c443b72ae560791 +20e28c8b386ddbb38ead777f717d7c44 96c6b586a6afb6d72dc8b93b30f844d5 -768d12956504372d4dcffea0f0bc2865 -39b329017c9d46eeb7f89f11e8540c96 -a01d7dccbd0a43d02a87035b60b5ca8c -8745faaac931fd3990eaad40b663a00d -82f254a1bc551aee1583bd6461b62cfe +351ce642d2008500c8780cce574acdb2 +fc1cb0e9030ce6b891319ce46dd8c434 +95bf00532c504c237041c4e3f04936a1 +bdf5ae55ea4d553beb785266dd0f9ffa +2894170c52a47ac02bf094bf047f1984 +fa8aa7a5c2077676637614809bc0ea0c +b8f1f393d7a247fdfe7668acf776e9d2 +35b71c6a8e678cdaa9d484ebab42c2ca +8f55434707b160cf1a8331d27e37e7e4 +4711cc4662b9136a881497c27b596135 +950310a6c12362b084a68b0cfa7f3373 +6ac17b4d7485fe73dd2d754ce2a0e2d9 +96fe7b1e5cd48c7332cf17b789f7af66 +02aac38356af65808e08e21f1ddd225d +bccc18d3b8c2b941ef7ef6602aab6c69 +de96058dc4fedbe4ccca03f9966ff743 3daad3713df02c15beebd09ceecacacd -0583253d3e49f14e3b6306fa788a6f66 -d0a111306e668d146a52e2299597888e -a722bf1cb509c0218c9b0d41386fdbbe +b8b582e30d3f3bd8867221dcc3dbf365 +75c68bb955477a99fc98600f5e1f40a3 +bf1c8fcdd3706774086cd133a6e04d45 +eee692f442eaec2b8291419a2017e50b +f9389202889738a0935be0d96f3aa609 +9b187fb3a908fb75b7b2a8573a4d13c4 c458a95a74915bb3e01102060bf3d27c -66a08a1e2a2405c7ad5affeca0f81b2f -4674617014723f062743145bd2952df7 +78fdf805f1cea6cd01912192821ec734 +34b9ef2cadf050ad58f391a7990c6975 +c0f60dd955a2bd3e6bace66eb362c9a5 +a5f3fbbef1831fe0bcd060edb6e5010b +c49883919b7912057b1ffad674a9c7c2 +99d8349acae8fcd95094364adf24dae2 +72b2fd6a41260897ef758436603d33a2 cacdbe68a428ae36151a3d1152b2b77b -1aa821a18b07bc7cba92552a372b8f9d -42f2f6e2122319a302b2769011897b2a -205fd4b7bc978688de8420087c161bcb +86c5b7ba9581a58bf6e465aea7d52e46 +3c4338d70de8c99a86b3ee15924172a1 +fb794db6e06fa3cf7479fc889894caf3 -0d24de61581243b069fb508efbc78a67 -561027d7adbd2358225866cba60568d2 +3abe66ba8da6b6bf9cf1c6b0e907d51d +9a29da1e201fb23de4f499adbb9f6a71 edd56d70cac390ef63feeef7e9d71b3f -75837274a0d67e19ee975aaef9e283ee +5f4ae32bd59400b8f788ac644b693ed2 8f83bbc144d70505672f82679546c72d -5c546b7f37191a754b6743a640c6a0cd +809d819fe86dc60509c0b39997fc0d4f 17bfd10e3232de9145f5b74a6ef6afac -bd2d14a110664154fc509e3d3f9421dd +67b77209f88a051d1a7dd39e6584212b b162a10416c2cba0be1ba5d979e19145 @@ -5756,8 +5801,13 @@ 93d0209adac1b1a2b4e3cf2173cf995a 20e95e9c16378e6ac4df49011220f904 + +778ee87bf2f490b2737b2575d6a8367d +36e0aff3d3354e60d6470d44c07d1760 +c6f393b8430b95f521554b427d675a68 + -4ad543978a9d6664dccfe0e58b428c5f +d2a5b87e5832c708a67b8718e6cb89bd 6bff9cf68d35e1f83c670731e270c91c f6b62af680035531c943bb9fe3f416a1 725a7d1d35aaa7deb29d8d7b68d5a7f9 @@ -5802,7 +5852,7 @@ 758456bd92e4f81e1fdff423d4f914ab -f80e903b3aef314dc7e173ba95324c56 +fc8213a4a5a98ee458ddacc6bdd363c4 edc900f68ee6af819ace6dc30b968d80 @@ -5814,7 +5864,7 @@ 69caa949b7e0f3137c6ce7482f38e0f8 -c234c6e7b71d97e977d881538fab1d5e +a040ae2fc7273f1761c0b6294465db86 a0fa0788291ee95ccb306b8aded3fce3 @@ -5837,7 +5887,7 @@ ac2861b424e2b7e30a532f37b33d6889 97bfaff0b5c453d074f05fef1fc4c3df 35433c33dbc3525adc99ba89816d3733 -45b742c58510d055adee01e93aa33ff3 +4aad58f34304117925aeb72dde0e16ec d41d8cd98f00b204e9800998ecf8427e @@ -5931,32 +5981,34 @@ af876c926d49c59376d8b6d642ce9f66 -b30fb8f9811c1fa4d96fb35456366a8d +2ba22b10ce887c66563fb062cab1d79c 5fa21d6616fd146640d8cb59d52fd6d2 -0425a56b168d7f707d31028ad6122c26 +62e1ab1273d5a8dba9003cf14e678f94 9f9e7fb20c0cfc32dd7879ea99bcb3a0 -fedfac2139ca74edbddaba770b52995e +9b6ecbb4d4ec11fe513ec2a724749201 d41d8cd98f00b204e9800998ecf8427e 5c09b3d75fcba736c3353468236e5338 688c47e56752db341e110657c4f6f4de -d6d72917df770c5f42763d5bafd71857 +6f0972a6d7681bb65406b323efa8c202 0a81d81144952f49baecb31cfc610fee -453d482e2c6217d080e4ba4ac382aff7 +85a44971ad662216ae35ee13cc448517 +3cfe3654b3fc16954d91d3968fe71e24 d41d8cd98f00b204e9800998ecf8427e -46ff31a1787666ae78665dcea6351800 +e4a89a0342afbc8771e9178a78677517 +0e38e1224840ed30469ccfc96cae5407 2e7c67c1f808b58e33a5d256c282f02f d41d8cd98f00b204e9800998ecf8427e -33d557efbd941e679c386377e63d949b +17cd44fc331db26f8a7eb438b6f83cd3 e122c4a3c7fd8e1814f52d447e2d1a87 @@ -5965,8 +6017,8 @@ 0ea32bda75dc7855fd061f23d129c35c -de6be0f3faeef94e762c4e1ea1def02d -f38b902b5ce63c83e6dc6ffe2f9cf0bb +c5afccdb1da5846e310db9f174201302 +ad942ced24fef3b0b541041a3ce20205 25b3ce6e2f12f227c4a1ac8db9fab357 @@ -5986,6 +6038,24 @@ d25255649d1fb417a7e7041ed86dc8c9 23a9fe711137f3cb4f06dd011d38c23b + +d41d8cd98f00b204e9800998ecf8427e +93f6a40587eabe04d03bd3e910a780c3 + + +9b2c6de73503cceb102e875a364f6626 +6c5d484bdf6d9ef4529adc17eb829766 +65e54e9e6458c353a92eeaafdb0d0022 + + +d41d8cd98f00b204e9800998ecf8427e +cff8400cdba7775f87330b11ec9a4a65 + + +8a6845f5a3f6180df651c1be45e24878 +bebba22e7a5fdb20a52dfcf1b64772a1 +477b247136b3b54b251d5257ed61ee19 + d41d8cd98f00b204e9800998ecf8427e 0ac7cc84f48f255d71c0be34442038c1 @@ -6000,7 +6070,7 @@ d41d8cd98f00b204e9800998ecf8427e 7d845e5c3c1ac2c7b1c49de0d7e1c7e9 -8d01e83c7ea6584ed8244fe84628bd7b +241877437e8750febbd662602dd0efcd abefa8f7d035ae87eb5b45b0c43843be @@ -6014,16 +6084,16 @@ a7a90ee73e8f7f25267dc0ed66b3d8aa -a7f47e13476c054174040b29f993c271 +c541711e1f2070a1cc8528e9991d7fed -3cf2e98145b2f736130d75ebce1998f2 +fb4334120f1d5c30e64da6c12d2c777f d41d8cd98f00b204e9800998ecf8427e 1d09e4bcc7c8b15b8870ee521b50f1f6 f94fa580d25989d4f7a0729699c794f4 -dcd7588470066bf274c070ea79bf0b3c +bdb60ef8622cea7e270534ffb78c9714 d41d8cd98f00b204e9800998ecf8427e @@ -6037,7 +6107,7 @@ d41d8cd98f00b204e9800998ecf8427e -c5b4ae74b2b2e938d18d6f91ae094157 +4cc2f72a3e23dd082248e7e1582b9cb1 502547de717912a19aca06ddd223995c 4c457d8c88e79b1bab6c830a9162e718 2395be35cede1fb715ef9a4e497300a0 @@ -6075,12 +6145,12 @@ d41d8cd98f00b204e9800998ecf8427e -8c73a6f5b6e511bc183fcf2b5c1f8783 +ff07e29c887a25d0261857b7bc9e1deb d41d8cd98f00b204e9800998ecf8427e 63a86b61d1158210eedd7055b3bfd935 -d9f10175f29b8f142255f95be2d07965 +dd4877a4d2778561d4ccdbdba4b8b76d 648275f02e4c1be714897110a9aae56c @@ -6097,9 +6167,9 @@ 2a452e950585fb39d94e41a414471df5 -4703a36c950de669ee918e763e014fe1 +4dfd0119f671aa86ba1405c9814b08b0 977109b651acad563d27a9f05efa820a -f0bd1599b002694c6ec351d6606921f4 +3fa0561c00883f627c54f080237ca03d d41d8cd98f00b204e9800998ecf8427e @@ -6112,9 +6182,9 @@ d41d8cd98f00b204e9800998ecf8427e 3e8b72640f3dd0117bde24b366b7a8f5 6a1a6da93f9c2d77d68c8edb90139899 -3285c87826c9621ebf4352cf2a3ee2a0 -8a1c4f997f37fb274bc58c905649c0e0 -2211e75d50ae16f94e147f2f05a85d91 +6f6227ce98c203851dcddd1f027a86d5 +4ae815a0b31e0c4b8b900b7da88ab8c1 +1806b43471d2254c540ce3ab52353877 d6e07b8cab924d1b1b4e7b467aad3e67 80c65c798aad65e52c21289ba4fc8db2 @@ -6152,29 +6222,29 @@ 926bd78111e0f27f638bb0705f92439b -8e16469fd236e9975f6a14a9e59c147c +7a998e3b11f1086c7953293442f3530a 37d695c0d624c79d4d5fa14dd131876e -040fcead42553050d648d53d01d642b6 +01ec301f4005d3565727c01ea5b63eb5 58e190fe5c72ba2cd4db99fd17aac7ac -212fcab202e934b30e6fcc7c5128ed3d -6a692cc606a48741b08fef765bdaec4c +a0668dc98834af718fd96f310c7f6003 +56db30e1de65b6fb81931cd4469be39b d41d8cd98f00b204e9800998ecf8427e 3d18b6afcda65c40d3e5b1565e0ae3f1 -0cde765c7d578d103c71dfc4197438c8 +091c302f41e52a36598a19df1860971f 4bac12077505462bd962adb666852966 -3ce4735205d14eef357f1fc90d655ece +22a2ab52185732bcafd64fbd4a68eea8 cc7d7a963ee9ef58ede0680241f53de1 ebb2e597917e22900853dfa300de88da d41d8cd98f00b204e9800998ecf8427e -5b69636b3ce9773a65a8750f65d31ee9 +2c6f884e37b89f861f19faba99009ecb 32df7d91f327cfdcd67d831f6e7535eb @@ -6297,10 +6367,11 @@ 1fce4641b42b1c6680093428f2ccada5 -f4306fe54c33047d10182d177f39b89f +255c511cf57d5c863564fd3ec0bae654 d41d8cd98f00b204e9800998ecf8427e 957b9030b18c319e7c1529a4ffc72b85 6b6851714ab5e4f9491c2500a26c8ceb +29dbab62db9356e1b3574520bf3fa8b6 6dee88d0cf667f9b940d2696690f6744 @@ -6314,24 +6385,27 @@ 5ef3117292cb272cb72190d67bda189d -25d6c35728da1df381db408e61137d98 +9e42ef4e51c3d0795c44215d8264acc4 ff890ffae74d79a90ade34016ffd241d 1e1d68cabdaa8e946ad786f083a114a1 080945adaf8304688ce778f8acc821fe a2546e7613e0c76e1c26692507f66836 8cc4b11d20b0e01eb7e7b7401c2f12c8 -190087a51700f34c1b861261d838a6cf +10740fb22bfc2ac1b339e9d784cb9c23 6cea8bdd89a385b695dda1279e3021fa -e48ba3cc3d7d8641f31fb4d1e1cce67a -fbe31176a2ece8671e34270b56ed9224 -cf7fe720eedb6cef5c6cb67feb5a31ea +c41cd25f077b172e0acff8f4e6830847 +ae990e59fea5de5b4483ff48d541723f +bd68e17f01cde910409d40075ec640bf 4aeaafb21fcc66d532de0612676423e5 b7c3b27785924f5b023754855bbe3177 -526b1578733967a53e9c7ea0d3687334 +537bb9602db6a018f9e12b2286bd26e6 9e2d3bb695cfcdfebe705c171aa299ec -d7f98378b22bf02d1e96caa8c354a518 +02e18a866ed73982a37672572da83321 60d139c55b1533b31a8fcd4150ac35ed -d02f3b80bd620e44b248b763a745c555 +cd235b4afb8a95d5975434d7526fd7d3 + + +a4a1f69d36f0c22e9eb2767ea3f0adbd d41d8cd98f00b204e9800998ecf8427e @@ -6341,11 +6415,11 @@ 6534c21938d98c00bad6449081c65979 42a382d9a7146ddbf4c31c3aa55d6623 7a69303716cb7dff3ae011d2202de8f8 -8c209ae5445bf45531c133034a243439 +9b9fe5839d3b4cdf2bd5bd8faae1206b b4987de205c69745a11bb3ca910cf99f -b9ef591e526bb7585e2e9e7224d9ce66 +61d3ec9976c54d1a116baee6582b4d8c 3beda9cd6565bab822fd85e21efcf733 @@ -6378,21 +6452,21 @@ 6648383dfcecce0fa8010ee26e19c029 10d80a81dab8b4b36bc477b7d06b2c89 d41d8cd98f00b204e9800998ecf8427e -bd966e5b800b4d63bc3884eb6c4dc944 +4c2e051a6a49ecd0ff1f82fe3c63118c f0e5ef9a4d74a8c802f1b67415f319a1 d67feaff91ea41dbdb614dce38ba542f 6a42f85c4852916c71548c179234aeef 0db78f95e23062feab46593d28704532 639d7ee6567e210b36ecae473c5ce5fd -14dcc1c1453ec2180a3bdc0cc53fc18d +f772672fe0aeee71dd5c6bfd8d14808e 2de8820df5ad2c53044c62ff4ad718b9 454ff3948173d81e3f0c7ac1b77fc91a 98b51504f52bc57c9d900d0fc1bdb4ab -84fca517a57320901e6f4d09aee570e5 -47fdbddb0716950e3754211aa67c8c43 +620414a7322b7ecf17e2644a9a3f80cb +9a92997f7f8d84b6ef1685765babe1e5 f01a62497c9a085386bdc7c1defae763 ea8f7edcca4e35f95a3f2b7eed940d90 -66809106d19298be518b4f947dc0f323 +7f6a63a8afc26cee7c61918fd7559f77 a14866ebe77e5755d7b9772210696e42 b28954162df69981caec0998d15b77cc 447cb865dedd025c82a0402a41d2253e @@ -6400,29 +6474,30 @@ 7b53b4073832d6097d69bdf50ccf5ba2 1b0a44d142ae00530558bf5a6562492d 6cbfa567b0f4153bbc7f74adfe6bb4d2 -b6f90f0325529e3a39ebe651d0f910e7 +efa61e935b3bddded6bf488f1c27109f 88379d7c5cf4379d141f0e277fc2d499 3c36fca38f15327101e2cc37493e60fa c3d1e1b3f31c8bc2c6ac7582205a85ab 2c4b8a901ebd2581714ea5b7db8ffd1b daff44759e4f9c193a667ed427ba5444 -29b823646e763c2e7a64098be3ba5130 +dd505607a04547e95b76e3821ae75568 +666a30d3eb073d969dae5b1f73fa7d2e f4d35924864fb87b787ab9a9925fb091 2cf0c82aa4ed8fa0e22c393b7f5ecee4 2cb5c8f2cf03c6df6d3b70394b454d1e c65c84d23e2a8ad950ca58a1a2ca90db 73aae48b832026e3d24c305f58743806 e7df06c253dee16873fac26b32670722 -d4ce19166b58327ea8fe72de57a8dd85 +0bb1fb4ad3250cc312d571055323db79 507d7fd927984729187a4891f616f37c ed773b5b64093d6017aecdf1ca79fef5 4b15299e9a1c837d8e32aafe9abb00d7 b418b86d6c9003364c5a060946082ccb 16f583734d76081ef1a4b44d1e0657a6 -4dd69e598e667405299c866a9277af26 -e07da2dad2151513bd8dcbfe29d43e3c +dcff719e866b3af9fd9555b5a5867d64 +e72a74aa70d48feb14c3a5fde6089fcc a239faf6b54526481abaffe15d1f594d -4b9010ae3ecbf6e792d3bfb687ea2ab7 +e28bd469ef1c049843bc41dbe0f84d66 fe33e132e503f32398fb9809fe51da85 4b85147a9ebfcb923038a17487822286 e639d0ea5fc52734d43abbba8262dbb0 @@ -6436,7 +6511,7 @@ d41d8cd98f00b204e9800998ecf8427e 80f54c48fa46d0aaa977e404035aadf5 febda7bf2f326668d1f627ea9f2230b1 -4e6602a9b00bab8fd936f4800a1014ec +4f695f9327d6b2361640731a09e99a33 fe8c6f4acebea37d34b626a537db0e29 90ffdb58422df4e942a1a90cf5225c11 f1a8c3f9d6af74c305810725f125691f @@ -6460,8 +6535,8 @@ 38da2f7fcc1f2fe80b87db53e8767282 51e003dd68580f4f37558726f8452b53 748938e5e5aadef1aef9a8b79362b1bc -e4a93615651fab4af7d9288cdcecc86e -6d73868eae09dc15710f4c71ea25d7a0 +0de6fae1b00ab6cd538ffeef40f045be +00de18319f0abfb4c50f76b60f3fa2e7 6b58f5c0cad8d233b94b0874a41e4c7d 9596a02e5898fe117ac4d2f080a1b3bf afee7ccb55d1420cc8e36da4657825d1 @@ -6469,7 +6544,7 @@ d2b5ecf5e328a75e984f342ec80a60e2 07e043e1c42a0fe90d2226eaacb013e2 4cd01a2e1b1d02f7bfaff7792fb45da9 -f12d4e2a7b8866e08c4635b6776c1b02 +81a2f4c5a6b5946b088aabf7f5e9404e ce24eb153015acfdeca2e5559cc41583 a969dd13ed2ab6f921564ecd22121515 c2ced639d9b476d69e952e110169346b @@ -6477,22 +6552,23 @@ 3e30f76aaabd46ad9759658b706af3f8 4d7e3a9cca8144dca5f184f23e63953a 60c540c4dfb653ef65e67a628645f590 -abb811eb8d79dbeb78f5e67711905618 -1653a3d486b7113e331b01813407091a +3c3312f639641a1e2f7d5eab79209b7f +604bdd7909398dc5d136d47f9fc4bf39 98ca2d412c720690b46b8bf566cf4fb5 a9d45ffd6281800146fcfb2e3ab90ab6 66b21a3ea2de0ae271e470c339c40d07 9bfcd5451fd684e35ed69b3912791a6c b416db3eacff1ad448692d14aadff327 -b37a46d1de1e9b957b33881225da36dd +c8f2877e5e9d05fde24a7c7059c145ed b0bd3479b483ba56d613a91242e0efdb 0bbc469b628cbc940ebdd59f2e218b6c e1ed3c24b7fa01be0254d5e6393237e5 0e5a8ff24a2f4bb98d5c6c732e57619a 811dbf5341b537fccdf98ff790cda72c d868ca6c92ed42be6d193a71b5ae5a7d -11709bdc16ba921e8fe3774a1c7aba5f +d3361d904c96677405ad3081d4bbfc4f 503104f81619bf8296bdd1893079765f +595325924223d40b0ea97c9df4ebfde4 aa7ebaddf8d815b3dfd1b3281f26de84 59519c8b2bd240bdfc50476ea344cf8a f68235c447fde10de92e0732d17258bd @@ -6502,7 +6578,7 @@ 3cfbb9ef9c493bf739d501114cbe798c 0d3a43a7afc190f34f52855f28a34e4f 48f9b2c134655de1b0f5f7d50f01b765 -b3c941e7ae9574a1330c98ce07aade9f +03f439fdc6137b29736006bd4bee8ec5 70c6fc7d08f3c562322c9f53273f1393 @@ -6547,7 +6623,7 @@ 8c78f30a301fd7c5092ed59d95f2f688 -db4b88a7cb7f2e983e9349a0564aa877 +841ebb62c8967f82132d6c19e372bdff f8bfc1daca01458dceb9aebc7ffb5ddf @@ -6578,10 +6654,12 @@ 79a20f938fb5d3f145447ae44db05477 f2a1930d9be82084b365ccc8819d8484 d41d8cd98f00b204e9800998ecf8427e +5468ba4d16d0e057cf45f0984a79ac2e 1de24508893015db0757ec63e74a8086 2ae8b7de36d0e4c3630977569bf93bd6 -7af81ecb2106b1ca78c310332a02c604 +050cbe3b9406a05a76f6a8d1c2fed6e6 2b19c3592fbed5e4bd96730f87af438c +69bb08052b60d7d59cbe0e6ff0e45089 de943e7a2b8a603c3ebc34507309a46d @@ -6603,7 +6681,7 @@ d41d8cd98f00b204e9800998ecf8427e 4553664f3a8bd058468c8fe3a6622db9 -86a595136563ba16d9b4fbb1cb97415c +7ffccecde85645232cd150f4ceb54f8d f0e4f84ac2849eef8c8da252f2a875fd fdc9f14617e70aba304986ff7e32811e @@ -6692,7 +6770,7 @@ 347df504c0b23da0ae91c9b5a344c1a2 d41d8cd98f00b204e9800998ecf8427e 9b301131818ad7072d10624d9fce65b8 -215929b6545fc8cfacbb7386e4cbedca +fd0799a717f127a9c48bcb11d33a4d72 d41d8cd98f00b204e9800998ecf8427e @@ -6717,7 +6795,7 @@ 80af429597316aca3852de474a686ff4 -391c970a033d0593a16fb904119818d7 +5a89df7d532fb5730ba5fa40e3fb4037 d41d8cd98f00b204e9800998ecf8427e @@ -6728,12 +6806,12 @@ 35063f32bb86ee8cd1460cc9b50460ba cc44ae6151419f24f801a399a8da8e9a -577a5a6dd151bcd7cf6d8fcbd70677e8 +1a4b02d31eef47e71fb394b5688cd663 d41d8cd98f00b204e9800998ecf8427e 6b8b8ce50599e40cb74603a883f5d49b -b6e05cae93872a350f3ca2352f15f6ea +2cce9a1d8bf4c822dda113e210bc4f6b d41d8cd98f00b204e9800998ecf8427e @@ -6764,11 +6842,11 @@ d41d8cd98f00b204e9800998ecf8427e -70b0380559e50123f150a6f30a4d6699 +be907e7e9b0ac5a24a34af01ec1c21a6 d41d8cd98f00b204e9800998ecf8427e -04876764536d2c0ff37e0f1c9035c639 +a64def4ba4a8a55272108f79d0667e39 3621a212806836a2b3ca23f601c1b670 b3f46a3f7cc553bcda255db88fd2309a @@ -6777,6 +6855,19 @@ 6bb3fb472a3ff31f31945a68bb806cde 29977b078710f6ebe992f5b534b7d897 e1efd5d8bc348da70c325a08fc8c37a8 + + +d175d0af5c450eb501bca361a275c309 +d41d8cd98f00b204e9800998ecf8427e +13e7a0e137341f5a38764ea645b425f8 + + +d41d8cd98f00b204e9800998ecf8427e +e4239be8b90a077f8afc116e683151c9 +751806f248816fea7429cc7c4132539b +ebf0a4412227a0b61ae52df0105d46fe + + 610022638254b2075ec4bba535c5fe37 @@ -6819,10 +6910,10 @@ d41d8cd98f00b204e9800998ecf8427e -6a04d0a55d694688b7a8e43c72f63891 +9f8ec55a2df1f58b2ebd299fae8a1c6d -5ba605e1b76e515803012ab67abe2e4a +bcc3831429d49ff3a32c645c64be2e0e 0276bf6040d05e80ab5f6c6910f6ddfc @@ -6837,10 +6928,10 @@ bea23817aaf13e638fc0e6d274b0a63f d41d8cd98f00b204e9800998ecf8427e 2f133b07231a558b4551cfe813b6dd92 -c304ed5cba54aec736b4550b472a1337 +ccba00148532ae0e30f6f1d082817c10 -36473125e09319a9870285bf7302b83e +83bd77075a70f4b3a661fb57a0f0212f d41d8cd98f00b204e9800998ecf8427e db3734d67e45bf4a5140fbb38effa947 @@ -6861,28 +6952,28 @@ d41d8cd98f00b204e9800998ecf8427e -bd77bec5b425c9fbc1a4830a3ccccaa6 +6be749cfe859aafce02b030d57362ad7 -60d1a2024e5d8c9d6cdc0c295a243652 +898b153724a1748b8ea360e0b94aba77 d41d8cd98f00b204e9800998ecf8427e d07b23771a6639fd5f6216da796ff343 -290e1eed5e28283e741bea66c30ec042 +b1328a661909e538f58d43197eac2a40 5cba7b9316b591829c756097ae0485cb d41d8cd98f00b204e9800998ecf8427e 1f669f066fd46b6c9ca05177e177ed23 -bef21989e641a45d0f362fcb97281341 +3c270b13f4a5b576799d30edf1b7061c 00b8f993b58e8278a8115fb82ba7db57 32cfbcb58d6ae71455e0c58f951f2849 -bbdf49461b8f7bfda4446af93641d362 +69db05aac79ae05729e3797abcc2f1d1 710958b3055ce271a53ebd4e6325eee4 @@ -6893,13 +6984,13 @@ d41d8cd98f00b204e9800998ecf8427e 4dfcdf4d3cb3af826834c1fbb852f513 -9ee40eca1f3111186855090e11978198 +08bd77ccf4ecfd2cccf23e9925909375 d787be1614e93a5b0dff651c2d1962b8 d41d8cd98f00b204e9800998ecf8427e fc2cd8f1b832bcd093d8f65cf48d6be1 -94d4a670a65a20356db9e332884b5b3e +eea69eebcbf32860db846f30a803b9e5 05afeb97327056d436d21d891b041057 @@ -6937,6 +7028,7 @@ e1e875671e566acb90ca03d16b7e63ed be1a34c1c77c5431dfcee9caaabcfd88 f71705be8958fd18f828eb64eb254202 +3be7925340a260d3ffccc912ede415b5 36602e78494c46c4704cc578d4fb90cd d0889baa672fc0c803bf11ba7f57f6b1 @@ -6956,7 +7048,7 @@ 1a47a847fe417086b3f0b8d467d35d1b b69b43bab30c28687680635f91a53017 311aab84570c363ed4ff7e5069f5d949 -fa7542a63fa8d175b25c6db3d460d8a2 +3f0df7430bd8ed69801318a62221f4b6 6ce7b2cb223fead83bb4294741e580e2 @@ -7001,8 +7093,8 @@ 6a4676f26cc4774608c53cd47ae76efa -5cdd42491af381a414bea885fb5c234a -8df084360e41bb5dcce4719ba16c4804 +3273ff24d482f29e015604a5a5190712 +6b13618c39c1ae78d6be5a9580a25daf a90e349b1dfda275772af8b109e8be6f @@ -7024,7 +7116,7 @@ d41d8cd98f00b204e9800998ecf8427e 86b05756ec73691d2b88e25bbce1e86a b123826d90b2ffa257bd9880c090a6ac -f454a5cbdd36bfd22d6240b85e503e3d +30a766af9cb25ef9be5c36d4823109f3 59d8e23aebde2396d3440271828f4e20 @@ -7068,7 +7160,7 @@ 1921a40ef2e203a9c7e33e33d8481630 -84c13b91d89d2ca2851e10c25a0cd166 +3bd4ca8f6d546fed7f45d59930fab106 3afe82801f5cd602354186397efe9210 @@ -7080,14 +7172,14 @@ 7d040a1858a6f1e8b3d8e7fc68b1b008 -2d1bc07a8c28954534f37204c02c33f5 +4515ffcb074f47a2d9a4af2766b074cb a267dd6d9a787dbaa95ee81e9812a81a d41d8cd98f00b204e9800998ecf8427e 90bc49dfe52d6be339781906352ddbdb b3586b44a75323dbf02f85aea44e25db -e4d79c5376e95d08abe328aefaee064f +d5cde2d518971a3d6bd1e682b7c42092 1699071ff4bb09210ac267d430c05352 @@ -7095,6 +7187,42 @@ 202fffca61e528efe134dd32a3a44c64 9db7bfe5fec55a085d9f0dec8717479c + +83e824012a7c92746e71afc022ecb636 + + +18df2d1590e825952abeb40304a9597a + + +596d7781222e476b027a59499fa2d92a +ffae59f2cf83f882b269e06e420602c3 +7dd46b8a806a7567c0a88a13fa4f905b + + +9b9b0157749548ed0fa38782aca9b1e1 +296f4be076bb584ea5779e3059648a53 + + +1b2ed3db48be32e106a6dd6351f324be +b1688c8a3bd5948865884f0eaf3a0251 + + +99bd91055f47d5a74f9c395d74fbab6c + + +74d1739c0d14cabc655cde37e2fb25a8 + + +81d6b2b51a9b495e2512ab0952fb3afa + + +3542838ab2e1d4ec2cdd98db328a247d +3645cf8b754a2925eb02025881aa3ffb + + +fd8e048c8923d556fd7ae7c5234ad474 +b9dce9a8342b0e0d203581e86770d28d + d9cb53a9d7329a35ccba6560d05ca39c @@ -7118,8 +7246,8 @@ 3b3a6cb8fed3de208bc9a97209fed209 -c4b52ea2075814429b8a00a486f74baf -3229eae002e5525f9b545644256aede8 +a42209411960f30b6b6e5e38bc560af4 +7855abdb54739fae3eb0ae1d5a18ecb2 583594a72118966d0ce436acbf5ab344 @@ -7132,10 +7260,10 @@ 1aaa761fff1db6880a873b2f7aba4769 -73b7987dbc53760d356ad398d8f31a6b +96ee353361cdd805d62109efa227f63d ffcd5053589c705062adeade31ce92f6 68dc3ea2cd9c6508a925df50fa011221 -95444b95d6bfbb4cc05bddb1fd2d430b +694616680b479a5a29cc4bcf08d2b0a9 deac83a4c0eda829eedb0f9136a1fae5 @@ -7204,9 +7332,8 @@ bda3f6f14b6ef2f298a116a9e5e4de47 d41d8cd98f00b204e9800998ecf8427e -14cf870bc89190b003d4b67d08399a82 9b4cf41fd9e3065e1849aff895a0999d -b9866ad3e2a12514c3062cf74a711f6e +b34de60c5a1ca8b6e1e0d1c614022e80 3b29a33fb5f50c27d39d0645b1d1d96b @@ -7221,50 +7348,51 @@ d41d8cd98f00b204e9800998ecf8427e -87a15a164f064663c4d567a67b877a14 +282d8a4bd07329456966b4a7a359ddc5 d41d8cd98f00b204e9800998ecf8427e -51b4e94e74766a82470e5ff6c5753cea +c0b5fb2dce5b0a621a8653d6db38785c 3d863d079d9ebd0a4d6450acbed047f3 -68ef70376e6452b0db41d188de3e7309 +2ff2dde238be1c2c76ff373412a78e9e d41d8cd98f00b204e9800998ecf8427e -583e353c57d884970f1753605d7ab749 +ec17764560eab22337e40b09dab7fa84 bc584ec274c28d5fd6bc06909523cb8d -447dafbb6d90617a37c7f8e9038d2d45 -5d709c9a142b17a1cd1439197ac62ff2 +db597412bbafac95b4df7c52007804d3 +0950ed07fcf3abc1d21340fcc9d51be9 +138f3da6669669416a9600e7bcf485ec -e01dc79eab31ca899f8bd155d989482e -9946885ee4e9044e9a3fab8e6bf4f0c1 -8574e2c0ea7292d815892d241b029a73 +bdabc11685cbe7bcd760143cc3431e3f +4b52f2ecd9144b4fc8cf9484c23157af +b0599b42b4a17c1d140801a1b2dbfcc1 0529ddc77e8c681c33c47b9b7687e810 faa2eda13c5607ace72e34e9c0966a0c b704dae630c7215138b1f90caf77b450 -285e61a9ffd5231adede10df1871ab5d -714867efd7c071524ee3b0b4667a3ddd -9477e6a93b94cf81c26b5cbcd7f7fd67 +5da52c371983bff1e44d50c00565aa5c +dc5cd8b4ba8b06cf2c836d35f5117a5a +4fb1cb61faf463c209fddd1bb0b3ff81 d41d8cd98f00b204e9800998ecf8427e -d2d4f3c4b03e226a2ae751d35adc84c7 -f60aa8f7e04400f4af3bab2ea21f3383 +b03a23d99ff8934ba5a850184a0b0d0c +c86ea16e4f10b94df31701289c00b4ab -9ad62e69014ff23f232dcc43859b6018 -c741e135218d1dbfbcc03a6a4e0271a9 -1960bfd361ca2e7b2582c1633c35b0a3 +0896aa5a8e5444e0bb03ae80c097e82d +dd5996e0d69cf32275d6870b55b56bfa +c7e4e70e698600098ac2c42e411db419 07fe07a999542e322404d77a30264169 -18296a04b5d36082d8afca4e449f1ee6 -87f5b2af13b175d47eca8a33bcc68005 +86aac7d09e8e3ac69c3279b861b80968 +93cad33fd939e06b959b63c019777d91 43cc87a6b84afe612af178e9c0945279 @@ -7321,7 +7449,7 @@ d41d8cd98f00b204e9800998ecf8427e 7bd2acd718a001933d1b9723411d4371 6288df74fb85f7c954c18bf614aafcd3 -845e63a81a5b8edfa079c2fec094d6e1 +aed3cd0e313e75338a46d0dc30bb718c 55cc97fa2026cc42b4771d975b45fedb @@ -7345,7 +7473,7 @@ d41d8cd98f00b204e9800998ecf8427e cbf93873197cf6bdd0e36cd66d2a87c8 -86da383df93404580615782f4265bcb8 +009c4b4f2f9ed03cb27e8a74b3839136 2758f3882de560e1d11d208959c0627e @@ -7364,27 +7492,26 @@ ab88360e0141e3ddb3c8be3ee745008b -099c61f85742fec38c0e6fedff80d7eb -f15cbc07a79882808b31c59831725260 -2f76a335578ef4412e9b3b4a222ccb08 +f81a579ee5ec1adcd1a1de6fce3cb5c8 +5aad4002fc93b2b92d994edbbf95c50b 6fe5e34cc37004b4342377afa27fe78e 65306d3a5faf1ede100f0b433e707aa9 d41d8cd98f00b204e9800998ecf8427e -5baae840658acdb066b3294b07d6ed63 -e2e322bda8e0a19f571796b5ca46a266 +d6814238960c3d3ae89a8748af2cd846 +1dc3d6a1dd909a8a58fe8eca47ead5ac 87ab6c05827eaa2db8236ca2c0262ead -04e84d93b6851156225d86b33bc68056 +1d878883bffeb35ff573a04d207a7938 748fa3c47dca5861db4a736455d0f981 -762d623e34cb8c1d8b575801543027c8 -e99a525c7011b5cc748b27040716cfd1 +b3cf8bd9552d63ecc9746ca05452bf2f +674268c96f941fc5a6cd52da5fb0fd43 abcdf41603da0d617bee025c713adb41 c7c981cbe885fadb6853ac3250aab799 b9a967a29731ccf78b3693d680e3790a -848ba012f7bb08ead96269cac742157a +4a04cfbfb8d5f124746c3e2cd8007186 ccf2ea9b4262741181a0cff7c620146c @@ -7409,7 +7536,7 @@ 76e6aec3a1262b7b199fd88ae651d049 -1d00dfe3dd378ed263a943b10148ffb6 +a3148c5d3f8b6a38cf976cc250985d9f 479aca46b8b848649e96c290319deff5 @@ -7432,9 +7559,9 @@ 4c3fefbce8919598e7f04618a3e54ea2 -03f893c7c0667770a66ed0fd11f1a710 +a63bc90ab57ab5555e882b8db7130b63 d41d8cd98f00b204e9800998ecf8427e -0d39677613072296fbda7f35c0ed9d70 +60a4cd8e106aecadb8d082876de57a25 d60fa512ab394825284751728195161c @@ -7444,10 +7571,10 @@ cf7beba0674c611eca3eb40103a9d56d -c61793fa62504e540c4c08fc387776f1 +be4909eb830f52517bb34572822210b6 d41d8cd98f00b204e9800998ecf8427e cf3df8807edf32bdf31d3d0d148cba77 -d93f9826f6e8ef4bc66e8a92ae30020e +1f61fc5521e5a125d27fce95bd4ae5dc 6d0f156645b7ce84c269ff3adb915803 @@ -7469,7 +7596,7 @@ 831e6575098342dfa342551494097a24 -062c91c56e9a1aacf0045ba9ef2d295c +c425f95f5b0e994be961e09520cde9b3 d6d047f9389cde6f11b9175ffda432ac @@ -7509,7 +7636,7 @@ af528677086b2c26806ac47af95d9d9d -fa82bbcd66e5d31ac2f43c52caaa4acc +43b599b8900f31fcd51d013ccac558b2 d41d8cd98f00b204e9800998ecf8427e @@ -7542,7 +7669,7 @@ fde1dac27ff95323136138883a8cb086 -020e671dfeaf92176c35766720c2b8ec +64e3aebc902234add5ddbc3714b778fc d41d8cd98f00b204e9800998ecf8427e @@ -7559,9 +7686,9 @@ b3c7a210b2be2599c7fe2af126eeb062 994337d7c14c76b4537aa2e748b48729 b77816831ef40cf1b79779e1ada51d8e -1b526413dd24dc7b5d6910cf07f3aa1a -319b65909579d3ec171265423a48e35e -d6a0e0fc84f08a62d144e63ccd0f798d +5446b7733bcb58774c487c717831a8f4 +dd0fa2140f5450e0f05d6555af374289 +ca4c5271c26dc0bd0f7537f2d4fe8d75 fe62c00b682dd677dbca4764d5f0fe97 @@ -7576,8 +7703,8 @@ 21055e6d625cd5dc3e805ededd1f350a -bcc15386db16f0050d01b4d80fe68dbd -d77e4af5d17f15fdfd920ec8fda7fc45 +aec47b386df0e0df628a1e31f109e998 +0f079eeaf763fe056f582fd3d821b216 95559609c47c88b112952073fb77410e b79674bb1410c34f6428a0e392318740 ee9a71add932db04def7fb3a6d8af20f @@ -7597,10 +7724,10 @@ ea1a3bd45013d291cafdce135ebbd13c -c78c359e1ac036fa9a991e635efbfac5 +5b0073ef255ade9c14c4d56a735c5684 221d0b581479c434f039e58da4718a8d a6f5b10b14e766e788351b506b6f6024 -48ac89c72e2794fbcbb1078e0fe7d9ba +f94ccfe8360d382460cf8aca0492b9a0 9423e6de63cf281df2bcda0892da0a88 c8506bcf84839f36e61a555912e7c31c 2e5082f8e6d7976945c0e8e951d5f261 @@ -7633,7 +7760,7 @@ bef639ba5d15fbe93aa7df26bf6c3a70 -32160cab79f75fc38ed26bb590037169 +70bd9741b82ec97e1e005663b8ee8671 d00dcd6a42cd0d91cbd5639c56a4b6a7 008656d6620cb1ef43935edc30fd2994 @@ -7641,15 +7768,15 @@ 7ab5486f4cec78b1c4d93a1df0d83b51 -8b9453a22ca4ec5cd5f504b0f3338238 +73644c7a9c7312b638a8de811c0f71b8 d41d8cd98f00b204e9800998ecf8427e -0e3fff0ddbce47ecce252c82a6e02fa7 +770001d8b9e70249a27cfc567e770219 f47f735ec8627b7b3e9ce6a5e1643d4c fff5ddf9542281c2d2568153781b4c73 16e1a29a5b79d4a3668b3a71ca3d86df -992dde85a7ee2f81661fd7a54abf7f89 +5aa861a485746b0cce73cee39a4eebc6 78a3befa9a3a9bdb40420e432352250b a42439ac674abe10958f58d747f7cde0 @@ -8029,19 +8156,19 @@ f1f34d8c0f864daa5e8ab56801027430 -b7454525aa100e079c56a92ef4866283 +831fe459f7d3606afc5482fbfbe85278 c3e50ad0d4c93692a2810e136ada70d7 ab274a62d5a3a8ab5f1e745725b83dfc c4e9cd5c18af616969894e4dceb95f97 462f3f2edf24c9118a0a6df7f00765fa -a7f112322d606a3807c6e4eff9bf9b1f +5b2e22d569f45024f23cd0f6c213ea86 90a76b121fb7fe4b51daad580591cc8c ef12ff29adae2685e120e58aa04e23bc bc8b10dd8cc1f841662dfdd87868197c 311cb7d4bf06cb181cfffb6e44ed5826 e1161971bb06488cabe9066c8e827741 -90086ae0090269082c6221cdaff54d9c -4573107d98f6599ed40b01012378fa81 +f7b4e392e8e49b03c37439ecd4210e83 +7528006b9faf6605713f4b2f19f19f17 3222e8667905ffdb07a756fa25a26bd9 c710e46b08ef99b41b5167db96309c81 f28164a5a95f0a8408bfa00f4a40680d @@ -8060,7 +8187,7 @@ 75fb4c310c4f0554d3ac9859d0c5b646 e337dc8e080a86ce2e187cf3a38d0b10 de30767cf0a5d454269ab9986fce13c0 -b84cc0bb32567be3d521af1a1d2b4cce +1c3f72b75a408faa2fd8b60944cc2533 34be9245428cb84ae31c992eb21f33d3 9eea13d3889d78fdbc614dea77011565 6f3b6f771da549d8e22263e795ddecaf @@ -8070,14 +8197,15 @@ fb5913e34a812d5fdf9e25b8ca8c9fb2 3c801db51ff672838b9306c63df460e0 51a8ed92619d4857e0eaddd369a14b38 -a4fcafdd9412d243c46e1b55d7911f2c +3687aa1cf5d5f099a8b746660efe601c 5f5e1f71ef91392a3edee6cdf5e03408 8cc192424d2a8a3a8439cf6c9e9c866d 228b0316d26bdd36e56a9158eea64ef6 59b195fcff4d3877045fee21c364d524 324f3b1c1afefe3296f76db472cbc9f6 -8d2578f24429a8c9863f267bd792fb16 -6ec9a9a11b06059192bcf4a71a34dd22 +4897fa688236216c771946add0f2564c +d01fdb1e6043fb26b049108da5e4df60 +d091b8b83cd5b9dfb948872eb9b9e4dc a171ba167ab22bbfd25e570f28bd8483 f0d89af2ab05f3af36e1a4edec69c7db 1a6980f79392b14b3a7e00db58f915ff @@ -9748,24 +9876,24 @@ be05aa1b12e3b558de747e470b5731c8 -c2f72a6d3ee9b7e45506ead106bc8f86 +65db64d894cf8b776148fc4324d16986 3262db34410c13ae4d777e263d779217 -d11569807aab1e77f9bcd96fe375bde9 +97af3c06de8fcf9955b0d09d7d2c7397 c08f79985fa33fe026ef475f840f87b1 -e61deb16dd6421608631ed5c1f671c6a -f71ca57649aece8045b66345a612e20a -48451fe44b83835898ec108b9d9bf866 +1a6a7ea85a76cb09bc7568856b7f9a28 +4a00c2ddb39f4e28db51f6d0f3283859 +385be3b28799de9f80d0ef46508efbdc 98fec0976eec22385c2b735cb80d7448 b7c27239e68ce6f51296820da50bfffa 60d670dc85d029ed1c3f63693d0d4288 186dbbf4b11a9684557157006bf2a232 -8e42376332e36c72edf33421d3f12bf8 -cb73d7bfbdae912945ec4d98c0d1ec9b +78663365fd9c3f521c456712bf1aaf17 +45ac46e656485f54c2e642c00ece251c cfc96587347a77604730af23372d747f -6b1538d4b9683808221f30ddad0414d8 +398d48fad9f224e2c8a811b7e63cfb5b f5f165bb15c6391fc12ebac3e0a0f3e6 555145f760c70cf34b190b7214e3b5cc -dd62bf79621c56e565feabc0b84574d0 +c4db7841d9ac141c2e07f986344cf10e 7508982db7d5e9e5c7fec3f096de32b0 aa86f6cb23c2ae8294bcbd6f2315e8ed c56f3ea358f24bb4e820768e948b416b @@ -9776,11 +9904,11 @@ 2da0a1995db50d0752d2e509a3bca37f 78f2edd4512d3859d13e1c90618932ff 10c2dcc555137e38039193ccedfc0cd3 -b0d093ebda261c4ac0a6bb982cfa41f0 +f3cb3a7da6c4a8e947856ce9a7529a90 418334153f5b6a5543f6cb5a28f3c82b -bac99d873d638b05891fda9f7c62d562 -021de63f1074cc73a6d83a3e83a5ae55 -c7f8ee7a8d27fb0d86b5386b8cd9a6f7 +c760d45b0959664fe5ef8f18e31cd4ae +d01ee19b9b423b0378dfb48c8a20b021 +914772c1d09c8268418beaafaf36313d 199dcc4ae427c0d0e5fbde6c0d2d2f99 57da58850de2f4591fc18e23473ba8ad 08fc6ae338f02d76f77339c8537012ba @@ -9799,8 +9927,8 @@ 7dcd96797a60b5e466e25990e534f588 1818aababec2539efc6cee74006d4d0c 16202ce23ad23f4f86fcbd0c5d16dea2 -83a5a0b9fdc95c8f1647075e8c63c00a -d95dd0afca51ee1616ffe9550cfc1f93 +2086b1a692e4c3cc5dbe6edbc87976d4 +8dcd21c1d37a27cc9a9f227a2b283388 87eae3bfbea127d8e90970cf3fe8a9a1 @@ -10153,8 +10281,9 @@ 9ff187bdce93767cf2f24dbb5b0a34c5 c04364a46b55ae75b65db731f040dbee 5437aca264069f35e46a3fc46f04c2d9 -438c872ca8fdb808934df640ad361350 +b00df950231dc8222d5a74855b0708b5 9d95d44e6045f242b1ad717ed35f195b +5f1f15ee0a4ecc70e93427b814af9489 cf750bc5baeb59198423a8ba9039fccf b50591f99fa324afaba5e4e1d15829f3 349416524f35254fa72144bc7e08f9a6 @@ -10188,15 +10317,16 @@ 1008cbc1e61ed90dfd79c57cd620c92b 46f6b55d98da9ef1ffec9b1d1a6125bd e4e03fc7d82d2da0126d8445f09f61c2 -7a0cedeb2e3c160aa33e736ebba6059e +03cdf6ba23e31c14abc2bb3a79b7472c fab14e1ece001f18e03308c4abd5d7b6 2bac51be88c59c5ee21511836859e221 0889424a15f7ae4d5147e680d379e3c0 b8357efaf2331cd36af04b80256e3181 5a0de7d0f34fd6f63ae32d20e0a32b9d a1fe9c904ea0bd6d6ea490b977432ffc -d98e38cacdacd9d7c74df773358d6e6f +f424ed5d8ad204b2ccfd39045ab44d3b 3bb797554b6eedd86f67a0c36e9918ec +89b6756ccb0d05b4191b704aafaf5803 9afb68804040e5f7d92d7c308b79f770 d7d2fd96c741b616945e848ade9f9539 7767ff394313f1229871b8ee58c26a99 @@ -10429,7 +10559,7 @@ 52517073ee32fd105af7fccfde018e29 -2fb346f0383dd975a301eca9a423c12a +ca1f6c3cde7a72fc33fa826f580ca872 d41d8cd98f00b204e9800998ecf8427e @@ -10440,17 +10570,17 @@ d41d8cd98f00b204e9800998ecf8427e -1ba9555290fac6190106a623ece3376f -3a9bf22080b7d3c4d3a154affe9d6095 +e4a286e635b8486ef952cd5e7c063272 +daa87eb4e5a5dec7a491a6313f9335c9 bdd80120aa3357c1ac276e8b2ffb81a6 -7cb5f8fa9f76dae5e107abfbc0e35d82 +720ce5f162f6879e42bd51a2e677966c 8326aa93734dd8035a04c12062e68ce4 d41d8cd98f00b204e9800998ecf8427e -a6eb7d29b6a4649096f384711efdf232 +529b00d17c929c47878ebeb1cf313267 099f9b1f56cae48a1b679ed282e3766d @@ -12286,6 +12416,7 @@ 2e0eb0e3d978cfc35b462a199aeded78 9e36c55b53a1b080066d9947a92d2ce3 9e36c55b53a1b080066d9947a92d2ce3 +8f120e35f8b6608fb34e38edf9a2687c a9e38adb81052e1178a2486de8a87c28 7389cc51b77b11b297ccce79048a1c7f 0474bee65715fc6918a92b668178be6c @@ -12350,7 +12481,7 @@ d41d8cd98f00b204e9800998ecf8427e -be5e2576e65fca0640a3e943edb7b4a2 +b7ac1e65cfb2226f71c4c585b87ef36d fd6a54cb5cf80f075d7687ad66dd2cb9 @@ -12368,20 +12499,20 @@ 11689e5722e4204b9d01e5e4483b92ef -cc97395704f8c817d0c92e81b4626429 +ba1182650ae38ce16735a2f783046f85 a20a84fb09238e216ab80d91674426b1 d41d8cd98f00b204e9800998ecf8427e 4b94e9ad89c520b4cc4ab986a1cfb5f8 -348ac1d0cc575dcee2a8bd3fe3da6096 +62867ac6e7f63524ba1bbd195e5504ef 96a92bc03a6ca67f39d363c36031dee7 db802ba04a77501799a7073600802c80 0e4f03114e8298dfc23bb94d0df5d390 5e1aea18f899b4a763a0291dcf1f2b90 -c6798747955c37d2da47a6753d831cf4 +f34e17319f0c0f4b26c44fed42091c3b eed35a94809263558ac663233eaa2f38 @@ -12390,44 +12521,153 @@ d41d8cd98f00b204e9800998ecf8427e -74d19c16439bec3b2eeabde4bb8b6b1d -15faab5d58a32bd40d3f163cfaf951b6 +2174cc25f7e4e713034396fa94be1c93 +8334218ca0707e5c27f28b6897c673e6 a1838ba6f718aeec0172bc6e9d90f4b6 -eb474eb2e1039037169aaacb91443c3e +1d1dd963b8dfb47170403042c4c86431 7770e9e8e3fb4b98bc149059c5bc9633 -7aece8343f1f3c70f617733955c2bce6 +b0fd3b28285996794ea374e10881da03 7b7cde9c324feeed6e94f50e1655ba40 3c77ad60389c5eaaa410ac4a176b3ab6 bdb99f4a1594eaf4923129f21035a88d 966129fc8b4d82883741779cf87ea57a -9c258004b01196601cc918cc09857b0a +a2252f5482460d20d054a1f7d36f4dbe + + +3064b1ab98d9562f84c353c586a36765 +4d843333d740ee7e132b9aba3ca84c79 + + +352318e7e91b1ea9e37097409c9907a4 + + +48e867f61a945a10e84ccc6b297b530d + + +decda684aa41b7e3d4c9cbd82c57bf16 + + +e85c36b02b54ca8575353e41a035ef98 + + +a9edd5331230715886153f1ac2535d10 +a76cbf5801d8a007cdf2b8d82534e922 +a7f9c53e667b559a168e9c669751b9b4 + + +09fd73462e6973de1e5b4d5ea13015f3 + + +c030f0ca220a0377d27db496ed8b5318 + + +4fbee2586602efafa0764319b427939f + + +2acaf08f39c54745ac076d2e907273a8 + + +628ed9cddef9a2221251063053805324 +1fa2e700c74403c7941380638b09d82c +75f02406119800a1604d0b579ef3e61b +4f45d10b5ee1f09cb3fe944a95d6862b +f2a7ed553bd2288e8618c2c270a904df + + +8e3e6864c5fc86e81a2fa2ab2a39c6cf + + +dc14015d4641c2ace184a65f28bbe2a8 + + +eb6922c389258f0bcdee9efd22fb92ce + + +8aa3a2b726bc259ba9d57cb66d1ebeee + + +569784a8bbe92385bb2e32740788ad5c +b31ffb415b0662026fc6b92c0f87953c + + +839af79be6bad3e0880427117aa63e1f + + +ced84ab2bf5bd9391ea24b6bc30e987d + + +1f34e4ab0ec69431bd6661f39e138684 + + +19399c45ec6fb7cd97adf8455d766818 +aee69fb06398d6982ddbd7a4c8462a50 +6802f7660d7b71d1684e3a0ad0472ad8 +5ace6d4ad483742bc7d0679a934ed312 + + +593cc9cb911cbd7433bc198d2e0ea7f5 +93c7eed93f34e0951873519d5c60df2b + + +d6051e8e91e3b9275fb3315c5f10bd4d +e4552f8e8c2cb90661b4d9693e13ba52 + + +a2621ad34bd5b20864c8cf669c3d8a93 +469ce28873bd63023d33e9738b52d92e +b98d1eb79425c7db97a6837942aa64f7 + + +8a6217da856e75f4de79612f74f12e9e + + +660ce536dc1d691a14b4cede3f8c25cc +7abe92af6f134fc8ab7b414ddfa9fdc3 +8a8f3a86b7714c89caddbe4bdc73af8f + + +1bf6a453a4d929acc0c868e4cf6bc083 +144997b030c9e8c99a686d3c8d17ead6 + + +7e9686417f83eab48e7d19d61b6a5f7f + + +060b91056472c88d12426eaddd919c41 +4a313ea27e6c40565d7381b271199751 +a911dbae66b9f63328e9033182ae455a + + +a9d6e5bf4ae47e75eacbee49bce7d945 +15a61b5570ae5be9f79bfd79f6ee6faa +df00595a449a2aa6ebd8e79c8aad37ee 9382e7efb69651b29045f2421d618717 0b959ec99ed9ee63f065c7d40454b9ec -ce4ff827937faf5800380ff9867324b5 +a7387351fcf1eaf404d6f7f41b178ca4 -be24a0530d2ce043c5f6df3e85e309b1 +2c0d16fc13d82dcc90011730fb8c32aa -dc472d539640920357d694745d5c7f9d +c660c836df813f50dfdfe793821cbb94 1ebef0db96238c1bd7372bea81b9761d 4a3747f8978a90ab4ed41be95c2f5695 4f9ad2e49a960637c6f48ee7c228ee0f 0e96616ba6ef78c2874b6c9fb9c10c7a -857ef0aa17df0f205806791dcd65427c -986e2f39e85074de9facf0ea7973f315 +9da09c907dca9a53fd16ba8b261e4f62 +6df215e0c6cc349308be769a25c4ce74 d41d8cd98f00b204e9800998ecf8427e From 1660c1c05bd72a2e9a8187b01ddd1c10e479c2f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 01:30:46 +0100 Subject: [PATCH 26/80] Fix bug introduced with var_dump --- htdocs/core/db/mssql.class.php | 52 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index e2d938da710..3523e21bdf0 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -237,10 +237,10 @@ class DoliDBMssql extends DoliDB $res=mssql_query('select @@TRANCOUNT'); $this->transaction_opened=mssql_result($res, 0, 0); - + if ($this->transaction_opened == 0) { - //return 1; //There is a mess with auto_commit and 'SET IMPLICIT_TRANSACTIONS ON' generate also a mess + //return 1; //There is a mess with auto_commit and 'SET IMPLICIT_TRANSACTIONS ON' generate also a mess $ret=mssql_query("SET IMPLICIT_TRANSACTIONS OFF;BEGIN TRANSACTION;",$this->db); if ($ret) { @@ -264,7 +264,7 @@ class DoliDBMssql extends DoliDB { $res=mssql_query('select @@TRANCOUNT'); $this->transaction_opened=mssql_result($res, 0, 0); - + if ($this->transaction_opened == 1) { //return 1; //There is a mess with auto_commit and 'SET IMPLICIT_TRANSACTION ON' generate also a mess @@ -296,7 +296,7 @@ class DoliDBMssql extends DoliDB { $res=mssql_query('select @@TRANCOUNT'); $this->transaction_opened=mssql_result($res, 0, 0); - + if ($this->transaction_opened == 1) { $ret=mssql_query("ROLLBACK TRANSACTION",$this->db); @@ -322,7 +322,7 @@ class DoliDBMssql extends DoliDB function query($query,$usesavepoint=0,$type='auto') { $query = trim($query); - + if (preg_match('/^--/',$query)) return true; // Conversion syntaxe MySql vers MSDE. @@ -331,7 +331,7 @@ class DoliDBMssql extends DoliDB $query = str_ireplace(", tms = tms", "", $query); $query=preg_replace("/([. ,\t(])(percent|file|public)([. ,=\t)])/","$1[$2]$3",$query); - + if ($type=="auto" || $type='dml') { $query=preg_replace('/AUTO_INCREMENT/i','IDENTITY',$query); @@ -339,7 +339,7 @@ class DoliDBMssql extends DoliDB $query=preg_replace('/float\((.*)\)/','numeric($1)',$query); $query=preg_replace('/([ \t])unsigned|IF NOT EXISTS[ \t]/i','$1',$query); $query=preg_replace('/([ \t])(MEDIUM|TINY|LONG){0,1}TEXT([ \t,])/i',"$1VARCHAR(MAX)$3",$query); - + $matches=array(); $original_query=''; if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+(?:(UNIQUE)|INDEX)\h+(?:INDEX)?\h*(\w+?)\h*\((.+)\)/is', $query,$matches)) @@ -360,7 +360,7 @@ class DoliDBMssql extends DoliDB if ($query_comp) $query.=" WHERE ".implode(" AND ",$query_comp); } - } + } else { if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+PRIMARY\h+KEY\h+(\w+?)\h*\((.+)\)/is', $query, $matches)) @@ -369,7 +369,7 @@ class DoliDBMssql extends DoliDB $query="ALTER TABLE [".$matches[1]."] ADD CONSTRAINT [".$matches[2]."] PRIMARY KEY CLUSTERED (".$matches[3].")"; } } - + } if ($type=="auto" || $type='ddl') @@ -384,13 +384,13 @@ class DoliDBMssql extends DoliDB // Supprimer l'instruction MySql $query = str_ireplace(" limit ".$number, "", $query); } - + $itemfound = stripos($query, " week("); if ($itemfound !== false) { // Recreer une requete sans instruction Mysql $positionMySql = stripos($query, " week("); $newquery = substr($query, 0, $positionMySql); - + // Recuperer la date passee en parametre $extractvalue = stristr($query, " week("); $extractvalue = substr($extractvalue, 6); @@ -398,7 +398,7 @@ class DoliDBMssql extends DoliDB // Conserver la fin de la requete $endofquery = substr($extractvalue, $positionMySql); $extractvalue = substr($extractvalue, 0, $positionMySql); - + // Remplacer l'instruction MySql en Sql Server // Inserer la date en parametre et le reste de la requete $query = $newquery." DATEPART(week, ".$extractvalue.$endofquery; @@ -407,11 +407,11 @@ class DoliDBMssql extends DoliDB { //var_dump($query); //var_dump($matches); - if (stripos($query,'llx_c_departements') !== false) var_dump($query); + //if (stripos($query,'llx_c_departements') !== false) var_dump($query); $sql='SET IDENTITY_INSERT ['.trim($matches[1]).'] ON;'; @mssql_query($sql, $this->db); $post_query='SET IDENTITY_INSERT ['.trim($matches[1]).'] OFF;'; - + } } //print ""; @@ -427,7 +427,7 @@ class DoliDBMssql extends DoliDB { $ret = mssql_query($query, $this->db); } - + if (!empty($post_query)) { @mssql_query($post_query, $this->db); @@ -732,13 +732,13 @@ class DoliDBMssql extends DoliDB //TODO: Check if we need to force a charset //$sql.= ' DEFAULT CHARACTER SET '.$charset.' DEFAULT COLLATE '.$collation; $ret=$this->query($sql); - + $this->select_db($database); $sql="CREATE USER [$owner] FOR LOGIN [$owner]"; mssql_query($sql,$this->db); $sql="ALTER ROLE [db_owner] ADD MEMBER [$owner]"; mssql_query($sql,$this->db); - + $sql="ALTER DATABASE [$database] SET ANSI_NULL_DEFAULT ON;"; @mssql_query($sql,$this->db); $sql="ALTER DATABASE [$database] SET ANSI_NULL ON;"; @@ -976,12 +976,12 @@ class DoliDBMssql extends DoliDB } $sql="SELECT name from sys.databases where name='".$dolibarr_main_db_name."'"; $ressql=$this->query($sql); - if (! $ressql) + if (! $ressql) { dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_WARNING); return -1; - } - else + } + else { if ($num) { @@ -1106,7 +1106,7 @@ class DoliDBMssql extends DoliDB return array(); } - + /** * Escape a field name according to escape's syntax * @@ -1116,18 +1116,18 @@ class DoliDBMssql extends DoliDB function EscapeFieldName($fieldname) { return "[".$fieldname."]"; } - - + + /** * Get information on field - * + * * @param string $table Table name which contains fields * @param mixed $fields String for one field or array of string for multiple field * @return boolean|multitype:object */ function GetFieldInformation($table,$fields) { $sql="SELECT * from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='".$this->escape($table)."' AND COLUMN_NAME"; - if (is_array($fields)) + if (is_array($fields)) { $where=" IN ('".implode("','",$fields)."')"; } @@ -1144,7 +1144,7 @@ class DoliDBMssql extends DoliDB $result[]=$obj; } } - else + else return false; return $result; From 049174b76f02424cbbd7fa985a09ead6a788c2dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 01:53:02 +0100 Subject: [PATCH 27/80] Fix bugs reported by https://scrutinizer-ci.com/g/Dolibarr/dolibarr/ --- htdocs/admin/fichinter.php | 2 +- htdocs/admin/security_file.php | 2 +- htdocs/contrat/document.php | 2 +- htdocs/core/class/commonobject.class.php | 24 ++++++++++++------------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 8965b225cfb..8e06e946dee 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -221,7 +221,7 @@ else if ($action == 'set_FICHINTER_DRAFT_WATERMARK') elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS') { $val = GETPOST('FICHINTER_PRINT_PRODUCTS','alpha'); - $res = dolibarr_set_const($db, "FICHINTER_PRINT_PRODUCTS",($val == 'on'),'bool',0,'',$conf->entity); + $res = dolibarr_set_const($db, "FICHINTER_PRINT_PRODUCTS",($val == 'on' ? 1 : 0),'bool',0,'',$conf->entity); if (! $res > 0) $error++; diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 4c0dd435634..d99db6ed638 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -208,7 +208,7 @@ $formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestF // List of document $filearray=dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1); -$formfile->list_of_documents($filearray, '', 'admin_temp', ''); +$formfile->list_of_documents($filearray, null, 'admin_temp', ''); llxFooter(); $db->close(); diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 6c520105c36..49466c7fcb0 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -91,7 +91,7 @@ llxHeader(); if ($object->id) { - $head=contract_prepare_head($object, $user); + $head=contract_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("Contract"), 0, 'contract'); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3c5bb73d93e..8ad8ecd2331 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -888,7 +888,7 @@ abstract class CommonObject if (! $this->table_element) { - dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined", LOG_ERR); + dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined"); return -1; } @@ -2389,8 +2389,8 @@ abstract class CommonObject return 1; } } - - + + /** * Return incoterms informations * @@ -2409,13 +2409,13 @@ abstract class CommonObject $res = $this->db->fetch_object($result); $out .= $res->code; } - } - + } + $out .= ' - '.$this->location_incoterms; - + return $out; } - + /** * Return incoterms informations for pdf display * @@ -2430,12 +2430,12 @@ abstract class CommonObject $res = $this->db->fetch_object($resql); return 'Incoterm : '.$res->code.' - '.$this->location_incoterms; } - else + else { - return false; + return false; } } - + /** * Define incoterms values of current object * @@ -2457,14 +2457,14 @@ abstract class CommonObject { $this->fk_incoterms = $id_incoterm; $this->location_incoterms = $location; - + $sql = 'SELECT libelle FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; $res = $this->db->query($sql); if ($res) { $obj = $this->db->fetch_object($res); $this->libelle_incoterms = $obj->libelle; - } + } return 1; } else From c7c7c393ee9db5dc52eadc5371c07b3f7067b59e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 02:14:59 +0100 Subject: [PATCH 28/80] sql syntax errors --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 2 +- .../mysql/tables/llx_askpricesupplierdet_extrafields.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 3233022d3f9..2a36ef78737 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -316,7 +316,7 @@ CREATE TABLE llx_askpricesupplier_extrafields ( ) ENGINE=innodb; CREATE TABLE llx_askpricesupplierdet_extrafields ( - rowid integer AUTO_INCREMENT PRIMAR KEY, + rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, fk_object integer NOT NULL, import_key varchar(14) DEFAULT NULL diff --git a/htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql b/htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql index 6ecbcf83d2c..7bfab6e408c 100644 --- a/htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql @@ -16,7 +16,7 @@ -- ======================================================================== CREATE TABLE llx_askpricesupplierdet_extrafields ( - rowid integer AUTO_INCREMENT PRIMAR KEY, + rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, fk_object integer NOT NULL, import_key varchar(14) DEFAULT NULL From a0762a5113942f6b9a2f1dc39c915fec1022a78f Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Fri, 6 Mar 2015 01:31:49 +0000 Subject: [PATCH 29/80] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/admin/system/filecheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 278aae8ea5b..8eff6821224 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -108,7 +108,7 @@ $db->close(); /** * Function to get list of updated or modified files * - * @param object $dir SimpleXMLElement of files to test + * @param SimpleXMLElement $dir SimpleXMLElement of files to test * @param string $path Path of file * @return array Array of filenames */ From 27e99793a373a7348ccf1185d051999f618f8782 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Fri, 6 Mar 2015 02:10:01 +0000 Subject: [PATCH 30/80] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/core/class/commondocgenerator.class.php | 4 ++-- htdocs/core/class/cookie.class.php | 2 +- htdocs/core/class/html.form.class.php | 12 ++++++------ htdocs/core/class/html.formbank.class.php | 2 +- htdocs/core/class/html.formcron.class.php | 4 ++-- htdocs/core/class/html.formmailing.class.php | 2 +- htdocs/core/class/html.formother.class.php | 8 ++++---- htdocs/core/class/menu.class.php | 4 ++-- htdocs/core/class/mobiledetect.class.php | 8 ++++---- htdocs/core/class/openid.class.php | 14 +++++++------- htdocs/core/class/translate.class.php | 8 ++++---- htdocs/core/datepicker.php | 2 +- htdocs/core/db/mysql.class.php | 4 ++-- htdocs/core/db/mysqli.class.php | 6 +++--- htdocs/core/db/pgsql.class.php | 10 +++++----- htdocs/core/lib/json.lib.php | 2 +- .../askpricesupplier/modules_askpricesupplier.php | 4 ++-- htdocs/core/modules/commande/modules_commande.php | 4 ++-- htdocs/core/modules/contract/modules_contract.php | 4 ++-- htdocs/core/modules/dons/modules_don.php | 2 +- .../core/modules/expedition/modules_expedition.php | 4 ++-- .../expensereport/modules_expensereport.php | 4 ++-- htdocs/core/modules/export/modules_export.php | 2 +- htdocs/core/modules/facture/modules_facture.php | 4 ++-- htdocs/expedition/class/expeditionbatch.class.php | 4 ++-- 25 files changed, 62 insertions(+), 62 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index b7f8e09677f..bf11c4fea13 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -206,7 +206,7 @@ abstract class CommonDocGenerator /** * Define array with couple subtitution key => subtitution value * - * @param Object $object contact + * @param Contact $object contact * @param Translate $outputlangs object for output * @param array_key $array_key Name of the key for return array * @return array of substitution key->code @@ -442,7 +442,7 @@ abstract class CommonDocGenerator /** * Define array with couple substitution key => substitution value * - * @param Object $object Main object to use as data source + * @param Expedition $object Main object to use as data source * @param Translate $outputlangs Lang object to use for output * @param array_key $array_key Name of the key for return array * @return array Array of substitution diff --git a/htdocs/core/class/cookie.class.php b/htdocs/core/class/cookie.class.php index bcca9fcfa73..150d52fae62 100644 --- a/htdocs/core/class/cookie.class.php +++ b/htdocs/core/class/cookie.class.php @@ -109,7 +109,7 @@ class DolCookie * * @param string $cookie Cookie name * @param string $value Cookie value - * @param string $expire Expiration + * @param integer $expire Expiration * @param string $path Path of cookie * @param string $domain Domain name * @param int $secure 0 or 1 diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c5cdbc3f9e7..31fb095e3c8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -480,7 +480,7 @@ class Form * @param string $selected Id or Code or Label of preselected country * @param string $htmlname Name of html select object * @param string $htmloption Options html on select object - * @param string $maxlength Max length for labels (0=no limit) + * @param integer $maxlength Max length for labels (0=no limit) * @return string HTML string with select */ function select_country($selected='',$htmlname='country_id',$htmloption='',$maxlength=0) @@ -658,7 +658,7 @@ class Form * @param string $htmlname Name of field in html form * @param int $showempty Add an empty field * @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select) - * @param string $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, -1=Force none (and set hidden field to 'service') + * @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, -1=Force none (and set hidden field to 'service') * @return void */ function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0) @@ -1072,9 +1072,9 @@ class Form * @param int $showempty 0=no empty value, 1=add an empty value * @param string $exclude List of contacts id to exclude * @param string $limitto Disable answers that are not id in this array list - * @param string $showfunction Add function into label + * @param integer $showfunction Add function into label * @param string $moreclass Add more class to class style - * @param string $showsoc Add company into label + * @param integer $showsoc Add company into label * @param int $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param bool $options_only Return options only (for ajax treatment) @@ -1095,10 +1095,10 @@ class Form * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit) * @param string $exclude List of contacts id to exclude * @param string $limitto Disable answers that are not id in this array list - * @param string $showfunction Add function into label + * @param integer $showfunction Add function into label * @param string $moreclass Add more class to class style * @param bool $options_only Return options only (for ajax treatment) - * @param string $showsoc Add company into label + * @param integer $showsoc Add company into label * @param int $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return int <0 if KO, Nb of contact in list if OK diff --git a/htdocs/core/class/html.formbank.class.php b/htdocs/core/class/html.formbank.class.php index 12bff860a26..6335e25dd72 100644 --- a/htdocs/core/class/html.formbank.class.php +++ b/htdocs/core/class/html.formbank.class.php @@ -45,7 +45,7 @@ class FormBank /** * Retourne la liste des types de comptes financiers * - * @param string $selected Type pre-selectionne + * @param integer $selected Type pre-selectionne * @param string $htmlname Nom champ formulaire * @return void */ diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 4de88a7bfc9..86c80413855 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -47,8 +47,8 @@ class FormCron extends Form * Display On Off selector * * @param string $htmlname Html control name - * @param string $selected selected value - * @param string $readonly Select is read only or not + * @param integer $selected selected value + * @param integer $readonly Select is read only or not * @return string HTML select field */ function select_typejob($htmlname,$selected=0,$readonly=0) diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index 98a76c84686..93fdac553a3 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -48,7 +48,7 @@ class FormMailing extends Form * * @param string $selectedid the selected id * @param string $htmlname name of controm - * @param number $show_empty show empty option + * @param integer $show_empty show empty option * @return string HTML select */ public function selectDestinariesStatus($selectedid='',$htmlname='dest_status', $show_empty=0) { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index d418a32fd77..4ea60dbf2c1 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -157,7 +157,7 @@ class FormOther * * @param string $selected Preselected ecotaxes * @param string $htmlname Name of combo list - * @return void + * @return integer */ function select_ecotaxes($selected='',$htmlname='ecotaxe_id') { @@ -268,7 +268,7 @@ class FormOther /** * Return a HTML select list to select a percent * - * @param string $selected pourcentage pre-selectionne + * @param integer $selected pourcentage pre-selectionne * @param string $htmlname nom de la liste deroulante * @param int $disabled Disabled or not * @param int $increment increment value @@ -303,7 +303,7 @@ class FormOther * Return select list for categories (to use in form search selectors) * * @param int $type Type of categories (0=product, 1=suppliers, 2=customers, 3=members) - * @param string $selected Preselected value + * @param integer $selected Preselected value * @param string $htmlname Name of combo list * @param int $nocateg Show also an entry "Not categorized" * @return string Html combo list code @@ -834,7 +834,7 @@ class FormOther * @param int $offset Offset * @param int $invert Invert * @param string $option Option - * @return void + * @return string */ function selectyear($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='') { diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php index 411158dea84..dff357d8f91 100644 --- a/htdocs/core/class/menu.class.php +++ b/htdocs/core/class/menu.class.php @@ -53,7 +53,7 @@ class Menu * * @param string $url Url to follow on click * @param string $titre Label of menu to add - * @param string $level Level of menu to add + * @param integer $level Level of menu to add * @param int $enabled Menu active or not (0=Not active, 1=Active, 2=Active but grey) * @param string $target Target lien * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) @@ -71,7 +71,7 @@ class Menu * @param int $idafter Array key after which inserting new entry * @param string $url Url to follow on click * @param string $titre Label of menu to add - * @param string $level Level of menu to add + * @param integer $level Level of menu to add * @param int $enabled Menu active or not * @param string $target Target lien * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) diff --git a/htdocs/core/class/mobiledetect.class.php b/htdocs/core/class/mobiledetect.class.php index 297058698aa..b04e0e98c91 100644 --- a/htdocs/core/class/mobiledetect.class.php +++ b/htdocs/core/class/mobiledetect.class.php @@ -687,7 +687,7 @@ class MobileDetect /** * Retrieve the User-Agent. * - * @return string|null The user agent if it's set. + * @return string The user agent if it's set. */ public function getUserAgent() { @@ -879,7 +879,7 @@ class MobileDetect * * @param string $name Name * @param array $arguments Arguments - * @return mixed + * @return null|boolean * * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is' * @method boolean is[...]() @@ -926,7 +926,7 @@ class MobileDetect * * @param string $key Key * @param string $userAgent deprecated - * @return mixed + * @return null|boolean */ protected function matchUAAgainstKey($key, $userAgent = null) { @@ -1009,7 +1009,7 @@ class MobileDetect * @param string $key key * @param string $userAgent deprecated * @param string $httpHeaders deprecated - * @return bool|int|null + * @return null|boolean * * @todo: The httpHeaders part is not yet used. */ diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index a5e01998ecd..d46481a0c60 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -150,7 +150,7 @@ class SimpleOpenID /** * GetIdentity * - * @return void + * @return string */ function GetIdentity() { // Get Identity @@ -187,7 +187,7 @@ class SimpleOpenID /** * IsError * - * @return void + * @return boolean */ function IsError() { @@ -225,7 +225,7 @@ class SimpleOpenID * OpenID_Standarize * * @param string $openid_identity Server - * @return void + * @return string */ function OpenID_Standarize($openid_identity = null) { @@ -251,7 +251,7 @@ class SimpleOpenID * array2url * * @param array $arr An array - * @return boolean|string false if KO, string of url if OK + * @return false|string false if KO, string of url if OK */ function array2url($arr) { // converts associated array to URL Query String @@ -303,7 +303,7 @@ class SimpleOpenID * @param string $url URL * @param string $method Method * @param string $params Params - * @return boolean|unknown + * @return string */ function CURL_Request($url, $method="GET", $params = "") { // Remember, SSL MUST BE SUPPORTED @@ -384,7 +384,7 @@ class SimpleOpenID /** * GetRedirectURL * - * @return void + * @return string */ function GetRedirectURL() { @@ -428,7 +428,7 @@ class SimpleOpenID /** * ValidateWithServer * - * @return void + * @return boolean */ function ValidateWithServer() { diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 7347b065a79..0e55da2769a 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -153,7 +153,7 @@ class Translate * If $domain is "file@module" instead of "file" then we look for module lang file * in htdocs/custom/modules/mymodule/langs/code_CODE/file.lang * then in htdocs/module/langs/code_CODE/file.lang instead of htdocs/langs/code_CODE/file.lang - * @param string $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US) + * @param integer $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US) * @param int $stopafterdirection Stop when the DIRECTION tag is found (optimize speed) * @param int $forcelangdir To force a different lang directory * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK @@ -548,7 +548,7 @@ class Translate * Return list of all available languages * * @param string $langdir Directory to scan - * @param string $maxlength Max length for each value in combo box (will be truncated) + * @param integer $maxlength Max length for each value in combo box (will be truncated) * @param int $usecode Show code instead of country name for language variant * @return array List of languages */ @@ -583,7 +583,7 @@ class Translate * Return if a filename $filename exists for current language (or alternate language) * * @param string $filename Language filename to search - * @param string $searchalt Search also alernate language file + * @param integer $searchalt Search also alernate language file * @return boolean true if exists and readable */ function file_exists($filename,$searchalt=0) @@ -720,7 +720,7 @@ class Translate * Return a currency code into its symbol * * @param string $currency_code Currency code - * @param string $forceloadall 1=Force to load all currencies into cache. We know we need to use all of them. By default read and cache only required currency. + * @param integer $forceloadall 1=Force to load all currencies into cache. We know we need to use all of them. By default read and cache only required currency. * @return string Currency symbol encoded into UTF8 */ function getCurrencySymbol($currency_code, $forceloadall=0) diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php index c1918ed6247..eae723946f6 100644 --- a/htdocs/core/datepicker.php +++ b/htdocs/core/datepicker.php @@ -122,7 +122,7 @@ print ''."\n"; * Convert date to timestamp * * @param string $mysqldate Date YYYMMDD - * @return timestamp Timestamp + * @return integer Timestamp */ function xyzToUnixTimestamp($mysqldate) { diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index bd3e77f37d5..64efc837bcd 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -183,7 +183,7 @@ class DoliDBMysql extends DoliDB * @param string $login login * @param string $passwd password * @param string $name name of database (not used for mysql, used for pgsql) - * @param string $port Port of database server + * @param integer $port Port of database server * @return resource Database access handler * @see close */ @@ -314,7 +314,7 @@ class DoliDBMysql extends DoliDB /** * Return datas as an array * - * @param Resultset $resultset Resultset of request + * @param resource $resultset Resultset of request * @return array Array */ function fetch_row($resultset) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index cd692db677c..1126f6c8a57 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -186,7 +186,7 @@ class DoliDBMysqli extends DoliDB * @param string $login login * @param string $passwd password * @param string $name name of database (not used for mysql, used for pgsql) - * @param string $port Port of database server + * @param integer $port Port of database server * @return resource Database access handler * @see close */ @@ -317,7 +317,7 @@ class DoliDBMysqli extends DoliDB /** * Return datas as an array * - * @param Resultset $resultset Resultset of request + * @param resource $resultset Resultset of request * @return array Array */ function fetch_row($resultset) @@ -716,7 +716,7 @@ class DoliDBMysqli extends DoliDB * * @param string $table Name of table * @param string $field Optionnel : Name of field if we want description of field - * @return resultset Resultset x (x->Field, x->Type, ...) + * @return resource Resultset x (x->Field, x->Type, ...) */ function DDLDescTable($table,$field="") { diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 94a2e5fa975..285bdc2cdef 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -368,7 +368,7 @@ class DoliDBPgsql extends DoliDB * @param string $login Login * @param string $passwd Password * @param string $name Name of database (not used for mysql, used for pgsql) - * @param string $port Port of database server + * @param integer $port Port of database server * @return resource Database access handler * @see close */ @@ -546,7 +546,7 @@ class DoliDBPgsql extends DoliDB /** * Return datas as an array * - * @param Resultset $resultset Resultset of request + * @param resource $resultset Resultset of request * @return array Array */ function fetch_array($resultset) @@ -559,7 +559,7 @@ class DoliDBPgsql extends DoliDB /** * Return datas as an array * - * @param Resultset $resultset Resultset of request + * @param resource $resultset Resultset of request * @return array Array */ function fetch_row($resultset) @@ -771,7 +771,7 @@ class DoliDBPgsql extends DoliDB * * @param string $fieldorvalue Field name or value to encrypt * @param int $withQuotes Return string with quotes - * @return return XXX(field) or XXX('value') or field or 'value' + * @return string XXX(field) or XXX('value') or field or 'value' */ function encrypt($fieldorvalue, $withQuotes=0) { @@ -1010,7 +1010,7 @@ class DoliDBPgsql extends DoliDB * * @param string $table Name of table * @param string $field Optionnel : Name of field if we want description of field - * @return resultset Resultset x (x->attname) + * @return resource Resultset x (x->attname) */ function DDLDescTable($table,$field="") { diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 0d92233e62a..121e719bb6f 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -269,7 +269,7 @@ function dol_json_decode($json, $assoc=false) /** * Return text according to type * - * @param mixed $val Value to decode + * @param string $val Value to decode * @return string Formated value */ function _unval($val) diff --git a/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php b/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php index 1b0095308c8..4014452d8c2 100644 --- a/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php +++ b/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php @@ -43,7 +43,7 @@ abstract class ModelePDFAskPriceSupplier extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -149,7 +149,7 @@ abstract class ModeleNumRefAskPriceSupplier * Create a document onto disk according to template module. * * @param DoliDB $db Database handler - * @param object $object Object askpricesupplier + * @param AskPriceSupplier $object Object askpricesupplier * @param string $modele Force model to use ('' to not force) * @param Translate $outputlangs Object langs to use for output * @param int $hidedetails Hide details of lines diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index 2caf1f905e6..9253f4dc650 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -45,7 +45,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -153,7 +153,7 @@ abstract class ModeleNumRefCommandes * Create a document onto disk accordign to template module. * * @param DoliDB $db Database handler - * @param Object $object Object order + * @param Commande $object Object order * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines diff --git a/htdocs/core/modules/contract/modules_contract.php b/htdocs/core/modules/contract/modules_contract.php index 9ffd5d93881..d4311bf3028 100644 --- a/htdocs/core/modules/contract/modules_contract.php +++ b/htdocs/core/modules/contract/modules_contract.php @@ -44,7 +44,7 @@ abstract class ModelePDFContract extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -148,7 +148,7 @@ class ModelNumRefContracts * Create a contract document on disk using template defined into CONTRACT_ADDON_PDF * * @param DoliDB $db objet base de donnee - * @param Object $object Object contract + * @param Contrat $object Object contract * @param string $modele force le modele a utiliser ('' par defaut) * @param Translate $outputlangs objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index d676d2c6f70..8c894e7fa1f 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -40,7 +40,7 @@ abstract class ModeleDon extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php index 43292ae95c4..d9205503e11 100644 --- a/htdocs/core/modules/expedition/modules_expedition.php +++ b/htdocs/core/modules/expedition/modules_expedition.php @@ -43,7 +43,7 @@ abstract class ModelePdfExpedition extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -146,7 +146,7 @@ abstract class ModelNumRefExpedition * Cree un bon d'expedition sur disque * * @param DoliDB $db Objet base de donnee - * @param Object $object Object expedition + * @param Expedition $object Object expedition * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs Objet lang a utiliser pour traduction * @return int <=0 if KO, >0 if OK diff --git a/htdocs/core/modules/expensereport/modules_expensereport.php b/htdocs/core/modules/expensereport/modules_expensereport.php index 3fa32af0fdf..5a6dcf29a34 100755 --- a/htdocs/core/modules/expensereport/modules_expensereport.php +++ b/htdocs/core/modules/expensereport/modules_expensereport.php @@ -30,7 +30,7 @@ class ModeleExpenseReport extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -52,7 +52,7 @@ class ModeleExpenseReport extends CommonDocGenerator * expensereport_pdf_create * * @param DoliDB $db Database handler - * @param Object $object Object order + * @param ExpenseReport $object Object order * @param string $message Message * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs objet lang a utiliser pour traduction diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 62599016b3d..113f35299ca 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -43,7 +43,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * Load into memory list of available export format * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates (same content than array this->driverlabel) */ function liste_modeles($db,$maxfilenamelength=0) diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index bca513e3fd6..2bf03edf557 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -43,7 +43,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -148,7 +148,7 @@ abstract class ModeleNumRefFactures * Create a document onto disk according to template module. * * @param DoliDB $db Database handler - * @param Object $object Object invoice + * @param Facture $object Object invoice * @param string $modele Force template to use ('' to not force) * @param Translate $outputlangs objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php index cc5726ed0c8..38fe5078d9e 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -147,7 +147,7 @@ class ExpeditionLineBatch extends CommonObject /** * Delete batch record attach to a shipment * - * @param object $db Database object + * @param DoliDB $db Database object * @param int $id_expedition rowid of shipment * @return int -1 if KO, 1 if OK */ @@ -172,7 +172,7 @@ class ExpeditionLineBatch extends CommonObject /** * Retrieve all batch number details link to a shipment line * - * @param object $db Database object + * @param DoliDB $db Database object * @param int $id_line_expdet id of shipment line * @return variant -1 if KO, array of ExpeditionLineBatch if OK */ From 0d801be6a1563f1c6b39683ab901b2ea69dce3b0 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 6 Mar 2015 06:12:47 +0100 Subject: [PATCH 31/80] NEW: (Dev) DolGraph allow extended class to override $_stringtoshow --- htdocs/core/class/dolgraph.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index c400dc151d3..5451d7457ce 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -65,7 +65,7 @@ class DolGraph var $bgcolorgrid=array(255,255,255); // array(R,G,B) var $datacolor; // array(array(R,G,B),...) - private $_stringtoshow; // To store string to output graph into HTML page + protected $_stringtoshow; // To store string to output graph into HTML page /** From 9a7346f8895e54ef6e4727c87837b4726522b2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Fri, 6 Mar 2015 12:09:23 +0100 Subject: [PATCH 32/80] Update ChangeLog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index e861f04ae86..0664bda856d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ English Dolibarr ChangeLog - Fix: [ bug #1827 ] Tax reports gives incorrect amounts when using external modules that create lines with special codes - Fix: [ bug #1822 ] SQL error in clientfourn.php report with PostgreSQL - Fix: [ bug #1832 ] SQL error when adding a product with no price defined to an object +- Fix: [ bug #1833 ] user permissions in contact/note.php not working - Fix: [ bug #1826 ] Supplier payment types are not translated into fourn/facture/paiement.php - Fix: [ bug #1830 ] Salaries payment only allows checking accounts - Fix: [ bug #1825 ] External agenda: hide/show checkbox doesn't work From 77dd07c846e335869800b6e1e0f01ed6c7086e3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 13:12:33 +0100 Subject: [PATCH 33/80] Fix thumbs generation --- htdocs/categories/class/categorie.class.php | 16 +++++++++----- htdocs/product/class/product.class.php | 24 +++++++++++++-------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index f5828ecdea7..b9876bb8382 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1330,17 +1330,23 @@ class Categorie extends CommonObject * Build thumb * * @param string $file Chemin du fichier d'origine - * @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut) - * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut) * @return void */ - function add_thumb($file, $maxWidth = 160, $maxHeight = 120) + function add_thumb($file) { - require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; + global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... if (file_exists($file)) { - vignette($file,$maxWidth,$maxHeight); + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($file, $maxwidthsmall, $maxheightsmall, '_small', $quality); + + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($file, $maxwidthmini, $maxheightmini, '_mini', $quality); } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e26f9102544..653925701ad 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3100,11 +3100,9 @@ class Product extends CommonObject * * @param string $sdir Target directory * @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...) - * @param int $maxWidth Largeur maximum que dois faire la miniature (160 by defaut) - * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 by defaut) * @return int <0 if KO, >0 if OK */ - function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120) + function add_photo($sdir, $file) { global $conf; @@ -3114,10 +3112,12 @@ class Product extends CommonObject $dir = $sdir; if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos"; + else $dir .= '/'.dol_sanitizeFileName($this->ref); dol_mkdir($dir); $dir_osencoded=$dir; + if (is_dir($dir_osencoded)) { $originImage = $dir . '/' . $file['name']; @@ -3128,7 +3128,7 @@ class Product extends CommonObject if (file_exists(dol_osencode($originImage))) { // Cree fichier en taille vignette - $this->add_thumb($originImage,$maxWidth,$maxHeight); + $this->add_thumb($originImage); } } @@ -3140,18 +3140,24 @@ class Product extends CommonObject * Build thumb * * @param string $file Chemin du fichier d'origine - * @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut) - * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut) * @return void */ - function add_thumb($file, $maxWidth = 160, $maxHeight = 120) + function add_thumb($file) { - require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; + global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... $file_osencoded=dol_osencode($file); if (file_exists($file_osencoded)) { - vignette($file,$maxWidth,$maxHeight); + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($file, $maxwidthsmall, $maxheightsmall, '_small', $quality); + + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($file, $maxwidthmini, $maxheightmini, '_mini', $quality); } } From a169b3348ee2d5249baccc0fadc8adeffd747c75 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 14:36:22 +0100 Subject: [PATCH 34/80] Fix show alays date fields for contract module. Fix select of product were lost. --- htdocs/commande/card.php | 32 +++++++++++------------ htdocs/core/tpl/objectline_create.tpl.php | 22 +++++++--------- htdocs/fourn/commande/card.php | 6 ++--- htdocs/product/class/product.class.php | 4 +-- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 12150f9a61e..27c333eec21 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -207,13 +207,13 @@ if (empty($reshook)) if ($datecommande == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), 'errors'); $action = 'create'; - $error ++; + $error++; } if ($socid < 1) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); $action = 'create'; - $error ++; + $error++; } if (! $error) { @@ -334,7 +334,7 @@ if (empty($reshook)) $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); if ($result < 0) { - $error ++; + $error++; break; } @@ -349,14 +349,14 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) - $error ++; + $error++; } else { setEventMessage($srcobject->error, 'errors'); - $error ++; + $error++; } } else { setEventMessage($object->error, 'errors'); - $error ++; + $error++; } } else { // Required extrafield left blank, error message already defined by setOptionalsFromPost() @@ -390,7 +390,7 @@ if (empty($reshook)) $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); if ($result < 0) { setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); - $error ++; + $error++; } } @@ -554,24 +554,24 @@ if (empty($reshook)) if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error ++; + $error++; } if ($qty == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); - $error ++; + $error++; } if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { @@ -826,7 +826,7 @@ if (empty($reshook)) if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); - $error ++; + $error++; } } else { $type = GETPOST('type'); @@ -835,7 +835,7 @@ if (empty($reshook)) // Check parameters if (GETPOST('type') < 0) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; + $error++; } } @@ -1137,10 +1137,10 @@ if (empty($reshook)) if (empty($reshook)) { $result = $object->insertExtraFields(); if ($result < 0) { - $error ++; + $error++; } } else if ($reshook < 0) - $error ++; + $error++; } if ($error) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 6037f6c77c9..e3f2431783f 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -153,12 +153,12 @@ else { if (empty($senderissupplier)) { - $form->select_produits('', 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id); + $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id); } else { $ajaxoptions=array( - 'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tag will be edited with which ajax json response key + 'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tags that will be edited with which ajax json response key 'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error' ); @@ -192,23 +192,16 @@ else { service->enabled) && $dateSelector && GETPOST('type') != '0') +if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; else $colspan = 9; @@ -493,6 +486,11 @@ jQuery(document).ready(function() { if (jQuery('#idprod').val() > 0) jQuery('#dp_desc').focus(); if (jQuery('#idprodfournprice').val() > 0) jQuery('#dp_desc').focus(); }); + + + setforpredef(); + + }); /* Function to set fields from choice */ diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 7750250b00b..eefd5c961e2 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -251,7 +251,7 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $idprod=0; $productsupplier = new ProductFournisseur($db); - if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-2; // Same behaviour than with combolist. When not select idprodfournprice is now -2 (to avoid conflict with next action that may return -1) + if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (GETPOST('idprodfournprice') > 0) { @@ -294,12 +294,12 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $date_end ); } - if ($idprod == -2 || $idprod == 0) + if ($idprod == 0 || $idprod == -99) { // Product not selected $error++; $langs->load("errors"); - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")), 'errors'); + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), 'errors'); } if ($idprod == -1) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 653925701ad..ac3d8e967a2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1229,14 +1229,14 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -3; } } } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -2; } } From e55a983c0373da451c4f4b07280afa82a0ecf0fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 16:13:09 +0100 Subject: [PATCH 35/80] Fix td balance --- htdocs/fourn/commande/dispatch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index a68f11f0f69..81c9e410c28 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -393,7 +393,7 @@ if ($id > 0 || ! empty($ref)) } else { - print '"; } From dd3f569ede8ee53737d0643a515dfd3a2084e934 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 20:34:00 +0100 Subject: [PATCH 36/80] NEW: Enhance the natural_search function so we can use it to search numeric fields with criteria with operator <>= inside (< 100, >= 1000) --- htdocs/core/lib/functions.lib.php | 62 +++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 438f0ee22ca..c5d8d509b08 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4946,34 +4946,64 @@ function dol_getmypid() /** - * Natural search + * Generate natural SQL search string * - * @param mixed $fields String or array of strings filled with the fields names in the SQL query - * @param string $value The value to look for (example: "keyword1 keyword2") - * @return string $res The statement to append to the SQL query + * @param string|string[] $fields String or array of strings, filled with the name of fields in the SQL query + * @param string $value The value to look for. + * If param $numeric is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2 + * If param $numeric is 1, can contains an operator <>= like "<10" or ">=100.5 < 1000" + * @param string $number 0=value is list of keywords, 1=value is a numeric test + * @return string $res The statement to append to the SQL query */ -function natural_search($fields, $value) +function natural_search($fields, $value, $numeric=0) { - global $db; + global $db,$langs; + + if ($numeric) + { + $value=preg_replace('/([<>=]+)\s([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do + } $crits = explode(' ', $value); $res = ''; if (! is_array($fields)) $fields = array($fields); - $end = count($fields); + $nboffields = count($fields); $end2 = count($crits); $j = 0; - foreach ($crits as $crit) { - $i = 0; - foreach ($fields as $field) { - if ( $i > 0 && $i < $end) $res .= " OR "; - $res .= $field . " LIKE '%" . $db->escape(trim($crit)) . "%'"; + foreach ($crits as $crit) + { + $i = 0; $i2 = 0; + $newres = ''; + foreach ($fields as $field) + { + if ($numeric) + { + $operator='='; + $newcrit = preg_replace('/([<>=]+)/','',trim($crit)); + + preg_match('/([<>=]+)/',trim($crit), $reg); + if ($reg[1]) + { + $operator = $reg[1]; + } + if ($newcrit != '') + { + $newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' '.$operator.' '.price2num($newcrit); + $i2++; // a criteria was added to string + } + } + else + { + $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " LIKE '%" . $db->escape(trim($crit)) . "%'"; + $i2++; // a criteria was added to string + } $i++; } - if ($end > 1) $res .= ')'; - if ($j < $end2 - 1) $res .= " AND "; - if ($end > 1 && $j < $end2 - 1) $res .= '('; + if ($newres) $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') .$newres . ($i2 > 1 ? ')' : ''); $j++; } - return " AND " . ($end > 1? '(' : '') . $res; + $res = " AND (" . $res . ")"; + //print 'xx'.$res.'yy'; + return $res; } From 9e4e9a54111ae543692a77d1eac08b58151bfac1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 20:59:18 +0100 Subject: [PATCH 37/80] NEW: Can search on customer order amount into customer order list. --- htdocs/comm/card.php | 2 +- htdocs/comm/propal/list.php | 10 +++++----- htdocs/commande/list.php | 18 ++++++++++++++---- htdocs/compta/facture.php | 4 ++-- htdocs/compta/facture/list.php | 16 ++++++++-------- htdocs/core/lib/functions.lib.php | 2 +- htdocs/fourn/commande/list.php | 14 +++++++------- htdocs/fourn/facture/list.php | 14 +++++++------- 8 files changed, 45 insertions(+), 35 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index ffc01a998d5..78b786d2366 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -400,7 +400,7 @@ if ($id > 0) // display amount and link to unpaid bill $outstandigBills = $object->get_OutstandingBill(); if ($outstandigBills != 0) - print " / ".price($outstandigBills).''; + print " (".$langs->trans("CurrentOutstandingBill")." ".price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency).')'; print ''; print ''; } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index a3ef72bb6ca..da6e56c9460 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -182,9 +182,9 @@ if ($search_author) { $sql.= " AND u.login LIKE '%".$db->escape(trim($search_author))."%'"; } -if ($search_montant_ht) +if ($search_montant_ht != '') { - $sql.= " AND p.total_ht='".$db->escape(price2num(trim($search_montant_ht)))."'"; + $sql.= natural_search("p.total_ht", $search_montant_ht, 1); } if ($sall) { $sql .= natural_search(array('s.nom', 'p.note_private', 'p.note_public', 'pd.description'), $sall); @@ -316,12 +316,12 @@ if ($result) print ''; print ''; // Amount - print ''; // Author print ''; print ''; - print ''; + print ''; print '\n"; @@ -328,7 +337,8 @@ if ($resql) $generic_commande = new Commande($db); $generic_product = new Product($db); - while ($i < min($num,$limit)) { + while ($i < min($num,$limit)) + { $objp = $db->fetch_object($resql); $var=!$var; print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 4cb696836bd..d38519bf6d5 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1962,11 +1962,11 @@ if ($action == 'create') // Outstanding Bill $outstandigBills = $soc->get_OutstandingBill(); print ' (' . $langs->trans('CurrentOutstandingBill') . ': '; - print price($outstandigBills, '', $langs, 0, 0, - 1, $conf->currency); + print price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency); if ($soc->outstanding_limit != '') { if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); - print ' / ' . price($soc->outstanding_limit); + print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency); } print ')'; print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 56bd57c725a..dc081424ace 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -187,13 +187,13 @@ if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } -if ($search_montant_ht) +if ($search_montant_ht != '') { - $sql.= ' AND f.total = \''.$db->escape(price2num(trim($search_montant_ht))).'\''; + $sql.= natural_search('f.total', $search_montant_ht, 1); } -if ($search_montant_ttc) +if ($search_montant_ttc != '') { - $sql.= ' AND f.total_ttc = \''.$db->escape(price2num(trim($search_montant_ttc))).'\''; + $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); } if ($search_status != '') { @@ -263,8 +263,8 @@ if ($resql) if ($search_societe) $param.='&search_societe=' .$search_societe; if ($search_sale > 0) $param.='&search_sale=' .$search_sale; if ($search_user > 0) $param.='&search_user=' .$search_user; - if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; - if ($search_montant_ttc) $param.='&search_montant_ttc='.$search_montant_ttc; + if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht; + if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc; print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); $i = 0; @@ -323,9 +323,9 @@ if ($resql) print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; } print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; } print ''; if (! empty($conf->stock->enabled)) { - print ''; + print ''; } else { From fc0be43f5f8e4d4ccb90077bddcd7501c6825220 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 22:40:41 +0100 Subject: [PATCH 39/80] Fix: beautify search box --- htdocs/product/stats/commande.php | 8 +++++--- htdocs/product/stats/commande_fournisseur.php | 8 +++++--- htdocs/product/stats/facture.php | 4 +++- htdocs/product/stats/facture_fournisseur.php | 4 +++- htdocs/product/stats/propal.php | 4 +++- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 2ae1dcd1582..49a443938ab 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -141,9 +141,9 @@ if ($id > 0 || ! empty($ref)) $sql.= " AND d.fk_commande = c.rowid"; $sql.= " AND d.fk_product =".$product->id; if (! empty($search_month)) - $sql.= ' AND MONTH(f.datef) IN (' . $search_month . ')'; + $sql.= ' AND MONTH(c.date_commande) IN (' . $search_month . ')'; if (! empty($search_year)) - $sql.= ' AND YEAR(f.datef) IN (' . $search_year . ')'; + $sql.= ' AND YEAR(c.date_commande) IN (' . $search_year . ')'; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND c.fk_soc = ".$socid; $sql.= " ORDER BY $sortfield $sortorder "; @@ -189,12 +189,14 @@ if ($id > 0 || ! empty($ref)) print_barre_liste($langs->trans("CustomersOrders"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,$totalrecords,''); print '
'; - print $langs->trans('Period').'('.$langs->trans("DateInvoice") .') '; + print $langs->trans('Period').' ('.$langs->trans("OrderDate") .') - '; print $langs->trans('Month') . ': '; print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; print ''; print ''; print '
'; + print '
'; $i = 0; print '
'.$langs->trans("TableName").'Rows'.$langs->trans("NbOfRecord").'
tva_assuj == "0") echo '0'; - else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); - } + if ($seller->tva_assuj == "0") echo '0'; + else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); ?> - "> - - "> - "> @@ -273,7 +266,7 @@ else {
'; + print ''; print $linktoprod; print "
 '; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; print ''; $formpropal->selectProposalStatus($viewstatut,1); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 9d143d87eb2..c38b1a8e34f 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -51,6 +51,7 @@ $sall=GETPOST('sall'); $socid=GETPOST('socid','int'); $search_user=GETPOST('search_user','int'); $search_sale=GETPOST('search_sale','int'); +$search_total_ht=GETPOST('search_total_ht','alpha'); // Security check $id = (GETPOST('orderid')?GETPOST('orderid'):GETPOST('id','int')); @@ -79,6 +80,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_ref=''; $search_ref_customer=''; $search_company=''; + $search_total_ht=''; $orderyear=''; $ordermonth=''; $deliverymonth=''; @@ -96,6 +98,7 @@ $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + /* * View */ @@ -198,7 +201,10 @@ if ($search_user > 0) { $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; } - +if ($search_total_ht != '') +{ + $sql.= natural_search('c.total_ht', $search_total_ht, 1); +} $sql.= ' ORDER BY '.$sortfield.' '.$sortorder; $nbtotalofrecords = 0; @@ -252,7 +258,8 @@ if ($resql) if ($search_ref_customer) $param.='&search_ref_customer='.$search_ref_customer; if ($search_user > 0) $param.='&search_user='.$search_user; if ($search_sale > 0) $param.='&search_sale='.$search_sale; - + if ($search_total_ht != '') $param.='&search_total_ht='.$search_total_ht; + $num = $db->num_rows($resql); print_barre_liste($title, $page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); $i = 0; @@ -316,7 +323,9 @@ if ($resql) print ''; $formother->select_year($deliveryyear?$deliveryyear:-1,'deliveryyear',1, 20, 5); print ' '; + print ''; + print ''; print ''; print "
   '; print ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c5d8d509b08..509f237b0d6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4961,7 +4961,7 @@ function natural_search($fields, $value, $numeric=0) if ($numeric) { - $value=preg_replace('/([<>=]+)\s([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do + $value=preg_replace('/([<>=]+)\s([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do } $crits = explode(' ', $value); $res = ''; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 613eb463366..6926997f0f1 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -100,7 +100,7 @@ $offset = $conf->liste_limit * $page ; /* - * Mode Liste + * Mode list */ $sql = "SELECT s.rowid as socid, s.nom as name, cf.date_commande as dc,"; @@ -130,13 +130,13 @@ if ($search_user) { $sql.= " AND u.login LIKE '%".$db->escape($search_user)."%'"; } -if ($search_ht) +if ($search_ht != '') { - $sql .= " AND cf.total_ht = '".$db->escape(price2num($search_ht))."'"; + $sql .= natural_search("cf.total_ht",$search_ht, 1); } -if ($search_ttc) +if ($search_ttc != '') { - $sql .= " AND cf.total_ttc = '".$db->escape(price2num($search_ttc))."'"; + $sql .= natural_search("cf.total_ttc", $search_ttc, 1); } if ($sall) { @@ -214,8 +214,8 @@ if ($resql) print '  '; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index d59870d8fc5..66ad20e4c05 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -153,7 +153,7 @@ if ($search_ref) if (is_numeric($search_ref)) $sql .= natural_search(array('fac.ref'), $search_ref); else $sql .= natural_search('fac.ref', $search_ref); } -if (search_ref_supplier) +if ($search_ref_supplier) { $sql .= natural_search('fac.ref_supplier', $search_ref_supplier); } @@ -178,14 +178,14 @@ if ($search_company) $sql .= natural_search('s.nom', $search_company); } -if ($search_amount_no_tax) +if ($search_amount_no_tax != '') { - $sql .= " AND fac.total_ht = '".$db->escape(price2num($search_amount_no_tax))."'"; + $sql .= natural_search('fac.total_ht', $search_amount_no_tax, 1); } -if ($search_amount_all_tax) +if ($search_amount_all_tax != '') { - $sql .= " AND fac.total_ttc = '".$db->escape(price2num($search_amount_all_tax))."'"; + $sql .= natural_search('fac.total_ttc', $search_amount_all_tax, 1); } $nbtotalofrecords = 0; @@ -270,9 +270,9 @@ if ($resql) print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; $liststatus=array('paye:0'=>$langs->trans("Unpaid"), 'paye:1'=>$langs->trans("Paid")); print $form->selectarray('filtre', $liststatus, $filter, 1); From c80007c6801840bc0cb2ba2179be92d922c19f08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 21:57:58 +0100 Subject: [PATCH 38/80] Fix: we must use stockreal of stockvirtual when we are speaking about stock ('stock' alone is not accurate enough) --- htdocs/expedition/shipment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index d5d82f2baa3..973066971a3 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -402,7 +402,7 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("KeepToShip").''.$langs->trans("Stock").''.$langs->trans("RealStock").'
'; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 3141b3266e9..8cbdea41495 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -150,9 +150,9 @@ if ($id > 0 || ! empty($ref)) { $sql .= " AND d.fk_commande = c.rowid"; $sql .= " AND d.fk_product =" . $product->id; if (! empty($search_month)) - $sql .= ' AND MONTH(f.datef) IN (' . $search_month . ')'; + $sql .= ' AND MONTH(c.date_commande) IN (' . $search_month . ')'; if (! empty($search_year)) - $sql .= ' AND YEAR(f.datef) IN (' . $search_year . ')'; + $sql .= ' AND YEAR(c.date_commande) IN (' . $search_year . ')'; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; if ($socid) @@ -199,12 +199,14 @@ if ($id > 0 || ! empty($ref)) { print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); print '
'; - print $langs->trans('Period') . '(' . $langs->trans("DateInvoice") . ') '; + print $langs->trans('Period') . ' (' . $langs->trans("OrderDate") . ') - '; print $langs->trans('Month') . ': '; print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; print ''; print ''; print '
'; + print '
'; $i = 0; print '
'; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index b59bc008f17..2ae8164b0f9 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -190,12 +190,14 @@ if ($id > 0 || ! empty($ref)) print_barre_liste($langs->trans("CustomersInvoices"),$page,$_SERVER["PHP_SELF"],"&id=".$product->id,$sortfield,$sortorder,'',$num,$totalrecords,''); print '
'; - print $langs->trans('Period').'('.$langs->trans("DateInvoice") .') '; + print $langs->trans('Period').' ('.$langs->trans("DateInvoice") .') - '; print $langs->trans('Month') . ': '; print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; print ''; print ''; print '
'; + print '
'; $i = 0; print '
'; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 0feb415cc43..2e8e84621ba 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -191,12 +191,14 @@ if ($id > 0 || ! empty($ref)) print_barre_liste($langs->trans("SuppliersInvoices"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); print '
'; - print $langs->trans('Period') . '(' . $langs->trans("DateInvoice") . ') '; + print $langs->trans('Period') . ' (' . $langs->trans("DateInvoice") . ') - '; print $langs->trans('Month') . ': '; print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; print ''; print ''; print '
'; + print '
'; $i = 0; print '
'; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 50d7c952b6d..10fd8247204 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -192,12 +192,14 @@ if ($id > 0 || ! empty($ref)) print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); print '
'; - print $langs->trans('Period') . '(' . $langs->trans("DateInvoice") . ') '; + print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - '; print $langs->trans('Month') . ': '; print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; print ''; print ''; print '
'; + print '
'; $i = 0; print '
'; From df305bd31661351190d95fff91323b4bf840fb5b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 7 Mar 2015 15:01:30 +0100 Subject: [PATCH 40/80] Deactivate conflict with Mod Deplacement - Need to access on old data --- htdocs/core/modules/modExpenseReport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index 5d826ae9a54..cf106fa4588 100755 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -84,7 +84,7 @@ class modExpenseReport extends DolibarrModules // Dependencies $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->conflictwith = array("modDeplacement"); + // $this->conflictwith = array("modDeplacement"); // Deactivate for access on old information $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->phpmin = array(4,3); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,7); // Minimum version of Dolibarr required by module From 402e0c8ad5d90a33cc107b68cc597d9836f862d0 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 7 Mar 2015 15:06:45 +0100 Subject: [PATCH 41/80] Add condition to access on dictionary c_type_fees when the module is enabled --- htdocs/admin/dict.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 05402898ee6..8de52ef73c5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2013 Marcos García * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2014 Alexandre Spangaro + * Copyright (C) 2011-2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -316,7 +316,7 @@ $tabcond[13]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabl $tabcond[14]= (! empty($conf->product->enabled) && ! empty($conf->ecotax->enabled)); $tabcond[15]= true; $tabcond[16]= (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)); -$tabcond[17]= ! empty($conf->deplacement->enabled); +$tabcond[17]= (! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)); $tabcond[18]= ! empty($conf->expedition->enabled); $tabcond[19]= ! empty($conf->societe->enabled); $tabcond[20]= ! empty($conf->fournisseur->enabled); From f780e908f419cf49421177870283050765368eba Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 7 Mar 2015 15:14:51 +0100 Subject: [PATCH 42/80] Add index.html --- htdocs/expensereport/ajax/index.html | 0 htdocs/expensereport/class/index.html | 0 htdocs/expensereport/index.html | 0 htdocs/expensereport/stats/index.html | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 htdocs/expensereport/ajax/index.html create mode 100644 htdocs/expensereport/class/index.html create mode 100644 htdocs/expensereport/index.html create mode 100644 htdocs/expensereport/stats/index.html diff --git a/htdocs/expensereport/ajax/index.html b/htdocs/expensereport/ajax/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/expensereport/class/index.html b/htdocs/expensereport/class/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/expensereport/index.html b/htdocs/expensereport/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/expensereport/stats/index.html b/htdocs/expensereport/stats/index.html new file mode 100644 index 00000000000..e69de29bb2d From 1baf71874ccf9a9e366a39db617f284f6e70e4cf Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 7 Mar 2015 15:31:23 +0100 Subject: [PATCH 43/80] Sql & $_SERVER["PHP_SELF"] --- htdocs/expensereport/card.php | 10 +++++----- .../class/expensereport.class.php | 20 +++++++++---------- htdocs/expensereport/list.php | 10 +++++----- htdocs/expensereport/synchro_compta.php | 18 ++++++++--------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 86c113c24da..345d983b2f6 100755 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -733,12 +733,12 @@ if ($action == "confirm_paid" && GETPOST('confirm')=="yes" && $id > 0 && $user-> $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); if ($insertid > 0): - $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport d"; + $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " SET integration_compta = 1, fk_bank_account = $idAccount"; $sql.= " WHERE rowid = $idTrip"; $resql=$db->query($sql); if($result): - Header("Location: ".$_SEVER["PHP_SELF"]."?id=".$id); + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; else: dol_print_error($db); @@ -1529,9 +1529,9 @@ else $sql.= ' fde.fk_c_tva as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; $sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det fde'; - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees ctf ON fde.fk_c_type_fees=ctf.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet pjt ON fde.fk_projet=pjt.rowid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde'; + $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pjt ON fde.fk_projet=pjt.rowid'; $sql.= ' WHERE fde.fk_expensereport = '.$id; $resql = $db->query($sql); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index b31329fae95..c34edc5ff79 100755 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -270,7 +270,7 @@ class ExpenseReport extends CommonObject $sql.= " d.fk_user_author, d.fk_user_validator, d.fk_c_expensereport_statuts as status, d.fk_c_paiement,"; $sql.= " d.fk_user_valid, d.fk_user_approve, d.fk_user_paid,"; $sql.= " dp.libelle as libelle_paiement, dp.code as code_paiement"; // INNER JOIN paiement - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." d LEFT JOIN ".MAIN_DB_PREFIX."c_paiement dp ON d.fk_c_paiement = dp.id"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id"; if ($ref) $sql.= " WHERE d.ref = '".$this->db->escape($ref)."'"; else $sql.= " WHERE d.rowid = ".$id; $sql.= $restrict; @@ -707,8 +707,8 @@ class ExpenseReport extends CommonObject $sql.= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,'; $sql.= ' p.ref as ref_projet, p.title as title_projet'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as de'; - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees ctf ON de.fk_c_type_fees = ctf.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet p ON de.fk_projet = p.rowid'; + $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON de.fk_projet = p.rowid'; $sql.= ' WHERE de.'.$this->fk_element.' = '.$this->id; dol_syslog('ExpenseReport::fetch_lines sql='.$sql, LOG_DEBUG); @@ -1186,7 +1186,7 @@ class ExpenseReport extends CommonObject // Select du taux de tva par rapport au code $sql = "SELECT t.taux as taux_tva"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva t"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t"; $sql.= " WHERE t.rowid = ".$c_tva; $result = $this->db->query($sql); $objp_tva = $this->db->fetch_object($result); @@ -1222,7 +1222,7 @@ class ExpenseReport extends CommonObject // Select des infos sur le type fees $sql = "SELECT c.code as code_type_fees, c.label as libelle_type_fees"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_type_fees c"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_type_fees as c"; $sql.= " WHERE c.id = ".$type_fees_id; $result = $this->db->query($sql); $objp_fees = $this->db->fetch_object($result); @@ -1231,7 +1231,7 @@ class ExpenseReport extends CommonObject // Select des informations du projet $sql = "SELECT p.ref as ref_projet, p.title as title_projet"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet p"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " WHERE p.rowid = ".$projet_id; $result = $this->db->query($sql); $objp_projet = $this->db->fetch_object($result); @@ -1460,9 +1460,9 @@ class ExpenseReportLine $sql.= ' fde.fk_c_tva as tva_taux, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; $sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det fde'; - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees ctf ON fde.fk_c_type_fees=ctf.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet pjt ON fde.fk_projet=pjt.rowid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde'; + $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pjt ON fde.fk_projet=pjt.rowid'; $sql.= ' WHERE fde.rowid = '.$rowid; $result = $this->db->query($sql); @@ -1708,4 +1708,4 @@ function select_type_fees_id($selected='',$htmlname='type',$showempty=0) } } print ''; -} +} \ No newline at end of file diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index d6700ac26a2..76a72836e17 100755 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -88,16 +88,16 @@ $pagenext = $page + 1; $sql = "SELECT d.rowid, d.ref, d.total_ht, d.total_tva, d.total_ttc, d.fk_c_expensereport_statuts as status,"; $sql.= " d.date_debut, d.date_fin,"; $sql.= " u.rowid as id_user, u.firstname, u.lastname"; -$sql.= " FROM ".MAIN_DB_PREFIX."expensereport d\n"; -$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user u ON d.fk_user_author = u.rowid\n"; +$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; +$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid"; // WHERE if(!empty($search_ref)){ - $sql.= " WHERE d.ref LIKE '%".$db->escape($search_ref)."%'\n"; + $sql.= " WHERE d.ref LIKE '%".$db->escape($search_ref)."%'"; }else{ - $sql.= " WHERE 1 = 1\n"; + $sql.= " WHERE 1 = 1"; } // DATE START if ($month_start > 0) { @@ -156,7 +156,7 @@ if ($month_start > 0) { } } } -if (!empty($search_user) && $search_user > 0) $sql.= " AND d.fk_user_author = ".$search_user."\n"; +if (!empty($search_user) && $search_user > 0) $sql.= " AND d.fk_user_author = '".$search_user."'"; if($search_state != '') $sql.= " AND d.fk_c_expensereport_statuts = '$search_state'\n"; // RESTRICT RIGHTS diff --git a/htdocs/expensereport/synchro_compta.php b/htdocs/expensereport/synchro_compta.php index b8f7760e409..a436f92e682 100755 --- a/htdocs/expensereport/synchro_compta.php +++ b/htdocs/expensereport/synchro_compta.php @@ -49,12 +49,12 @@ if ($_GET["action"] == 'confirm_ndf_to_account' && $_GET["confirm"] == "yes"): $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); if ($insertid > 0): - $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport d"; + $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " SET integration_compta = 1, fk_bank_account = $idAccount"; $sql.= " WHERE rowid = $idTrip"; $resql=$db->query($sql); if($result): - Header("Location: synchro_compta.php?account=".$idAccount); + Header("Location: ".$_SERVER["PHP_SELF"]."?account=".$idAccount); exit; else: dol_print_error($db); @@ -75,12 +75,12 @@ if ($_GET["action"] == 'confirm_account_to_ndf' && $_GET["confirm"] == "yes"): $sql.= " WHERE label LIKE '%".$expensereport->ref."%'"; $resql=$db->query($sql); if ($resql > 0): - $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport d"; + $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " SET integration_compta = 0, fk_bank_account = 0"; $sql.= " WHERE rowid = $idTrip"; $resql=$db->query($sql); if($result): - Header("Location: synchro_compta.php?account=".$idAccount); + Header("Location: ".$_SERVER["PHP_SELF"]."?account=".$idAccount); exit; else: dol_print_error($db); @@ -110,13 +110,13 @@ dol_fiche_head(''); if ($_GET["action"] == 'ndfTOaccount'): $idTrip = $_GET['idTrip']; - $ret=$html->form_confirm("synchro_compta.php?idTrip=".$idTrip."&account=".$idAccount,$langs->trans("ndfToAccount"),$langs->trans("ConfirmNdfToAccount"),"confirm_ndf_to_account","","",1); + $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?idTrip=".$idTrip."&account=".$idAccount,$langs->trans("ndfToAccount"),$langs->trans("ConfirmNdfToAccount"),"confirm_ndf_to_account","","",1); if ($ret == 'html') print '
'; endif; if ($_GET["action"] == 'accountTOndf'): $idTrip = $_GET['idTrip']; - $ret=$html->form_confirm("synchro_compta.php?idTrip=".$idTrip."&account=".$idAccount,$langs->trans("AccountToNdf"),$langs->trans("ConfirmAccountToNdf"),"confirm_account_to_ndf","","",1); + $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?idTrip=".$idTrip."&account=".$idAccount,$langs->trans("AccountToNdf"),$langs->trans("ConfirmAccountToNdf"),"confirm_account_to_ndf","","",1); if ($ret == 'html') print '
'; endif; @@ -138,8 +138,8 @@ else: $sql = "SELECT d.fk_bank_account, d.ref, d.rowid, d.date_valid, d.fk_user_author, d.total_ttc, d.integration_compta, d.fk_c_expensereport_statuts"; $sql.= " ,CONCAT(u.firstname,' ',u.lastname) as declarant_NDF"; - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport d"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user u ON d.fk_user_author = u.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid"; $sql.= " WHERE d.fk_c_expensereport_statuts = 6"; $sql.= " ORDER BY d.date_valid DESC"; @@ -200,7 +200,7 @@ else: print "
"; else: - print '
'.$langs->trans("AucuneTripToSynch").'
'; + print '
'.$langs->trans("NoTripToSync").'
'; endif; $db->free($resql); From 2c738df1970fd460bbd65e955573801dc2e186a0 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 7 Mar 2015 15:34:58 +0100 Subject: [PATCH 44/80] Add GPLV3 & Copyright --- .../class/expensereport.class.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index c34edc5ff79..e1ddbc6198b 100755 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1,5 +1,22 @@ + * Copyright (C) 2015 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; /** * Class to manage Trips and Expenses From 55db57d10c8fd8c0eeb5acc3186892bc3af25ef0 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 7 Mar 2015 15:41:30 +0100 Subject: [PATCH 45/80] Path --- htdocs/expensereport/class/expensereportstats.class.php | 4 ++-- htdocs/expensereport/export_csv.php | 4 ++-- htdocs/expensereport/index.php | 4 ++-- htdocs/expensereport/list.php | 4 ++-- htdocs/expensereport/synchro_compta.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 9536d59937d..5d71be15738 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -19,11 +19,11 @@ /** * \file htdocs/expensereport/class/expensereportstats.class.php - * \ingroup factures + * \ingroup ExpenseReport * \brief Fichier de la classe de gestion des stats des expensereport et notes de frais */ include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -dol_include_once('/expensereport/class/expensereport.class.php'); +include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; /** * Classe permettant la gestion des stats des expensereports et notes de frais diff --git a/htdocs/expensereport/export_csv.php b/htdocs/expensereport/export_csv.php index 05036deaf7c..8228eb68532 100755 --- a/htdocs/expensereport/export_csv.php +++ b/htdocs/expensereport/export_csv.php @@ -21,8 +21,8 @@ */ require '../main.inc.php'; -require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); -dol_include_once("/expensereport/class/expensereport.class.php"); +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; $langs->load("users"); $langs->load("trips"); diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 89469609e2a..b90e6416192 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -25,8 +25,8 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -dol_include_once("/expensereport/class/expensereport.class.php"); +require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; $langs->load("companies"); $langs->load("users"); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 76a72836e17..44f1426fd36 100755 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -25,8 +25,8 @@ */ require "../main.inc.php"; -dol_include_once("/expensereport/class/expensereport.class.php"); -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; $langs->load("companies"); $langs->load("users"); diff --git a/htdocs/expensereport/synchro_compta.php b/htdocs/expensereport/synchro_compta.php index a436f92e682..ec2703d059a 100755 --- a/htdocs/expensereport/synchro_compta.php +++ b/htdocs/expensereport/synchro_compta.php @@ -16,8 +16,8 @@ */ require '../main.inc.php'; -require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'); -dol_include_once("/expensereport/class/expensereport.class.php"); +require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; $langs->load("companies"); $langs->load("users"); From 26b1f6902548a7b86c66283bb863695718ba3d7c Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 7 Mar 2015 15:47:08 +0100 Subject: [PATCH 46/80] Add traduction on type label --- .../class/expensereport.class.php | 33 +++++++++++++++++++ htdocs/expensereport/index.php | 3 +- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index e1ddbc6198b..c14c7ff2be7 100755 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1420,6 +1420,39 @@ class ExpenseReport extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } + + /** + * List of types + * + * @param int $active Active or not + * @return array + */ + 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; + } } diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index b90e6416192..ec9ccba2c0b 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -111,8 +111,7 @@ print ''; print ''.$langs->trans("Statistics").''; print "\n"; -//$listoftype=$tripandexpense_static->listOfTypes(); -$listoftype=$label; +$listoftype=$tripandexpense_static->listOfTypes(); foreach ($listoftype as $code => $label) { $dataseries[]=array('label'=>$label,'data'=>(isset($somme[$code])?(int) $somme[$code]:0)); From 6db3f1b30ed294d0054d35830b64d64c3977745f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Mar 2015 19:06:56 +0100 Subject: [PATCH 47/80] Add mdule askpricesupplier into MAIN__MODULES_FOR_EXTERNAL --- htdocs/core/class/conf.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 67b5b8147d5..b6cc390ca33 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -452,7 +452,7 @@ class Conf $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024); // Define list of limited modules - if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later. + if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,askpricesupplier,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later. // Enable select2 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)) $conf->global->MAIN_USE_JQUERY_MULTISELECT='select2'; From 56b5bfd25b63041cb8d0298b939da4721e5509a7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Mar 2015 02:08:26 +0100 Subject: [PATCH 48/80] NEW: Implement option SUPPLIER_ORDER_USE_DISPATCH_STATUS to add a status into each dispathing line of supplier order to "verify" a reception is ok. Status of order can be set to "total/done" only if line is verified. --- htdocs/core/class/commonobject.class.php | 3 +- htdocs/core/class/html.formorder.class.php | 6 +- .../class/fournisseur.commande.class.php | 82 +++++++++++-- .../fournisseur.commande.dispatch.class.php | 18 +-- htdocs/fourn/commande/card.php | 25 ++-- htdocs/fourn/commande/dispatch.php | 113 +++++++++++++----- htdocs/fourn/commande/list.php | 10 +- htdocs/langs/en_US/errors.lang | 1 + htdocs/langs/en_US/main.lang | 2 + htdocs/langs/en_US/orders.lang | 1 + htdocs/theme/eldy/style.css.php | 9 ++ 11 files changed, 200 insertions(+), 70 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8ad8ecd2331..02ccd13b97c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2141,7 +2141,8 @@ abstract class CommonObject $fieldstatus="fk_statut"; if ($elementTable == 'user') $fieldstatus="statut"; if ($elementTable == 'expensereport') $fieldstatus="fk_c_expensereport_statuts"; - + if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status"; + $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; $sql.= " SET ".$fieldstatus." = ".$status; // If status = 1 = validated, update also fk_user_valid diff --git a/htdocs/core/class/html.formorder.class.php b/htdocs/core/class/html.formorder.class.php index 5ea5b33c1f4..2abc0c38485 100644 --- a/htdocs/core/class/html.formorder.class.php +++ b/htdocs/core/class/html.formorder.class.php @@ -57,11 +57,11 @@ class FormOrder { print ''; + print ''; if (empty($conf->global->SUPPLIER_ORDER_HIDE_REF_SUPPLIER)) print ''; - print ''; + print ''; if (! empty($conf->global->PROJECT_SHOW_REF_INTO_LISTS)) { print ''; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index be75e3a96a3..3d83901194b 100755 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -160,6 +160,7 @@ ErrorPriceExpressionInternal=Internal error '%s' ErrorPriceExpressionUnknown=Unknown error '%s' ErrorSrcAndTargetWarehouseMustDiffers=Source and target warehouses must differs ErrorTryToMakeMoveOnProductRequiringBatchData=Error, trying to make a stock movement without batch/serial information, on a product requiring batch/serial information +ErrorCantSetReceptionToTotalDoneWithReceptionToApprove=All recorded receptions must first be verified before being allowed to do this action # Warnings WarningMandatorySetupNotComplete=Mandatory setup parameters are not yet defined diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index be893d52569..551807aad59 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -159,6 +159,7 @@ Search=Search SearchOf=Search Valid=Valid Approve=Approve +Disapprove=Disapprove ReOpen=Re-Open Upload=Send file ToLink=Link @@ -524,6 +525,7 @@ DateFromTo=From %s to %s DateFrom=From %s DateUntil=Until %s Check=Check +Uncheck=Uncheck Internal=Internal External=External Internals=Internal diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 4f6e0b0dfb2..ea3659b90de 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -42,6 +42,7 @@ StatusOrderCanceled=Canceled StatusOrderDraft=Draft (needs to be validated) StatusOrderValidated=Validated StatusOrderOnProcess=Ordered - Standby reception +StatusOrderOnProcessWithValidation=Ordered - Standby reception or validation StatusOrderProcessed=Processed StatusOrderToBill=Delivered StatusOrderToBill2=To bill diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index ccf54a6f9b5..206b1df019e 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -361,6 +361,15 @@ fieldset { border: 1px solid #AAAAAA !important; box-shadow: 2px 2px 3px #DDD; } -moz-box-shadow: none; cursor: auto; } +.buttonRefused { + pointer-events: none; + cursor: default; + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} form { padding:0px; margin:0px; From 3e4845635962e323eb9d61ff53e54b1875dee8fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Mar 2015 02:13:47 +0100 Subject: [PATCH 49/80] Fix when no price defined, we must how nothing instead of 0 --- htdocs/fourn/product/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index afaf4c8e796..33e1ea46dd9 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -125,7 +125,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } -$sql .= " ORDER BY ".$sortfield." ".$sortorder; +$sql .= $db->order($sortfield,$sortorder); $sql .= $db->plimit($limit + 1, $offset); dol_syslog("fourn/product/list.php:", LOG_DEBUG); @@ -225,11 +225,11 @@ if ($resql) if ($companystatic->id > 0) print $companystatic->getNomUrl(1,'supplier'); print ''; - print ''.price($objp->price).''; + print ''.(isset($objp->price) ? price($objp->price) : '').''; print ''.$objp->qty.''; - print ''.price($objp->unitprice).''; + print ''.(isset($objp->unitprice) ? price($objp->unitprice) : '').''; print "\n"; $i++; From 7c08f33fe184fbebcff5c87e74f5858f2849f051 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Mar 2015 02:26:41 +0100 Subject: [PATCH 50/80] Missing style buttonRefused --- htdocs/theme/amarok/style.css.php | 18 ++++++++++++++++++ htdocs/theme/auguria/style.css.php | 17 +++++++++++++++++ htdocs/theme/bureau2crea/style.css.php | 17 +++++++++++++++++ htdocs/theme/cameleo/style.css.php | 17 +++++++++++++++++ 4 files changed, 69 insertions(+) diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php index bd41d0735a5..c7f3d27dcfb 100644 --- a/htdocs/theme/amarok/style.css.php +++ b/htdocs/theme/amarok/style.css.php @@ -1125,6 +1125,24 @@ td.formdocbutton {padding-top:6px;} ); color:white; } +.button:disabled { + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + cursor: auto; +} +.buttonRefused { + pointer-events: none; + cursor: default; + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} + /* ============================================================================== */ /* Tables */ diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php index 35e0cdd36c9..7278521e092 100644 --- a/htdocs/theme/auguria/style.css.php +++ b/htdocs/theme/auguria/style.css.php @@ -184,6 +184,23 @@ legend { margin-bottom: 8px; } padding: 0px 2px 0px 2px; margin: 0px 0px 0px 0px; } +.button:disabled { + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + cursor: auto; +} +.buttonRefused { + pointer-events: none; + cursor: default; + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} form { padding: 0em 0em 0em 0em; margin: 0em 0em 0em 0em; diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php index b720bd4a802..31071f0b10c 100644 --- a/htdocs/theme/bureau2crea/style.css.php +++ b/htdocs/theme/bureau2crea/style.css.php @@ -209,6 +209,23 @@ legend { margin-bottom: 8px; } padding: 0px 2px 0px 2px; margin: 0px 0px 0px 0px; } +.button:disabled { + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + cursor: auto; +} +.buttonRefused { + pointer-events: none; + cursor: default; + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} form { padding: 0em 0em 0em 0em; margin: 0em 0em 0em 0em; diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php index a49ad6daaec..d09cb844b88 100644 --- a/htdocs/theme/cameleo/style.css.php +++ b/htdocs/theme/cameleo/style.css.php @@ -185,6 +185,23 @@ legend { margin-bottom: 8px; } padding: 0px 2px 0px 2px; margin: 0px 0px 0px 0px; } +.button:disabled { + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + cursor: auto; +} +.buttonRefused { + pointer-events: none; + cursor: default; + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} form { padding: 0em 0em 0em 0em; margin: 0em 0em 0em 0em; From 3894a48ffdaba5acfff20e1c34e71b0c190f9289 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Mar 2015 02:37:25 +0100 Subject: [PATCH 51/80] Fix: bad CSS --- htdocs/compta/bank/index.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 050db37fefc..9c9f0574c31 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -174,7 +174,11 @@ foreach ($accounts as $key=>$type) $total[$acc->currency_code] += $solde; } } -if (! $found) print ''.$langs->trans("None").''; +if (! $found) +{ + $var = !$var; + print ''.$langs->trans("None").''; +} // Total foreach ($total as $key=>$solde) { From f3258d59c6f97e192256815dd5cb002c3f78749b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 8 Mar 2015 07:21:07 +0100 Subject: [PATCH 52/80] Uniformize status & add price() --- htdocs/compta/hrm.php | 8 +-- htdocs/expensereport/card.php | 44 +++++++-------- .../class/expensereport.class.php | 54 +++++++++---------- .../class/expensereportstats.class.php | 2 +- htdocs/expensereport/index.php | 6 +-- htdocs/expensereport/list.php | 4 +- htdocs/expensereport/synchro_compta.php | 4 +- .../install/mysql/migration/3.7.0-3.8.0.sql | 2 +- .../mysql/tables/llx_expensereport.sql | 2 +- 9 files changed, 63 insertions(+), 63 deletions(-) diff --git a/htdocs/compta/hrm.php b/htdocs/compta/hrm.php index 866399ef1cc..59389f41d51 100644 --- a/htdocs/compta/hrm.php +++ b/htdocs/compta/hrm.php @@ -196,7 +196,7 @@ if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) { - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, x.rowid, x.date_debut as date, x.tms as dm, x.total_ttc"; + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, x.rowid, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = x.fk_user_author"; @@ -218,7 +218,7 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -239,9 +239,9 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire print ''; print ''; print ''; - print ''; + print ''; print ''; - //print ''; + print ''; print ''; $var=!$var; $i++; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 345d983b2f6..02d899def0a 100755 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -109,7 +109,7 @@ if ($action == 'add' && $user->rights->expensereport->creer) $object->date_debut = $date_start; $object->date_fin = $date_end; - $object->fk_c_expensereport_statuts = 1; + $object->fk_statut = 1; $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); $object->fk_user_validator = GETPOST('fk_user_validator','int'); $object->note_public = GETPOST('note_public'); @@ -151,7 +151,7 @@ if ($action == 'update' && $user->rights->expensereport->creer) $object->date_debut = $date_start; $object->date_fin = $date_end; - if($object->fk_c_expensereport_statuts < 3) + if($object->fk_statut < 3) { $object->fk_user_validator = GETPOST('fk_user_validator','int'); } @@ -1197,7 +1197,7 @@ else $head = expensereport_prepare_head($object); - if ($action == 'edit' && ($object->fk_c_expensereport_statuts < 3 || $object->fk_c_expensereport_statuts==99)) + if ($action == 'edit' && ($object->fk_statut < 3 || $object->fk_statut==99)) { print "\n"; print ''; @@ -1205,7 +1205,7 @@ else dol_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip'); - if($object->fk_c_expensereport_statuts==99) + if($object->fk_statut==99) { print ''; } @@ -1246,7 +1246,7 @@ else print ''; } - if($object->fk_c_expensereport_statuts<3) + if($object->fk_statut<3) { print ''; print ''; // Approbator @@ -1275,7 +1275,7 @@ else $userfee->fetch($object->fk_user_author); print $userfee->getNomUrl(1); print ''; - if ($object->fk_c_expensereport_statuts==6) + if ($object->fk_statut==6) { print ''; print ''; @@ -1437,7 +1437,7 @@ else print ''; print ''; print ''; - if($object->fk_c_expensereport_statuts==6) + if($object->fk_statut==6) { print ''; print ''; @@ -1452,7 +1452,7 @@ else print ''; } - if($object->fk_c_expensereport_statuts<3) // informed + if($object->fk_statut<3) // informed { print ''; print ''; @@ -1465,7 +1465,7 @@ else } print ''; } - elseif($object->fk_c_expensereport_statuts==4) + elseif($object->fk_statut==4) { print ''; print ''; @@ -1504,7 +1504,7 @@ else print ''; } - if($object->fk_c_expensereport_statuts==99 || !empty($object->detail_refuse)) + if($object->fk_statut==99 || !empty($object->detail_refuse)) { print ''; print ''; @@ -1566,7 +1566,7 @@ else print ''; } // Ajout des boutons de modification/suppression - if ($object->fk_c_expensereport_statuts < 2 || $object->fk_c_expensereport_statuts==99) + if ($object->fk_statut < 2 || $object->fk_statut==99) { print ''; } @@ -1609,7 +1609,7 @@ else } // Ajout des boutons de modification/suppression - if($object->fk_c_expensereport_statuts<2 OR $object->fk_c_expensereport_statuts==99) + if($object->fk_statut<2 OR $object->fk_statut==99) { print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; - // Sélection date + // Select date print ''; - // Sélection projet + // Select project print ''; - // Sélection type + // Select type print ''; @@ -1732,7 +1732,7 @@ else print ''; print ''; - // Sélection TVA + // Select VAT print ''; - // Quantité + // Quantity print ''; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 5d82aa1be4e..864c169c11c 100755 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -335,7 +335,7 @@ class ExpenseReport extends CommonObject if ($this->fk_user_validator > 0) $user_approver->fetch($this->fk_user_validator); $this->user_validator_infos = dolGetFirstLastname($user_approver->firstname, $user_approver->lastname); - $this->fk_statut = $obj->status; + $this->fk_statut = $obj->status; $this->status = $obj->status; $this->fk_c_paiement = $obj->fk_c_paiement; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index f48a0111a46..6d82b86e4af 100755 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -21,12 +21,13 @@ /** * \file htdocs/expensereport/index.php - * \brief Page liste des expensereports + * \brief list of expense reports */ require "../main.inc.php"; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; $langs->load("companies"); $langs->load("users"); @@ -39,7 +40,7 @@ $result = restrictedArea($user, 'expensereport','',''); $search_ref = GETPOST('search_ref'); $search_user = GETPOST('search_user','int'); -$search_state = GETPOST('search_state','int'); +$search_status = GETPOST('search_status','int'); $month_start = GETPOST("month_start","int"); $year_start = GETPOST("year_start","int"); $month_end = GETPOST("month_end","int"); @@ -49,7 +50,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both { $search_ref=""; $search_user=""; - $search_state=""; + $search_status=""; $month_start=""; $year_start=""; $month_end=""; @@ -69,13 +70,12 @@ llxHeader('', $langs->trans("ListOfTrips")); $max_year = 5; $min_year = 5; -$sortorder = $_GET["sortorder"]; -$sortfield = $_GET["sortfield"]; -$page = $_GET["page"]; +$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST("sortfield"); +$page = GETPOST("page"); if (!$sortorder) $sortorder="DESC"; if (!$sortfield) $sortfield="d.date_debut"; - if ($page == -1) { $page = 0 ; } @@ -91,73 +91,47 @@ $sql.= " u.rowid as id_user, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid"; - - -// WHERE +// Where if(!empty($search_ref)){ $sql.= " WHERE d.ref LIKE '%".$db->escape($search_ref)."%'"; }else{ $sql.= " WHERE 1 = 1"; } -// DATE START -if ($month_start > 0) { - if ($year_start > 0) { - if($month_end > 0) { - if($year_end > 0) { - $sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'"; - $sql.= " AND date_format(d.date_fin, '%Y-%m') <= '$year_end-$month_end'"; - } else { - $sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'"; - $sql.= " AND date_format(d.date_fin, '%m') <= '$month_end'"; - } - } else { - if($year_end > 0) { - $sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'"; - $sql.= " AND date_format(d.date_fin, '%Y') <= '$year_end'"; - } else { - $sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'"; - } - } - } else { - $sql.= " AND date_format(d.date_debut, '%m') >= '$month_start'"; - } -} else { - if ($year_start > 0) { - if($month_end > 0) { - if($year_end > 0) { - $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'"; - $sql.= " AND date_format(d.date_fin, '%Y-%m') <= '$year_end-$month_end'"; - } else { - $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'"; - $sql.= " AND date_format(d.date_fin, '%m') <= '$month_end'"; - } - } else { - if($year_end > 0) { - $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'"; - $sql.= " AND date_format(d.date_fin, '%Y') <= '$year_end'"; - } else { - $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'"; - } - } - } else { - if($month_end > 0) { - if($year_end > 0) { - $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'"; - $sql.= " AND date_format(d.date_fin, '%Y-%m') <= '$year_end-$month_end'"; - } else { - $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'"; - $sql.= " AND date_format(d.date_fin, '%m') <= '$month_end'"; - } - } else { - if($year_end > 0) { - $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'"; - $sql.= " AND date_format(d.date_fin, '%Y') <= '$year_end'"; - } - } - } +// Date Start +if ($month_start > 0) +{ + if ($year_start > 0 && empty($day)) + $sql.= " AND d.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,$month_start,false))."' AND '".$db->idate(dol_get_last_day($year_start,$month_start,false))."'"; + else if ($year_start > 0 && ! empty($day)) + $sql.= " AND d.date_debut BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_start, $day, $year_start))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_start, $day, $year_start))."'"; + else + $sql.= " AND date_format(d.date_debut, '%m') = '".$month_start."'"; } -if (!empty($search_user) && $search_user > 0) $sql.= " AND d.fk_user_author = '".$search_user."'"; -if($search_state != '') $sql.= " AND d.fk_statut = '$search_state'\n"; +else if ($year_start > 0) +{ + $sql.= " AND d.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,1,false))."' AND '".$db->idate(dol_get_last_day($year_start,12,false))."'"; +} +// Date Start +if ($month_end > 0) +{ + if ($year_end > 0 && empty($day)) + $sql.= " AND d.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,$month_end,false))."' AND '".$db->idate(dol_get_last_day($year_end,$month_end,false))."'"; + else if ($year_end > 0 && ! empty($day)) + $sql.= " AND d.date_fin BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_end, $day, $year_end))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_end, $day, $year_end))."'"; + else + $sql.= " AND date_format(d.date_fin, '%m') = '".$month_end."'"; +} +else if ($year_end > 0) +{ + $sql.= " AND d.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,1,false))."' AND '".$db->idate(dol_get_last_day($year_end,12,false))."'"; +} +// User +if ($search_name) +{ + $sql .= natural_search('u.lastname', $search_name); +} +// Status +if($search_status != '') $sql.= " AND d.fk_statut = '".$search_status."'"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) @@ -219,17 +193,13 @@ if ($resql) print ''; } - print ''; - print ''; - - print '"; + print ''; // Status print ''; print ''; print ''; print ''; - /*print ''; - print ''; - print ''; - */ print ''; print ''; print ''; @@ -281,11 +247,7 @@ if ($resql) print ''; print ''; - /* - print ''; - print ''; - print ''; - */ + print ''; print ''; print ''; From e6984bae9d260e33b856d05106420623340d11a8 Mon Sep 17 00:00:00 2001 From: delcroix Patrick Date: Sun, 8 Mar 2015 12:37:07 +0100 Subject: [PATCH 54/80] FIX: jdate returning -62169955200 on x64 machine on x64 machine jdate return -62169955200 instead of 0 when the input is 00-00-00 00:00:00 or equivalent same issue for mktime https://bugs.php.net/bug.php?id=53662 --- htdocs/core/db/DoliDB.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 67e3022d6e3..c689e49b85e 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -274,6 +274,8 @@ abstract class DoliDB implements Database */ function jdate($string, $gm=false) { + if($string==0 || $string=="0000-00-00 00:00:00") + return NULL; $string=preg_replace('/([^0-9])/i','',$string); $tmp=$string.'000000'; $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); From 9d320e4268132df3a3accadf196524699f649b3a Mon Sep 17 00:00:00 2001 From: "Estephe L." Date: Sun, 8 Mar 2015 23:29:09 +0100 Subject: [PATCH 55/80] Fix Anchor link for quick access when editing. This is a quick fix to make anchor link works well when editing a proposal, order or invoice ... --- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 948a61bae2c..c31d8da9277 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -27,7 +27,7 @@ global->MAIN_VIEW_LINE_NUMBER)) { ?> - '; } From 84695845bbd3c1e575efd958b07c9ea2de092829 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Mar 2015 21:20:56 +0100 Subject: [PATCH 60/80] Some fixes into translation and permissions --- htdocs/admin/perms.php | 11 +- htdocs/commande/card.php | 6 +- .../modules/modAskPriceSupplier.class.php | 8 +- htdocs/core/modules/modCommande.class.php | 5 +- htdocs/core/modules/modFournisseur.class.php | 2 +- htdocs/langs/en_US/admin.lang | 2 + htdocs/user/perms.php | 354 +++++++++--------- 7 files changed, 197 insertions(+), 191 deletions(-) diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 907ed389b38..3a7c47f3acf 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -67,7 +67,7 @@ llxHeader('',$langs->trans("DefaultRights")); print_fiche_titre($langs->trans("SecuritySetup"),'','setup'); print $langs->trans("DefaultRightsDesc"); -print " ".$langs->trans("OnlyActiveElementsAreShown")."
\n"; +print " ".$langs->trans("OnlyActiveElementsAreShown")."

\n"; $db->begin(); @@ -115,16 +115,15 @@ foreach ($modulesdir as $dir) $db->commit(); -// Show warning about external users -print info_admin(showModulesExludedForExternal($modules)).'
'."\n"; -print "
\n"; - - $head=security_prepare_head(); dol_fiche_head($head, 'default', $langs->trans("Security")); +// Show warning about external users +print info_admin(showModulesExludedForExternal($modules)).'
'."\n"; + + print '
'.$langs->trans("BoxTitleLastModifiedExpenses",min($max,$num)).''.$langs->trans("FeesAmount").''.$langs->trans("TotalTTC").''.$langs->trans("DateModificationShort").' 
'.$expensereportstatic->getNomUrl(1).''.$userstatic->getNomUrl(1).''.$obj->total_ttc.''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->dm),'day').''.$expensereportstatic->LibStatut($obj->fk_statut,3).''.$expensereportstatic->LibStatut($obj->status,3).'
'.$langs->trans("VALIDATOR").'
'.$langs->trans("AUTHORPAIEMENT").''.$langs->trans("DATE_SAVE").''.dol_print_date($object->date_create,'dayhour').'
'.$langs->trans("AUTHORPAIEMENT").'
'.$langs->trans("VALIDATOR").'
'.$langs->trans("CANCEL_USER").'
'.$langs->trans("REFUSEUR").''.$langs->trans('AmountTTC').''; print 'rowid.'#'.$objp->rowid.'">'; @@ -1689,7 +1689,7 @@ else //print ''; // Add a line - if (($object->fk_c_expensereport_statuts==0 || $object->fk_c_expensereport_statuts==99) && $action != 'editline') + if (($object->fk_statut==0 || $object->fk_statut==99) && $action != 'editline') { print_fiche_titre($langs->trans("AddLine"),'',''); @@ -1799,7 +1799,7 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_author == user courant * Afficher : "Enregistrer" / "Modifier" / "Supprimer" */ - if ($user->rights->expensereport->creer && $object->fk_c_expensereport_statuts==0) + if ($user->rights->expensereport->creer && $object->fk_statut==0) { if ($object->fk_user_author == $user->id) { @@ -1825,7 +1825,7 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_author == user courant * Afficher : "Enregistrer" / "Modifier" / "Supprimer" */ - if($user->rights->expensereport->creer && $object->fk_c_expensereport_statuts==99) + if($user->rights->expensereport->creer && $object->fk_statut==99) { if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { @@ -1845,7 +1845,7 @@ if ($action != 'create' && $action != 'edit') } } - if ($user->rights->expensereport->to_paid && $object->fk_c_expensereport_statuts==5) + if ($user->rights->expensereport->to_paid && $object->fk_statut==5) { if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { @@ -1859,7 +1859,7 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_validator == user courant * Afficher : "Valider" / "Refuser" / "Supprimer" */ - if ($object->fk_c_expensereport_statuts == 2) + if ($object->fk_statut == 2) { if ($object->fk_user_author == $user->id) { @@ -1868,7 +1868,7 @@ if ($action != 'create' && $action != 'edit') } } - if ($user->rights->expensereport->approve && $object->fk_c_expensereport_statuts == 2) + if ($user->rights->expensereport->approve && $object->fk_statut == 2) { //if($object->fk_user_validator==$user->id) //{ @@ -1895,7 +1895,7 @@ if ($action != 'create' && $action != 'edit') * ET user à droit de "to_paid" * Afficher : "Annuler" / "Payer" / "Supprimer" */ - if ($user->rights->expensereport->to_paid && $object->fk_c_expensereport_statuts == 5) + if ($user->rights->expensereport->to_paid && $object->fk_statut == 5) { // Payer print ''.$langs->trans('TO_PAID').''; @@ -1918,7 +1918,7 @@ if ($action != 'create' && $action != 'edit') * ET user à droit "to_paid" * Afficher : "Annuler" */ - if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_c_expensereport_statuts==6) + if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_statut==6) { // Annuler print ''.$langs->trans('Cancel').''; @@ -1933,7 +1933,7 @@ if ($action != 'create' && $action != 'edit') * ET user à droit "supprimer" * Afficher : "Supprimer" */ - if ($user->rights->expensereport->supprimer && $object->fk_c_expensereport_statuts==4) + if ($user->rights->expensereport->supprimer && $object->fk_statut==4) { if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) @@ -1959,7 +1959,7 @@ print '
'; /* * Documents generes */ -if($user->rights->expensereport->export && $object->fk_c_expensereport_statuts>0 && $action != 'edit') +if($user->rights->expensereport->export && $object->fk_statut>0 && $action != 'edit') { $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index c14c7ff2be7..5d82aa1be4e 100755 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -43,7 +43,7 @@ class ExpenseReport extends CommonObject var $fk_user_validator; var $status; - var $fk_c_expensereport_statuts; // -- 1=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied + var $fk_statut; // -- 1=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied var $fk_c_paiement; var $user_author_infos; @@ -150,7 +150,7 @@ class ExpenseReport extends CommonObject $sql.= ",date_create"; $sql.= ",fk_user_author"; $sql.= ",fk_user_validator"; - $sql.= ",fk_c_expensereport_statuts"; + $sql.= ",fk_statut"; $sql.= ",fk_c_paiement"; $sql.= ",note_public"; $sql.= ",note_private"; @@ -164,7 +164,7 @@ class ExpenseReport extends CommonObject $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", ".($user->id > 0 ? $user->id:"null"); $sql.= ", ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null"); - $sql.= ", ".($this->fk_c_expensereport_statuts > 1 ? $this->fk_c_expensereport_statuts:0); + $sql.= ", ".($this->fk_statut > 1 ? $this->fk_statut:0); $sql.= ", ".($this->fk_c_paiement > 0 ? $this->fk_c_paiement:"null"); $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); @@ -248,7 +248,7 @@ class ExpenseReport extends CommonObject $sql.= " , fk_user_validator = ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null"); $sql.= " , fk_user_valid = ".($this->fk_user_valid > 0 ? $this->fk_user_valid:"null"); $sql.= " , fk_user_paid = ".($this->fk_user_paid > 0 ? $this->fk_user_paid:"null"); - $sql.= " , fk_c_expensereport_statuts = ".($this->fk_c_expensereport_statuts >= 0 ? $this->fk_c_expensereport_statuts:'0'); + $sql.= " , fk_statut = ".($this->fk_statut >= 0 ? $this->fk_statut:'0'); $sql.= " , fk_c_paiement = ".($this->fk_c_paiement > 0 ? $this->fk_c_paiement:"null"); $sql.= " , note_public = ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"''"); $sql.= " , note_private = ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"''"); @@ -284,7 +284,7 @@ class ExpenseReport extends CommonObject $sql.= " d.date_refuse, d.date_cancel,"; // ACTIONS $sql.= " d.total_ht, d.total_ttc, d.total_tva,"; // TOTAUX (int) $sql.= " d.date_debut, d.date_fin, d.date_create, d.date_valid, d.date_approve, d.date_paiement,"; // DATES (datetime) - $sql.= " d.fk_user_author, d.fk_user_validator, d.fk_c_expensereport_statuts as status, d.fk_c_paiement,"; + $sql.= " d.fk_user_author, d.fk_user_validator, d.fk_statut as status, d.fk_c_paiement,"; $sql.= " d.fk_user_valid, d.fk_user_approve, d.fk_user_paid,"; $sql.= " dp.libelle as libelle_paiement, dp.code as code_paiement"; // INNER JOIN paiement $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id"; @@ -335,18 +335,18 @@ class ExpenseReport extends CommonObject if ($this->fk_user_validator > 0) $user_approver->fetch($this->fk_user_validator); $this->user_validator_infos = dolGetFirstLastname($user_approver->firstname, $user_approver->lastname); - $this->fk_c_expensereport_statuts = $obj->status; + $this->fk_statut = $obj->status; $this->status = $obj->status; $this->fk_c_paiement = $obj->fk_c_paiement; - if ($this->fk_c_expensereport_statuts==5 || $this->fk_c_expensereport_statuts==6) + if ($this->fk_statut==5 || $this->fk_statut==6) { $user_valid = new User($this->db); if ($this->fk_user_valid > 0) $user_valid->fetch($this->fk_user_valid); $this->user_valid_infos = dolGetFirstLastname($user_valid->firstname, $user_valid->lastname); } - if ($this->fk_c_expensereport_statuts==6) + if ($this->fk_statut==6) { $user_paid = new User($this->db); if ($this->fk_user_paid > 0) $user_paid->fetch($this->fk_user_paid); @@ -514,7 +514,7 @@ class ExpenseReport extends CommonObject $this->date_approve = $now; $this->status = 5; - $this->fk_c_expensereport_statuts = 5; + $this->fk_statut = 5; $this->fk_user_author = $user->id; $this->fk_user_valid = $user->id; @@ -584,7 +584,7 @@ class ExpenseReport extends CommonObject $objp = $db->fetch_object($result); - $sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_c_expensereport_statuts"; + $sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_statut"; $sql2.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql2.= " WHERE d.rowid = '".$objp->fk_expensereport."'"; @@ -593,7 +593,7 @@ class ExpenseReport extends CommonObject $objp->fk_user_author = $obj->fk_user_author; $objp->ref = $obj->ref; - $objp->fk_c_expensereport_status = $obj->fk_c_expensereport_statuts; + $objp->fk_c_expensereport_status = $obj->fk_statut; $objp->rowid = $obj->rowid; $total_HT = $total_HT + $objp->total_ht; @@ -848,10 +848,10 @@ class ExpenseReport extends CommonObject $this->ref = strtoupper($user->login).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d'); } - if ($this->fk_c_expensereport_statuts != 2) + if ($this->fk_statut != 2) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 2, fk_user_valid = ".$user->id.","; + $sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$user->id.","; $sql.= " ref_number_int = ".$ref_number_int; $sql.= ' WHERE rowid = '.$this->id; @@ -894,10 +894,10 @@ class ExpenseReport extends CommonObject $this->date_debut = $this->db->jdate($objp->date_debut); - if ($this->fk_c_expensereport_statuts != 2) + if ($this->fk_statut != 2) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_c_expensereport_statuts = 2"; + $sql.= " SET fk_statut = 2"; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_save_from_refuse sql=".$sql, LOG_DEBUG); @@ -930,10 +930,10 @@ class ExpenseReport extends CommonObject // date approval $this->date_approve = $this->db->idate($now); - if ($this->fk_c_expensereport_statuts != 5) + if ($this->fk_statut != 5) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 5, fk_user_approve = ".$user->id.","; + $sql.= " SET ref = '".$this->ref."', fk_statut = 5, fk_user_approve = ".$user->id.","; $sql.= " date_approve='".$this->date_approve."'"; $sql.= ' WHERE rowid = '.$this->id; if ($this->db->query($sql)) @@ -963,17 +963,17 @@ class ExpenseReport extends CommonObject $now = dol_now(); // date de refus - if ($this->fk_c_expensereport_statuts != 99) + if ($this->fk_statut != 99) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 99, fk_user_refuse = ".$user->id.","; + $sql.= " SET ref = '".$this->ref."', fk_statut = 99, fk_user_refuse = ".$user->id.","; $sql.= " date_refuse='".$this->db->idate($now)."',"; $sql.= " detail_refuse='".$this->db->escape($details)."'"; $sql.= " fk_user_approve=NULL,"; $sql.= ' WHERE rowid = '.$this->id; if ($this->db->query($sql)) { - $this->fk_c_expensereport_statuts = 99; + $this->fk_statut = 99; $this->fk_user_refuse = $user->id; $this->detail_refuse = $details; $this->date_refuse = $now; @@ -1002,10 +1002,10 @@ class ExpenseReport extends CommonObject $now= dol_now(); $this->date_paiement = $this->db->idate($now); - if ($this->fk_c_expensereport_statuts != 6) + if ($this->fk_statut != 6) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_c_expensereport_statuts = 6, fk_user_paid = ".$user->id.","; + $sql.= " SET fk_statut = 6, fk_user_paid = ".$user->id.","; $sql.= " date_paiement='".$this->db->idate($this->date_paiement)."'"; $sql.= ' WHERE rowid = '.$this->id; @@ -1037,7 +1037,7 @@ class ExpenseReport extends CommonObject if ($this->fk_c_deplacement_statuts != 5) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_c_expensereport_statuts = 5"; + $sql.= " SET fk_statut = 5"; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_unpaid sql=".$sql, LOG_DEBUG); @@ -1065,10 +1065,10 @@ class ExpenseReport extends CommonObject function set_cancel($user,$detail) { $this->date_cancel = $this->db->idate(gmmktime()); - if ($this->fk_c_expensereport_statuts != 4) + if ($this->fk_statut != 4) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_c_expensereport_statuts = 4, fk_user_cancel = ".$user->id; + $sql.= " SET fk_statut = 4, fk_user_cancel = ".$user->id; $sql.= ", date_cancel='".$this->date_cancel."'"; $sql.= " ,detail_cancel='".$this->db->escape($detail)."'"; $sql.= ' WHERE rowid = '.$this->id; @@ -1197,7 +1197,7 @@ class ExpenseReport extends CommonObject function updateline($rowid, $type_fees_id, $projet_id, $c_tva, $comments, $qty, $value_unit, $date, $expensereport_id) { - if ($this->fk_c_expensereport_statuts==0 || $this->fk_c_expensereport_statuts==99) + if ($this->fk_statut==0 || $this->fk_statut==99) { $this->db->begin(); @@ -1693,7 +1693,7 @@ class ExpenseReportLine * @param int $useempty 1=Add empty line * @return string HTML select with sattus */ -function select_expensereport_statut($selected='',$htmlname='fk_c_expensereport_statuts',$useempty=1) +function select_expensereport_statut($selected='',$htmlname='fk_statut',$useempty=1) { global $db; diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 5d71be15738..140e492972e 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -59,7 +59,7 @@ class ExpenseReportStats extends Stats $this->from = MAIN_DB_PREFIX.$object->table_element; $this->field='total_ht'; - $this->where = " fk_c_expensereport_statuts > 0 and date_valid > '2000-01-01'"; + $this->where = " fk_statut > 0 and date_valid > '2000-01-01'"; //$this->where.= " AND entity = ".$conf->entity; if ($this->socid) { diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index ec9ccba2c0b..62f5cbe89fc 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -142,7 +142,7 @@ $max=10; $langs->load("boxes"); -$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_c_expensereport_statuts as fk_status"; +$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_statut as fk_status"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."user as u"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = d.fk_user_author"; @@ -186,8 +186,8 @@ if ($result) print '
'.$expensereportstatic->getNomUrl(1).''.$userstatic->getNomUrl(1).''.$obj->total_ht.''.$obj->total_ttc.''.price($obj->total_ht).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->dm),'day').''; //print $obj->libelle; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 44f1426fd36..f48a0111a46 100755 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -85,7 +85,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$sql = "SELECT d.rowid, d.ref, d.total_ht, d.total_tva, d.total_ttc, d.fk_c_expensereport_statuts as status,"; +$sql = "SELECT d.rowid, d.ref, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,"; $sql.= " d.date_debut, d.date_fin,"; $sql.= " u.rowid as id_user, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; @@ -157,7 +157,7 @@ if ($month_start > 0) { } } if (!empty($search_user) && $search_user > 0) $sql.= " AND d.fk_user_author = '".$search_user."'"; -if($search_state != '') $sql.= " AND d.fk_c_expensereport_statuts = '$search_state'\n"; +if($search_state != '') $sql.= " AND d.fk_statut = '$search_state'\n"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) diff --git a/htdocs/expensereport/synchro_compta.php b/htdocs/expensereport/synchro_compta.php index ec2703d059a..58fcbaee301 100755 --- a/htdocs/expensereport/synchro_compta.php +++ b/htdocs/expensereport/synchro_compta.php @@ -136,11 +136,11 @@ else: print ' '; print ""; - $sql = "SELECT d.fk_bank_account, d.ref, d.rowid, d.date_valid, d.fk_user_author, d.total_ttc, d.integration_compta, d.fk_c_expensereport_statuts"; + $sql = "SELECT d.fk_bank_account, d.ref, d.rowid, d.date_valid, d.fk_user_author, d.total_ttc, d.integration_compta, d.fk_statut"; $sql.= " ,CONCAT(u.firstname,' ',u.lastname) as declarant_NDF"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid"; - $sql.= " WHERE d.fk_c_expensereport_statuts = 6"; + $sql.= " WHERE d.fk_statut = 6"; $sql.= " ORDER BY d.date_valid DESC"; $resql=$db->query($sql); diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 2a36ef78737..aa0b0571bbb 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -157,7 +157,7 @@ CREATE TABLE llx_expensereport ( fk_user_refuse integer DEFAULT NULL, fk_user_cancel integer DEFAULT NULL, fk_user_paid integer DEFAULT NULL, - fk_c_expensereport_statuts integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé + fk_statut integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé fk_c_paiement integer DEFAULT NULL, note_public text, note_private text, diff --git a/htdocs/install/mysql/tables/llx_expensereport.sql b/htdocs/install/mysql/tables/llx_expensereport.sql index e60be7251a5..657d8f9e278 100755 --- a/htdocs/install/mysql/tables/llx_expensereport.sql +++ b/htdocs/install/mysql/tables/llx_expensereport.sql @@ -44,7 +44,7 @@ CREATE TABLE llx_expensereport ( fk_user_refuse integer DEFAULT NULL, fk_user_cancel integer DEFAULT NULL, fk_user_paid integer DEFAULT NULL, - fk_c_expensereport_statuts integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé + fk_statut integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé fk_c_paiement integer DEFAULT NULL, note_public text, note_private text, From 69dc3cdd6153cd6ccccdc5419c28af79096a9cd5 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 8 Mar 2015 08:21:49 +0100 Subject: [PATCH 53/80] Correct fk_statut & work en list --- htdocs/core/class/commonobject.class.php | 2 +- .../doc/pdf_standard.modules.php | 8 +- .../core/modules/modExpenseReport.class.php | 2 +- htdocs/expensereport/card.php | 10 +- .../class/expensereport.class.php | 2 +- htdocs/expensereport/list.php | 128 ++++++------------ 6 files changed, 57 insertions(+), 95 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 02ccd13b97c..114648fdf14 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2140,7 +2140,7 @@ abstract class CommonObject $fieldstatus="fk_statut"; if ($elementTable == 'user') $fieldstatus="statut"; - if ($elementTable == 'expensereport') $fieldstatus="fk_c_expensereport_statuts"; + if ($elementTable == 'expensereport') $fieldstatus="fk_statut"; if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status"; $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index bdb19778c87..d2cdb71e429 100755 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -508,7 +508,7 @@ class pdf_standard extends ModeleExpenseReport */ // Filligrane brouillon - if ($object->fk_c_expensereport_statuts==1 && ! empty($conf->global->EXPENSEREPORT_FREE_TEXT)) + if ($object->fk_statut==1 && ! empty($conf->global->EXPENSEREPORT_FREE_TEXT)) { pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_FREE_TEXT); } @@ -640,7 +640,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outpulangs),0,'L'); } - if ($object->fk_c_expensereport_statuts==99) + if ($object->fk_statut==99) { if ($object->fk_user_refuse > 0) { @@ -656,7 +656,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outpulangs),0,'L'); } } - else if($object->fk_c_expensereport_statuts==4) + else if($object->fk_statut==4) { if ($object->fk_user_cancel > 0) { @@ -686,7 +686,7 @@ class pdf_standard extends ModeleExpenseReport } } - if($object->fk_c_expensereport_statuts==6) + if($object->fk_statut==6) { if ($object->fk_user_paid > 0) { diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index cf106fa4588..53289c512ff 100755 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -270,7 +270,7 @@ class modExpenseReport extends DolibarrModules 'titre'=>'ListToApprove', 'mainmenu'=>'hrm', 'leftmenu'=>'expensereport_detaillist_approve', - 'url'=>'/expensereport/list.php?search_state=2', + 'url'=>'/expensereport/list.php?search_status=2', 'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>100, 'enabled'=>'$conf->expensereport->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 02d899def0a..c71705628b6 100755 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1712,17 +1712,17 @@ else print '
'; $form->select_date($date?$date:-1,'date'); print ''; $formproject->select_projects(-1, GETPOST('fk_projet'), 'fk_projet', 0, 0, 1, 1); print ''; select_type_fees_id(GETPOST('fk_c_type_fees'),'fk_c_type_fees',1); print ''; $defaultvat=-1; if (! empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; @@ -1747,7 +1747,7 @@ else print ''; print ''; print ''; print '   '; - print " '; - select_expensereport_statut($search_state,'search_state'); + select_expensereport_statut($search_status,'search_status'); print ''; @@ -257,10 +227,6 @@ if ($resql) print ''.($objp->date_debut > 0 ? dol_print_date($objp->date_debut, 'day') : '').''.($objp->date_fin > 0 ? dol_print_date($objp->date_fin, 'day') : '').''.img_object($langs->trans("ShowUser"),"user").' '.dolGetFirstLastname($objp->firstname, $objp->lastname).''.price($objp->total_tva, '', $langs, 0, 'MT', 0, $conf->currency).''.price($objp->total_ht, '', $langs, 0, 'MT', 0, $conf->currency).''.price($objp->total_ttc, '', $langs, 0, 'MT', 0, $conf->currency).''.price($objp->total_ht).''.price($objp->total_tva).''.price($objp->total_ttc).'
'.$langs->trans("Total").''.price($total_total_tva, '', $langs, 0, 'MT', 0, $conf->currency).''.price($total_total_ht, '', $langs, 0, 'MT', 0, $conf->currency).''.price($total_total_ttc, '', $langs, 0, 'MT', 0, $conf->currency).''.$total_total_ht.''.$total_total_tva.''.$total_total_ttc.'
+
info_bits & 2) == 2) { ?> info_bits & 2) == 2) { ?> - id.'#'.$line->id; ?>"> + id.'#line_'.$line->id; ?>"> From f8dfa618595106bdc7b3a0bb0b185ee99735896b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 9 Mar 2015 16:20:51 +0100 Subject: [PATCH 56/80] FIXED #1901: Inverted supplier order/invoice buttons in project referring objects --- htdocs/projet/element.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index f0e5efa7254..5a499007fae 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -360,11 +360,11 @@ foreach ($listofreferent as $key => $value) { if ($key == 'order_supplier' && ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->creer) { - print ''.$langs->trans("AddSupplierInvoice").''; + print ''.$langs->trans("AddSupplierOrder").''; } if ($key == 'invoice_supplier' && ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->creer) { - print ''.$langs->trans("AddSupplierOrder").''; + print ''.$langs->trans("AddSupplierInvoice").''; } } } From bd6f13e6ed2349c701dccc2c983509fa493c7119 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Mar 2015 19:13:19 +0100 Subject: [PATCH 57/80] Can export extra fields of lines. --- .../modules/modAskPriceSupplier.class.php | 1 - htdocs/core/modules/modFournisseur.class.php | 92 ++++++++++++++++--- 2 files changed, 81 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php index f64126e224e..d415d615756 100644 --- a/htdocs/core/modules/modAskPriceSupplier.class.php +++ b/htdocs/core/modules/modAskPriceSupplier.class.php @@ -110,7 +110,6 @@ class modAskPriceSupplier extends DolibarrModules $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'creer'; - $r++; $this->rights[$r][0] = $this->numero + $r; // id de la permission $this->rights[$r][1] = 'Validate supplier proposals'; // libelle de la permission diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 45cb61b04fd..9e26b0e8b81 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Philippe Grand @@ -251,11 +251,11 @@ class modFournisseur extends DolibarrModules $this->export_icon[$r]='bill'; $this->export_permission[$r]=array(array("fournisseur","facture","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_buy'=>'ProductAccountancyBuyCode'); - //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); - $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); + //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Number','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); + $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Number','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.remise_percent'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product','p.accountancy_code_buy'=>'product'); $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - // Add extra fields + // Add extra fields object $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) @@ -288,13 +288,48 @@ class modFournisseur extends DolibarrModules $this->export_entities_array[$r][$fieldname]='invoice'; } } - // End add axtra fields - $this->export_sql_start[$r]='SELECT DISTINCT '; + // End add extra fields + // Add extra fields line + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'"; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extraline.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $typeFilter="Text"; + switch($obj->type) + { + case 'int': + case 'double': + case 'price': + $typeFilter="Numeric"; + break; + case 'date': + case 'datetime': + $typeFilter="Date"; + break; + case 'boolean': + $typeFilter="Boolean"; + break; + case 'sellist': + $typeFilter="List:".$obj->param; + break; + } + $this->export_fields_array[$r][$fieldname]=$fieldlabel; + $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; + $this->export_entities_array[$r][$fieldname]='invoice_line'; + } + } + // End add extra fields line + $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object'; $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn'; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')'; @@ -309,7 +344,7 @@ class modFournisseur extends DolibarrModules $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment'); $this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - // Add extra fields + // Add extra fields object $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) @@ -342,7 +377,7 @@ class modFournisseur extends DolibarrModules $this->export_entities_array[$r][$fieldname]='invoice'; } } - // End add axtra fields + // End add extra fields object $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; @@ -361,10 +396,10 @@ class modFournisseur extends DolibarrModules $this->export_icon[$r]='order'; $this->export_permission[$r]=array(array("fournisseur","commande","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); - $this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.fk_statut'=>'Status','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Number",'fd.qty'=>"Number",'fd.remise_percent'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.total_tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); + $this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.fk_statut'=>'Status','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Number",'fd.qty'=>"Number",'fd.remise_percent'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.total_tva'=>"Number",'fd.product_type'=>'Number','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"order",'f.ref'=>"order",'f.ref_supplier'=>"order",'f.date_creation'=>"order",'f.date_commande'=>"order",'f.total_ht'=>"order",'f.total_ttc'=>"order",'f.tva'=>"order",'f.fk_statut'=>'order','f.note_public'=>"order",'f.note_private'=>"order",'fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product'); $this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - // Add extra fields + // Add extra fields object $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) @@ -397,13 +432,48 @@ class modFournisseur extends DolibarrModules $this->export_entities_array[$r][$fieldname]='order'; } } - // End add axtra fields + // End add extra fields object + // Add extra fields line + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'"; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extraline.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $typeFilter="Text"; + switch($obj->type) + { + case 'int': + case 'double': + case 'price': + $typeFilter="Numeric"; + break; + case 'date': + case 'datetime': + $typeFilter="Date"; + break; + case 'boolean': + $typeFilter="Boolean"; + break; + case 'sellist': + $typeFilter="List:".$obj->param; + break; + } + $this->export_fields_array[$r][$fieldname]=$fieldlabel; + $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; + $this->export_entities_array[$r][$fieldname]='order_line'; + } + } + // End add extra fields line $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande'; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order',1).')'; From bd81dec1a3b6a7e33359e85222201d80f70fa502 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Mar 2015 19:28:38 +0100 Subject: [PATCH 58/80] Fix missing translation --- htdocs/core/modules/modContrat.class.php | 6 ++++-- htdocs/langs/en_US/contracts.lang | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index dc97964fa45..27299e0f291 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -41,7 +41,7 @@ class modContrat extends DolibarrModules */ function __construct($db) { - global $conf; + global $conf, $langs; $this->db = $db; $this->numero = 54; @@ -118,10 +118,12 @@ class modContrat extends DolibarrModules // Exports //-------- + $langs->load("contracts"); + $r=1; $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='ContractAndServices'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_label[$r]=$langs->trans('ContractsAndLine'); // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r]='contract'; $this->export_permission[$r]=array(array("contrat","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode', diff --git a/htdocs/langs/en_US/contracts.lang b/htdocs/langs/en_US/contracts.lang index 57ba3bb15d8..d1be0e6513f 100644 --- a/htdocs/langs/en_US/contracts.lang +++ b/htdocs/langs/en_US/contracts.lang @@ -19,6 +19,7 @@ ServiceStatusLateShort=Expired ServiceStatusClosed=Closed ServicesLegend=Services legend Contracts=Contracts +ContractsAndLine=Contracts and line of contracts Contract=Contract NoContracts=No contracts MenuServices=Services From 88a29b7c9cffe98e92a6b756d557759e3122f88d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Mar 2015 20:26:56 +0100 Subject: [PATCH 59/80] Add an advance permission to check/uncheck reception --- htdocs/core/modules/modFournisseur.class.php | 8 +++++ htdocs/fourn/commande/dispatch.php | 38 +++++++++++++++----- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 9e26b0e8b81..84e6385694d 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -177,6 +177,14 @@ class modFournisseur extends DolibarrModules $this->rights[$r][4] = 'commande'; $this->rights[$r][5] = 'receptionner'; + $r++; + $this->rights[$r][0] = 1189; + $this->rights[$r][1] = 'Check/Uncheck a supplier order reception'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'commande_advance'; + $this->rights[$r][5] = 'check'; + $r++; $this->rights[$r][0] = 1188; $this->rights[$r][1] = 'Supprimer une commande fournisseur'; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 2610111023a..f2dd3518868 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -67,7 +67,10 @@ $mesg=''; * Actions */ -if ($action == 'checkdispatchline') +if ($action == 'checkdispatchline' && + ! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))) +) { $supplierorderdispatch = new CommandeFournisseurDispatch($db); $result=$supplierorderdispatch->fetch($lineid); @@ -81,7 +84,10 @@ if ($action == 'checkdispatchline') } } -if ($action == 'uncheckdispatchline') +if ($action == 'uncheckdispatchline' && + ! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))) +) { $supplierorderdispatch = new CommandeFournisseurDispatch($db); $result=$supplierorderdispatch->fetch($lineid); @@ -630,15 +636,31 @@ if ($id > 0 || ! empty($ref)) // Add button to check/uncheck disaptching print '
'; - $disabled=''; - if ($commande->statut == 5) $disabled=1; - if (empty($objp->status)) + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)) + ) { - print 'dispatchlineid.'">'.$langs->trans("Check").''; + if (empty($objp->status)) + { + print ''.$langs->trans("Check").''; + } + else + { + print ''.$langs->trans("Uncheck").''; + } } - else + else { - print 'dispatchlineid.'">'.$langs->trans("Uncheck").''; + $disabled=''; + if ($commande->statut == 5) $disabled=1; + if (empty($objp->status)) + { + print 'dispatchlineid.'">'.$langs->trans("Check").''; + } + else + { + print 'dispatchlineid.'">'.$langs->trans("Uncheck").''; + } } print '
'; // Affiche lignes des permissions diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 5f6c085831f..bef752f5954 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2243,7 +2243,11 @@ if ($action == 'create' && $user->rights->commande->creer) } // Cancel order - if ($object->statut == 1 && $user->rights->commande->annuler) { + if ($object->statut == 1 && + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->cloturer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler))) + ) + { print ''; } diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php index d415d615756..4614b0b819d 100644 --- a/htdocs/core/modules/modAskPriceSupplier.class.php +++ b/htdocs/core/modules/modAskPriceSupplier.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin @@ -21,11 +21,11 @@ */ /** - * \defgroup askpricesupplier Module de demandes de prix fournisseurs - * \brief Module pour gerer la tenue des demandes fournisseurs + * \defgroup askpricesupplier Module to request supplier price proposals + * \brief Module to request supplier price proposals * \file htdocs/core/modules/modAskPriceSupplier.class.php * \ingroup askpricesupplier - * \brief Fichier de description et activation du module AskPriceSupplier + * \brief File to describe and activate module AskPriceSupplier */ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index c7fb5cfa587..53584e419eb 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -151,8 +151,9 @@ class modCommande extends DolibarrModules $this->rights[$r][1] = 'Annuler les commandes clients'; $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'annuler'; - + $this->rights[$r][4] = 'order_advance'; + $this->rights[$r][5] = 'annuler'; + $r++; $this->rights[$r][0] = 89; $this->rights[$r][1] = 'Supprimer les commandes clients'; diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 84e6385694d..98986a045da 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -180,7 +180,7 @@ class modFournisseur extends DolibarrModules $r++; $this->rights[$r][0] = 1189; $this->rights[$r][1] = 'Check/Uncheck a supplier order reception'; - $this->rights[$r][2] = 'd'; + $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'commande_advance'; $this->rights[$r][5] = 'check'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e701db32106..b8590a1fc38 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -500,6 +500,8 @@ Module700Name=Donations Module700Desc=Donation management Module770Name=Expense Report Module770Desc=Management and claim expense reports (transportation, meal, ...) +Module1120Name=Supplier commercial proposal +Module1120Desc=Request supplier commercial proposal and prices Module1200Name=Mantis Module1200Desc=Mantis integration Module1400Name=Accounting diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index b63b3e65ffc..a01b5ffa7ab 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -1,24 +1,24 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Juanjo Menent - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +* Copyright (C) 2004-2012 Laurent Destailleur +* Copyright (C) 2004 Eric Seigne +* Copyright (C) 2005-2012 Regis Houssin +* Copyright (C) 2012 Juanjo Menent +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ /** * \file htdocs/user/perms.php @@ -74,10 +74,10 @@ if ($user->id <> $id && ! $canreaduser) accessforbidden(); if ($action == 'addrights' && $caneditperms) { - $edituser = new User($db); + $edituser = new User($db); $edituser->fetch($id); - //$edituser->addrights($rights, $module, '', $entity); // TODO unused for the moment - $edituser->addrights($rights, $module); + //$edituser->addrights($rights, $module, '', $entity); // TODO unused for the moment + $edituser->addrights($rights, $module); // Si on a touche a ses propres droits, on recharge if ($id == $user->id) @@ -90,10 +90,10 @@ if ($action == 'addrights' && $caneditperms) if ($action == 'delrights' && $caneditperms) { - $edituser = new User($db); + $edituser = new User($db); $edituser->fetch($id); - //$edituser->delrights($rights, $module, '', $entity); // TODO unused for the moment - $edituser->delrights($rights, $module); + //$edituser->delrights($rights, $module, '', $entity); // TODO unused for the moment + $edituser->delrights($rights, $module); // Si on a touche a ses propres droits, on recharge if ($id == $user->id) @@ -133,39 +133,39 @@ $modulesdir = dolGetModulesDirs(); foreach($modulesdir as $dir) { $handle=@opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') - { - $modName = substr($file, 0, dol_strlen($file) - 10); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + { + $modName = substr($file, 0, dol_strlen($file) - 10); - if ($modName) - { - include_once $dir.$file; - $objMod = new $modName($db); + if ($modName) + { + include_once $dir.$file; + $objMod = new $modName($db); - // Load all lang files of module - if (isset($objMod->langfiles) && is_array($objMod->langfiles)) - { - foreach($objMod->langfiles as $domain) - { - $langs->load($domain); - } - } - // Load all permissions - if ($objMod->rights_class) - { - $forceEntity=((! empty($conf->multicompany->enabled) && ! empty($fuser->entity)) ? $fuser->entity : null); - $ret=$objMod->insert_permissions(0, $forceEntity); - $modules[$objMod->rights_class]=$objMod; - //print "modules[".$objMod->rights_class."]=$objMod;"; - } - } - } - } - } + // Load all lang files of module + if (isset($objMod->langfiles) && is_array($objMod->langfiles)) + { + foreach($objMod->langfiles as $domain) + { + $langs->load($domain); + } + } + // Load all permissions + if ($objMod->rights_class) + { + $forceEntity=((! empty($conf->multicompany->enabled) && ! empty($fuser->entity)) ? $fuser->entity : null); + $ret=$objMod->insert_permissions(0, $forceEntity); + $modules[$objMod->rights_class]=$objMod; + //print "modules[".$objMod->rights_class."]=$objMod;"; + } + } + } + } + } } $db->commit(); @@ -195,19 +195,19 @@ dol_syslog("get user perms", LOG_DEBUG); $result=$db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); - array_push($permsuser,$obj->id); - $i++; - } - $db->free($result); + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($result); + array_push($permsuser,$obj->id); + $i++; + } + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } // Lecture des droits groupes @@ -231,27 +231,27 @@ dol_syslog("get user perms", LOG_DEBUG); $result=$db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); - if (! isset($permsgroupbyentity[$obj->entity])) - $permsgroupbyentity[$obj->entity] = array(); - array_push($permsgroupbyentity[$obj->entity], $obj->id); - $i++; - } - $db->free($result); + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($result); + if (! isset($permsgroupbyentity[$obj->entity])) + $permsgroupbyentity[$obj->entity] = array(); + array_push($permsgroupbyentity[$obj->entity], $obj->id); + $i++; + } + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } /* * Ecran ajout/suppression permission - */ +*/ print '
'; @@ -274,9 +274,9 @@ print ''."\n"; print '

'; -if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules"), 0, 1).'
'; +if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules")); // Show warning about external users -if (empty($user->societe_id)) print info_admin(showModulesExludedForExternal($modules)).'

'."\n"; +if (empty($user->societe_id)) print info_admin(showModulesExludedForExternal($modules))."\n"; // For multicompany transversal mode // TODO Place a hook here @@ -310,115 +310,115 @@ $sql.= " ORDER BY r.module, r.id"; $result=$db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - $var = True; - $oldmod=''; + $num = $db->num_rows($result); + $i = 0; + $var = True; + $oldmod=''; - while ($i < $num) - { - $obj = $db->fetch_object($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); - // Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore - if (empty($modules[$obj->module])) - { - $i++; - continue; - } + // Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore + if (empty($modules[$obj->module])) + { + $i++; + continue; + } - if (isset($obj->module) && ($oldmod <> $obj->module)) - { - $oldmod = $obj->module; - $var = !$var; + if (isset($obj->module) && ($oldmod <> $obj->module)) + { + $oldmod = $obj->module; + $var = !$var; - // Rupture detectee, on recupere objMod - $objMod=$modules[$obj->module]; - $picto=($objMod->picto?$objMod->picto:'generic'); + // Rupture detectee, on recupere objMod + $objMod=$modules[$obj->module]; + $picto=($objMod->picto?$objMod->picto:'generic'); - if ($caneditperms && (empty($objMod->rights_admin_allowed) || empty($fuser->admin))) - { - // On affiche ligne pour modifier droits - print ''; - print ''.img_object('',$picto).' '.$objMod->getName(); - print ' '; - print ''; - print ''.$langs->trans("All").""; - print '/'; - print ''.$langs->trans("None").""; - print ''; - print ' '; - print ''."\n"; - } - } + if ($caneditperms && (empty($objMod->rights_admin_allowed) || empty($fuser->admin))) + { + // On affiche ligne pour modifier droits + print ''; + print ''.img_object('',$picto).' '.$objMod->getName(); + print ' '; + print ''; + print ''.$langs->trans("All").""; + print '/'; + print ''.$langs->trans("None").""; + print ''; + print ' '; + print ''."\n"; + } + } - print ''; + print ''; - // Picto and label of permission - print ''.img_object('',$picto).' '.$objMod->getName().''; + // Picto and label of permission + print ''.img_object('',$picto).' '.$objMod->getName().''; - // Permission and tick - if (! empty($fuser->admin) && ! empty($objMod->rights_admin_allowed)) // Permission own because admin - { - if ($caneditperms) - { - print ''.img_picto($langs->trans("Administrator"),'star').''; - } - print ''; - print img_picto($langs->trans("Active"),'tick'); - print ''; - } - else if (in_array($obj->id, $permsuser)) // Permission own by user - { - if ($caneditperms) - { - print ''.img_edit_remove($langs->trans("Remove")).''; - } - print ''; - print img_picto($langs->trans("Active"),'tick'); - print ''; - } + // Permission and tick + if (! empty($fuser->admin) && ! empty($objMod->rights_admin_allowed)) // Permission own because admin + { + if ($caneditperms) + { + print ''.img_picto($langs->trans("Administrator"),'star').''; + } + print ''; + print img_picto($langs->trans("Active"),'tick'); + print ''; + } + else if (in_array($obj->id, $permsuser)) // Permission own by user + { + if ($caneditperms) + { + print ''.img_edit_remove($langs->trans("Remove")).''; + } + print ''; + print img_picto($langs->trans("Active"),'tick'); + print ''; + } - else if (is_array($permsgroupbyentity[$entity])) - { - if (in_array($obj->id, $permsgroupbyentity[$entity])) // Permission own by group - { - if ($caneditperms) - { - print ''; - print $form->textwithtooltip($langs->trans("Inherited"),$langs->trans("PermissionInheritedFromAGroup")); - print ''; - } - print ''; - print img_picto($langs->trans("Active"),'tick'); - print ''; - } - else - { - // Do not own permission - if ($caneditperms) - { - print ''.img_edit_add($langs->trans("Add")).''; - } - print ' '; - } - } - else - { - // Do not own permission - if ($caneditperms) - { - print ''.img_edit_add($langs->trans("Add")).''; - } - print ' '; - } + else if (is_array($permsgroupbyentity[$entity])) + { + if (in_array($obj->id, $permsgroupbyentity[$entity])) // Permission own by group + { + if ($caneditperms) + { + print ''; + print $form->textwithtooltip($langs->trans("Inherited"),$langs->trans("PermissionInheritedFromAGroup")); + print ''; + } + print ''; + print img_picto($langs->trans("Active"),'tick'); + print ''; + } + else + { + // Do not own permission + if ($caneditperms) + { + print ''.img_edit_add($langs->trans("Add")).''; + } + print ' '; + } + } + else + { + // Do not own permission + if ($caneditperms) + { + print ''.img_edit_add($langs->trans("Add")).''; + } + print ' '; + } - $perm_libelle=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$obj->libelle)); - print ''.$perm_libelle. ''; + $perm_libelle=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$obj->libelle)); + print ''.$perm_libelle. ''; - print ''."\n"; + print ''."\n"; - $i++; - } + $i++; + } } else dol_print_error($db); print ''; From 94acbeaa221f8233250ca216a97bf9c824615b16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Mar 2015 21:40:24 +0100 Subject: [PATCH 61/80] Prepare perms on extrafields --- htdocs/core/class/extrafields.class.php | 37 +++++++++++++------ .../install/mysql/migration/3.7.0-3.8.0.sql | 2 + .../install/mysql/tables/llx_extrafields.sql | 1 + 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f1ad5d6687f..e7cc87efef5 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -48,11 +48,13 @@ class ExtraFields var $attribute_required; // Array to store parameters of attribute (used in select type) var $attribute_param; - // Int to store position of attribute + // Array to store position of attribute var $attribute_pos; - // Int to store if attribute is editable regardless of the document status + // Array to store if attribute is editable regardless of the document status var $attribute_alwayseditable; - + // Array to store permission to check + var $attribute_perms; + var $error; var $errno; @@ -90,6 +92,7 @@ class ExtraFields $this->attribute_elementtype = array(); $this->attribute_unique = array(); $this->attribute_required = array(); + $this->attribute_perms = array(); } /** @@ -106,9 +109,10 @@ class ExtraFields * @param string $default_value Defaulted value * @param array $param Params for field * @param int $alwayseditable Is attribute always editable regardless of the document status + * @param string $perms Permission to check * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param=0, $alwayseditable=0) + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param=0, $alwayseditable=0, $perms='') { if (empty($attrname)) return -1; if (empty($label)) return -1; @@ -124,7 +128,7 @@ class ExtraFields if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') { // Add declaration of field into table - $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param, $alwayseditable); + $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param, $alwayseditable, $perms); $err2=$this->errno; if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) { @@ -225,9 +229,10 @@ class ExtraFields * @param int $required Is field required or not * @param array||string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status + * @param string $perms Permission to check * @return int <=0 if KO, >0 if OK */ - private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0) + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='') { global $conf; @@ -251,7 +256,7 @@ class ExtraFields $params=''; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable, perms)"; $sql.= " VALUES('".$attrname."',"; $sql.= " '".$this->db->escape($label)."',"; $sql.= " '".$type."',"; @@ -263,6 +268,7 @@ class ExtraFields $sql.= " '".$required."',"; $sql.= " '".$params."',"; $sql.= " '".$alwayseditable."'"; + $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null"); $sql.=')'; dol_syslog(get_class($this)."::create_label", LOG_DEBUG); @@ -363,9 +369,10 @@ class ExtraFields * @param int $pos Position of attribute * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status + * @param string $perms Permission to check * @return int >0 if OK, <=0 if KO */ - function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0) + function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='') { if ($elementtype == 'thirdparty') $elementtype='societe'; @@ -402,7 +409,7 @@ class ExtraFields { if ($label) { - $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable); + $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms); } if ($result > 0) { @@ -451,12 +458,13 @@ class ExtraFields * @param int $pos Position of attribute * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status + * @param string $perms Permission to check * @return int <=0 if KO, >0 if OK */ - private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0) + private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='') { global $conf; - dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required); + dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms); if ($elementtype == 'thirdparty') $elementtype='societe'; @@ -485,6 +493,7 @@ class ExtraFields $sql.= " elementtype,"; $sql.= " fieldunique,"; $sql.= " fieldrequired,"; + $sql.= " perms,"; $sql.= " pos,"; $sql.= " alwayseditable,"; $sql.= " param"; @@ -497,6 +506,7 @@ class ExtraFields $sql.= " '".$elementtype."',"; $sql.= " '".$unique."',"; $sql.= " '".$required."',"; + $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null"); $sql.= " '".$pos."',"; $sql.= " '".$alwayseditable."',"; $sql.= " '".$param."'"; @@ -542,7 +552,7 @@ class ExtraFields // For avoid conflicts with external modules if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; @@ -571,6 +581,7 @@ class ExtraFields $this->attribute_param[$tab->name]=unserialize($tab->param); $this->attribute_pos[$tab->name]=$tab->pos; $this->attribute_alwayseditable[$tab->name]=$tab->alwayseditable; + $this->attribute_perms[$tab->name]=$tab->perms; } } } @@ -603,6 +614,7 @@ class ExtraFields $unique=$this->attribute_unique[$key]; $required=$this->attribute_required[$key]; $param=$this->attribute_param[$key]; + $perms=$this->attribute_perms[$key]; if ($type == 'date') { $showsize=10; @@ -1040,6 +1052,7 @@ class ExtraFields $unique=$this->attribute_unique[$key]; $required=$this->attribute_required[$key]; $params=$this->attribute_param[$key]; + $perms=$this->attribute_perms[$key]; if ($type == 'date') { $showsize=10; diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 2a36ef78737..22890a149ce 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -19,6 +19,8 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); +ALTER TABLE llx_extrafields ADD COLUMN perms varchar(255) after fieldrequired; + UPDATE llx_projet_task_time SET task_datehour = task_date where task_datehour IS NULL; ALTER TABLE llx_projet_task_time ADD COLUMN task_date_withhour integer DEFAULT 0 after task_datehour; diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql index f91d21fedb1..11271125508 100644 --- a/htdocs/install/mysql/tables/llx_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_extrafields.sql @@ -29,6 +29,7 @@ create table llx_extrafields size varchar(8) DEFAULT NULL, fieldunique integer DEFAULT 0, fieldrequired integer DEFAULT 0, + perms varchar(255), pos integer DEFAULT 0, alwayseditable integer DEFAULT 0, param text From 90abe5cdf97afcc9124fc02019e8eac75eb2e546 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 09:29:24 +0100 Subject: [PATCH 62/80] NEW: Add current salary on list of payment --- htdocs/compta/salaries/index.php | 22 ++++++++++++++++------ htdocs/langs/en_US/salaries.lang | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 678b3bfaa2e..79d139255c2 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2011-2014 Alexandre Spangaro + * Copyright (C) 2015 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,7 +83,7 @@ $form = new Form($db); $salstatic = new PaymentSalary($db); $userstatic = new User($db); -$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,"; +$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.salary, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id,"; @@ -93,7 +94,7 @@ $sql.= " AND s.entity = ".$conf->entity; // Search criteria if ($search_ref) $sql.=" AND s.rowid=".$search_ref; if ($search_label) $sql.=" AND s.label LIKE '%".$db->escape($search_label)."%'"; -if ($search_amount) $sql.=" AND s.amount='".$db->escape(price2num(trim($search_amount)))."'"; +if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1); if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; @@ -124,9 +125,10 @@ if ($result) print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CurrentSalary"),$_SERVER["PHP_SELF"],"u.salary","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datev","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre(""); print "\n"; @@ -136,6 +138,9 @@ if ($result) print ''; print ''; print ''; + // People + print ' '; + // Current salary print ' '; // Label print ''; @@ -161,8 +166,13 @@ if ($result) $userstatic->firstname=$obj->firstname; $salstatic->id=$obj->rowid; $salstatic->ref=$obj->rowid; - print "".$salstatic->getNomUrl(1)."\n"; + // Ref + print "".$salstatic->getNomUrl(1)."\n"; + // User name print "".$userstatic->getNomUrl(1)."\n"; + // Current salary + print "".($obj->salary?price($obj->salary):'')."\n"; + // Label payment print "".dol_trunc($obj->label,40)."\n"; print ''.dol_print_date($db->jdate($obj->dm),'day')."\n"; // Type @@ -176,7 +186,7 @@ if ($result) $i++; } - print ''.$langs->trans("Total").''; + print ''.$langs->trans("Total").''; print ''.price($total,0,$outputlangs,1,-1,-1,$conf->currency).""; print " "; diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index 0087cbe83e6..0f5f636a3f3 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -10,3 +10,4 @@ SalariesPayments=Salaries payments ShowSalaryPayment=Show salary payment THM=Average hourly price TJM=Average daily price +CurrentSalary=Current salary \ No newline at end of file From a065b8a9b4f732015b9a188b93361e160e08dc36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Votruba?= Date: Tue, 10 Mar 2015 09:57:40 +0100 Subject: [PATCH 63/80] travis: PHP 7.0 nightly added --- .travis.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 031226251c1..e3348e97b67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,10 +18,15 @@ services: language: php php: # - "5.2" is not supported because pyrus to install PHP_Codesniffer is not available - - "5.3" - - "5.4" - - "5.5" - - "5.6" + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - 7.0 + +matrix: + allow_failures: + - php: 7.0 env: - DB=mysql From dc300922906d939c2a5aea5d02618c61d93fb28c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 10:11:51 +0100 Subject: [PATCH 64/80] Add column to store salary ref when doing payment. --- htdocs/compta/charges/index.php | 15 ++++++++------- htdocs/compta/salaries/card.php | 9 +++++++-- .../compta/salaries/class/paymentsalary.class.php | 4 +++- htdocs/compta/salaries/index.php | 9 +++++++-- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 2 ++ .../install/mysql/tables/llx_payment_salary.sql | 1 + 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index ca03e11bcba..eb10fce7768 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -93,9 +93,10 @@ if ($conf->salaries->enabled) print_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); - $sql = "SELECT s.rowid, s.amount, s.label, s.datev as dm"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sql.= " WHERE s.entity = ".$conf->entity; + $sql = "SELECT s.rowid, s.amount, s.label, s.datev as dm, s.salary, u.salary as current_salary"; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE s.entity IN (".getEntity('user',1).")"; + $sql.= " AND u.rowid = s.fk_user"; if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, @@ -132,11 +133,11 @@ if ($conf->salaries->enabled) print "".$obj->label."\n"; - print ''.price($obj->amount).""; + print ''.($obj->salary?price($obj->salary):'').""; // Ref payment - $sal_static->id=$obj->rowid; - $sal_static->ref=$obj->rowid; + $sal_static->id=$obj->rowid; + $sal_static->ref=$obj->rowid; print ''.$sal_static->getNomUrl(1)."\n"; print ''.dol_print_date($db->jdate($obj->dm),'day')."\n"; @@ -146,7 +147,7 @@ if ($conf->salaries->enabled) $i++; } print ''.$langs->trans("Total").''; - print ''.price($total).""; + print ''.""; print ' '; print ' '; print ''.price($total).""; diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 49c3192fa7f..3bd93659b5e 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -67,8 +67,8 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]); $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); - $sal->accountid=GETPOST("accountid"); - $sal->fk_user=GETPOST("fk_user"); + $sal->accountid=GETPOST("accountid","int"); + $sal->fk_user=GETPOST("fk_user","int"); $sal->datev=$datev; $sal->datep=$datep; $sal->amount=price2num(GETPOST("amount")); @@ -80,6 +80,11 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $sal->num_payment=GETPOST("num_payment"); $sal->fk_user_creat=$user->id; + // Set user current salary as ref salaray for the payment + $fuser=new User($db); + $fuser->fetch(GETPOST("fk_user","int")); + $sal->salary=$fuser->salary; + if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep)) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 83a1c937545..f566123809c 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -324,6 +324,7 @@ class PaymentSalary extends CommonObject $sql.= ", datep"; $sql.= ", datev"; $sql.= ", amount"; + $sql.= ", salary"; $sql.= ", fk_typepayment"; $sql.= ", num_payment"; if ($this->note) $sql.= ", note"; @@ -338,7 +339,8 @@ class PaymentSalary extends CommonObject $sql.= "'".$this->fk_user."'"; $sql.= ", '".$this->db->idate($this->datep)."'"; $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", '".$this->amount."'"; + $sql.= ", ".$this->amount; + $sql.= ", ".($this->salary > 0 ? $this->salary : "null"); $sql.= ", '".$this->type_payment."'"; $sql.= ", '".$this->num_payment."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 79d139255c2..484010c9f03 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -83,7 +83,8 @@ $form = new Form($db); $salstatic = new PaymentSalary($db); $userstatic = new User($db); -$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.salary, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,"; +$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_societe as fk_soc,"; +$sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id,"; @@ -125,7 +126,7 @@ if ($result) print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("CurrentSalary"),$_SERVER["PHP_SELF"],"u.salary","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.salary","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datev","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); @@ -164,6 +165,10 @@ if ($result) $userstatic->id=$obj->uid; $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; + $userstatic->admin=$obj->admin; + $userstatic->login=$obj->login; + $userstatic->email=$obj->email; + $userstatic->societe_id=$obj->fk_soc; $salstatic->id=$obj->rowid; $salstatic->ref=$obj->rowid; // Ref diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 2a36ef78737..2de1556ed3e 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -19,6 +19,8 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); +ALTER TABLE llx_payment_salary ADD COLUMN salary real after datev; + UPDATE llx_projet_task_time SET task_datehour = task_date where task_datehour IS NULL; ALTER TABLE llx_projet_task_time ADD COLUMN task_date_withhour integer DEFAULT 0 after task_datehour; diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql index b82ff66ecc1..2498c771ba6 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -23,6 +23,7 @@ create table llx_payment_salary fk_user integer NOT NULL, datep date, -- date de paiement datev date, -- date de valeur + salary real, -- salary of user when payment was done amount real NOT NULL DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), From 35dfaf4dd14e0575bef702073e8b84bcbbfbe5ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 10:14:24 +0100 Subject: [PATCH 65/80] Natural search on numeric works also with several space after operator --- htdocs/core/lib/functions.lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 509f237b0d6..d7fc398e082 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4949,7 +4949,7 @@ function dol_getmypid() * Generate natural SQL search string * * @param string|string[] $fields String or array of strings, filled with the name of fields in the SQL query - * @param string $value The value to look for. + * @param string $value The value to look for. * If param $numeric is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2 * If param $numeric is 1, can contains an operator <>= like "<10" or ">=100.5 < 1000" * @param string $number 0=value is list of keywords, 1=value is a numeric test @@ -4958,10 +4958,10 @@ function dol_getmypid() function natural_search($fields, $value, $numeric=0) { global $db,$langs; - + if ($numeric) { - $value=preg_replace('/([<>=]+)\s([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do + $value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do } $crits = explode(' ', $value); $res = ''; @@ -4970,19 +4970,19 @@ function natural_search($fields, $value, $numeric=0) $nboffields = count($fields); $end2 = count($crits); $j = 0; - foreach ($crits as $crit) + foreach ($crits as $crit) { $i = 0; $i2 = 0; $newres = ''; - foreach ($fields as $field) + foreach ($fields as $field) { - if ($numeric) + if ($numeric) { $operator='='; $newcrit = preg_replace('/([<>=]+)/','',trim($crit)); - + preg_match('/([<>=]+)/',trim($crit), $reg); - if ($reg[1]) + if ($reg[1]) { $operator = $reg[1]; } @@ -4992,7 +4992,7 @@ function natural_search($fields, $value, $numeric=0) $i2++; // a criteria was added to string } } - else + else { $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " LIKE '%" . $db->escape(trim($crit)) . "%'"; $i2++; // a criteria was added to string From d847f9581e2c1057bd09275b221797b3d4cb8f44 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 11:31:23 +0100 Subject: [PATCH 66/80] Fix generation of RUM number. Show it on card to help debug. --- .../class/bonprelevement.class.php | 25 +++++++++++++++---- .../class/companybankaccount.class.php | 8 +++++- htdocs/societe/rib.php | 16 ++++++++++-- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 2c07baba5a0..eb0344d7010 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1300,7 +1300,7 @@ class BonPrelevement extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $ListOfFactures, $obj->idfac, $obj->iban, $obj->bic, $obj->datec, $obj->drum); + $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $ListOfFactures, $obj->idfac, $obj->iban, $obj->bic, $this->db->jdate($obj->datec), $obj->drum); $this->total = $this->total + $obj->somme; $i++; } @@ -1502,6 +1502,20 @@ class BonPrelevement extends CommonObject } + /** + * Build RUM number for a customer bank account + * + * @param string $row_code_client Customer code (soc.code_client) + * @param int $row_datec Creation date of bank account (rib.datec) + * @param string $row_drum Id of customer bank account (rib.rowid) + * @return string RUM number + */ + static function buildRumNumber($row_code_client, $row_datec, $row_drum) + { + $pre = ($row_datec > 1359673200) ? 'Rum' : '++R'; + return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); + } + /** * Write recipient of request (customer) * @@ -1520,7 +1534,7 @@ class BonPrelevement extends CommonObject * @param string $row_iban rib.iban_prefix AS iban, * @param string $row_bic rib.bic AS bic, * @param string $row_datec rib.datec, - * @param string $row_drum rib.rowid AS drum + * @param string $row_drum rib.rowid used to generate rum * @return string Return string with SEPA part DrctDbtTxInf */ function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_facnumber, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum) @@ -1530,10 +1544,11 @@ class BonPrelevement extends CommonObject // Define value for RUM // Example: RUMCustomerCode-CustomerBankAccountId-01424448606 (note: Date is date of creation of CustomerBankAccountId) - $Date_Rum = strtotime($row_datec); + $Rum = $this->buildRumNumber($row_code_client, $row_datec, $row_drum); + + // Define date of RUM signature $DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d'); - $pre = ($date_Rum > 1359673200) ? 'Rum' : '++R'; - $Rum = $pre.$row_code_client.$row_drum.'-0'.date('U', $Date_Rum); + $XML_DEBITOR =''; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 37e646d6b88..255ab6a05a6 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -49,6 +49,10 @@ class CompanyBankAccount extends Account var $owner_address; var $default_rib; + var $datec; + var $datem; + + /** * Constructor * @@ -174,7 +178,7 @@ class CompanyBankAccount extends Account { if (empty($id) && empty($socid)) return -1; - $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio, owner_address, default_rib, label"; + $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio, owner_address, default_rib, label, datec, tms as datem"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; if ($id) $sql.= " WHERE rowid = ".$id; if ($socid) $sql.= " WHERE fk_soc = ".$socid." AND default_rib = 1"; @@ -200,6 +204,8 @@ class CompanyBankAccount extends Account $this->owner_address = $obj->owner_address; $this->label = $obj->label; $this->default_rib = $obj->default_rib; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->datem); } $this->db->free($resql); diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index ab14d757f6f..5af9d2a7df2 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -29,6 +29,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; $langs->load("companies"); $langs->load("commercial"); @@ -191,6 +192,7 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') */ $form = new Form($db); +$prelevement = new BonPrelevement($db); llxHeader(); @@ -320,11 +322,11 @@ if ($socid && $action != 'edit' && $action != "create") print "
"; - + /* * List of bank accounts */ - + print_titre($langs->trans("AllRIB")); $rib_list = $soc->get_all_rib(); @@ -339,6 +341,10 @@ if ($socid && $action != 'edit' && $action != "create") print_liste_field_titre($langs->trans("RIB")); print_liste_field_titre($langs->trans("IBAN")); print_liste_field_titre($langs->trans("BIC")); + if (! empty($conf->prelevement->enabled)) + { + print 'RUM'; + } print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"'); print ''; print ''; @@ -356,6 +362,12 @@ if ($socid && $action != 'edit' && $action != "create") print ''.$rib->iban.''; // BIC print ''.$rib->bic.''; + + if (! empty($conf->prelevement->enabled)) + { + print ''.$prelevement->buildRumNumber($soc->code_client, $rib->datec, $rib->id).''; + } + // Default print ''; if (!$rib->default_rib) { From 194260fc5b45128d851c74660a989edc4f08065c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 13:25:25 +0100 Subject: [PATCH 67/80] NEW: Add search box for supplier order search. --- htdocs/comm/index.php | 15 +++++++++++++++ htdocs/fourn/commande/list.php | 2 +- htdocs/langs/en_US/orders.lang | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index ea0494866a1..cb5a07c32d3 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -103,6 +103,21 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print "
\n"; } +// Search supplier order +if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) +{ + $var=false; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "
'.$langs->trans("SearchASupplierOrder").'
'; + print ':
:

\n"; +} + // Search contract if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 7e525a9d080..386caad8134 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -140,7 +140,7 @@ if ($search_ttc != '') } if ($sall) { - $sql .= natural_search(array('cf.ref', 'cf.note_public', 'cf.note_private'), $sall); + $sql .= natural_search(array('cf.ref', 'cf.ref_supplier', 'cf.note_public', 'cf.note_private'), $sall); } if ($socid) $sql.= " AND s.rowid = ".$socid; diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index ea3659b90de..602bd1bda59 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -59,6 +59,7 @@ MenuOrdersToBill=Orders delivered MenuOrdersToBill2=Billable orders SearchOrder=Search order SearchACustomerOrder=Search a customer order +SearchASupplierOrder=Search a supplier order ShipProduct=Ship product Discount=Discount CreateOrder=Create Order From 12be50d4baa4eaa6c693275e38436098fb021bb9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 13:50:05 +0100 Subject: [PATCH 68/80] Doxygen --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d7fc398e082..601908bc412 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4952,7 +4952,7 @@ function dol_getmypid() * @param string $value The value to look for. * If param $numeric is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2 * If param $numeric is 1, can contains an operator <>= like "<10" or ">=100.5 < 1000" - * @param string $number 0=value is list of keywords, 1=value is a numeric test + * @param string $numeric 0=value is list of keywords, 1=value is a numeric test * @return string $res The statement to append to the SQL query */ function natural_search($fields, $value, $numeric=0) From 9a3e5d7fc593e985c453a5c58ec9c447b477665f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 13:58:26 +0100 Subject: [PATCH 69/80] Fix code unreachable --- .../core/modules/askpricesupplier/doc/pdf_aurore.modules.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php index 2c817314ecb..753c9ad9237 100644 --- a/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php @@ -591,12 +591,9 @@ class pdf_aurore extends ModelePDFAskPriceSupplier } else { - $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR"); + $this->error=$langs->trans("ErrorConstantNotDefined","ASKSUPPLIERPICE_OUTPUTDIR"); return 0; } - - $this->error=$langs->trans("ErrorUnknown"); - return 0; // Erreur par defaut } /** From b564b754fcfd67d97a27ec82cb91e95a3bb57358 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 14:09:29 +0100 Subject: [PATCH 70/80] Doxygen --- htdocs/core/db/DoliDB.class.php | 3 ++- htdocs/core/lib/functions.lib.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 67e3022d6e3..94f1568c5a2 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -1,6 +1,7 @@ + * Copyright (C) 2014-2015 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -270,7 +271,7 @@ abstract class DoliDB implements Database * * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ - * @return timestamp|string Date TMS + * @return int|string Date TMS */ function jdate($string, $gm=false) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 601908bc412..63c0f6ce433 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1157,7 +1157,7 @@ function dol_getdate($timestamp,$fast=false) * @param int $year Year * @param mixed $gm True or 1 or 'gmt'=Input informations are GMT values, False or 0 or 'server' = local to server TZ, 'user' = local to user TZ * @param int $check 0=No check on parameters (Can use day 32, etc...) - * @return timestamp|string Date as a timestamp, '' or false if error + * @return int|string Date as a timestamp, '' or false if error * @see dol_print_date, dol_stringtotime, dol_getdate */ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) From 209f8946d051a558fd8aa37df7a07aaf0c4702b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 14:17:58 +0100 Subject: [PATCH 71/80] All files must be lowercase --- htdocs/adherents/class/adherent.class.php | 4 ++-- htdocs/compta/bank/class/account.class.php | 4 ++-- ...orkboardResponse.class.php => workboardresponse.class.php} | 4 ++-- htdocs/index.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) rename htdocs/core/class/{WorkboardResponse.class.php => workboardresponse.class.php} (94%) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 6b9a8768495..78195bfa868 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1721,8 +1721,8 @@ class Adherent extends CommonObject /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * - * @param User $user Objet user - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + * @param User $user Objet user + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ function load_board($user) { diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index cfbda320fb7..80262babbbf 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -917,7 +917,7 @@ class Account extends CommonObject * * @param User $user Objet user * @param int $filteraccountid To get info for a particular account id - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ function load_board($user,$filteraccountid=0) { @@ -940,7 +940,7 @@ class Account extends CommonObject $langs->load("banks"); $now=dol_now(); - require_once DOL_DOCUMENT_ROOT.'/core/class/WorkboardResponse.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; $response = new WorkboardResponse(); $response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24; diff --git a/htdocs/core/class/WorkboardResponse.class.php b/htdocs/core/class/workboardresponse.class.php similarity index 94% rename from htdocs/core/class/WorkboardResponse.class.php rename to htdocs/core/class/workboardresponse.class.php index c36b50b421e..13de74281ff 100644 --- a/htdocs/core/class/WorkboardResponse.class.php +++ b/htdocs/core/class/workboardresponse.class.php @@ -49,8 +49,8 @@ class WorkboardResponse public $url_late; /** - * Delay time to mark an item as late - * @var int + * Delay time to mark an item as late. In number of days. + * @var double */ public $warning_delay; diff --git a/htdocs/index.php b/htdocs/index.php index c13c15d80eb..15967013e8a 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -311,7 +311,7 @@ print ''."\n"; // Do not include sections without management permission // -require DOL_DOCUMENT_ROOT.'/core/class/WorkboardResponse.class.php'; +require DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; // Number of actions to do (late) if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) From 978dc8170dfff1a03138e7dd476a4a2c06c7a490 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 10 Mar 2015 14:56:58 +0100 Subject: [PATCH 72/80] Fix : display proposal date on proposal list --- htdocs/comm/propal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index ba0a49f2772..21d774e36bb 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -388,7 +388,7 @@ if ($result) // Date proposal print ''; - print dol_print_date($db->jdate($obj->dp), 'day'); + print dol_print_date($db->jdate($objp->dp), 'day'); print "\n"; // Date end validity From 05a2a6af00f1c2a2934574d8d961fe3e27b41a7e Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 10 Mar 2015 15:53:02 +0100 Subject: [PATCH 73/80] FIX : [bug #1900] Unable to remove a salary with enough permissions --- htdocs/compta/salaries/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/salaries/fiche.php b/htdocs/compta/salaries/fiche.php index 34a2b9b4435..dac250eabc7 100644 --- a/htdocs/compta/salaries/fiche.php +++ b/htdocs/compta/salaries/fiche.php @@ -365,7 +365,7 @@ if ($id) print "
\n"; if ($salpayment->rappro == 0) { - if (! empty($user->rights->tax->charges->supprimer)) + if (! empty($user->rights->salaries->delete)) { print ''.$langs->trans("Delete").''; } From 0df2b4cc26cc8c76d7f5338e3a611a11a9cec037 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 16:14:46 +0100 Subject: [PATCH 74/80] Fix check parameters --- htdocs/societe/class/societe.class.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a18aedfcc1b..dc6503646b4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1158,12 +1158,21 @@ class Societe extends CommonObject * @param boolean $case Case sensitive (true/false) * @param boolean $similar Add test if string inside name into database, or name into database inside string. Do not use this: Not compatible with other database. * @param string $clause Clause for filters - * @return array Array of thirdparties object + * @return array|int <0 if KO, array of thirdparties object if OK */ function searchByName($name, $type='0', $filters = array(), $exact = false, $case = false, $similar = false, $clause = 'AND') { $thirdparties = array(); + dol_syslog("searchByName name=".$name." type=".$type." exact=".$exact); + + // Check parameter + if (empty($name)) + { + $this->errors[]='ErrorBadValueForParameter'; + return -1; + } + // Generation requete recherche $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE entity IN (".getEntity('category',1).")"; @@ -1242,7 +1251,7 @@ class Societe extends CommonObject } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error=$this->db->lasterror(); return -1; } } From 154865f545466e212e8f85f4aa34ab3ae66cb2e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 16:37:39 +0100 Subject: [PATCH 75/80] Fix return error when it is not --- htdocs/societe/class/societe.class.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index dc6503646b4..181c9f3ec8d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -953,7 +953,7 @@ class Societe extends CommonObject * @param string $idprof2 Prof id 2 of third party (Warning, this can return several records) * @param string $idprof3 Prof id 3 of third party (Warning, this can return several records) * @param string $idprof4 Prof id 4 of third party (Warning, this can return several records) - * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof. + * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='') { @@ -1008,7 +1008,7 @@ class Societe extends CommonObject { $this->error='Fetch several records found for ref='.$ref; dol_syslog($this->error, LOG_ERR); - $result = -1; + $result = -2; } if ($num) { @@ -1128,17 +1128,15 @@ class Societe extends CommonObject $this->fetch_optionals($this->id,$extralabels); } else - { - $this->error='Fetch no third party found for id='.$rowid; - dol_syslog($this->error, LOG_ERR); - $result = -2; + { + $result = 0; } $this->db->free($resql); } else - { - $this->error=$this->db->error(); + { + $this->error=$this->db->lasterror(); $result = -3; } From 364b1854424aacc1fcb54f12503b9220f2e9b5a3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 18:33:14 +0100 Subject: [PATCH 76/80] Fix sql syntax --- htdocs/core/class/extrafields.class.php | 88 ++++++++++++++----------- 1 file changed, 51 insertions(+), 37 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f1ad5d6687f..5a79c5ccf97 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -48,10 +48,12 @@ class ExtraFields var $attribute_required; // Array to store parameters of attribute (used in select type) var $attribute_param; - // Int to store position of attribute + // Array to store position of attribute var $attribute_pos; - // Int to store if attribute is editable regardless of the document status + // Array to store if attribute is editable regardless of the document status var $attribute_alwayseditable; + // Array to store permission to check + var $attribute_perms; var $error; var $errno; @@ -90,6 +92,7 @@ class ExtraFields $this->attribute_elementtype = array(); $this->attribute_unique = array(); $this->attribute_required = array(); + $this->attribute_perms = array(); } /** @@ -106,9 +109,10 @@ class ExtraFields * @param string $default_value Defaulted value * @param array $param Params for field * @param int $alwayseditable Is attribute always editable regardless of the document status + * @param string $perms Permission to check * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param=0, $alwayseditable=0) + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param=0, $alwayseditable=0, $perms='') { if (empty($attrname)) return -1; if (empty($label)) return -1; @@ -124,7 +128,7 @@ class ExtraFields if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') { // Add declaration of field into table - $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param, $alwayseditable); + $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param, $alwayseditable, $perms); $err2=$this->errno; if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) { @@ -225,9 +229,10 @@ class ExtraFields * @param int $required Is field required or not * @param array||string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status + * @param string $perms Permission to check * @return int <=0 if KO, >0 if OK */ - private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0) + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='') { global $conf; @@ -251,7 +256,7 @@ class ExtraFields $params=''; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable, perms)"; $sql.= " VALUES('".$attrname."',"; $sql.= " '".$this->db->escape($label)."',"; $sql.= " '".$type."',"; @@ -262,7 +267,8 @@ class ExtraFields $sql.= " '".$unique."',"; $sql.= " '".$required."',"; $sql.= " '".$params."',"; - $sql.= " '".$alwayseditable."'"; + $sql.= " '".$alwayseditable."',"; + $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null"); $sql.=')'; dol_syslog(get_class($this)."::create_label", LOG_DEBUG); @@ -363,9 +369,10 @@ class ExtraFields * @param int $pos Position of attribute * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status + * @param string $perms Permission to check * @return int >0 if OK, <=0 if KO */ - function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0) + function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='') { if ($elementtype == 'thirdparty') $elementtype='societe'; @@ -402,7 +409,7 @@ class ExtraFields { if ($label) { - $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable); + $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms); } if ($result > 0) { @@ -451,12 +458,13 @@ class ExtraFields * @param int $pos Position of attribute * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status + * @param string $perms Permission to check * @return int <=0 if KO, >0 if OK */ - private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0) + private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='') { global $conf; - dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required); + dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms); if ($elementtype == 'thirdparty') $elementtype='societe'; @@ -485,6 +493,7 @@ class ExtraFields $sql.= " elementtype,"; $sql.= " fieldunique,"; $sql.= " fieldrequired,"; + $sql.= " perms,"; $sql.= " pos,"; $sql.= " alwayseditable,"; $sql.= " param"; @@ -497,6 +506,7 @@ class ExtraFields $sql.= " '".$elementtype."',"; $sql.= " '".$unique."',"; $sql.= " '".$required."',"; + $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; $sql.= " '".$pos."',"; $sql.= " '".$alwayseditable."',"; $sql.= " '".$param."'"; @@ -542,7 +552,7 @@ class ExtraFields // For avoid conflicts with external modules if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; @@ -571,6 +581,7 @@ class ExtraFields $this->attribute_param[$tab->name]=unserialize($tab->param); $this->attribute_pos[$tab->name]=$tab->pos; $this->attribute_alwayseditable[$tab->name]=$tab->alwayseditable; + $this->attribute_perms[$tab->name]=$tab->perms; } } } @@ -603,6 +614,8 @@ class ExtraFields $unique=$this->attribute_unique[$key]; $required=$this->attribute_required[$key]; $param=$this->attribute_param[$key]; + $perms=$this->attribute_perms[$key]; + if ($type == 'date') { $showsize=10; @@ -883,7 +896,7 @@ class ExtraFields elseif ($type == 'chkbxlst') { $value_arr = explode(',', $value); - + if (is_array($param['options'])) { $param_list = array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); @@ -893,7 +906,7 @@ class ExtraFields // 3 : key field parent (for dependent lists) // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid'); - + if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) { list ( $parentName, $parentField ) = explode('|', $InfoFieldList[3]); $keyList .= ', ' . $parentField; @@ -905,13 +918,13 @@ class ExtraFields $keyList = $InfoFieldList[2] . ' as rowid'; } } - + $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label)) { $keyList .= ', '; $keyList .= implode(', ', $fields_label); } - + $sqlwhere = ''; $sql = 'SELECT ' . $keyList; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; @@ -927,7 +940,7 @@ class ExtraFields $sqlwhere .= ' WHERE 1'; } if (in_array($InfoFieldList[0], array ( - 'tablewithentity' + 'tablewithentity' ))) $sqlwhere .= ' AND entity = ' . $conf->entity; // Some tables may have field, some other not. For the moment we disable it. // $sql.=preg_replace('/^ AND /','',$sqlwhere); @@ -941,7 +954,7 @@ class ExtraFields while ( $i < $num ) { $labeltoshow = ''; $obj = $this->db->fetch_object($resql); - + // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label)) { @@ -953,7 +966,7 @@ class ExtraFields $labeltoshow = $obj->$InfoFieldList[1]; } $labeltoshow = dol_trunc($labeltoshow, 45); - + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { foreach ( $fields_label as $field_toshow ) { $translabel = $langs->trans($obj->$field_toshow); @@ -965,9 +978,9 @@ class ExtraFields } $out .= 'rowid . '"'; - + $out .= 'checked="checked"'; - + $out .= '/>' . $labeltoshow . '
'; } else { if (! $notrans) { @@ -980,31 +993,31 @@ class ExtraFields } if (empty($labeltoshow)) $labeltoshow = '(not defined)'; - + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { $out .= 'rowid . '"'; - + $out .= 'checked="checked"'; $out .= ''; - + $out .= '/>' . $labeltoshow . '
'; } - + if (! empty($InfoFieldList[3])) { $parent = $parentName . ':' . $obj->{$parentField}; } - + $out .= 'rowid . '"'; - + $out .= ((is_array($value_arr) && in_array($obj->rowid, $value_arr)) ? ' checked="checked" ' : ''); ; $out .= ''; - + $out .= '/>' . $labeltoshow . '
'; } - + $i ++; } $this->db->free($resql); @@ -1040,6 +1053,7 @@ class ExtraFields $unique=$this->attribute_unique[$key]; $required=$this->attribute_required[$key]; $params=$this->attribute_param[$key]; + $perms=$this->attribute_perms[$key]; if ($type == 'date') { $showsize=10; @@ -1172,24 +1186,24 @@ class ExtraFields elseif ($type == 'chkbxlst') { $value_arr = explode(',', $value); - + $param_list = array_keys($params['options']); $InfoFieldList = explode(":", $param_list[0]); - + $selectkey = "rowid"; $keyList = 'rowid'; - + if (count($InfoFieldList) >= 3) { $selectkey = $InfoFieldList[2]; $keyList = $InfoFieldList[2] . ' as rowid'; } - + $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label)) { $keyList .= ', '; $keyList .= implode(', ', $fields_label); } - + $sql = 'SELECT ' . $keyList; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; if (strpos($InfoFieldList[4], 'extra') !== false) { @@ -1197,14 +1211,14 @@ class ExtraFields } // $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; // $sql.= ' AND entity = '.$conf->entity; - + dol_syslog(get_class($this) . ':showOutputField:$type=chkbxlst',LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $value = ''; // value was used, so now we reste it to use it to build final output - + while ( $obj = $this->db->fetch_object($resql) ) { - + // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { From 548e720ca2c76b45417f27ca990ebe46d5615499 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 19:31:04 +0100 Subject: [PATCH 77/80] Uniformize code --- htdocs/comm/propal.php | 17 ++++++++--------- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- htdocs/fourn/commande/card.php | 22 +++++++++++----------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 98f662e3d5d..4a45f724f01 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -2003,8 +2003,7 @@ if ($action == 'create') // Amount HT print '' . $langs->trans('AmountHT') . ''; - print '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . ''; - print ''; + print '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . ''; // Margin Infos if (! empty($conf->margin->enabled)) { @@ -2016,27 +2015,27 @@ if ($action == 'create') // Amount VAT print '' . $langs->trans('AmountVAT') . ''; - print '' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . ''; - print ''; + print '' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; - print '' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print '' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . ''; print ''; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 { print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; - print '' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . ''; - print ''; + print '' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''; } // Amount TTC print '' . $langs->trans('AmountTTC') . ''; - print '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . ''; - print ''; + print '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''; // Statut print '' . $langs->trans('Status') . '' . $object->getLibStatut(4) . ''; diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 7f0115b83bc..b6b26cc380d 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -65,7 +65,7 @@ if (empty($reshook) && ! empty($extrafields->attribute_label)) print '' . img_edit().''; print ''; - print ''; + print ''; // Convert date into timestamp format if (in_array($extrafields->attribute_type[$key], array('date','datetime'))) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 6101aa7e17d..41d06bebf43 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1947,28 +1947,28 @@ elseif (! empty($object->id)) // Ligne de 3 colonnes print ''.$langs->trans("AmountHT").''; - print ''.price($object->total_ht).''; - print ''.$langs->trans("Currency".$conf->currency).''; + print ''.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).''; + print ''; - print ''.$langs->trans("AmountVAT").''.price($object->total_tva).''; - print ''.$langs->trans("Currency".$conf->currency).''; + print ''.$langs->trans("AmountVAT").''.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).''; + print ''; // Amount Local Taxes if ($mysoc->localtax1_assuj=="1" || $object->total_localtax1 != 0) //Localtax1 { print ''.$langs->transcountry("AmountLT1",$mysoc->country_code).''; - print ''.price($object->total_localtax1).''; - print ''.$langs->trans("Currency".$conf->currency).''; + print ''.price($object->total_localtax1,'',$langs,1,-1,-1,$conf->currency).''; + print ''; } if ($mysoc->localtax2_assuj=="1" || $object->total_localtax2 != 0) //Localtax2 { print ''.$langs->transcountry("AmountLT2",$mysoc->country_code).''; - print ''.price($object->total_localtax2).''; - print ''.$langs->trans("Currency".$conf->currency).''; + print ''.price($object->total_localtax2,'',$langs,1,-1,-1,$conf->currency).''; + print ''; } - print ''.$langs->trans("AmountTTC").''.price($object->total_ttc).''; - print ''.$langs->trans("Currency".$conf->currency).''; + print ''.$langs->trans("AmountTTC").''.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).''; + print ''; print "
"; @@ -2610,7 +2610,7 @@ elseif (! empty($object->id)) print ''.$langs->trans("ReOpen").''; } } - + // Create bill if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted { From c27125745282002d91b08f82b25229d37d5db17b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 22:27:16 +0100 Subject: [PATCH 78/80] Prepare extrafield for option by default into lists --- htdocs/core/class/extrafields.class.php | 46 +++++++++++++------ .../install/mysql/migration/3.7.0-3.8.0.sql | 1 + .../install/mysql/tables/llx_extrafields.sql | 3 +- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 5a79c5ccf97..24d8c40f5b3 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -54,6 +54,8 @@ class ExtraFields var $attribute_alwayseditable; // Array to store permission to check var $attribute_perms; + // Array to store permission to check + var $attribute_list; var $error; var $errno; @@ -93,6 +95,7 @@ class ExtraFields $this->attribute_unique = array(); $this->attribute_required = array(); $this->attribute_perms = array(); + $this->attribute_list = array(); } /** @@ -110,9 +113,10 @@ class ExtraFields * @param array $param Params for field * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check + * @param int $list Into list view by default * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param=0, $alwayseditable=0, $perms='') + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param=0, $alwayseditable=0, $perms='', $list=0) { if (empty($attrname)) return -1; if (empty($label)) return -1; @@ -122,13 +126,13 @@ class ExtraFields // Create field into database except for separator type which is not stored in database if ($type != 'separate') { - $result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value,$param); + $result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value, $param, $perms, $list); } $err1=$this->errno; if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') { // Add declaration of field into table - $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param, $alwayseditable, $perms); + $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param, $alwayseditable, $perms, $list); $err2=$this->errno; if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) { @@ -156,10 +160,11 @@ class ExtraFields * @param int $required Is field required or not * @param string $default_value Default value for field * @param array $param Params for field (ex for select list : array('options'=>array('value'=>'label of option')) - * + * @param string $perms Permission + * @param int $list Into list view by default * @return int <=0 if KO, >0 if OK */ - private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='') + private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list=0) { if ($elementtype == 'thirdparty') $elementtype='societe'; @@ -230,9 +235,10 @@ class ExtraFields * @param array||string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check + * @param int $list Into list view by default * @return int <=0 if KO, >0 if OK */ - private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='') + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=0) { global $conf; @@ -240,6 +246,7 @@ class ExtraFields // Clean parameters if (empty($pos)) $pos=0; + if (empty($list)) $list=0; if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname)) { @@ -256,7 +263,7 @@ class ExtraFields $params=''; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable, perms)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable, perms, list)"; $sql.= " VALUES('".$attrname."',"; $sql.= " '".$this->db->escape($label)."',"; $sql.= " '".$type."',"; @@ -268,7 +275,8 @@ class ExtraFields $sql.= " '".$required."',"; $sql.= " '".$params."',"; $sql.= " '".$alwayseditable."',"; - $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null"); + $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; + $sql.= " ".$list; $sql.=')'; dol_syslog(get_class($this)."::create_label", LOG_DEBUG); @@ -370,9 +378,10 @@ class ExtraFields * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check + * @param int $list Into list view by default * @return int >0 if OK, <=0 if KO */ - function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='') + function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='',$list='') { if ($elementtype == 'thirdparty') $elementtype='societe'; @@ -409,7 +418,7 @@ class ExtraFields { if ($label) { - $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms); + $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list); } if ($result > 0) { @@ -459,14 +468,17 @@ class ExtraFields * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check + * @param int $list Into list view by default * @return int <=0 if KO, >0 if OK */ - private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='') + private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0) { global $conf; - dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms); + dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list); + // Clean parameters if ($elementtype == 'thirdparty') $elementtype='societe'; + if (empty($list)) $list=0; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { @@ -496,7 +508,8 @@ class ExtraFields $sql.= " perms,"; $sql.= " pos,"; $sql.= " alwayseditable,"; - $sql.= " param"; + $sql.= " param,"; + $sql.= " list"; $sql.= ") VALUES ("; $sql.= "'".$attrname."',"; $sql.= " ".$conf->entity.","; @@ -510,6 +523,7 @@ class ExtraFields $sql.= " '".$pos."',"; $sql.= " '".$alwayseditable."',"; $sql.= " '".$param."'"; + $sql.= " ".$list; $sql.= ")"; dol_syslog(get_class($this)."::update_label", LOG_DEBUG); $resql2=$this->db->query($sql); @@ -552,7 +566,7 @@ class ExtraFields // For avoid conflicts with external modules if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,list"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; @@ -582,6 +596,7 @@ class ExtraFields $this->attribute_pos[$tab->name]=$tab->pos; $this->attribute_alwayseditable[$tab->name]=$tab->alwayseditable; $this->attribute_perms[$tab->name]=$tab->perms; + $this->attribute_perms[$tab->name]=$tab->list; } } } @@ -615,6 +630,7 @@ class ExtraFields $required=$this->attribute_required[$key]; $param=$this->attribute_param[$key]; $perms=$this->attribute_perms[$key]; + $list=$this->attribute_list[$key]; if ($type == 'date') { @@ -1054,6 +1070,8 @@ class ExtraFields $required=$this->attribute_required[$key]; $params=$this->attribute_param[$key]; $perms=$this->attribute_perms[$key]; + $list=$this->attribute_list[$key]; + if ($type == 'date') { $showsize=10; diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 03736b088fc..6d767e20d45 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -20,6 +20,7 @@ ALTER TABLE llx_extrafields ADD COLUMN perms varchar(255) after fieldrequired; +ALTER TABLE llx_extrafields ADD COLUMN list integer DEFAULT 0 after perms; ALTER TABLE llx_payment_salary ADD COLUMN salary real after datev; diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql index 11271125508..21610d07c0e 100644 --- a/htdocs/install/mysql/tables/llx_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_extrafields.sql @@ -32,5 +32,6 @@ create table llx_extrafields perms varchar(255), pos integer DEFAULT 0, alwayseditable integer DEFAULT 0, - param text + param text, + list integer DEFAULT 0 )ENGINE=innodb; From ec322e2e2974d52f767d4132bb1878e6685ded55 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Mar 2015 03:03:17 +0100 Subject: [PATCH 79/80] Revert was not complete --- htdocs/admin/system/database-tables.php | 5 +- htdocs/core/db/sqlite.class.php | 84 +++---------------------- htdocs/core/db/sqlite3.class.php | 3 +- htdocs/install/etape2.php | 3 +- htdocs/install/fileconf.php | 3 +- 5 files changed, 17 insertions(+), 81 deletions(-) diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index e75cec3f513..39b3dd4cad5 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -66,7 +66,8 @@ else if ($conf->db->type == 'mssql') //$sqls[0] = ""; //$base=3; } -else if ($conf->db->type == 'sqlite3') { +else if ($conf->db->type == 'sqlite' || $conf->db->type == 'sqlite3') +{ //$sql = "SELECT name, type FROM sqlite_master"; $base = 4; } @@ -176,7 +177,7 @@ else if ($base == 4) { - // Sqlite3 + // Sqlite by PDO or by Sqlite3 print ''; print ''; print ''; diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 786bf435fcf..88efde86394 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -40,12 +40,6 @@ class DoliDBSqlite extends DoliDB //! Resultset of last query private $_results; - /** - * Indique que les fonctions personnalisées sont définies - * @var boolean - */ - private static $customFunctionsDefined = false; - /** * Constructor. * This create an opened connexion to a database server and eventually to a database @@ -56,6 +50,7 @@ class DoliDBSqlite extends DoliDB * @param string $pass Mot de passe * @param string $name Nom de la database * @param int $port Port of database server + * @return int 1 if OK, 0 if not */ function __construct($type, $host, $user, $pass, $name='', $port=0) { @@ -159,7 +154,7 @@ class DoliDBSqlite extends DoliDB // Process case: "CREATE TABLE llx_mytable(rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,code..." if (preg_match('/[\s\t\(]*(\w*)[\s\t]+int.*auto_increment/i',$line,$reg)) { - $newline=preg_replace('/([\s\t\(]*)([a-zA-Z_0-9]*)[\s\t]+int.*auto_increment[^,]*/i','\\1 \\2 integer PRIMARY KEY AUTOINCREMENT',$line); + $newline=preg_replace('/([\s\t\(]*)([a-zA-Z_0-9]*)[\s\t]+int.*auto_increment[^,]*/i','\\1 \\2 SERIAL PRIMARY KEY',$line); //$line = "-- ".$line." replaced by --\n".$newline; $line=$newline; } @@ -248,18 +243,11 @@ class DoliDBSqlite extends DoliDB $line = "-- ".$line." replaced by --\n"; $line.= "CREATE ".(preg_match('/UNIQUE/',$reg[2])?'UNIQUE ':'')."INDEX ".$idxname." ON ".$tablename." (".$fieldlist.")"; } - if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+CONSTRAINT\s+(.*)\s*FOREIGN\s+KEY\s*\(([\w,\s]+)\)\s*REFERENCES\s+(\w+)\s*\(([\w,\s]+)\)/i',$line, $reg)) { - // Pour l'instant les contraintes ne sont pas créées - dol_syslog(get_class().'::query line emptied'); - $line = 'SELECT 0;'; - - } - - //if (preg_match('/rowid\s+.*\s+PRIMARY\s+KEY,/i', $line)) { - //preg_replace('/(rowid\s+.*\s+PRIMARY\s+KEY\s*,)/i', '/* \\1 */', $line); - //} } + // To have postgresql case sensitive + $line=str_replace(' LIKE \'',' ILIKE \'',$line); + // Delete using criteria on other table must not declare twice the deleted table // DELETE FROM tabletodelete USING tabletodelete, othertable -> DELETE FROM tabletodelete USING othertable if (preg_match('/DELETE FROM ([a-z_]+) USING ([a-z_]+), ([a-z_]+)/i',$line,$reg)) @@ -400,53 +388,7 @@ class DoliDBSqlite extends DoliDB $this->error = 0; // Convert MySQL syntax to SQLite syntax - if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+CONSTRAINT\s+(.*)\s*FOREIGN\s+KEY\s*\(([\w,\s]+)\)\s*REFERENCES\s+(\w+)\s*\(([\w,\s]+)\)/i',$query, $reg)) { - // Ajout d'une clef étrangère à la table - // procédure de remplacement de la table pour ajouter la contrainte - // Exemple : ALTER TABLE llx_adherent ADD CONSTRAINT adherent_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid) - // -> CREATE TABLE ( ... ,CONSTRAINT adherent_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid)) - $foreignFields = $reg[5]; - $foreignTable = $reg[4]; - $localfields = $reg[3]; - $constraintname=trim($reg[2]); - $tablename=trim($reg[1]); - - $res = $this->db->query("SELECT sql FROM sqlite_master WHERE name='" . $tablename . "'"); - $descTable = $res->fetchColumn(); - $res->closeCursor(); - - // 1- Renommer la table avec un nom temporaire - $res = $this->query('ALTER TABLE ' . $tablename . ' RENAME TO tmp_' . $tablename); - $res->closeCursor(); - - // 2- Recréer la table avec la contrainte ajoutée - - // on bricole la requete pour ajouter la contrainte - $descTable = substr($descTable, 0, strlen($descTable) - 1); - $descTable .= ", CONSTRAINT " . $constraintname . " FOREIGN KEY (" . $localfields . ") REFERENCES " .$foreignTable . "(" . $foreignFields . ")"; - - // fermeture de l'instruction - $descTable .= ')'; - - // Création proprement dite de la table - $res = $this->query($descTable); - $res->closeCursor(); - - // 3- Transférer les données - $res = $this->query('INSERT INTO ' . $tablename . ' SELECT * FROM tmp_' . $tablename); - $res->closeCursor(); - - - // 4- Supprimer la table temporaire - $res = $this->query('DROP TABLE tmp_' . $tablename); - $res->closeCursor(); - - // dummy statement - $query="SELECT 0"; - - } else { - $query=$this->convertSQLFromMysql($query,$type); - } + $query=$this->convertSQLFromMysql($query,$type); //print "After convertSQLFromMysql:\n".$query."
\n"; dol_syslog('sql='.$query, LOG_DEBUG); @@ -546,11 +488,7 @@ class DoliDBSqlite extends DoliDB { // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } - if (preg_match("/^SELECT/i", $resultset->queryString)) { - $res = $this->db->query("SELECT count(*) FROM (" . $resultset->queryString . ") q"); - return $res->fetchColumn(); - } - return $resultset->rowCount(); + return $resultset->rowCount(); } /** @@ -592,12 +530,7 @@ class DoliDBSqlite extends DoliDB */ function escape($stringtoencode) { - $ret = $this->db->quote($stringtoencode); - $l = strlen($ret); - if ($l >= 2) { - return substr($ret, 1, $l -2); - } - return ''; + return $this->db->quote($stringtoencode); } /** @@ -1203,6 +1136,5 @@ class DoliDBSqlite extends DoliDB return $result; } - } diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index c52578fa579..ce3762202e4 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -354,7 +354,8 @@ class DoliDBSqlite3 extends DoliDB */ function getVersion() { - return $this->db->version()['versionString']; + $tmp=$this->db->version(); + return $tmp['versionString']; } /** diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php index 612c3c64148..8c0e3f8ab5c 100644 --- a/htdocs/install/etape2.php +++ b/htdocs/install/etape2.php @@ -51,7 +51,8 @@ if ($dolibarr_main_db_type == "mysql") $choix=1; if ($dolibarr_main_db_type == "mysqli") $choix=1; if ($dolibarr_main_db_type == "pgsql") $choix=2; if ($dolibarr_main_db_type == "mssql") $choix=3; -if ($dolibarr_main_db_type == "sqlite3") $choix=4; +if ($dolibarr_main_db_type == "sqlite") $choix=4; +if ($dolibarr_main_db_type == "sqlite3") $choix=5; //if (empty($choix)) dol_print_error('','Database type '.$dolibarr_main_db_type.' not supported into etape2.php page'); diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index ec3e208374b..5dce328d04c 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -306,7 +306,7 @@ if (! empty($force_install_message)) $class='DoliDB'.ucfirst($type); include_once $dir."/".$file; - if ($type == 'sqlite') continue; // We hide sqlite because support can't be complete unti sqlit does not manage foreign key creation after table creation + if ($type == 'sqlite') continue; // We hide sqlite because support can't be complete until sqlite does not manage foreign key creation after table creation // Version min of database $versionbasemin=explode('.',$class::VERSIONMIN); @@ -320,6 +320,7 @@ if (! empty($force_install_message)) if ($type=='mysqli') { $testfunction='mysqli_connect'; $testclass=''; } if ($type=='pgsql') { $testfunction='pg_connect'; $testclass=''; } if ($type=='mssql') { $testfunction='mssql_connect'; $testclass=''; } + if ($type=='sqlite') { $testfunction=''; $testclass='PDO'; } if ($type=='sqlite3') { $testfunction=''; $testclass='SQLite3'; } $option.='
'.$langs->trans("TableName").'