pref.inc.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of PhpCompta.
00004  *
00005  *   PhpCompta is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   PhpCompta is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with PhpCompta; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 /* $Revision: 4474 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00021 /* !\file
00022  * \brief this file is always included and then executed
00023  *        it permits to change the user preferences
00024  * \see user_pref.php
00025  */
00026 
00027 require_once('class_user.php');
00028 require_once("class_iselect.php");
00029 require_once("class_iperiod.php");
00030 require_once('class_acc_report.php');
00031 require_once('class_periode.php');
00032 echo '<DIV class="content">';
00033 //----------------------------------------------------------------------
00034 //
00035 global $g_user;
00036 
00037 $g_user=new User($cn);
00038 $inside_dossier = false;
00039 
00040 if (isset($_REQUEST['gDossier']))
00041 {
00042     $g_user->load_global_pref();
00043     $msg = "";
00044     $cn = new Database($_REQUEST['gDossier']);
00045     $g_user->cn = $cn;
00046     $inside_dossier = true;
00047     $local_pref=$g_user->get_preference();
00048 }
00049 //// Save value
00050 if (isset($_POST['val']))
00051 {
00052     extract($_POST);
00053 
00054     if (strlen(trim($pass_1)) != 0 && strlen(trim($pass_2)) != 0)
00055     {
00056         if ($pass_1 == $pass_2)
00057         {
00058             $repo = new Database();
00059             $l_pass = md5($_POST['pass_1']);
00060             $repo->exec_sql("update ac_users set use_pass=$1 where use_login=$2", array($l_pass, $_SESSION['g_user']));
00061             $_SESSION['g_pass'] = $_POST['pass_1'];
00062             echo "<i>" . _('Mot de passe est modifiée') . "</i>";
00063         }
00064         else
00065         {
00066             alert(_("Les mots de passe ne correspondent pas. Mot de passe inchangé"));
00067         }
00068     }
00069     if ($inside_dossier)
00070     {
00071         $g_user->set_periode($period);
00072         $g_user->save_global_preference('THEME', $style_user);
00073         $g_user->save_global_preference('LANG', $lang);
00074         $g_user->save_global_preference('PAGESIZE', $p_size);
00075         $g_user->set_mini_report($minirap);
00076         $_SESSION['g_theme']=$style_user;
00077         $_SESSION['g_pagesize']=$p_size;
00078         $_SESSION['g_lang']=$lang;
00079     }
00080 }
00081 
00082 //////////////////////////////////////////////////////////////////////////
00083 // Theme
00084 //////////////////////////////////////////////////////////////////////////
00085 
00086     $repo = new Database();
00087 // charge tous les styles
00088     $res = $repo->exec_sql("select the_name from theme
00089                     order by the_name");
00090     $style = new ISelect('style_user');
00091     $style->value = $repo->make_array("select the_name,the_name
00092         from theme
00093         order by the_name");
00094     $style->selected =$_SESSION['g_theme'];
00095     echo '<h2 class="info2">' . _('Changez vos préférences') . '</h2>';
00096 ?>
00097 
00098 <div class="content">
00099 
00100     <FORM  METHOD="POST">
00101         <fieldset><legend><?php echo _('Options Générales')?></legend>
00102             <table>
00103                 <tr><td>
00104                         Mot de passe :
00105                     </td>
00106                     <td><input type="password" value="" class="input_type" name="pass_1" nohistory>
00107                         <input type="password" value="" class="input_type" name="pass_2" nohistory>
00108                     </td>
00109                 </tr>
00110 
00111                 <tr>
00112                     <td>
00113                         <?php echo _('Thème');?>
00114                     </td>
00115                     <td>
00116                         <?php echo $style->input();?>
00117                     </td>
00118                 </tr>
00119 
00120                 <?php
00121                 if ($inside_dossier)
00122                 {
00123                     $l_user_per = $g_user->get_periode();
00124                     if ($l_user_per == "")
00125                         $l_user_per = $cn->get_value("select min(p_id) from parm_periode where p_closed='f'");
00126 
00127 // if periode is closed then warns the users
00128                     $period = new Periode($cn, $l_user_per);
00129 
00130                     $period->p_id = $l_user_per;
00131                     $period->jrn_def_id = 0;
00132                     if ($period->is_closed($l_user_per) == 1)
00133                     {
00134                         $msg = _('Attention cette période est fermée, vous ne pourrez rien modifier dans le module comptable');
00135                         $msg = '<h2 class="notice">' . $msg . '</h2>';
00136                     }
00137 
00138                     $period = new IPeriod("period");
00139                     $period->user = $g_user;
00140                     $period->cn = $cn;
00141                     $period->filter_year = false;
00142                     $period->value = $l_user_per;
00143                     $period->type = ALL;
00144                     $l_form_per = $period->input();
00145                     ?>
00146                 <tr><td><?php echo _('Période');?></td>
00147                     <td>
00148                             <?php printf(' %s ', $l_form_per);?>
00149                     </td>
00150                     <td>  <?php echo $msg;?></td>
00151                 <tr>
00152                     <td><? echo _('Taille des pages');?></td>
00153                     <td>
00154                         <SELECT NAME="p_size">
00155                             <option value="15">15
00156                             <option value="25">25
00157                             <option value="50">50
00158                             <option value="100">100
00159                             <option value="150">150
00160                             <option value="200">200
00161                             <option value="-1"><?php echo _('Illimité');?>
00162                                     <?php
00163                                     $label = ($_SESSION['g_pagesize'] == -1) ? _('Illimité') : $_SESSION['g_pagesize'];
00164                                     echo '<option value="' . $_SESSION['g_pagesize'] . '" selected>' . $label;
00165                                     ?>
00166                         </SELECT>
00167 
00168                     </td>
00169                 </tr>
00170                     <?
00171                 }
00172                 ?>
00173             </table>
00174         </fieldset>
00175         <?php
00176         if ($inside_dossier)
00177         {
00178             /* Pref for welcome page */
00179             echo '<fieldset>';
00180             echo '<legend>' . _('Options pour la page d\'accueil') . '</legend>';
00181             echo _('Mini-Rapport : ');
00182             $rapport = new Acc_Report($cn);
00183             $aRapport = $rapport->make_array();
00184             $aRapport[] = array("value" => 0, "label" => _('Aucun mini rapport'));
00185             $wRapport = new ISelect();
00186             $wRapport->name = "minirap";
00187             $wRapport->selected = $g_user->get_mini_report();
00188             $wRapport->value = $aRapport;
00189             echo $wRapport->input();
00190             echo '<span class="notice">' . _('Le mini rapport est un rapport qui s\'affiche  sur votre page d\'accueil') . '</span>';
00191             echo '</fieldset>';
00192         }
00193 
00194         echo '<fieldset>';
00195         echo '<legend>' . _('Langue') . '</legend>';
00196         echo _('Selectionnez votre langue');
00197         $aLang = array(array(_('Français'), 'fr_FR.utf8'),
00198             array(_('Anglais'), 'en_US.utf8'),
00199             array(_('Néerlandais'), 'nl_NL.utf8'),
00200         );
00201         echo '<select name="lang" id="l">';
00202         for ($i = 0; $i < count($aLang); $i++)
00203         {
00204             $sel = "";
00205             if ($aLang[$i][1] == $_SESSION['g_lang'])
00206                 $sel = " selected ";
00207             printf('<option value="%s" %s>%s</option>', $aLang[$i][1], $sel, $aLang[$i][0]);
00208         }
00209         echo '</select>';
00210         echo '</fieldset>';
00211 
00212 
00213         echo HtmlInput::submit("val", _("Valider"));
00214         echo '</form>';
00215 
00216 
00217 
00218 
00219         if (!$inside_dossier)
00220         {
00221             echo HtmlInput::button_anchor(_('Retour'), 'user_login.php?');
00222         }
00223         else
00224           {
00225             echo HtmlInput::button_anchor(_('Retour'), 'do.php?'.Dossier::get());
00226 
00227           }
00228 
00229 
00230         echo "</DIV>";
00231         ?>