noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 02/14: Tache 0001743: Une couleur par dossier


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 02/14: Tache 0001743: Une couleur par dossier
Date: Mon, 22 Aug 2022 12:21:52 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit bc5355dfa1117ea0734e1537c6405dceb9a62353
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sat Aug 13 15:05:29 2022 +0200

    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(-)

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 @@
+<?php
+/*
+ *   This file is part of NOALYSS.
+ *    NOALYSS 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 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    NOALYSS 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 NOALYSS; if not, write to the Free Software
+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *    Copyright Author Dany De Bontridder danydb@noalyss.eu
+ *
+ */
+
+/**
+ * @file
+ * @brief  Contains some parameters to change appearance of noalyss
+ */
+
+/**
+ * @class
+ * @brief Contains some parameters to change appearance of noalyss, the colors 
are saved
+ * into the table parm_appearance
+ */
+class Noalyss_Appearance
+{
+    static private $aCSSColor = ['H2' => '#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 <<<EOF
+    <style>
+    #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;
+    }
+    </style>
+
+EOF;
+
+    }
+
+    function input_reset()
+    {
+        $r="";
+        $label=_("Cocher pour remettre les couleurs d'origine");
+        $chk=new ICheckBox("reset_color",1);
+
+        $str_reset=$chk->input();
+        $r.=<<<EOF
+<div class="form-group">
+    <label for="reset_color">
+    {$label}
+</label>
+    {$str_reset}
+</div>
+EOF;
+        return $r;
+
+    }
+    function input_form()
+    {
+        $str = "";
+        $str = '<h3 style="text-align: center;border:1px solid 
black;">'._("Couleur de fond").'</h3>';
+        $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 .=  '<h3 style="text-align: center;border:1px solid 
black;">'._("Couleur police").'</h3>';
+                $f=1;
+            }
+            $str .= <<<EOF
+<div class="form-group">
+    <label for="{$key}">
+    {$label}
+</label>
+    {$str_icolor}
+</div>
+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"';
                 <label class="w-20" for="p_tva"><?= _("Numéro de Tva") 
?></label>
                 <?= $all->input("p_tva", $my->MY_TVA) ?>
             </div>
-            <div class="row">
-                <div class="col-4"></div>
-                <div class="col-4">
-                    <?php
-                    echo HtmlInput::submit("record_company", _("Sauve"), "", 
"button");
-                    ?>
 
-                </div>
-                <div class="col-4"></div>
-            </div>
             <div class="row">
                 <div class="col">
                     <h2>Paramètre supplémentaire</h2>
@@ -210,6 +201,32 @@ $all->style=' class="input_text"';
                     ?>
                 </div>
             </div>
+            <div class="row">
+                <div class="col">
+                    <h2><?=_("Apparence")?></h2>
+                    <?php
+                    $noalyss_appearance=new Noalyss_Appearance();
+                    $noalyss_appearance->load();
+                    if ( $noalyss_appearance->from_post() ) {
+                        if (DEBUGNOALYSS > 1 ) { echo "save appearance";}
+                        $noalyss_appearance->save();
+                    }
+                    echo $noalyss_appearance->input_form();
+                    ?>
+
+
+                </div>
+            </div>
+            <div class="row">
+                <div class="col-4"></div>
+                <div class="col-4">
+                    <?php
+                    echo HtmlInput::submit("record_company", _("Sauve"), "", 
"button");
+                    ?>
+
+                </div>
+                <div class="col-4"></div>
+            </div>
         </div>
 
         <div class="col">
@@ -221,7 +238,7 @@ $all->style=' class="input_text"';
                 <label class="w-20" for="p_compta">
 <?= _("Utilisation de la compta. analytique") ?></label>
                     <?= $compta->input("p_compta", $array) ?>
-            </div>        
+            </div>
 
             <div class="form-group">
                 <label class="" for="p_anc_filter">
@@ -232,7 +249,7 @@ $all->style=' class="input_text"';
 echo $anc_filter->input();
 echo Icon_Action::tips($anc_filter->title);
 ?>
