From bc5355dfa1117ea0734e1537c6405dceb9a62353 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 13 Aug 2022 15:05:29 +0200 Subject: [PATCH] Tache 0001743: Une couleur par dossier --- html/css/style-classic7.css | 5 +- include/class/noalyss_appearance.class.php | 271 +++++++++++++++++++++ include/company.inc.php | 60 +++-- include/constant.php | 4 +- include/lib/ac_common.php | 15 +- include/lib/icolor.class.php | 48 ++++ include/sql/patch/upgrade174.sql | 21 ++ 7 files changed, 397 insertions(+), 27 deletions(-) create mode 100644 include/class/noalyss_appearance.class.php create mode 100644 include/lib/icolor.class.php create mode 100644 include/sql/patch/upgrade174.sql diff --git a/html/css/style-classic7.css b/html/css/style-classic7.css index 035946107..9c73c4f0d 100644 --- a/html/css/style-classic7.css +++ b/html/css/style-classic7.css @@ -505,7 +505,6 @@ div.content a { font-family: 'openSansRegular'; text-decoration: none; display: inline-block; - color: #0000FF; padding: 0px 10px 0px 0px; text-decoration: underline; /*! background: rgb(247, 192, 156) none repeat scroll 0% 0%; */ @@ -809,7 +808,7 @@ a#anchorbutton, .button, a.button,div.content a.button { font-weight: bold; text-decoration:none; font-family: arial,verdana,sans-serif,helvetica; - background-image: url("font/bg-submit2.gif"); + background-image: url("image/bg-submit2.gif"); background-repeat: repeat-x; background-position: left; border-color: #0000FF; @@ -1332,6 +1331,8 @@ div.content a.nav:hover img,a.nav:hover img { text-align: center; font-variant:small-caps; font-weight: bolder; + height:5rem; + font-size: 125%; } } diff --git a/include/class/noalyss_appearance.class.php b/include/class/noalyss_appearance.class.php new file mode 100644 index 000000000..959d20975 --- /dev/null +++ b/include/class/noalyss_appearance.class.php @@ -0,0 +1,271 @@ + '#9fbcd6', + 'MENU1' => '#000074', + 'BODY' => '#ffffff', + 'MENU2' => '#3d3d87', + 'MENU1-SELECTED' => '#3d3d87', + 'TR-ODD'=>'#DCE7F5', + 'TR-EVEN'=>'#e4e7ed', + 'INNER-BOX'=>'#DCE1EF', + 'FONT-MENU1' => '#ffffff', + 'FONT-MENU2' => '#ffffff', + 'FONT-TABLE' => '#222bd0', + 'FONT-DEFAULT' => '#000074', + 'FOLDER' => '#ffffff', + 'FONT-TABLE-HEADER' =>'#0C106D', + 'FONT-FOLDER' => '#000074']; + static private $aCSSColorName = array(); + private $aColor; + + function __construct() + { + self::$aCSSColorName = ['H2' => _("Titre"), + 'MENU1' => _("Menu principal"), + 'BODY' => _("Fond d'écran"), + 'MENU2' => _("Menu second"), + 'MENU1-SELECTED' => _("Menu choisi"), + 'TR-ODD'=>_("Ligne impaire"), + 'TR-EVEN'=>_("Ligne paire"), + 'INNER-BOX'=>_("Fond Boîte dialogue"), + 'FOLDER' => _("Couleur dossier"), + 'FONT-MENU1' => _("Couleur police menu principale"), + 'FONT-MENU2' => _("Couleur police menu second"), + 'FONT-TABLE' => _("Couleur police dans les tables"), + 'FONT-DEFAULT' => _("Couleur police par défaut"), + 'FONT-TABLE-HEADER' => _("Couleur police en-tête table"), + 'FONT-FOLDER' => _("Couleur police dossier")]; + $this->aColor=self::$aCSSColor; + } + + function load() + { + $cn = Dossier::connect(); + $aColor = $cn->get_array("select a_code,a_value from parm_appearance"); + foreach ($aColor as $key => $value) { + $this->aColor[$value['a_code']] = $value['a_value']; + } + + } + + function save() + { + $cn = Dossier::connect(); + foreach ($this->aColor as $key => $value) { + $cn->exec_sql("insert into parm_appearance values ($1,$2) + on conflict (a_code) do update set a_value =excluded.a_value", [$key, $value]); + } + } + + function set_color($p_code, $p_value) + { + $aKey = array_keys($this->aColor); + if (!in_array($p_code, $aKey)) { + throw new \Exception("NA63: Code invalide "); + } + if (!preg_match('/^#[a-f0-9]{6}$/i', $p_value)) //hex color is valid + { + throw new \Exception("NA67: Couleur invalide "); + } + $this->aColor[$p_code] = $p_value; + } + + function print_css() + { + $this->load(); + $body = $this->aColor['BODY']; + $h2 = $this->aColor['H2']; + $menu1 = $this->aColor['MENU1']; + $menu2 = $this->aColor['MENU2']; + $menu1_selected = $this->aColor['MENU1-SELECTED']; + $menu1_font = $this->aColor['FONT-MENU1']; + $menu2_font = $this->aColor['FONT-MENU2']; + $font_table = $this->aColor['FONT-TABLE']; + $font_default = $this->aColor['FONT-DEFAULT']; + $font_table_header = $this->aColor['FONT-TABLE-HEADER']; + $folder_font = $this->aColor['FONT-FOLDER']; + $folder = $this->aColor['FOLDER']; + $tr_odd=$this->aColor['TR-ODD']; + $tr_even=$this->aColor['TR-EVEN']; + $inner_box=$this->aColor['INNER-BOX']; + + echo << + #dossier { + color:{$folder_font}; + background-color: {$folder}; + } + body { + background-color: {$body} !important; + color:{$font_default} !important; + } + h2 , hr { + background-color: {$h2} !important; + } + .nav-fill .nav-item { + background: {$menu1}; + color: {$menu1_font}; + } + .nav-level2 { + background-color: {$menu2}; + color:{$menu2_font}; + } + .nav-pills .nav-link.active { + background-color: {$menu1_selected} !important; + } + table.sortable, table.table_large, table.result ,table.resultfooter { + color:{$font_table} !important; + } + table.sortable th, table.table_large th, table.result th ,table.resultfooter th { + color:{$font_table_header}; + } + tr.odd,div.inner_box tr.odd,div.box tr.odd { + background-color: {$tr_odd}; + } + #calc1 , div.inner_box , div.box, #add_todo_list , div.add_todo_list,body.op_detail_frame, div.op_detail_frame { + background-color:{$inner_box}; + } + tr.even { + background-color: {$tr_even} !important; + } + + +EOF; + + } + + function input_reset() + { + $r=""; + $label=_("Cocher pour remettre les couleurs d'origine"); + $chk=new ICheckBox("reset_color",1); + + $str_reset=$chk->input(); + $r.=<< + + {$str_reset} + +EOF; + return $r; + + } + function input_form() + { + $str = ""; + $str = '

'._("Couleur de fond").'

'; + $f=0; + foreach (self::$aCSSColorName as $key => $value) { + $value = $this->aColor[$key]; + $icolor = new IColor($key, $value); + $str_icolor = $icolor->input(); + $label = self::$aCSSColorName[$key]; + $part=mb_strcut($key,0,4); + if ( strcmp($part , "FONT")==0 && $f==0 ){ + $str .= '

'._("Couleur police").'

'; + $f=1; + } + $str .= << + + {$str_icolor} + +EOF; + } + $str.=$this->input_reset(); + return $str; + } + + /** + * @return string[] + */ + public static function getACSSColor(): array + { + return self::$aCSSColor; + } + + /** + * @param string[] $aCSSColor + */ + public static function setACSSColor(array $aCSSColor): void + { + self::$aCSSColor = $aCSSColor; + } + + /** + * @return array + */ + public static function getACSSColorName(): array + { + return self::$aCSSColorName; + } + + /** + * @param array $aCSSColorName + */ + public static function setACSSColorName(array $aCSSColorName): void + { + self::$aCSSColorName = $aCSSColorName; + } + + function reset() + { + $this->aColor=self::$aCSSColor ; + } + /** + *@brief retrieve data from POST and returns true, if nothing is retrieved , returns false + */ + function from_post() + { + $http=new \HttpInput(); + if ( $http->post("reset_color","number",0) == 1 ) { + $this->reset(); + return true; + } + foreach (self::$aCSSColorName as $key=>$value) { + $color=$http->post($key,'string',""); + if (empty($color) ) { return false;} + $this->set_color($key,$color); + } + + return true; + } +} + + + diff --git a/include/company.inc.php b/include/company.inc.php index 33ecba00c..e90879aee 100644 --- a/include/company.inc.php +++ b/include/company.inc.php @@ -190,16 +190,7 @@ $all->style=' class="input_text"'; input("p_tva", $my->MY_TVA) ?> -
-
-
- -
-
-

Paramètre supplémentaire

@@ -210,6 +201,32 @@ $all->style=' class="input_text"'; ?>
+
+
+

+ load(); + if ( $noalyss_appearance->from_post() ) { + if (DEBUGNOALYSS > 1 ) { echo "save appearance";} + $noalyss_appearance->save(); + } + echo $noalyss_appearance->input_form(); + ?> + + +
+
+
+
+
+ + +
+
+
@@ -221,7 +238,7 @@ $all->style=' class="input_text"'; input("p_compta", $array) ?> -
+
+
@@ -242,32 +259,32 @@ echo Icon_Action::tips($anc_filter->title);
input("p_strict", $strict_array) ?> -
+
input("p_tva_use", $strict_array) ?> -
+
input("p_pj", $strict_array) ?> -
+
input("p_date_suggest", $strict_array) ?> -
+
input('p_check_periode', $strict_array) ?> -
+
@@ -275,31 +292,32 @@ echo Icon_Action::tips($anc_filter->title); input('p_alphanum') ?> -
+
input('p_updlab') ?> -
+
input() ?> -
+
input() ?> -
+ + -
+
'class/acc_other_tax_mtable.class.php', 'acc_other_tax_sql' => 'database/acc_other_tax_sql.class.php', 'jrn_tax_sql' => 'database/jrn_tax_sql.class.php', - 'additional_tax' => 'class/additional_tax.class.php' + 'additional_tax' => 'class/additional_tax.class.php', + 'noalyss_appearance' => 'class/noalyss_appearance.class.php', + 'icolor'=>'lib/icolor.class.php' ); if (isset ($aClass[$class])) { require_once NOALYSS_INCLUDE . "/" . $aClass[$class]; diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index fdd7e1960..3482c8629 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -376,6 +376,12 @@ function html_page_start($p_theme="", $p_script="", $p_script2="") } echo load_all_script(); + + // Retrieve colors for this folder + if ( isset($_REQUEST['gDossier']) ) { + $noalyss_appearance=new Noalyss_Appearance(); + $noalyss_appearance->print_css(); + } echo ' '; echo ""; @@ -442,9 +448,12 @@ function html_min_page_start($p_theme="", $p_script="", $p_script2="") "; echo ""; include_once NOALYSS_INCLUDE.'/lib/message_javascript.php'; - echo ' - '; - + // Retrieve colors for this folder + if ( isset($_REQUEST['gDossier']) ) { + $noalyss_appearance=new Noalyss_Appearance(); + $noalyss_appearance->print_css(); + } + echo ''; echo ""; /* If we are on the user_login page */ if (basename($_SERVER['PHP_SELF']) == 'user_login.php') diff --git a/include/lib/icolor.class.php b/include/lib/icolor.class.php new file mode 100644 index 000000000..7e65eb3da --- /dev/null +++ b/include/lib/icolor.class.php @@ -0,0 +1,48 @@ +id=(empty($this->id))?$this->name:$this->id; + $ret = sprintf( '', + $this->id,$this->name,$this->value); + return $ret; + } + function display() + { + return ""; + } + +} \ No newline at end of file diff --git a/include/sql/patch/upgrade174.sql b/include/sql/patch/upgrade174.sql new file mode 100644 index 000000000..afb99009b --- /dev/null +++ b/include/sql/patch/upgrade174.sql @@ -0,0 +1,21 @@ +begin; +create table parm_appearance (a_code text primary key , a_value text not null); + +insert into parm_appearance values ('H2' , '#9fbcd6') + ,('MENU1','#000074') + ,('BODY','#ffffff') + ,('MENU2','#3d3d87') + ,('MENU1-SELECTED','#3d3d87') + ,('FONT-MENU1','#ffffff') + ,('FONT-MENU2','#ffffff') + ,('FONT-TABLE','#222bd0') + ,('FONT-DEFAULT','#000074') + ,('FONT-TABLE-HEADER','#0C106D') + ,('FOLDER','#ffffff') + ,('FONT-FOLDER','#000074') + ,('TR-ODD','#DCE7F5') + ,('TR-EVEN','#e4e7ed') + ,('INNER-BOX','#DCE1EF') + ; +insert into version (val,v_description) values (175,'Folder Appearance'); +commit; \ No newline at end of file