diff --git a/html/central.php b/html/central.php index 0d219cd38..a4ee0a179 100644 --- a/html/central.php +++ b/html/central.php @@ -44,16 +44,14 @@ include_once ("user_menu.php"); echo ShowMenuCompta($_SESSION['g_dossier'],"user_advanced.php"); $cn=DbConnect($_SESSION['g_dossier']); -if ( $User->CheckAction($cn,CENTRALIZE)==0 ) { - /* Cannot Access */ - NoAccess(); -} include_once("central_inc.php"); echo '
'; echo ShowMenuAdvanced("central.php"); echo '
'; +$User->AccessRequest($cn,CENTRALIZE); + echo '
'; diff --git a/html/commercial.php b/html/commercial.php index 374b8658a..c1648590f 100644 --- a/html/commercial.php +++ b/html/commercial.php @@ -16,7 +16,9 @@ * along with PhpCompta; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + /* $Revision$ */ + // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr /*! \file * \brief Base of the module "Gestion", the p_action indicates what @@ -85,9 +87,9 @@ $p_action=(isset ($_REQUEST['p_action']))?$_REQUEST['p_action']:""; // TODO Menu with all the customer echo ShowItem(array( array('?p_action=client','Client'), - array('?p_action=facture','Facture'), + array('?p_action=facture','Vente/Facture'), array('?p_action=fournisseur','Fournisseur'), - array('?p_action=depense','Dépense'), + array('?p_action=depense','Achat/Dépense'), array('?p_action=impress','Impression'), array('?p_action=stock','Stock'), array('?p_action=bank','Banque'), diff --git a/html/compta.php b/html/compta.php index 4a4bd8783..ad815aae0 100644 --- a/html/compta.php +++ b/html/compta.php @@ -17,7 +17,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr + /* $Revision$ */ + /*! \file * \brief Main page for the printing */ @@ -50,11 +52,8 @@ $action=$_REQUEST['p_action']; // call impress sub-menu if ( $action == 'impress' ) { - if ( $User->CheckAction($cn,IMP) == 0) - { - NoAccess(); - exit; - } + + $User->AccessRequest($cn,IMP) ; require_once('impress.inc.php'); } diff --git a/html/ecrit_ouv.php b/html/ecrit_ouv.php index e6908720f..707e25e7c 100644 --- a/html/ecrit_ouv.php +++ b/html/ecrit_ouv.php @@ -44,13 +44,13 @@ echo '
'; echo ShowMenuCompta($_SESSION['g_dossier'],"user_advanced.php"); echo '
'; // \todo add a check for permission -if ( $User->CheckAction($cn,EXP_IMP_ECR) == 0 ) { - /* Cannot Access */ - NoAccess(); - exit -1; - } + echo ShowMenuAdvanced("ecrit_ouv.php"); + +$User->AccessRequest($cn,EXP_IMP_ECR); + + echo ''; include ("check_priv.php"); $cn=DbConnect($_SESSION['g_dossier']); -if ( $User->CheckAction($cn,FORM)==0){ - /* Cannot Access */ - NoAccess(); - } echo ShowMenuAdvanced("form.php"); +// Get The priv on the selected folder +$User->AccessRequest($cn,FORM); + + + + if ( isset ($_POST["record"] )) { // echo '
'; AddForm($cn,$_POST); diff --git a/html/image/compta.png b/html/image/compta.png index 03ee497e6..ed3b00993 100644 Binary files a/html/image/compta.png and b/html/image/compta.png differ diff --git a/html/image/home.png b/html/image/home.png index 45f54d7de..66f4c3d02 100644 Binary files a/html/image/home.png and b/html/image/home.png differ diff --git a/html/image/logout.png b/html/image/logout.png index 1360805f9..598cf76be 100644 Binary files a/html/image/logout.png and b/html/image/logout.png differ diff --git a/html/image/param.png b/html/image/param.png index 3c1035e68..6a2f729e6 100644 Binary files a/html/image/param.png and b/html/image/param.png differ diff --git a/html/image/preference.png b/html/image/preference.png index d8ec3fcbf..930d4c5e8 100644 Binary files a/html/image/preference.png and b/html/image/preference.png differ diff --git a/html/image/search.png b/html/image/search.png index ed31a8a1e..7d04c99c8 100644 Binary files a/html/image/search.png and b/html/image/search.png differ diff --git a/html/import.php b/html/import.php index a0854fed9..ac2092051 100644 --- a/html/import.php +++ b/html/import.php @@ -50,11 +50,11 @@ echo '
'; echo ShowMenuCompta($_SESSION['g_dossier'],"user_advanced.php"); echo '
'; $cn=DbConnect($_SESSION['g_dossier']); -if ( $User->CheckAction($cn,IMP_BQE)==0){ - /* Cannot Access */ - NoAccess(); - } + + echo ShowMenuAdvanced("import.php"); +$User->AccessRequest($cn,IMP_BQE); + echo ''; $cn=DbConnect($_SESSION['g_dossier']); -if ($User->CheckAction($cn,GJRN) == 0 ){ - /* Cannot Access */ - NoAccess(); - exit -1; - - } +$User->AccessRequest($cn,GJRN); + echo JS_SEARCH_POSTE; diff --git a/html/jrn_detail.php b/html/jrn_detail.php index 68572d1e4..883a543ce 100644 --- a/html/jrn_detail.php +++ b/html/jrn_detail.php @@ -46,11 +46,8 @@ echo '
'; include_once("check_priv.php"); $cn=DbConnect($_SESSION['g_dossier']); -if ( $User->CheckAction($cn,GJRN) == 0 ){ - /* Cannot Access */ - NoAccess(); - exit -1; -} +$User->AccessRequest($cn,GJRN); + // Javascript echo JS_SEARCH_POSTE; if ( isset( $_GET['p_jrn'] )) { diff --git a/html/jrn_update.php b/html/jrn_update.php index 99a6dabb1..0b59386bd 100644 --- a/html/jrn_update.php +++ b/html/jrn_update.php @@ -44,15 +44,15 @@ echo '
'; $cn=DbConnect($_SESSION['g_dossier']); -if ( $User->CheckAction($cn,GJRN) == 0 ) { - /* Cannot Access */ - NoAccess(); - exit -1; - } + + echo '
'; echo ShowMenuAdvanced("jrn_update.php"); echo '
'; +$User->AccessRequest($cn,GJRN); + + echo ''; diff --git a/html/line_update.php b/html/line_update.php index 1114d8956..8aa1a17e3 100644 --- a/html/line_update.php +++ b/html/line_update.php @@ -37,11 +37,8 @@ $User=new cl_user($rep); $User->Check(); html_page_start($User->theme,"onLoad='window.focus();'"); -if ( $User->CheckAction(DbConnect($_SESSION['g_dossier']),MPCMN) == 0 ) { - /* Cannot Access */ - NoAccess(); - exit -1; - } +$User->AccessRequest(DbConnect($_SESSION['g_dossier']),MPCMN); + include ("user_menu.php"); diff --git a/html/listing_client.php b/html/listing_client.php index 60f87c524..40127315e 100644 --- a/html/listing_client.php +++ b/html/listing_client.php @@ -34,10 +34,7 @@ $User->Check(); // TODO a specific level of security for the "bilan" ??? // Change must be done here -if ($User->CheckAction($cn,IMP) == 0 ){ - /* Cannot Access */ - NoAccess(); - } +$User->AccessRequest($cn,IMP); header('Content-type: application/bin'); header('Content-Disposition: attachment;filename="declaration.bin"',FALSE); diff --git a/html/parametre.php b/html/parametre.php index a80dcdd65..b5c6286e1 100644 --- a/html/parametre.php +++ b/html/parametre.php @@ -61,12 +61,7 @@ include_once ("check_priv.php"); $cn=DbConnect($_SESSION['g_dossier']); -if ( $User->CheckAction($cn,PARM) == 0 ) { - /* Cannot Access */ - NoAccess(); - exit -1; - -} +$User->AccessRequest($cn,PARM); // First action $p_action=""; diff --git a/html/pcmn_update.php b/html/pcmn_update.php index 7db44c1c7..fdc867a16 100644 --- a/html/pcmn_update.php +++ b/html/pcmn_update.php @@ -43,11 +43,8 @@ include_once ("check_priv.php"); echo ShowMenuCompta($_SESSION['g_dossier'],"user_advanced.php"); $cn=DbConnect($_SESSION['g_dossier']); -if ( $User->CheckAction($cn,MPCMN) == 0 ) { - /* Cannot Access */ - NoAccess(); - exit -1; - } + + echo JS_UPDATE_PCMN; /* Store the p_start parameter */ if ( ! isset ( $_SESSION['g_start']) ) { @@ -63,6 +60,9 @@ if ( isset ($_GET['p_start'])) { echo '
'; echo ShowMenuAdvanced("pcmn_update.php?p_start=1"); echo '
'; +$User->AccessRequest($cn,MPCMN); + + echo ''; diff --git a/html/poste_search.php b/html/poste_search.php index e91930337..00855643c 100644 --- a/html/poste_search.php +++ b/html/poste_search.php @@ -18,6 +18,7 @@ */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr /* $Revision$ */ + /*! \file * \brief Search a account in a popup window */ diff --git a/html/print_balance.php b/html/print_balance.php index b0a4a8a06..d0bf666d5 100644 --- a/html/print_balance.php +++ b/html/print_balance.php @@ -46,11 +46,8 @@ $User=new cl_user($rep); $User->Check(); $bal=new Balance($cn); -if ( $User->CheckAction($cn,BALANCE) == 0) - { - NoAccess(); - exit; - } +$User->AccessRequest($cn,BALANCE); + echo_debug('print_balance.php',__LINE__,"imp pdf journaux"); foreach ($_POST as $key=>$element) { ${"$key"}=$element; diff --git a/html/quick_code_csv.php b/html/quick_code_csv.php new file mode 100644 index 000000000..a647c851b --- /dev/null +++ b/html/quick_code_csv.php @@ -0,0 +1,78 @@ +Check(); + +$Fiche=new fiche($cn,$_REQUEST['f_id']); +$Fiche->getName(); +list($array,$tot_deb,$tot_cred)=$Fiche->GetRow( + $_POST['from_periode'], + $_POST['to_periode'] + ); +if ( count($Fiche->row ) == 0 ) +{ + echo "Aucune donnée"; + return; +} +echo '"Qcode;"'. +"\"Code interne\";". +"\"Date\";". +"\"Description\";". +"\"Débit\";". +"\"Crédit\""; +printf("\n"); + + +foreach ( $Fiche->row as $op ) { + echo '"'.$op['j_qcode'].'";'. + '"'.$op['jr_internal'].'"'.";". + '"'.$op['j_date'].'"'.";". + '"'.$op['description'].'"'.";". + sprintf("%8.4f",$op['deb_montant']).";". + sprintf("%8.4f",$op['cred_montant']); + printf("\n"); + + +} +$solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; +$diff=abs($tot_deb-$tot_cred); +printf( + '"'."$solde_type".'"'.";". + sprintf("%8.4f",$diff).";". + sprintf("%8.4f",$tot_deb).";". + sprintf("%8.4f",$tot_cred)."\n"); + +exit; +?> diff --git a/html/quick_code_pdf.php b/html/quick_code_pdf.php new file mode 100644 index 000000000..4a06ef686 --- /dev/null +++ b/html/quick_code_pdf.php @@ -0,0 +1,88 @@ +$element) { + ${"$key"}=$element; +} + +$ret=""; +$pdf=& new Cezpdf(); +$pdf->selectFont('./addon/fonts/Helvetica.afm'); + + +echo_debug("quick_code_pdf",__LINE__,$f_id); +$Fiche=new fiche($cn,$f_id); + + +list($array,$tot_deb,$tot_cred)=$Fiche->GetRow($from_periode,$to_periode); +// don't print empty account +if ( count($array) == 0 ) { + continue; +} +$Libelle=sprintf("(%s) %s ",$Fiche->id,$Fiche->getName()); + +// $pdf->ezText($Libelle,30); +$pdf->ezTable($array, + array ('jr_internal'=>'Opération', + 'j_date' => 'Date', + 'jrn_name'=>'Journal', + 'description'=>'Description', + 'deb_montant'=> 'Montant', + 'cred_montant'=> 'Montant' + ),$Libelle, + array('shaded'=>0,'showHeadings'=>1,'width'=>500, + 'cols'=>array('montant'=> array('justification'=>'right'), + ))); +$str_debit=sprintf("Débit % 12.2f",$tot_deb); +$str_cred=sprintf("Crédit % 12.2f",$tot_cred); +$diff_solde=$tot_deb-$tot_cred; +if ( $diff_solde < 0 ) { + $solde=" C "; + $diff_solde*=-1; +} else + { + $solde=" D "; + } +$str_solde=sprintf(" Solde %s %12.2f",$solde,$diff_solde); + +$pdf->ezText($str_debit,10,array('justification'=>'right')); +$pdf->ezText($str_cred,10,array('justification'=>'right')); +$pdf->ezText($str_solde,14,array('justification'=>'right')); + +//New page +$pdf->ezNewPage(); + + +$pdf->ezStream(); + +?> diff --git a/html/sec_pdf.php b/html/sec_pdf.php index e05069383..6d94162e0 100755 --- a/html/sec_pdf.php +++ b/html/sec_pdf.php @@ -43,11 +43,8 @@ include_once ("class_user.php"); $User=new cl_user($rep); $User->Check(); // Check Priv -if ( $User->CheckAction($cn,SECU) == 0 ) { - /* Cannot Access */ - NoAccess(); - exit -1; - } +$User->AccessRequest($cn,SECU); + //----------------------------------------------------- // Get User's info if ( ! isset($_GET['user_id']) ) diff --git a/html/user_advanced.php b/html/user_advanced.php index 36b6de561..120cc446b 100644 --- a/html/user_advanced.php +++ b/html/user_advanced.php @@ -18,6 +18,8 @@ */ // Auteur Dany De Bontridder ddebontridder@yahoo.fr include_once ("ac_common.php"); +require_once("check_priv.php"); + /* $Revision$ */ /*! \file * \brief Obsolete @@ -38,10 +40,7 @@ $User->Check(); include_once ("postgres.php"); echo_debug('user_advanced.php',__LINE__,"user is ".$_SESSION['g_user']); -$rep=DbConnect(); -include_once ("class_user.php"); -$User=new cl_user($rep); -$User->Check(); + // We don't check permissions here in fact, permission are tested in the // functions @@ -57,6 +56,9 @@ echo ShowMenuAdvanced(); if ( isset($_REQUEST['p_action']) && $_REQUEST['p_action'] == "periode" ) { + if ( $User->admin == 0 && CheckAction($_SESSION['g_dossier'],$_SESSION['g_user'],GESTION_PERIODE) == 0 ) + NoAccess(); + $p_action=$_REQUEST['p_action']; include_once("periode.inc.php"); } diff --git a/html/user_impress.php b/html/user_impress.php index 77bdd33bb..050bb6513 100644 --- a/html/user_impress.php +++ b/html/user_impress.php @@ -65,12 +65,8 @@ echo ""; include_once("impress_inc.php"); -if ( $User->admin == 0 ) { - if (CheckAction($_SESSION['g_dossier'],$_SESSION['g_user'],IMP) == 0 ){ - /* Cannot Access */ - NoAccess(); - } -} +$User->AccessRequest(DbConnect($_SESSION['g_dossier']),IMP); + // something is choosen $default=( isset ($_REQUEST['type']))?$_REQUEST['type']:""; diff --git a/html/user_jrn.php b/html/user_jrn.php index 710f16d45..015278916 100644 --- a/html/user_jrn.php +++ b/html/user_jrn.php @@ -17,7 +17,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr + /* $Revision$ */ + /*! \file * \brief Main page for encoding in the ledger */ @@ -54,12 +56,14 @@ echo ''; if ( $User->admin == 0 ) { // check if user can access // Acces Grand livre - if ($p_jrn == -1 && CheckAction($_SESSION['g_dossier'],$_SESSION['g_user'],ENCJRN) == 0 ){ + if ($jrn_type== 'NONE' && CheckAction($_SESSION['g_dossier'],$_SESSION['g_user'],ENCJRN) == 0 ){ + /* Cannot Access */ NoAccess(); } - // if a jrn is asked - if ( $p_jrn != -1 && CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$p_jrn) == 0 ){ + + if ( $jrn_type != 'NONE' && CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$p_jrn) == 0 ){ + /* Cannot Access */ NoAccess(); exit -1; @@ -67,14 +71,6 @@ if ( $User->admin == 0 ) { } -// Show the available jrn -// $result=ShowJrn("user_jrn.php?jrn_type=".$jrn_type); -// echo "
"; -// echo $result; -// echo "
"; - - - // if a journal is selected show the journal's menu if ( $p_jrn != -1 ) { diff --git a/html/user_sec.php b/html/user_sec.php index a5906a3af..2ddc4a13c 100644 --- a/html/user_sec.php +++ b/html/user_sec.php @@ -17,7 +17,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr + /* $Revision$ */ + /*! \file * \brief Set the security for an user */ diff --git a/include/ac_common.php b/include/ac_common.php index 952df92a5..3ed783562 100644 --- a/include/ac_common.php +++ b/include/ac_common.php @@ -198,12 +198,21 @@ function html_button_logout() { */ -function NoAccess() +function NoAccess($js=0) { - echo ""; - exit -1; + if ( $js == 1 ) + { + echo ""; + } + else + { + echo '
'; + echo '

