"; $result.=''; if ( $p_admin == 1 ) { $result.=" Administration "; } $result.=' Aide '; $result.=' Sortir'; $result.=""; $result.=""; if ( $p_array == 0 ) return $result." * Aucun dossier *"; $result.=""; for ($i=0;$i"; $result.=""; $result.=""; $result.=""; } $result.="
"; $result.=$id." $name"; $result.=""; $result.=$desc; $result.=""; $result.="Comptabilité"; $result.=""; $result.="Gestion"; $result.=""; $result.="Paramètres"; $result.="
"; return $result; } /*! * \brief Get all the available folders * for the users, checked with the security * * \param $p_user user login * \param $p_admin 1 if admin * \return array containing * - ac_dossier.dos_id * - ac_dossier.dos_name * - ac_dossier.dos_description * */ function GetAvailableFolder($p_user,$p_admin) { $filter=""; if ($p_admin==0) { // show only available folders // if user is not an admin $sql="select distinct dos_id,dos_name,dos_description from ac_users natural join jnt_use_dos natural join ac_dossier join priv_user on ( priv_jnt=jnt_id) where use_active=1 and use_login='$p_user' and priv_priv != 'NO' "; } else { $sql="select distinct dos_id,dos_name,dos_description from ac_users natural join jnt_use_dos natural join ac_dossier where use_active=1 "; } include_once("postgres.php"); $cn=DbConnect(); $Res=ExecSql($cn,$sql); $max=pg_numRows($Res); if ( $max == 0 ) return 0; for ($i=0;$i<$max;$i++) { $array[]=pg_fetch_array($Res,$i); } return $array; } /*! * \brief show the top menu for the user profile * and highight the selected one * \param p_dossier $_SESSION['g_dossier'] * \param p_high what to hightlight, by default it is autodetected * but sometimes it must be given. Default value="" * \todo clean param p_dossier * * \return none * */ function ShowMenuCompta($p_dossier,$p_high="") { include_once("postgres.php"); // find our current menu $default=basename($_SERVER['PHP_SELF']); switch ($default) { case "user_jrn.php": $default.="?show"; break; case "recherche.php": $default.="?p_dossier=$p_dossier"; break; case "fiche.php": $default.="?p_dossier=$p_dossier"; break; } if ( $p_high !== "" ) $default=$p_high; echo_debug('user_menu.php',__LINE__,'defaut is '.$default); $p_array=array( array("user_jrn.php?jrn_type=NONE" ,"Grand Livre"), array("user_jrn.php?jrn_type=VEN" ,"Entrée"), array("user_jrn.php?jrn_type=ACH","Dépense"), array("user_jrn.php?jrn_type=FIN","Financier"), array("user_jrn.php?jrn_type=OD","Op. Diverses"), array("compta.php?p_action=impress","Impression","Impression"), array("compta.php?p_action=fiche","Fiche","Ajouter, modifier ou effacer des fiches"), array("user_advanced.php","Avancé","Opérations délicates"), ); $result=ShowItem($p_array,'H',"mtitle","mtitle",$default,' width="100%"'); $r="

Comptabilité ".$_SESSION['g_name']; $r.='