-            </div>        
+            </div>
 
             <div class="form-group">
                 <label class="w-20" for="p_stock"><?= _("Utilisation des 
stocks") ?></label>
@@ -242,32 +259,32 @@ echo Icon_Action::tips($anc_filter->title);
             <div class="form-group">
                 <label class="w-20" for="p_strict"><?= _("Utilisation du mode 
strict ") ?></label>
 <?= $strict->input("p_strict", $strict_array) ?>
-            </div>        
+            </div>
 
 
             <div class="form-group">
                 <label class="w-20" for="p_tva_use"><?= _("Assujetti à la 
tva") ?></label>
 <?= $tva_use->input("p_tva_use", $strict_array) ?>
-            </div>        
+            </div>
 
             <div class="form-group">
                 <label class="w-20" for="p_pj"><?= _("Suggérer le numéro de 
pièce justificative") ?>
                 </label>
 <?= $pj_suggest->input("p_pj", $strict_array) ?>
-            </div>        
+            </div>
 
 
             <div class="form-group">
                 <label class="w-20" for="p_date_suggest"><?= _("Suggérer la 
date") ?></label>
 <?= $date_suggest->input("p_date_suggest", $strict_array) ?>
-            </div>        
+            </div>
 
 
             <div class="form-group">
                 <label class="w-20" for="p_check_periode"><?= _('Afficher la 
période comptable pour éviter les erreurs de date') ?>
                 </label>
 <?= $check_periode->input('p_check_periode', $strict_array) ?>
-            </div>        
+            </div>
 
 
             <div class="form-group">
@@ -275,31 +292,32 @@ echo Icon_Action::tips($anc_filter->title);
 <?= _('Utilisez des postes comptables alphanumérique') ?>
                 </label>
                     <?= $alpha_num->input('p_alphanum') ?>
-            </div>        
+            </div>
 
             <div class="form-group">
                 <label class="w-20" for="p_updlab">
 <?= _('Changer le libellé des détails') ?>
                 </label>
                     <?= $updlab->input('p_updlab') ?>
-            </div>        
+            </div>
 
             <div class="form-group">
                 <label class="" for="p_round_error_deb">
 <?= _("Poste comptable de CHARGE (D) pour les différences d'arrondi pour les 
opérations en devise") ?>
                 </label>
                     <?= $default_error_deb->input() ?>
-            </div>        
+            </div>
 
             <div class="form-group">
                 <label class="" for="p_round_error_cred">
 <?= _("Poste comptable en PRODUIT (C) pour les différences d'arrondi pour les 
opérations en devise") ?>
                 </label>
                     <?= $default_error_cred->input() ?>
-            </div>        
+            </div>
+
 
-            <div class="row">
                 <div class="col-4"></div>
+
                 <div class="col-4">
 <?php
 echo HtmlInput::submit("record_company", _("Sauve"), "", "button");
diff --git a/include/constant.php b/include/constant.php
index 3c3c02bfb..962fe2675 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -598,7 +598,9 @@ function noalyss_class_autoloader($class)
         "acc_other_tax_mtable" => '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 '    </HEAD>    ';
 
     echo "<BODY $p_script>";
@@ -442,9 +448,12 @@ function html_min_page_start($p_theme="", $p_script="", 
$p_script2="")
     <script src=\"js/smoke.js\" type=\"text/javascript\"></script>";
     echo "<LINK id=\"pagestyle\" REL=\"stylesheet\" type=\"text/css\" 
href=\"css/font/fontello/css/fontello.css\" media=\"screen\"/>";
     include_once NOALYSS_INCLUDE.'/lib/message_javascript.php';
-    echo '</HEAD>
-    ';
-
+    //  Retrieve colors for this folder
+    if ( isset($_REQUEST['gDossier'])  ) {
+        $noalyss_appearance=new Noalyss_Appearance();
+        $noalyss_appearance->print_css();
+    }
+    echo '</HEAD>';
     echo "<BODY $p_script>";
     /* 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 @@
+<?php
+/*
+ *   This file is part of NOALYSS.
+ *    NOALYSS 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 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    NOALYSS 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 NOALYSS; if not, write to the Free Software
+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *    Copyright Author Dany De Bontridder danydb@noalyss.eu
+ *
+ */
+
+
+/**
+ *\file
+  * \brief Html Input for color
+ */
+
+
+class IColor extends HtmlInput
+{
+    function __construct($p_name = "", $p_value = "", $p_id = "")
+    {
+        parent::__construct($p_name, $p_value, $p_id);
+
+    }
+    function input()
+    {
+        $this->id=(empty($this->id))?$this->name:$this->id;
+        $ret = sprintf( '<input type="color" id="%s" name="%s" value="%s">',
+            $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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]