Cette action ne vous est pas autorisée Contactez votre responsable

'; + echo '
'; + } + exit -1; } /*! * \brief Fix the problem with the quote char for the database diff --git a/include/admin.inc.php b/include/admin.inc.php index f53204ebf..d6cd8ad87 100644 --- a/include/admin.inc.php +++ b/include/admin.inc.php @@ -16,7 +16,9 @@ * along with PhpCompta; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + /* $Revision$ */ + // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr require_once("class_admin.php"); $sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:""; @@ -117,11 +119,22 @@ if ( $sub_action == "list" ) $w->name="fd_id"; $w->value= make_array($cn,"select fd_id,fd_label from fiche_def where ". " frd_id=".FICHE_TYPE_ADM_TAX); - echo $w->IOValue(); + if ( count($w->value) != 0 ) + { ?> +IOValue(); + } + else + { + echo '

Aucune fiche de catégories Administration

'; + echo 'allez dans fiche -> creation et choississez Administration comme catégorie'; + } +?> + CheckAction($cn,BALANCE) == 0) - { - NoAccess(); - exit; - } +$User->AccessRequest($cn,BALANCE); + + echo '
'; //----------------------------------------------------- diff --git a/include/check_priv.php b/include/check_priv.php index 32b3abd36..690b73b39 100644 --- a/include/check_priv.php +++ b/include/check_priv.php @@ -132,7 +132,10 @@ function CheckJrn($p_dossier,$p_user,$p_jrn,$p_detail=False) } /*! - * \brief Check if an user is allowed to do an action + * \brief Check if an user is allowed to do an action, + * this function is only used by the user_sec.php, + * otherwise you have to use cl_user->CheckAction + * or $cl_user->AccessRequest * * \param p_dossier dossier id * \param p_login user's login @@ -153,6 +156,7 @@ function CheckAction ( $p_dossier,$p_login,$p_action_id) if ( $Count == 1 ) return 1; echo "