'; $r.=$result; return $r; } /*! * \brief Open the first legder automaticaly * \param $p_dossier ($_SESSION['g_dossier']) * \param $p_type type of the ledger (VEN,ACH,FIN,ODS) * * * * \return the first jrn_def_id */ function GetFirstJrnIdForJrnType($p_dossier,$p_type) { include_once("postgres.php"); //get db connection $Cn=DbConnect($p_dossier); //execute query $Ret=ExecSql($Cn,"select min(jrn_def_id) from jrn_def ". "where jrn_def_type='".$p_type."';"); $l_line=pg_fetch_array($Ret,0); return $l_line[0]; //return 0; } /*! ShowMenuJrnUser($p_dossier,$p_type,$p_jrn) * \brief Show the Menu from the jrn encode * page * * \param $p_dossier number * \param $p_type type of journal (VEN,ACH,BQE,ODS) * \param $p_jrn journal * \param $p_extra html code to add at the return (before the \) * \return string with table in HTML * \note we use the PHP_SELF variable to build the href value but we need to add * a parameter when the REQUEST_url is commercial.php * * */ function ShowMenuJrnUser($p_dossier,$p_type,$p_jrn,$p_extra="") { include_once ("debug.php"); include_once("constant.php"); include_once("class_user.php"); echo_debug('user_menu.php',__LINE__,"U_SHOWMENUJRNUSER PTYPE=$p_type"); echo ''; include_once("postgres.php"); $Cn=DbConnect($p_dossier); $User=new cl_user($Cn); $User->Check(); if ( $User->Admin() ==0) { $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, jrn_deb_max_line,jrn_cred_max_line from jrn_def join jrn_type on jrn_def_type=jrn_type_id join user_sec_jrn on uj_jrn_id=jrn_def_id where uj_login='".$User->id."' and uj_priv !='X' and jrn_def_type='$p_type' order by jrn_Def_id "); } else { $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, jrn_type_id,jrn_desc,'W' as uj_priv from jrn_def join jrn_type on jrn_def_type=jrn_type_id where jrn_def_type='$p_type' order by jrn_Def_id"); } $Max=pg_NumRows($Ret); // If you can't access any ledger, so you don't have access if ( $Max == 0 ) NoAccess(); include_once("check_priv.php"); for ($i=0;$i<$Max;$i++) { $l_line=pg_fetch_array($Ret,$i); // Admin have always rights if ( $User->Admin() == 0 ){ $right=CheckJrn($p_dossier,$_SESSION['g_user'],$l_line['jrn_def_id']); }else { $right=3; } if ( $right > 0 ) { // Minimum Lecture echo_debug('user_menu.php',__LINE__,"p_jrn = $p_jrn "); if ( $l_line['jrn_def_id'] != $p_jrn ) { $href=basename($_SERVER["PHP_SELF"]); $add=""; // if the PHP_SELF == commercial.php, we need to add the parameter // p_action=facture if ( $href=="commercial.php" ) { $add='&p_action='.$_REQUEST['p_action']; } echo '', $href, $l_line['jrn_def_type'], $l_line['jrn_def_id'], $add, $l_line['jrn_def_name'] ); } else { echo ''; } }// if right }// for if ( $p_extra !="" ) echo $p_extra; echo ''; echo "
'; printf ('%s'. $l_line['jrn_def_name'].'
"; //echo ''; } /*! * \brief Show the menu of the jrn depending of its type, check with the security * * \param p_cn database connection * \param p_jrn_type type of the ledger * \param p_jrn jrn id * * * \return string containing the menu * */ function ShowMenuJrn($p_cn,$p_jrn_type,$p_jrn) { $Res=ExecSql($p_cn,"select ja_name,ja_url,ja_action,ja_desc from jrn_action where ja_jrn_type='$p_jrn_type' order by ja_id"); $num=pg_NumRows($Res); if ($num==0) return ""; // Retrieve in the database the menu $ret=""; $access_key_list = array(); for ($i=0;$i<$num;$i++) { $action=pg_fetch_array($Res,$i); $access_key=get_quick_key($action['ja_name'],$access_key_list); $lib=str_replace($access_key,''.$access_key.'',$action['ja_name']); $ret.=sprintf('', $access_key, $action['ja_desc'], $action['ja_url'], $action['ja_action'], $p_jrn, $_REQUEST['jrn_type'], $lib); } $ret.='
%s
'; return $ret; } /*! get_quick_key * \brief Show the menu of the jrn depending of its type * return a not yet used access key. The returned key is added to $access_key_list * * \param $title * \param &$access_key_list * * * \return string containing the menu * - */ function get_quick_key($title,&$access_key_list) { $quick = $title[0]; if(array_key_exists($quick, $access_key_list)) { echo_debug(" key exists: " . $quick); return get_quick_key(substr($title, 1), $access_key_list); } else { echo_debug(" new key: " . $quick); } $access_key_list[$quick] = $quick; return $quick; } /*! * \brief Returns the form for the search (module accountancy) * * \param : * \param $p_cn database connection * \param $p_jrn jrn id * \param $p_array=null previous search * * * \return HTML Code * * */ function u_ShowMenuRecherche($p_cn,$p_jrn,$p_sessid,$p_array=null) { echo_debug('user_menu.php',__LINE__,"u_ShowMenuRecherche($p_cn,$p_array)"); if ( $p_array != null ) { foreach ( $p_array as $key=> $element) { ${"p_$key"}=$element; echo_debug('user_menu.php',__LINE__,"p_$key =$element;"); } } // Find the journal property $opt='