Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

user_menu.php

Go to the documentation of this file.
00001 <?
00002 
00003 /*
00004  *   This file is part of PhpCompta.
00005  *
00006  *   PhpCompta is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   PhpCompta is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with PhpCompta; if not, write to the Free Software
00018  *   Foundation, Inshowc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 */
00025 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00026 /* $Revision$ */
00027 
00037 function u_ShowDossier($p_user,$p_admin)
00038 {
00039   $p_array=GetAvailableFolder($p_user,$p_admin);   
00040   if ( $p_array == 0 ) return " * Aucun dossier *";
00041   $result="";
00042   $result.="<table>";
00043   $result.='<TR>';
00044     if ( $p_admin == 1 ) {
00045       $result.="<TD><A class=\"mtitle\" HREF=\"admin_repo.php\"> Administration : </A></TD>";
00046     }
00047     $result.='<TD><A HREF="logout.php" CLASS="mtitle">: Sortir</a></TD>';
00048     $result.="</TR>";
00049   $result.="</table>";
00050   $result.="<TABLE>";
00051   for ($i=0;$i<sizeof($p_array);$i++) {
00052     $id=$p_array[$i]['dos_id'];
00053     $name= $p_array[$i]['dos_name'];
00054     $desc=$p_array[$i]['dos_description'];
00055     if ( $i%2 == 0) 
00056       $tr="odd";
00057     else $tr="even";
00058 
00059     $result.="<TR class=\"$tr\"><TD class=\"$tr\">";
00060     $result.=$id."  <B>$name</B>";
00061     $result.="</TD><TD class=\"$tr\">";
00062     $result.=$desc;
00063     $result.="</TD><TD class=\"mtitle\">";
00064     $result.="<A class=\"mtitle\" HREF=\"user_compta.php?dos=$id\">Comptabilité</A>";
00065     $result.="</TD>";
00066     $result.="<TD class=\"mtitle\">";
00067     $result.="<A class=\"mtitle\" HREF=\"commercial.php?dos=$id\">Gestion</A>";
00068     $result.="</TD>";
00069     $result.="<TD class=\"mtitle\">";
00070     $result.="<A class=\"mtitle\" HREF=\"parametre.php?dos=$id\">Paramètres</A>";
00071     $result.="</TD>";
00072 
00073     $result.="</TR>";
00074   }
00075   $result.="</TABLE>";
00076   return $result;
00077 }
00090 function GetAvailableFolder($p_user,$p_admin)
00091 {
00092   $filter="";
00093   if ($p_admin==0) {
00094     // show only available folders
00095     // if user is not an admin
00096     $sql="select distinct dos_id,dos_name,dos_description from ac_users 
00097                   natural join jnt_use_dos 
00098                   natural join  ac_dossier 
00099                   join  priv_user on ( priv_jnt=jnt_id)
00100           where use_active=1 
00101          and use_login='$p_user' 
00102          and priv_priv != 'NO' ";
00103 
00104   } else {
00105     $sql="select distinct dos_id,dos_name,dos_description from ac_users 
00106                   natural join jnt_use_dos 
00107                   natural join  ac_dossier 
00108       where  use_active=1 ";
00109   }
00110   include_once("postgres.php");
00111   $cn=DbConnect();
00112   $Res=ExecSql($cn,$sql);
00113   $max=pg_numRows($Res);
00114   if ( $max == 0 ) return 0;
00115 
00116   for ($i=0;$i<$max;$i++) {
00117     $array[]=pg_fetch_array($Res,$i);
00118   }
00119   return $array;
00120 }
00132 function ShowMenuCompta($p_dossier,$p_high="")
00133 {
00134   include_once("postgres.php");
00135 
00136   // find our current menu
00137   $default=basename($_SERVER['SCRIPT_NAME']);
00138   switch ($default) {
00139   case "user_jrn.php":
00140     $default.="?show";
00141     break;
00142   case "recherche.php":
00143     $default.="?p_dossier=$p_dossier";
00144     break;
00145   case "fiche.php":
00146     $default.="?p_dossier=$p_dossier";
00147     break;
00148   }
00149   if ( $p_high !== "" ) $default=$p_high;
00150 
00151   echo_debug('user_menu.php',__LINE__,'defaut is '.$default);
00152 
00153   $p_array=array(array("user_jrn.php?show","Journaux","Les journaux permettent d'encoder toutes les opérations"),
00154                  array("recherche.php?p_dossier=$p_dossier","Recherche","Pour retrouver une opération"),
00155                  array("fiche.php?p_dossier=$p_dossier","Fiche","Ajouter, modifier ou effacer des fiches"),
00156                  array("user_impress.php","Impression","Impression"),
00157                  array("user_advanced.php","Avancé","Opérations délicates"),
00158 
00159                  array('user_pref.php','Preference',"Préférence de l'utilisateur"),
00160                  array('parametre.php?dos='.$_SESSION['g_dossier'],"Paramètre"),
00161                  array('commercial.php?dos='.$_SESSION['g_dossier'],"Gestion"),
00162                  array('login.php','Accueil',"Accueil"),
00163                  array('logout.php','logout',"Sortie")
00164                  );
00165 
00166   $result=ShowItem($p_array,'H',"mtitle","mtitle",$default,' width="100%"');
00167 
00168   $r="<H2 class=\"info\">Comptabilit&eacute;  ".$_SESSION['g_name']." </H2>";
00169   $r.=$result;
00170   return $r;
00171 
00172 
00173 
00174 
00175 }
00186 function GetFirstJrnIdForJrnType($p_dossier,$p_type)
00187 {
00188   include_once("postgres.php");
00189   
00190   //get db connection
00191   $Cn=DbConnect($p_dossier);  
00192   //execute query
00193   $Ret=ExecSql($Cn,"select min(jrn_def_id) from jrn_def where jrn_def_type='".$p_type."';");
00194   $l_line=pg_fetch_array($Ret,0);
00195   return $l_line[0];
00196   //return 0;
00197 }
00212 function ShowMenuJrnUser($p_dossier,$p_type,$p_jrn,$p_extra="")
00213 {
00214   include_once ("debug.php");
00215   include_once("constant.php");
00216   include_once("class_user.php");
00217   echo_debug('user_menu.php',__LINE__,"U_SHOWMENUJRNUSER PTYPE=$p_type");
00218 
00219   echo '<TABLE><TR>';
00220   include_once("postgres.php");
00221   
00222   
00223   $Cn=DbConnect($p_dossier);
00224   
00225   $User=new cl_user($Cn);
00226   $User->Check();
00227   if ( $User->Admin() ==0) {
00228     $Ret=ExecSql($Cn,"select jrn_def_id,jrn_def_type,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
00229                                jrn_deb_max_line,jrn_cred_max_line
00230                              from jrn_def join jrn_type on jrn_def_type=jrn_type_id
00231                              join user_sec_jrn on uj_jrn_id=jrn_def_id 
00232                              where
00233                              uj_login='".$User->id."'
00234                              and uj_priv !='X'
00235                              and jrn_def_type='$p_type' order by jrn_Def_id
00236                              ");
00237     } else {
00238       $Ret=ExecSql($Cn,"select jrn_def_id,jrn_def_type,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line,
00239                             jrn_type_id,jrn_desc,'W' as uj_priv
00240                              from jrn_def join jrn_type on jrn_def_type=jrn_type_id where
00241                               jrn_def_type='$p_type' order by jrn_Def_id");
00242 
00243     } 
00244     $Max=pg_NumRows($Ret);
00245     include_once("check_priv.php");
00246 
00247     for ($i=0;$i<$Max;$i++) {
00248       $l_line=pg_fetch_array($Ret,$i);
00249       // Admin have always rights
00250       if ( $User->Admin() == 0 ){
00251         $right=CheckJrn($p_dossier,$_SESSION['g_user'],$l_line['jrn_def_id']);
00252       }else {
00253         $right=3;
00254       }
00255 
00256       if ( $right > 0 ) {
00257         // Minimum Lecture 
00258         echo_debug('user_menu.php',__LINE__,"p_jrn = $p_jrn ");
00259         if ( $l_line['jrn_def_id'] != $p_jrn ) {
00260           $href=$_SERVER["SCRIPT_NAME"];
00261           $add="";
00262           // if the SCRIPT_NAME == commercial.php, we need to add the parameter
00263           // p_action=facture
00264           if ( $href=="/commercial.php" ) 
00265             {
00266               $add='&p_action='.$_REQUEST['p_action'];
00267             }
00268           echo '<TD class="cell">';
00269           printf ('<A class="mtitle" HREF="%s?jrn_type=%s&p_jrn=%s%s">%s</A></TD>',
00270                   $href,
00271                   $l_line['jrn_def_type'],
00272                   $l_line['jrn_def_id'],
00273                   $add,
00274                   $l_line['jrn_def_name']
00275                   );
00276         } else
00277           {
00278             echo '<TD class="selectedcell">'. $l_line['jrn_def_name'].'</TD>';
00279           }
00280       }// if right
00281     }// for
00282     if ( $p_extra !="" ) echo $p_extra;
00283     echo '</TR>';
00284     echo "</TABLE>";
00285     //echo '</div>';
00286 
00287 }
00299 function ShowMenuJrn($p_cn,$p_jrn_type,$p_jrn) 
00300 {
00301 
00302   $Res=ExecSql($p_cn,"select ja_name,ja_url,ja_action,ja_desc from jrn_action  where ja_jrn_type='$p_jrn_type'
00303                       order by ja_id");
00304   $num=pg_NumRows($Res);
00305   if ($num==0)    return "";
00306   // Retrieve in the database the menu
00307   $ret="<TABLE>";
00308   $access_key_list = array();
00309   for ($i=0;$i<$num;$i++) {
00310     $action=pg_fetch_array($Res,$i);
00311     $access_key=get_quick_key($action['ja_name'],$access_key_list);
00312     $lib=str_replace($access_key,'<u>'.$access_key.'</u>',$action['ja_name']);
00313 
00314     $ret.=sprintf('<TR><TD class="cell"><A class="mtitle" accesskey="%s" title="%s" '.
00315                   'HREF="%s?%s&p_jrn=%s&jrn_type=%s">%s</A></td></tR>',
00316                   $access_key, 
00317                   $action['ja_desc'], 
00318                   $action['ja_url'],
00319                   $action['ja_action'], 
00320                   $p_jrn, 
00321                   $_REQUEST['jrn_type'],
00322                   $lib);
00323 
00324   }
00325   $ret.='</TABLE>';
00326   return $ret;
00327 
00328 }
00329 
00341 function get_quick_key($title,&$access_key_list)
00342 {
00343         $quick = $title[0];
00344         if(array_key_exists($quick, $access_key_list))
00345         {
00346                 echo_debug(" key exists: " . $quick);
00347                 return get_quick_key(substr($title, 1), $access_key_list);
00348         } else
00349         {
00350                 echo_debug(" new key: " . $quick);
00351         }
00352         $access_key_list[$quick] = $quick;
00353         
00354         return $quick;
00355 }
00356 
00371 function u_ShowMenuRecherche($p_cn,$p_jrn,$p_sessid,$p_array=null)
00372 {
00373   echo_debug('user_menu.php',__LINE__,"u_ShowMenuRecherche($p_cn,$p_array)");
00374   if ( $p_array != null ) {
00375     foreach ( $p_array as $key=> $element) {
00376       ${"p_$key"}=$element;
00377       echo_debug('user_menu.php',__LINE__,"p_$key =$element;");
00378     }
00379   }
00380 
00381   // Find the journal property
00382   //  $JrnProperty=GetJrnProperty($p_cn,$p_jrn);
00383 
00384   $opt='<OPTION VALUE="="> =';
00385   $opt.='<OPTION VALUE="<="> <=';
00386   $opt.='<OPTION VALUE="<"> <';
00387   $opt.='<OPTION VALUE=">"> >';
00388   $opt.='<OPTION VALUE=">="> >=';
00389   if ( ! isset ($p_date_start)) $p_date_start="";
00390   if ( ! isset ($p_date_end))   $p_date_end="";
00391   if ( ! isset ($p_mont_sel))$p_mont_sel="";
00392   if ( ! isset ($p_s_comment))$p_s_comment="";
00393   if ( ! isset ($p_s_montant)) $p_s_montant="";
00394   if ( ! isset ($p_s_internal)) $p_s_internal="";
00395   if ( ! isset ($p_poste)) $p_poste="";
00396   if ( ! isset ($p_qcode)) $p_qcode="";
00397 
00398 
00399   if ( $p_mont_sel != "" )  $opt.='<OPTION value="'.$p_mont_sel.'" SELECTED> '.$p_mont_sel;
00400   $r="";
00401  
00402   //  $r.= '<div style="border-style:outset;border-width:1pt;">';
00403 
00404   $r.=JS_SEARCH_POSTE;
00405   $r.= "<B>Recherche</B>";
00406   $r.= '<FORM ACTION="recherche.php" METHOD="GET">';
00407   $r.="<table><tr><TD>";  
00408   $r.= '<TABLE>';
00409   $r.= "<TR>";
00410   $r.= '<TD COLSPAN="3">  Date compris entre</TD> ';
00411   $r.= "</TR> <TR>";
00412   $r.= '<TD> <INPUT TYPE="TEXT" NAME="date_start" SIZE="10" VALUE="'.$p_date_start.'"></TD>';
00413   $r.= '<TD> <INPUT TYPE="TEXT" NAME="date_end" size="10" Value="'.$p_date_end.'"></TD>';
00414   $r.= '</TD><TD>';
00415   $r.= "</TR> <TR>";
00416   $r.= "<TD> Montant ";
00417   $r.= ' <SELECT NAME="mont_sel">'.$opt.' </SELECT></TD><TD>';
00418   $r.= ' <INPUT TYPE="TEXT" NAME="s_montant" SIZE="10" VALUE="'.$p_s_montant.'"></TD>';
00419   $r.= "</TR><TR>";
00420   $r.="<TD> Internal code</td>";
00421   $r.='<TD><input type="text" name="s_internal" value="'.$p_s_internal.'"></td>';
00422 
00423   $r.="</TD></TR></TABLE></td><TD><table>";
00424 
00425   $r.= "</TR>";
00426   $r.= "<TR>";
00427   $W=new widget("js_search_poste");
00428   $W->label="Numéro de poste";
00429   $W->name="poste";
00430   $W->value=$p_poste;
00431   $r.="<TR>".$W->IOValue();
00432   $r.= "</TR>";
00433   $r.= "<TR>";
00434   $A=new widget("TEXT");
00435   $A->label="Quick Code";
00436   $A->name="qcode";
00437   $A->value=$p_qcode;
00438   $r.="<TD> Quick Code</TD><TD>".$A->IOValue()."</TD>";
00439   $r.= "</TR>";
00440 
00441 
00442   $r.= '<TD colspan="3"> Le commentaire contient </TD>';
00443   $r.= "</TR><TR>";
00444   $r.= '<TD COLSPAN="3"> <INPUT TYPE="TEXT" NAME="s_comment" VALUE="'.$p_s_comment.'"></TD>';
00445   $r.= "</TR><TR>";
00446   $r.= '<TD COLSPAN="3"><INPUT TYPE="SUBMIT" VALUE="Recherche" NAME="viewsearch"></TD>';
00447   $r.= "</TR>";
00448   $r.= "</TABLE>";
00449   $r.="</TR></TABLE>";
00450   $r.= "</FORM>";
00451 
00452 
00453   return $r;
00454 
00455 }
00464 function ShowMenuAdvanced($default="") {
00465 // Show the left menu
00466 $left_menu=ShowItem(array(
00467                           //('rapprt.php','Rapprochement'),
00468                           array('jrn_update.php','Journaux'),
00469                           array('user_advanced.php?p_action=periode','Periode'),
00470                           array('central.php','Centralise'),
00471                           array('pcmn_update.php?p_start=1','Plan Comptable'),
00472                           array('stock.php','Stock'),
00473                           array('form.php','Rapport'),
00474                           array('import.php','Import Banque'),
00475                           array('ecrit_ouv.php','Ecriture ouverture')
00476                         
00477                           ),
00478                     'H',"cell","mtitle",$default);
00479  $r='<div class="u_subtmenu">'.$left_menu."</div>";
00480 return $r;
00481 }
00490 function ShowJrn($p_menu="")
00491 {
00492 
00493  $p_array=array(
00494                 array("user_jrn.php?jrn_type=NONE" ,"Grand Livre"),
00495                 array("user_jrn.php?jrn_type=VEN" ,"Entrée"),
00496                 array("user_jrn.php?jrn_type=ACH","Dépense"),
00497                 array("user_jrn.php?jrn_type=FIN","Financier"),
00498                 array("user_jrn.php?jrn_type=OD","Op. Diverses")
00499                  );
00500  $result=ShowItem($p_array,'H',"cell","mtitle",$p_menu);
00501  return $result;
00502 }
00503 
00514 function ShowMenuFiche($p_dossier)
00515 {
00516      $cn=DbConnect($p_dossier);
00517      echo '<div class="lmenu">';
00518      echo '<TABLE>';
00521       echo '<TR><TD colspan="3" class="mtitle">
00522           <A class="mtitle" HREF="fiche.php?action=add_modele&fiche=modele">Creation</A></TD></TR>';
00523      $Res=ExecSql($cn,"select fd_id,fd_label from fiche_def order by fd_label");
00524      $Max=pg_NumRows($Res);
00525      for ( $i=0; $i < $Max;$i++) {
00526        $l_line=pg_fetch_array($Res,$i);
00527        printf('<TR><TD class="cell">%s</TD><TD class="mshort"><A class="mtitle" HREF="fiche.php?action=vue&fiche=%d">Voir</A>
00528                </TD>
00529                <TD class="mshort"><A class="mtitle" HREF="fiche.php?action=modifier&fiche=%d">Modifier</A></TD>
00530                </TR>',
00531             $l_line['fd_label'],
00532             $l_line['fd_id'],
00533             $l_line['fd_id']);
00534      }
00535      echo "</TABLE>";
00536      echo '</div>';
00537 }
00539 /* \brief show the menu for user/database management 
00540 /*
00541 /* \return HTML code with the menu
00542 */
00543 
00544 function MenuAdmin()
00545 {
00546   $item=array (array("admin_repo.php?action=user_mgt","Utilisateurs"),
00547                array("admin_repo.php?action=dossier_mgt","Dossiers"),
00548                array("admin_repo.php?action=modele_mgt","Modèles"),
00549                array("login.php","Accueil"),
00550                array("logout.php","Logout")
00551                );
00552 
00553   $menu=ShowItem($item,'H');
00554   return $menu;
00555 }
00564 function ShowMenuDocument()
00565 {
00566   $base="parametre.php?p_action=document&sa=";
00567   $sub_menu=ShowItem(
00568                      array(array($base."add_document","Ajout"))
00569                      ,'V',"cell","mtitle");
00570   return $sub_menu;
00571 
00572 }
00584 function ShowMenuParam($p_action="")
00585 {
00586     $sub_menu=ShowItem(array(
00587                           
00588                           array('parametre.php?p_action=company','Sociétés'),
00589                           array('parametre.php?p_action=devise','Devises'),
00590                           array('parametre.php?p_action=tva','Tva'),
00591                           array('parametre.php?p_action=poste','Poste Comptable'),
00592                           array('parametre.php?p_action=fiche','Fiche'),
00593                           array('user_sec.php','Sécurité'),
00594                           array('parametre.php?p_action=document','Document'),
00595                           array('commercial.php?dos='.$_SESSION['g_dossier'],"Gestion"),
00596                           array('user_compta.php?dos='.$_SESSION['g_dossier'],"Comptabilité"),
00597 
00598                           array('login.php','Accueil',"Accueil"),
00599                           array('logout.php','logout',"Sortie")
00600                           ),
00601                     'H',"mtitle","mtitle",$p_action,' width="100%"');
00602     return $sub_menu;
00603 
00604 }
00617 function MenuJrn($p_dossier)
00618 {
00619     echo '<TABLE>';
00620     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="jrn_add.php">Création </A></TD></TR>';
00621     include_once("postgres.php");
00622     $Cn=DbConnect($p_dossier);
00623     $Ret=ExecSql($Cn,"select jrn_def_id,jrn_def_name,
00624                              jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc 
00625                              from jrn_def join jrn_type on jrn_def_type=jrn_type_id");
00626     $Max=pg_NumRows($Ret);
00627     for ($i=0;$i<$Max;$i++) {
00628       $l_line=pg_fetch_array($Ret,$i);
00629       printf ('<TR><TD class="mtitle"><A class="mtitle" HREF="jrn_detail.php?p_jrn=%s">%s</A></TD></TR>',
00630               $l_line['jrn_def_id'],$l_line['jrn_def_name']);
00631 
00632     }
00633     echo "</TABLE>";
00634 }
00647 function ShowMenuPcmn($p_start=1)
00648 {
00649     echo '<TABLE>';
00650     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=1">1 Immobilisé </A></TD></TR>';
00651     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=2">2 Actif a un an au plus</A></TD></TR>';
00652     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=3">3 Stock et commande</A></TD></TR>';
00653     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=4">4 Compte tiers</A></TD></TR>';
00654     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=5">5 Actif</A></TD></TR>';
00655     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=6">6 Charges</A></TD></TR>';
00656     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=7">7 Produits</A></TD></TR>';
00657     echo "</TABLE>";
00658 }
00670 function ShowMenuComptaForm($p_dossier) {
00671      $cn=DbConnect($p_dossier);
00672     echo '<div class="lmenu">';
00673     echo '<TABLE>';
00674     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="form.php?action=add">Ajout</A></TD></TR>';
00675     $Ret=ExecSql($cn,"select fr_id, fr_label 
00676                              from formdef order by fr_label");
00677     $Max=pg_NumRows($Ret);
00678     for ($i=0;$i<$Max;$i++) {
00679       $l_line=pg_fetch_array($Ret,$i);
00680       printf ('<TR><TD class="mtitle"><A class="mtitle" HREF="form.php?action=view&fr_id=%s">%s</A></TD></TR>',
00681               $l_line['fr_id'],$l_line['fr_label']);
00682 
00683     }
00684     echo "</TABLE>";
00685     echo '</div>';
00686 }
00687 
00693 function ShowMenuImport(){
00694     echo '<TABLE>';
00695     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="import.php?action=import">Importer CSV</A></TD></TR>';
00696     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="import.php?action=verif">Verif CSV</A></TD></TR>';
00697     echo '<TR><TD class="mtitle"><A class="mtitle" HREF="import.php?action=transfer">Transfert CSV</A></TD></TR>';
00698     
00699     echo "</TABLE>";
00700 }
00701 
00702 ?>

Generated on Sat Jun 24 20:41:33 2006 for phpcompta by  doxygen 1.4.4