Invalid action !!! $Count select * from user_sec_act where ua_login='$p_login' and ua_act_id=$p_action_id

"; } + /*! * \brief Check if an user is an administrator * diff --git a/include/class_fiche.php b/include/class_fiche.php index 613696d7e..6318c049b 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -17,6 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* $Revision$ */ + // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr include_once("class_attribut.php"); require_once('class_fiche_def.php'); @@ -39,7 +40,7 @@ class fiche { var $fiche_def; /*! \enum $fiche_def fd_id */ var $attribut; /*! \enum $attribut array of attribut object */ var $fiche_def_ref; /*!\enum $fiche_def_ref Type of the card here always FICHE_TYPE_CONTACT */ - + var $row; /*! \enum All the row from the ledgers */ function fiche($p_cn,$p_id=0) { $this->cn=$p_cn; $this->id=$p_id; @@ -455,7 +456,10 @@ class fiche { { echo_debug("insert ATTR_DEF_ACCOUNT"); $v=FormatString($value); - if ( isNumber($v) == 1 ) + if ( + isNumber($v) == 1 && + CountSql($this->cn,"select * from tmp_pcmn where pcm_val=$v") + ) { $sql=sprintf("select account_insert(%d,%f)", $this->id,$v); @@ -465,8 +469,8 @@ class fiche { $sql=sprintf("select account_insert(%d,null)", $this->id); } - $Ret=ExecSql($this->cn,$sql); - + ExecSql($this->cn,$sql); + continue; } // TVA @@ -711,6 +715,190 @@ class fiche { return $result[0]['frd_id']; } - + + /*! + * \brief Get data for poste + * + * \param $p_from periode from + * \param $p_to end periode + * \param $p_qcode quick_code of the card + * \return double array (j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal) + * (tot_deb,tot_credit + * + */ + function GetRow($p_from,$p_to) + { + if ( $this->id == 0 ) + { + echo_error("class_fiche",__LINE__,"id is 0"); + return; + } + $qcode=$this->strAttribut(ATTR_DEF_QUICKCODE); + $periode=sql_filter_per($this->cn,$p_from,$p_to,'p_id','jr_tech_per'); + + $Res=ExecSql($this->cn,"select to_char(j_date,'DD.MM.YYYY') as j_date,j_qcode,". + "case when j_debit='t' then j_montant else 0 end as deb_montant,". + "case when j_debit='f' then j_montant else 0 end as cred_montant,". + " jr_comment as description,jrn_def_name as jrn_name,". + "j_debit, jr_internal ". + " from jrnx left join jrn_def on jrn_def_id=j_jrn_def ". + " left join jrn on jr_grpt_id=j_grpt". + " where j_qcode='".$qcode."' and ".$periode. + " order by j_date::date"); + $array=array(); + $tot_cred=0.0; + $tot_deb=0.0; + $Max=pg_NumRows($Res); + if ( $Max == 0 ) return null; + for ($i=0;$i<$Max;$i++) { + $array[]=pg_fetch_array($Res,$i); + if ($array[$i]['j_debit']=='t') { + $tot_deb+=$array[$i]['deb_montant'] ; + } else { + $tot_cred+=$array[$i]['cred_montant'] ; + } + } + $this->row=$array; + return array($array,$tot_deb,$tot_cred); + } + + /*! + * \brief HtmlTable, display a HTML of a card for the asked period + * \param none + * + * \return none + */ + function HtmlTable() + { + $name=$this->getName(); + + list($array,$tot_deb,$tot_cred)=$this->GetRow( $_POST['from_periode'], + $_POST['to_periode'] + ); + + if ( count($this->row ) == 0 ) + return; + + $rep=""; + + echo '

