diff --git a/html/jrn_csv.php b/html/jrn_csv.php index a6e5a94d5..2606df94b 100644 --- a/html/jrn_csv.php +++ b/html/jrn_csv.php @@ -43,20 +43,24 @@ if ( $User->CheckAction($cn,IMP) == 0 || $Jrn=new jrn($cn,$_GET['jrn_id']); $Jrn->GetName(); -$Jrn->GetRow( $_GET['from_periode'], - $_GET['to_periode'], - $p_cent); +// Detailled printing +//--- +if ( $_GET['p_simple'] == 0 ) + { + $Jrn->GetRow( $_GET['from_periode'], + $_GET['to_periode'], + $p_cent); - if ( count($Jrn->row) == 0) - exit; - foreach ( $Jrn->row as $op ) { + if ( count($Jrn->row) == 0) + exit; + foreach ( $Jrn->row as $op ) { // should clean description : remove tag and '; char - $desc=$op['description']; - $desc=str_replace("","",$desc); - $desc=str_replace("","",$desc); - $desc=str_replace("","",$desc); - $desc=str_replace("","",$desc); - $desc=str_replace('"',"'",$desc); + $desc=$op['description']; + $desc=str_replace("","",$desc); + $desc=str_replace("","",$desc); + $desc=str_replace("","",$desc); + $desc=str_replace("","",$desc); + $desc=str_replace('"',"'",$desc); printf("\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t%8.4f\t%8.4f\n", $op['j_id'], @@ -68,6 +72,48 @@ $Jrn->GetRow( $_GET['from_periode'], $op['deb_montant'] ); + } + exit; } - exit; + else + { + $Row=$Jrn->GetRowSimple($_GET['from_periode'], + $_GET['to_periode'], + $p_cent); +//////////////////////////////////////////////////////////////////////////////// + printf ('" operation "'. + '"Date"'. + '"commentaire"'. + '"internal"'. + '"montant"'); + + foreach ($Row as $line) + { + echo $line['num'].";"; + echo $line['date'].";"; + echo $line['comment'].";"; + echo $line['jr_internal'].";"; + // echo "".$line['pj'].";"; + // If the ledger is financial : + // the credit must be negative and written in red + // Get the jrn type + if ( $line['jrn_def_type'] == 'FIN' ) { + $positive = CountSql($cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ". + " where jr_id=".$line['jr_id']." and (j_poste like '55%' or j_poste like '57%' )". + " and j_debit='f'"); + + + echo ( $positive != 0 )?sprintf("-%8.2f",$line['montant']):sprintf("%8.2f",$line['montant']); + echo ";"; + } + else + { + printf("% 8.2f",$line['montant']).";"; + } + + printf("\r\n"); + } + +//////////////////////////////////////////////////////////////////////////////// + } ?> diff --git a/html/user_jrn.php b/html/user_jrn.php index 120cdee0b..97f4583a7 100644 --- a/html/user_jrn.php +++ b/html/user_jrn.php @@ -85,8 +85,6 @@ if ( isset ($_GET['JRN_TYPE'] ) ) { ShowMenuJrnUser($_SESSION['g_dossier'],$_GET['JRN_TYPE'],$p_jrn); echo ""; if ( $jrn_type=='NONE' ) include('user_action_gl.php'); - if ( $jrn_type=='SALDO_FIN') include ('user_action_fin.php'); - } else { echo_debug("Selected is ".$p_jrn); @@ -103,11 +101,6 @@ if ( isset ($_GET['JRN_TYPE'] ) ) { echo ''; } -if ( $jrn_type=='FIN' ) -{ - //show balance of all bank accounts. Let's say their ID start with 5500 - //TODO -} // if a journal is selected show the journal's menu if ( $p_jrn != -1 ) { diff --git a/include/central_inc.php b/include/central_inc.php index eb03bcba0..3795d7f4d 100644 --- a/include/central_inc.php +++ b/include/central_inc.php @@ -68,6 +68,7 @@ $sql="insert into centralized( c_j_id, if ($Res==false) { rollback($p_cn); EndSql($p_cn); return ERROR;} // Set correctly the number of operation id (jr_opid) for each journal // get the existing jrn_def_id +//-- $Res = ExecSql($p_cn,"select jrn_def_id from jrn_def"); $MaxJrn=pg_NumRows($Res); // for each jrn_def_id diff --git a/include/class_jrn.php b/include/class_jrn.php index 93caf8b50..101e9c2ea 100644 --- a/include/class_jrn.php +++ b/include/class_jrn.php @@ -46,7 +46,7 @@ class jrn { } /* function GetRow - * Purpose : Get The data for the pdf printing + * Purpose : Get The data * * parm : * - connection @@ -73,10 +73,10 @@ class jrn { // Grand livre == 0 if ( $this->id != 0 ) { - if ( $cent=='off' ) { - echo_debug(__FILE__,__LINE__,"journaux non centralisé"); - // Journaux non centralisés - $Res=ExecSql($this->db,"select j_id,j_id as int_j_id,to_char(j_date,'DD.MM.YYYY') as j_date, + if ( $cent=='off' ) { + echo_debug(__FILE__,__LINE__,"journaux non centralisé"); + // Journaux non centralisés + $Res=ExecSql($this->db,"select j_id,j_id as int_j_id,to_char(j_date,'DD.MM.YYYY') as j_date, jr_internal, case j_debit when 't' then j_montant::text else ' ' end as deb_montant, case j_debit when 'f' then j_montant::text else ' ' end as cred_montant, @@ -221,5 +221,92 @@ class jrn { $a=array($array,$tot_deb,$tot_cred); return $a; } - + /* function GetRowSimple + ************************************************** + * Purpose : Get simplified row + * + * parm : + * - connection + * - array + * - p_limit starting line + * - p_offset number of lines + * + * gen : + * - none + * return: + * - Array with the asked data + * + */ + + function GetRowSimple($p_from,$p_to,$cent='off',$p_limit=-1,$p_offset=-1) + { + + echo_debug(__FILE__,__LINE__,"GetRowSimple ( $p_from,$p_to,$cent,$p_limit,$p_offset)"); + // Periode check + //--- + if ( $p_from == $p_to ) + $periode=" jr_tech_per = $p_from "; + else + $periode = "(jr_tech_per >= $p_from and jr_tech_per <= $p_to) "; + $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; + // Grand-livre : id= 0 + //--- + $jrn=($this->id == 0 )?"":"and jrn_def_id = ".$this->id; + // Non Centralise si cent=off + //-- + if ($cent=='off') + {// Non centralisé + //--- + $sql=" + SELECT jrn.jr_id as jr_id , + jrn.jr_id as num , + jrn.jr_def_id as jr_def_id, + jrn.jr_montant as montant, + jrn.jr_comment as comment, + to_char(jrn.jr_date,'DD-MM-YYYY') as date, + jr_internal, + jrn.jr_grpt_id as grpt_id, + jrn.jr_pj_name as pj, + jrn_def_type + FROM jrn join jrn_def on (jrn_def_id=jr_def_id) +where $periode $jrn order by jr_date"; + + + + } + else + { + //Centralisé + //--- + $id=($this->id == 0 ) ?"jr_c_opid as num":"jr_opid as num"; + $sql=" + SELECT jrn.jr_id as jr_id , + $id , + jrn.jr_def_id as jr_def_id, + jrn.jr_montant as montant, + jrn.jr_comment as comment, + to_char(jrn.jr_date,'DD-MM-YYYY') as date, + jr_internal, + jrn.jr_grpt_id as grpt_id, + jrn.jr_pj_name as pj, + jrn_def_type + FROM jrn join jrn_def on (jrn_def_id=jr_def_id) + where + $periode $jrn and + jr_opid is not null + order by jr_date"; + }// end else $cent=='off' + //load all data into an array + //--- + $Res=ExecSql($this->db,$sql); + if ( pg_NumRows($Res) == 0 ) + { + return null; + } + + + $array=pg_fetch_all($Res); + + return $array; + }// end function GetRowSimple } \ No newline at end of file diff --git a/include/impress_jrn.php b/include/impress_jrn.php index 1db5d0d21..d14db3703 100644 --- a/include/impress_jrn.php +++ b/include/impress_jrn.php @@ -32,10 +32,19 @@ include("class_jrn.php"); echo_debug(__FILE__,__LINE__,$d); $Jrn=new jrn($cn,$_POST['jrn_id']); $Jrn->GetName(); - $Jrn->GetRow( $_POST['from_periode'], - $_POST['to_periode'], - $p_cent); - + if ( $_POST['p_simple']==0 ) + { + $Jrn->GetRow( $_POST['from_periode'], + $_POST['to_periode'], + $p_cent); + } + else + { + $Row=$Jrn->GetRowSimple($_POST['from_periode'], + $_POST['to_periode'], + $p_cent); + // var_dump($Row); + } $rep=""; $submit=new widget(); $hid=new widget("hidden"); @@ -54,6 +63,7 @@ include("class_jrn.php"); $hid->IOValue("jrn_id",$Jrn->id). $hid->IOValue("from_periode",$_POST['from_periode']). $hid->IOValue("to_periode",$_POST['to_periode']); + echo $hid->IOValue("p_simple",$_POST['p_simple']); echo ""; echo '
'. @@ -63,31 +73,82 @@ include("class_jrn.php"); $hid->IOValue("jrn_id",$Jrn->id). $hid->IOValue("from_periode",$_POST['from_periode']). $hid->IOValue("to_periode",$_POST['to_periode']); - + echo $hid->IOValue("p_simple",$_POST['p_simple']); echo "
"; echo ""; echo ""; - if ( count($Jrn->row ) == 0 ) + if ( count($Jrn->row ) == 0 + && $Row==null) exit; - echo ""; - foreach ( $Jrn->row as $op ) { + echo "
"; + + if ( $_POST['p_simple'] == 0 ) { + // detailled printing + //--- + foreach ( $Jrn->row as $op ) { echo ""; // centralized if ( $p_cent == 'on') { echo ""; } - echo "". + echo "". "". "". "". "". "". ""; - } + }// end loop + } // if + else + { + include_once("jrn.php"); + // Simple printing + //--- + + echo "". + "". + "". + "". + /* "". */ + "". + ""; + + foreach ($Row as $line) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + // echo ""; + // If the ledger is financial : + // the credit must be negative and written in red + // Get the jrn type + if ( $line['jrn_def_type'] == 'FIN' ) { + $positive = CountSql($cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ". + " where jr_id=".$line['jr_id']." and (j_poste like '55%' or j_poste like '57%' )". + " and j_debit='f'"); + + echo ""; + } + else + { + echo ""; + } + + echo ""; + } + + } //else echo "
".$op['j_id']."".$op['internal']."".$op['internal']."".$op['j_date']."".$op['poste']."".$op['description']."".$op['deb_montant']."".$op['cred_montant']."
operation ". + "Date commentaire internalPièce justificative montant
".$line['num']."".$line['date']."".$line['comment']."".$line['jr_internal']."".$line['pj'].""; + echo ( $positive != 0 )?" - ".sprintf("%8.2f",$line['montant'])."":sprintf("%8.2f",$line['montant']); + echo "".sprintf("% 8.2f",$line['montant'])."
"; + echo ""; exit; } @@ -152,7 +213,12 @@ $centralise=new widget("checkbox"); $centralise->label="Depuis les journaux centralisés"; $centralise->table=1; print $centralise->IOValue('cent'); - +$a=array( + array('value'=>0,'label'=>'Detaillé'), + array('value'=>1,'label'=>'Simple') + ); +$w->selected=1; +echo $w->IOValue('p_simple',$a,'Style d\'impression'); print ""; echo ''; print $w->Submit('bt_html','Impression');