'.$this->id." ".$name.'

'; + echo ""; + echo "". + "". + "". + "". + "". + "". + ""; + + foreach ( $this->row as $op ) { + echo "". + "". + "". + "". + "". + "". + ""; + + } + $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; + $diff=round(abs($tot_deb-$tot_cred),2); + echo "". + "". + "". + "". + "". + "". + ""; + + echo "
Code interne Date Description Débit Crédit
".$op['jr_internal']."".$op['j_date']."".$op['description']."".$op['deb_montant']."".$op['cred_montant']."
$solde_type$diff$tot_deb$tot_cred
"; + + return; + } + /*! + * \brief Display HTML Table Header (button) + * + * \return none + */ + function HtmlTableHeader() + { + $submit=new widget(); + $hid=new widget("hidden"); + echo '
'; + echo ""; + echo ''; + + echo '"; + + echo '"; + + echo '"; + echo "
'. + $submit->Submit('bt_other',"Autre poste"). + $hid->IOValue("type","poste").$hid->IOValue('p_action','impress')."
'. + $submit->Submit('bt_pdf',"Export PDF"). + $hid->IOValue("type","poste"). + $hid->IOValue('p_action','impress'). + $hid->IOValue("f_id",$this->id). + $hid->IOValue("from_periode",$_POST['from_periode']). + $hid->IOValue("to_periode",$_POST['to_periode']); + echo "
'. + $submit->Submit('bt_csv',"Export CSV"). + $hid->IOValue("type","poste"). + $hid->IOValue('p_action','impress'). + $hid->IOValue("f_id",$this->id). + $hid->IOValue("from_periode",$_POST['from_periode']). + $hid->IOValue("to_periode",$_POST['to_periode']); + + echo "
"; + echo '
'; + + } + /*! + * \brief give the balance of an card + * \return + * balance of the card + * + */ +function GetSoldeDetail($p_cond="") { + if ( $this->id == 0 ) exit('fiche->id est nul'); + $qcode=$this->strAttribut(ATTR_DEF_QUICKCODE); + + if ( $p_cond != "") $p_cond=" and ".$p_cond; + $Res=ExecSql($this->cn,"select sum(deb) as sum_deb, sum(cred) as sum_cred from + ( select j_poste, + case when j_debit='t' then j_montant else 0 end as deb, + case when j_debit='f' then j_montant else 0 end as cred + from jrnx + where + j_qcode = ('$qcode'::text) + $p_cond + ) as m "); + $Max=pg_NumRows($Res); + if ($Max==0) return 0; + $r=pg_fetch_array($Res,0); + + return array('debit'=>$r['sum_deb'], + 'credit'=>$r['sum_cred'], + 'solde'=>abs($r['sum_deb']-$r['sum_cred'])); } +/*! + * \brief get the fd_id of the card : fd_id + * \param none + * + * \return none + */ + function get_categorie() + { + if ( $this->id == 0 ) exit('class_fiche : f_id = 0 '); + $sql='select fd_id from fiche where f_id='.$this->id; + $R=getDbValue($this->cn,$sql); + if ( $R == "" ) + $this->fd_id=0; + else + $this->fd_id=$R; + } + +} + ?> diff --git a/include/class_poste.php b/include/class_poste.php index 3de4f1965..fb7380e1b 100644 --- a/include/class_poste.php +++ b/include/class_poste.php @@ -234,49 +234,49 @@ function GetSoldeDetail($p_cond="") { return; } -} -/*! - * \brief Display HTML Table Header (button) - * \param poste_id - * - * \return none - */ -function HtmlTableHeader($p_poste) -{ - $submit=new widget(); - $hid=new widget("hidden"); - echo '
'; - echo ""; - echo ''; - - echo '"; + + /*! + * \brief Display HTML Table Header (button) + * + * \return none + */ + function HtmlTableHeader() + { + $submit=new widget(); + $hid=new widget("hidden"); + echo '
'; + echo "
'. - $submit->Submit('bt_other',"Autre poste"). - $hid->IOValue("type","poste").$hid->IOValue('p_action','impress')."
"; + echo ''; - echo '"; - - echo '"; - echo "
'. - $submit->Submit('bt_pdf',"Export PDF"). - $hid->IOValue("type","poste"). - $hid->IOValue('p_action','impress'). - $hid->IOValue("poste_id",$p_poste). - $hid->IOValue("from_periode",$_POST['from_periode']). - $hid->IOValue("to_periode",$_POST['to_periode']); - if (isset($_POST['poste_fille'])) - echo $hid->IOValue('poste_fille','on'); - echo "
'. - $submit->Submit('bt_csv',"Export CSV"). - $hid->IOValue("type","poste"). - $hid->IOValue('p_action','impress'). - $hid->IOValue("poste_id",$p_poste). - $hid->IOValue("from_periode",$_POST['from_periode']). - $hid->IOValue("to_periode",$_POST['to_periode']); - if (isset($_POST['poste_fille'])) - echo $hid->IOValue('poste_fille','on'); - - echo "
"; - echo '
'; - -} + echo '
'. + $submit->Submit('bt_other',"Autre poste"). + $hid->IOValue("type","poste").$hid->IOValue('p_action','impress')."
"; + + echo '
'. + $submit->Submit('bt_pdf',"Export PDF"). + $hid->IOValue("type","poste"). + $hid->IOValue('p_action','impress'). + $hid->IOValue("poste_id",$_POST['poste_id']). + $hid->IOValue("from_periode",$_POST['from_periode']). + $hid->IOValue("to_periode",$_POST['to_periode']); + if (isset($_POST['poste_fille'])) + echo $hid->IOValue('poste_fille','on'); + echo "
"; + + echo '
'. + $submit->Submit('bt_csv',"Export CSV"). + $hid->IOValue("type","poste"). + $hid->IOValue('p_action','impress'). + $hid->IOValue("poste_id",$_POST['poste_id']). + $hid->IOValue("from_periode",$_POST['from_periode']). + $hid->IOValue("to_periode",$_POST['to_periode']); + if (isset($_POST['poste_fille'])) + echo $hid->IOValue('poste_fille','on'); + + echo "
"; + echo ""; + echo '
'; + + } +} \ No newline at end of file diff --git a/include/class_user.php b/include/class_user.php index 1bfb4a210..d850b5cc2 100644 --- a/include/class_user.php +++ b/include/class_user.php @@ -247,6 +247,7 @@ function GetPreferences () if ( $Count == 0 ) return 0; if ( $Count == 1 ) return 1; echo "

Invalid action !!! $Count select * from user_sec_act where ua_login='$p_login' and ua_act_id=$p_action_id

"; + exit(); } /*! ************************************************** @@ -364,16 +365,29 @@ function getExercice() * otherwise warn and exit * \param $p_cn database connx * \param $action_id + * \param $p_js = 1 javascript, or 0 just a text * \return nothing the program exits automatically */ -function AccessRequest($p_cn,$p_action) +function AccessRequest($p_cn,$p_action,$p_js=0) { if ( $this->CheckAction($p_cn,$p_action)==0 ) { - echo ""; - exit(-1); + if ( $p_js == 1 ) + { + echo ""; + + } + else + { + echo '
'; + echo '

Cette action ne vous est pas autorisée Contactez votre responsable

'; + echo '
'; + + } + exit(-1); + } } } diff --git a/include/class_widget.php b/include/class_widget.php index 6f7a825fb..c780655c8 100644 --- a/include/class_widget.php +++ b/include/class_widget.php @@ -16,7 +16,9 @@ * along with PhpCompta; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + /* $Revision$ */ + // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr /*! \file @@ -98,7 +100,6 @@ class widget { $this->table=0; $this->label=""; $this->disabled=false; - $this->tabindex=32767; } function SetReadOnly($p_read) { $this->readonly=$p_read; @@ -123,7 +124,7 @@ class widget { $disabled = $this->disabled ? "DISABLED" : ""; if (strtoupper($this->type)=="TEXT") { if ( $this->readonly==false) { - $r="name\" VALUE=\"$this->value\" TABINDEX=\"$this->tabindex\" SIZE=\"$this->size\" ".$disabled.">";} else { + $r="name\" VALUE=\"$this->value\" SIZE=\"$this->size\" ".$disabled.">";} else { $r=sprintf('%s', $this->value,$this->name,$this->value); } @@ -380,7 +381,9 @@ class widget { - %s + + %s + ', $l_sessid, $this->extra, // deb or cred @@ -392,8 +395,7 @@ class widget { $this->extra2, $this->label, $this->name, - $this->value, - $this->tabindex + $this->value ); } else { // readonly == true @@ -422,7 +424,7 @@ class widget { $r=sprintf(' %s + ' NAME="%s" VALUE="%s" SIZE="8" > ', $l_sessid, $this->extra, @@ -430,8 +432,7 @@ class widget { $this->extra2, $this->label, $this->name, - $this->value, - $this->tabindex + $this->value ); } else @@ -439,15 +440,14 @@ class widget { $r=sprintf(' %s ', + ' NAME="%s" VALUE="%s" SIZE="8" > ', $l_sessid, $this->extra, $this->name, $this->extra2, $this->label, $this->name, - $this->value, - $this->tabindex + $this->value ); } } else { diff --git a/include/constant.php b/include/constant.php index d52ea43a2..102c5dc1f 100644 --- a/include/constant.php +++ b/include/constant.php @@ -18,6 +18,7 @@ */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr // $Revision$ + /*! \file * \brief Contains all the variable + the javascript * and some parameter @@ -55,6 +56,8 @@ define ("CENTRALIZE",10); define ("VEN",11); define ("BQE",12); define ("ODS",13); +// Access gestion periode comptable +define ("GESTION_PERIODE",31); //!\enum Security define("SEC_ACTION", 28); // Module Suivi Document diff --git a/include/contact.inc.php b/include/contact.inc.php index a03fdeb2b..f8ef477a8 100644 --- a/include/contact.inc.php +++ b/include/contact.inc.php @@ -16,7 +16,9 @@ * along with PhpCompta; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + /* $Revision$ */ + // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr //!\brief File for adding contact, contact is a kind of fiche require_once('class_contact.php'); @@ -133,7 +135,7 @@ if ( $sub_action == "list" ) // if array is empty show an warning and stops if ( sizeof ($w->value) == 0 ) { echo '

Aucune fiche de catégories contact

'; - echo '

allez dans comptabilité -> fiche creation et choississez contact comme sorte

'; + echo '

allez dans fiche creation et choississez contact comme sorte

'; exit(); } echo $w->IOValue(); diff --git a/include/fiche.inc.php b/include/fiche.inc.php index 825ac4d95..a3b6f71f2 100644 --- a/include/fiche.inc.php +++ b/include/fiche.inc.php @@ -164,7 +164,7 @@ if ( isset ( $_GET["action"]) ) { && ! isset ($_POST['add_fiche']) && ! isset ($_POST['update_fiche']) && ! isset ($_POST['delete'])) { - ShowRecherche(); + echo '
'; $fiche_def=new fiche_def($cn,$_GET['fiche']); $fiche_def->myList(); @@ -185,6 +185,11 @@ if ( isset ( $_GET["action"]) ) { } $str=""; $fiche=new fiche($cn,$_GET["fiche_id"]); + $fiche->get_categorie(); + $fiche_def=new fiche_def($cn,$fiche->fd_id); + $fiche_def->Get(); + echo '

'.$fiche_def->label.'

'; + if ( $_SESSION['g_pagesize'] != -1 ){ // retrieve value // with offet &offset=15&step=15&page=2&size=15 @@ -281,6 +286,9 @@ if ( isset ($_POST["fiche"]) && isset ($_POST["add"] ) ) { echo "

Pas d'accès

"; else { + $fiche_def=new fiche_def($cn,$_POST['fiche']); + $fiche_def->Get(); + echo '

'.$fiche_def->label.'

'; $url=$_SERVER['REQUEST_URI']; $fiche=new fiche($cn,0); @@ -340,7 +348,7 @@ if ( isset ($_POST["add_fiche"]) ) { //------------------------------------------------------------------------------ // Update a card if ( isset ($_POST["update_fiche"]) ) { - ShowRecherche(); + echo '
'; if ( $write ==0) echo "

Pas d'accès

"; diff --git a/include/impress.inc.php b/include/impress.inc.php index af49ee302..58fba9625 100644 --- a/include/impress.inc.php +++ b/include/impress.inc.php @@ -17,7 +17,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr + /* $Revision$ */ + /*! \file * \brief Main page for the printing */ @@ -43,15 +45,10 @@ $result=ShowItem($p_array,'H',"cell","mtitle",$default); echo $result; echo "
"; +$cn=DbConnect($_SESSION['g_dossier']); +$User->AccessRequest($cn,IMP); -if ( $User->admin == 0 ) { - if (CheckAction($_SESSION['g_dossier'],$_SESSION['g_user'],IMP) == 0 ){ - /* Cannot Access */ - NoAccess(); - } -} - include_once("impress_inc.php"); diff --git a/include/impress_fiche.php b/include/impress_fiche.php index 32a8ddc3a..b81b4f94b 100644 --- a/include/impress_fiche.php +++ b/include/impress_fiche.php @@ -75,7 +75,9 @@ if ( isset ($_REQUEST['fd_id'])) { $hid->IOValue("type","fiche"). $fiche_id->IOValue("fd_id",$_REQUEST['fd_id']). $hid->IOValue("with_amount"); - + echo '

Attention: les soldes ne tiennent pas compte des journaux OD qui '. + 'n\'utilisent pas les quick codes, les soldes des postes sont dans impression->poste

'; + echo ""; } @@ -112,9 +114,9 @@ if ( isset ($_REQUEST['fd_id'])) { if ( $dattribut->ad_id == ATTR_DEF_ACCOUNT && $with_amount) { - $account=new poste ($cn,$dattribut->av_text); + $sql_periode=sql_filter_per($cn,$_REQUEST['from_periode'],$_REQUEST['to_periode'],'p_id','j_tech_per'); - $solde= $account->GetSoldeDetail($sql_periode); + $solde= $detail->GetSoldeDetail($sql_periode); printf ("% 10.2f",$solde['debit']); printf ("% 10.2f",$solde['credit']); diff --git a/include/impress_poste.php b/include/impress_poste.php index 92ebe99e8..f2238234c 100644 --- a/include/impress_poste.php +++ b/include/impress_poste.php @@ -42,7 +42,7 @@ if ( isset( $_POST['bt_html'] ) ) { { $parent=$_POST['poste_id']; $a_poste=getarray($cn,"select pcm_val from tmp_pcmn where pcm_val like '$parent%'"); - $go=2; + $go=3; } // Check if the post is numeric and exists elseif ( CountSql($cn,'select * from tmp_pcmn where pcm_val='.FormatString($_POST['poste_id'])) != 0 ) @@ -54,35 +54,47 @@ if ( isset( $_POST['bt_html'] ) ) { { require_once("class_fiche.php"); // thanks the qcode we found the poste account - $fiche=new fiche($cn,$_POST['f_id']); - $fiche->GetByQCode($_POST['f_id']); + $fiche=new fiche($cn); + $qcode=$fiche->GetByQCode($_POST['f_id']); $p=$fiche->strAttribut(ATTR_DEF_ACCOUNT); if ( $p != "- ERROR -") { - $Poste=new poste($cn,$p); - $go=1; + $go=2; } } - // A account or a quick code is given + // A account is given if ( $go == 1) { echo '
'; - HtmlTableHeader($_POST['poste_id']); + $Poste->HtmlTableHeader(); $Poste->HtmlTable(); - HtmlTableHeader($_POST['poste_id']); + $Poste->HtmlTableHeader(); echo "
"; exit; } + + // A QuickCode is given + if ( $go == 2) + { + echo '
'; + $fiche->HtmlTableHeader(); + $fiche->HtmlTable($qcode); + $fiche->HtmlTableHeader(); + echo "
"; + exit; + } + // All the children account - if ( $go == 2 ) + if ( $go == 3 ) { if ( sizeof($a_poste) == 0 ) exit; echo '
'; - HtmlTableHeader($_POST['poste_id']); + $Poste=new poste($cn,$_POST['poste_id']); + $Poste->HtmlTableHeader($_POST['poste_id']); $Poste->HtmlTable(); foreach ($a_poste as $poste_id ) @@ -90,7 +102,7 @@ if ( isset( $_POST['bt_html'] ) ) { $Poste=new poste ($cn,$poste_id['pcm_val']); $Poste->HtmlTable(); } - HtmlTableHeader($_POST['poste_id']); + $Poste->HtmlTableHeader($_POST['poste_id']); echo "
"; exit; diff --git a/include/jrn.php b/include/jrn.php index 33f2553da..c8a1bcaa0 100644 --- a/include/jrn.php +++ b/include/jrn.php @@ -17,7 +17,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr + /* $Revision$ */ + /*! \file * \brief work with the ledger */ diff --git a/include/stock.inc.php b/include/stock.inc.php index efd4b0ad0..79c1666a7 100644 --- a/include/stock.inc.php +++ b/include/stock.inc.php @@ -18,7 +18,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Auteur Dany De Bontridder ddebontridder@yahoo.fr + /* $Revision$ */ + /*!\file * \brief Manage the stock by year */ @@ -46,16 +48,6 @@ $User->Check(); // Synchronize rights SyncRight($_SESSION['g_dossier'],$_SESSION['g_user']); -// Get The priv on the selected folder -if ( $User->admin == 0 ) { - - $r=CheckAction($_SESSION['g_dossier'],$_SESSION['g_user'],STOCK_READ); - if ($r == 0 ){ - /* Cannot Access */ - NoAccess(); - } - -} $href=basename($_SERVER['PHP_SELF']); if ($href=='compta.php') @@ -70,6 +62,9 @@ if ($href=='compta.php') //echo '