From 7d0683f3016cbcb9556e07aebdce3696c8f3de41 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 13 May 2010 01:16:05 +0000 Subject: [PATCH] Remove centralizatin mechanism, the table is not yet dropped --- html/annulation.php | 1 - html/bal_csv.php | 9 -- html/commercial.php | 4 - html/jrn_csv.php | 7 +- html/jrn_pdf.php | 21 ++--- html/modify_op.php | 1 - html/print_balance.php | 9 -- html/user_advanced.php | 6 -- include/balance.inc.php | 12 --- include/central.inc.php | 92 ------------------ include/central_inc.php | 158 ------------------------------- include/class_acc_balance.php | 17 ++-- include/class_acc_ledger.php | 164 +++++--------------------------- include/impress_inc.php | 171 ---------------------------------- include/impress_jrn.inc.php | 26 ++---- include/verif_bilan.inc.php | 14 +-- 16 files changed, 50 insertions(+), 662 deletions(-) delete mode 100644 include/central.inc.php delete mode 100644 include/central_inc.php diff --git a/html/annulation.php b/html/annulation.php index 35555bdf6..944987473 100644 --- a/html/annulation.php +++ b/html/annulation.php @@ -22,7 +22,6 @@ * \brief in a popup window manage the removal of the operations */ include_once ("ac_common.php"); -include_once("central_inc.php"); include_once("user_common.php"); require_once('class_database.php'); include_once("jrn.php"); diff --git a/html/bal_csv.php b/html/bal_csv.php index 0bf9d7ad4..6adaaae97 100644 --- a/html/bal_csv.php +++ b/html/bal_csv.php @@ -44,15 +44,6 @@ if ( $User->check_action(IMPBAL) == 0) echo 'poste;libelle;deb;cred;solde deb;solde cred'; printf("\n"); $bal=new Acc_Balance($cn); - -$t_cent=""; - //$per=join(',',$periode); -if ( isset($_GET['central']) ) { - $bal->central='Y'; - $t_cent="centralisée"; - } -else - $bal->central='N'; $bal->jrn=$_GET['p_jrn']; $bal->from_poste=$_GET['from_poste']; $bal->to_poste=$_GET['to_poste']; diff --git a/html/commercial.php b/html/commercial.php index 7fba13b00..e21364db8 100644 --- a/html/commercial.php +++ b/html/commercial.php @@ -209,10 +209,6 @@ if ( $p_action=='periode') { else $User->can_request(9999,1); } -if ( $p_action=='central') { - $User->can_request(PARCENT,1); - require_once ('central.inc.php'); - } //----------------------------------------------------- // Expense if ( $p_action == 'defreport') diff --git a/html/jrn_csv.php b/html/jrn_csv.php index 94836b9b9..acd8697cc 100644 --- a/html/jrn_csv.php +++ b/html/jrn_csv.php @@ -44,8 +44,6 @@ $User->check_dossier($gDossier); if ($_GET['jrn_id']!=0 && $User->check_jrn($_GET['jrn_id']) =='X') { NoAccess(); exit();} -$p_cent=( isset ( $_GET['central']) )?$_GET['central']:'off'; - $Jrn=new Acc_Ledger($cn,$_GET['jrn_id']); $Jrn->get_name(); @@ -56,8 +54,8 @@ $jrn_type=$Jrn->get_type(); if ( $_GET['p_simple'] == 0 ) { $Jrn->get_row( $_GET['from_periode'], - $_GET['to_periode'], - $p_cent); + $_GET['to_periode'] + ); if ( count($Jrn->row) == 0) exit; @@ -88,7 +86,6 @@ if ( $_GET['p_simple'] == 0 ) { $Row=$Jrn->get_rowSimple($_GET['from_periode'], $_GET['to_periode'], - $p_cent, 0); //----------------------------------------------------- if ( $jrn_type == 'ODS' || $jrn_type == 'FIN' || $jrn_type=='GL') diff --git a/html/jrn_pdf.php b/html/jrn_pdf.php index 51c8a2c87..d74663d32 100644 --- a/html/jrn_pdf.php +++ b/html/jrn_pdf.php @@ -41,13 +41,8 @@ $cn=new Database($gDossier); $periode=new Periode($cn); $l_type="JRN"; -$centr=" Non centralisé"; -$l_centr=0; $own=new Own($cn); -if ($_GET['central'] == 'on' ) { - $centr=" centralisé "; - $l_centr=1; -} + $Jrn=new Acc_Ledger($cn,$_GET['jrn_id']); $Jrn->get_name(); @@ -80,8 +75,8 @@ if ( $Jrn->id==0 || $jrn_type=='FIN' || $jrn_type=='ODS' || $_REQUEST['p_simple // detailled printing $rap_deb=0;$rap_cred=0; - // take all operations from jrn or centralized - $array=$Jrn->get_operation($_GET['from_periode'],$_GET['to_periode'],$l_centr); + // take all operations from jrn + $array=$Jrn->get_operation($_GET['from_periode'],$_GET['to_periode']); $pdf->SetFont('DejaVu','BI',7); $pdf->Cell(160,7,'report Débit',0,0,'R'); @@ -185,12 +180,9 @@ if ( ($jrn_type=='VEN' || $jrn_type=='ACH') && $_REQUEST['p_simple']== 1 ) $pdf->Cell(15,6,'TVAC',0,0,'R'); $pdf->Ln(5); - // if the period is centralized get the first amounts - if ( $l_centr==1) - $a=0; $a_jrn=$Jrn->get_operation($_GET['from_periode'], - $_GET['to_periode'], - $_GET['central']); + $_GET['to_periode']); + if ( $a_jrn == null ) exit(); /* * get rappel to initialize amount rap_xx @@ -411,8 +403,7 @@ if ( ($jrn_type=='VEN' || $jrn_type=='ACH') && $_REQUEST['p_simple']== 1 ) $pdf->Ln(5); $a_jrn=$Jrn->get_operation($_GET['from_periode'], - $_GET['to_periode'], - $_GET['central']); + $_GET['to_periode']); if ( $a_jrn == null ) exit(); /* * get rappel to initialize amount rap_xx diff --git a/html/modify_op.php b/html/modify_op.php index 620ea7384..dc51bcfee 100644 --- a/html/modify_op.php +++ b/html/modify_op.php @@ -24,7 +24,6 @@ * */ include_once ("ac_common.php"); -include_once("central_inc.php"); include_once("user_common.php"); require_once('class_database.php'); include_once("jrn.php"); diff --git a/html/print_balance.php b/html/print_balance.php index bbc87bc46..5592af846 100644 --- a/html/print_balance.php +++ b/html/print_balance.php @@ -50,15 +50,6 @@ $bal=new Acc_Balance($cn); $User->can_request(IMPBAL,1); extract ($_GET); -// if centralized -$t_cent=""; - -if ( isset($central) ) { - $bal->central='Y'; - $t_cent="centralisée"; - } - else - $bal->central='N'; $bal->jrn=$_GET['p_jrn']; $bal->from_poste=$_GET['from_poste']; diff --git a/html/user_advanced.php b/html/user_advanced.php index a56beeae0..6c485dce3 100644 --- a/html/user_advanced.php +++ b/html/user_advanced.php @@ -83,9 +83,6 @@ break; case 'verif'; $high=10; break; -case 'central'; -$high=3; - break; case 'defreport': $high=6; break; @@ -122,9 +119,6 @@ if ( $p_action=='verif' ) { require_once ('verif_bilan.inc.php'); exit(); } -if ( $p_action=='central') - require_once ('central.inc.php'); - if ($p_action=='defreport') { require_once('report.inc.php'); diff --git a/include/balance.inc.php b/include/balance.inc.php index 8d523987b..8735006aa 100644 --- a/include/balance.inc.php +++ b/include/balance.inc.php @@ -106,9 +106,6 @@ $to_poste->set_attribute('account','to_poste'); $to_poste->value=(isset($_POST['to_poste']))?$_POST['to_poste']:""; $to_span=new ISpan("to_poste_label",""); -$c=new ICheckBox(); -$c->label="centralisé"; -echo $c->input('central'); echo "
"; echo "Plage de postes :".$from_poste->input(); @@ -167,15 +164,6 @@ if ( isset($_POST['view'] ) ) { $bal->from_poste=$_POST['from_poste']; $bal->to_poste=$_POST['to_poste']; - $t_cent=""; - //$per=join(',',$periode); - if ( isset($_POST['central']) ) { - $bal->central='Y'; - $t_cent="centralisée"; - } - else - $bal->central='N'; - $row=$bal->get_row($_POST['from_periode'], $_POST['to_periode']); $periode=new Periode($cn); diff --git a/include/central.inc.php b/include/central.inc.php deleted file mode 100644 index 3072a62cf..000000000 --- a/include/central.inc.php +++ /dev/null @@ -1,92 +0,0 @@ -Check(); - -$cn=new Database($gDossier); - -include_once("central_inc.php"); - - -$User->can_request(PARCENT,1); - - - -echo '
'; -echo '

Centralise


'; -if ( isset ($_POST["central"] )) { - - //demande centralise -if ( $_POST["period"] != "" ) { - $ret=Centralise($cn,$_POST["period"]); - if ($ret==NOERROR) { - echo '

La période '.$_POST["period"].' est centralisée

'; - } else { - echo '

La période '.$_POST["period"].' n\' a pu être centralisée

'; - } - } -}// if ( isset ($_POST["central"] )) -$period=new IPeriod("period"); -$period->user=$User; -$period->cn=$cn; -$period->value=0; -$period->type=NOTCENTRALIZED; -try { - $ret=$period->input(); -} catch (Exception $e) { - if ( $e->getCode() != 0 ) { - echo $e->getMessage(); - exit; - } else { - echo $e->getTrace(); - exit; - } -} -if ( $ret != null) { - echo '
'; - echo HtmlInput::hidden('p_action','central'); - echo dossier::hidden(); - echo $ret; - echo HtmlInput::submit('central','Centralise'); - echo '
'; -} else { - echo '

Aucune période à centraliser

'; -} - -echo "
"; -html_page_stop(); -?> diff --git a/include/central_inc.php b/include/central_inc.php deleted file mode 100644 index db954d7bc..000000000 --- a/include/central_inc.php +++ /dev/null @@ -1,158 +0,0 @@ -start(); - $Res=$p_cn->exec_sql($sql); - $Res=$p_cn->exec_sql("update jrnx set j_centralized='t' where j_tech_per=".$p_periode); - - // Set correctly the number of operation id (jr_opid) for each journal - // get the existing jrn_def_id - //-- - $Res = $p_cn->exec_sql("select jrn_def_id from jrn_def"); - $MaxJrn=Database::num_row($Res); - // for each jrn_def_id - for ( $i=0; $i < $MaxJrn;$i++) { - $row=Database::fetch_array($Res,$i); - // get the op related to that jrn_def_id - $sql=sprintf("select jr_id from jrn - where - jr_tech_per=%d - and jr_def_id = %d - order by jr_date,jr_grpt_id desc", - $p_periode, - $row['jrn_def_id'] - ); - - $Res2=$p_cn->exec_sql($sql); - $MaxLine=Database::num_row($Res2); - $jrn_def_id=$row['jrn_def_id']; - /* if seq doesn't exist create it */ - if ( $p_cn->exist_sequence('s_jrn_'.$jrn_def_id) == false ) { - $p_cn->create_sequence('s_jrn_'.$jrn_def_id); - } - - for ($e=0;$e < $MaxLine;$e++) { - // each line is updated with a sequence - $line=Database::fetch_array($Res2,$e); - $jr_id=$line['jr_id']; - $sql=sprintf ("update jrn set - jr_opid = (select nextval('s_jrn_%d')) - where jr_id =%d", - $jrn_def_id, - $jr_id); - $Ret=$p_cn->exec_sql($sql); - - } - } - // Put jr_c_opid in centralized - // for each jrn_def_id - // get the op related to that jrn_def_id - $sql=sprintf("select jr_id from jrn - where - jr_tech_per=%d - order by jr_date,jr_grpt_id desc", - $p_periode - ); - - $Res2=$p_cn->exec_sql($sql); - $MaxLine=Database::num_row($Res2); - for ($e=0;$e < $MaxLine;$e++) { - // each line is updated with a sequence - $line=Database::fetch_array($Res2,$e); - $jr_id=$line['jr_id']; - $sql=sprintf ("update jrn set - jr_c_opid = (select nextval('s_central')) - where jr_id =%d", - $jr_id); - $Ret=$p_cn->exec_sql($sql); - } - // Set the order of the jrn - $Res=$p_cn->exec_sql("select c_id from centralized - inner join jrn on c_grp = jr_grpt_id - order by jr_c_opid, c_debit desc"); - for ( $e=0;$e < Database::num_row($Res);$e++) { - $row=Database::fetch_array($Res,$e); - $sql=sprintf ("update centralized set - c_order = (select nextval('s_central_order')) - where c_id = %d",$row['c_id']); - $Res2=$p_cn->exec_sql($sql); - - } - $p_cn->exec_sql("update parm_periode set p_central=true where p_id=$p_periode"); - } - catch(Exception $e) - { - rollback($p_cn); - return ERROR; - } - - - - - $p_cn->commit(); - return NOERROR; -} - -?> diff --git a/include/class_acc_balance.php b/include/class_acc_balance.php index 3a71ceb1a..412188395 100644 --- a/include/class_acc_balance.php +++ b/include/class_acc_balance.php @@ -28,7 +28,6 @@ require_once('class_acc_account.php'); class Acc_Balance { var $db; /*! < database connection */ - var $central; /*! < from centralized ledger if equal to Y */ var $row; /*! < row for ledger*/ var $jrn; /*!< jrn_def.jr_id or -1 for all of them */ @@ -36,10 +35,9 @@ class Acc_Balance { var $to_poste; /*!< to_poste filter on the post*/ function Acc_Balance($p_cn) { $this->db=$p_cn; - $this->central='N'; - $this->jrn=-1; - $from_poste=""; - $to_poste=""; + $this->jrn=-1; + $from_poste=""; + $to_poste=""; } @@ -62,11 +60,10 @@ class Acc_Balance { // filter on requested periode $per_sql=sql_filter_per($this->db,$p_from_periode,$p_to_periode,'p_id','j_tech_per'); - // if centralized - $cent=""; $and=""; $jrn=""; - $from_poste="";$to_poste=""; - if ( $this->central=='Y' ) { $cent="j_centralized = true";$and=" and "; } + $and=""; $jrn=""; + $from_poste="";$to_poste=""; + if ($this->jrn!= -1){ $jrn=" $and j_jrn_def=".$this->jrn;$and=" and ";} if ( strlen(trim($this->from_poste)) != 0 && $this->from_poste!=-1 ) { $from_poste=" $and j_poste::text >= '".$this->from_poste."'"; $and=" and "; @@ -83,7 +80,7 @@ class Acc_Balance { from jrnx join tmp_pcmn on j_poste=pcm_val left join parm_periode on j_tech_per = p_id where - $cent $jrn $from_poste $to_poste + $jrn $from_poste $to_poste $and $per_sql ) as m group by j_poste order by j_poste::text"; $cn=clone $this->db; diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index c0c2f6837..4235bafb5 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -125,13 +125,12 @@ class Acc_Ledger { * * \param p_from from periode * \param p_to to periode - * \param $p_cent (on or off) * \param p_limit starting line * \param p_offset number of lines * \return Array with the asked data * */ - function get_row($p_from,$p_to,$cent='off',$p_limit=-1,$p_offset=-1) { + function get_row($p_from,$p_to,$p_limit=-1,$p_offset=-1) { $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per'); @@ -141,10 +140,7 @@ class Acc_Ledger { $this->get_type(); // Grand livre == 0 if ( $this->id != 0 ) { - - if ( $cent=='off' ) { - // Journaux non centralises - $Res=$this->db->exec_sql("select j_id,j_id as int_j_id,to_char(j_date,'DD.MM.YYYY') as j_date, + $Res=$this->db->exec_sql("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, @@ -159,40 +155,8 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj " where j_jrn_def=".$this->id. " and ".$periode." order by j_date::date asc,jr_internal,j_debit desc ". $cond_limite); - }else { - // Journaux centralises - // echo'class_acc_ledger.php',__LINE__,"journaux centralise"; - $Sql="select jr_opid as j_id, - c_order as int_j_id, - to_char (c_date,'DD.MM.YYYY') as j_date , - c_internal as jr_internal, - case c_debit when 't' then c_montant::text else ' ' end as deb_montant, - case c_debit when 'f' then c_montant::text else ' ' end as cred_montant, - c_debit as j_debit, - c_poste as poste, - coalesce(j_text,pcm_lib) as description, - j_qcode, -jr_comment||' ('||c_internal||')'||case when jr_pj_number is not null and jr_pj_number !='' then 'pj:'||coalesce(jr_pj_number,'-') else '' end as jr_comment, - jr_montant, - c_grp as grp, - c_comment as comment, - c_rapt as oc, - c_periode as periode - from - - centralized left join jrnx on j_id=c_j_id - left join tmp_pcmn on pcm_val=c_poste - left join jrn on jr_grpt_id=c_grp - where ". - " c_jrn_def=".$this->id." and ". - $periode." order by c_order "; - $Res=$this->db->exec_sql($Sql.$cond_limite); - - } + } else { - // Grand Livre - if ( $cent == 'off') { - // Non centralise $Res=$this->db->exec_sql("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, @@ -207,33 +171,6 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj " ".$periode." order by j_date::date,j_grpt,j_debit desc ". $cond_limite); - } else { - // Centralise - $Sql="select jr_c_opid as j_id, - c_order as int_j_id, - c_j_id, - to_char (c_date,'DD.MM.YYYY') as j_date , - c_internal as jr_internal, - case c_debit when 't' then c_montant::text else ' ' end as deb_montant, - case c_debit when 'f' then c_montant::text else ' ' end as cred_montant, - c_debit as j_debit, - c_poste as poste, - coalesce(j_text,pcm_lib) as description, -jr_comment||' ('||c_internal||')'||case when jr_pj_number is not null and jr_pj_number !='' then 'pj:'||coalesce(jr_pj_number,'-') else '' end as jr_comment, - jr_montant, - c_grp as grp, - c_comment||' ('||c_internal||' '||jr_opid||')'||'pj:'||coalesce(jr_pj_number,'-') as comment, - c_rapt as oc, - j_qcode, - c_periode as periode - from centralized left join jrn on ". - "jr_grpt_id=c_grp left join tmp_pcmn ". - " on (pcm_val=c_poste) ". - " join jrnx on (j_id=c_j_id)". - " where ". - $periode." order by c_order "; - $Res=$this->db->exec_sql($Sql.$cond_limite); - } // Grand Livre } @@ -330,22 +267,17 @@ jr_comment||' ('||c_internal||')'||case when jr_pj_number is not null and jr_pj_ * * \param from periode * \param to periode - * \param centralized (on or off) * \param p_limit starting line * \param p_offset number of lines * \param trunc if data must be truncated (pdf export) * * \return an Array with the asked data */ - function get_rowSimple($p_from,$p_to,$cent='off',$trunc=0,$p_limit=-1,$p_offset=-1) + function get_rowSimple($p_from,$p_to,$trunc=0,$p_limit=-1,$p_offset=-1) { // Grand-livre : id= 0 //--- $jrn=($this->id == 0 )?"":"and jrn_def_id = ".$this->id; - // Non Centralise si cent=off - //-- - if ($cent=='off') - {// Non centralise $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per'); @@ -365,46 +297,15 @@ jr_comment||' ('||c_internal||')'||case when jr_pj_number is not null and jr_pj_ jrn.jr_tech_per FROM jrn join jrn_def on (jrn_def_id=jr_def_id) WHERE $periode $jrn order by jr_date $cond_limite"; - } - else - { - $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per'); - - $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; - //Centralise - //--- - $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, - substr(jrn.jr_comment,1,30)|| case when jr_pj_number is not null and jr_pj_number !='' then 'pj:'||coalesce(jr_pj_number,'-') else '' end 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, - jrn.jr_tech_per - FROM jrn join jrn_def on (jrn_def_id=jr_def_id) - where - $periode $jrn and - jr_opid is not null - order by num $cond_limite"; - }// end else $cent=='off' - //load all data into an array - //--- - - $Res=$this->db->exec_sql($sql); - $Max=Database::num_row($Res); - if ( $Max == 0 ) - { - return null; - } - $type=$this->get_type(); - // for type ACH and Ven we take more info + $Res=$this->db->exec_sql($sql); + $Max=Database::num_row($Res); + if ( $Max == 0 ) + { + return null; + } + $type=$this->get_type(); + // for type ACH and Ven we take more info if ( $type == 'ACH' || $type == 'VEN') { $a_ParmCode=$this->db->get_array('select p_code,p_value from parm_code'); @@ -472,7 +373,6 @@ jr_comment||' ('||c_internal||')'||case when jr_pj_number is not null and jr_pj_ $gDossier=dossier::id(); $amount_paid=0.0; $amount_unpaid=0.0; - include_once("central_inc.php"); $limit=($_SESSION['g_pagesize']!=-1)?" LIMIT ".$_SESSION['g_pagesize']:""; $offset=($_SESSION['g_pagesize']!=-1)?" OFFSET ".Database::escape_string($offset):""; $order=" order by jr_date_order asc,jr_internal asc"; @@ -997,28 +897,17 @@ jr_comment||' ('||c_internal||')'||case when jr_pj_number is not null and jr_pj_ /*!\brief get the saldo of a ledger for a specific period * \param $p_from start period * \param $p_to end period - * \param $p_cent 1 for a centralized period otherwise 0 */ - function get_solde($p_from,$p_to,$p_cent) { + function get_solde($p_from,$p_to) { $ledger=""; - if ( $this->id != 0 && $p_cent=='off') { + if ( $this->id != 0 ) { $ledger=" and j_jrn_def = ".$this->id; } - if ( $this->id != 0 && $p_cent=='on') { - $ledger=" and c_jrn_def = ".$this->id; - } + $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','j_tech_per'); + $sql='select j_montant as montant,j_debit as deb from jrnx where ' + .$periode.$ledger; - // we ask for a specific ledger - if ( $p_cent == 'off') { - $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','j_tech_per'); - $sql='select j_montant as montant,j_debit as deb from jrnx where ' - .$periode.$ledger; - }else { - $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','c_periode'); - $sql='select c_montant as montant,c_debit as deb from centralized where ' - .$periode.$ledger; - } $ret=$this->db->exec_sql($sql); $array=Database::fetch_all($ret); $deb=0.0; @@ -2310,15 +2199,13 @@ function get_last_date() } } /** - *@brief retrieve operation from centralized or jrn + *@brief retrieve operation from jrn *@param $p_from periode (id) *@param $p_to periode (id) - *@param $p_cent off or on *@return an array */ - function get_operation($p_from,$p_to,$cent) { + function get_operation($p_from,$p_to) { $jrn=($this->id==0)?'':' and jr_def_id = '.$this->id; - if ( $cent == 'off') { $sql="select jr_id as id ,jr_internal as internal, ". "jr_pj_number as pj,jr_grpt_id,". " to_char(jr_date,'DDMMYY') as date_fmt, ". @@ -2326,17 +2213,8 @@ function get_last_date() " jr_grpt_id". " from jrn where jr_tech_per >= $1 ". ' and jr_tech_per <=$2 '.$jrn.' order by jr_date,substring(jr_pj_number,\'\\\d+$\')::numeric asc'; - } else { - $sql="select jr_c_opid as id ,jr_internal as internal, ". - "jr_pj_number as pj,jr_grpt_id,". - " to_char(jr_date,'DDMMYY') as date_fmt, ". - " jr_comment as comment, jr_montant as montant ,". - " jr_grpt_id". - " from jrn where jr_grpt_id in ( select c_grp from centralized) and jr_tech_per >= $1 ". - " and jr_tech_per <=$2 $jrn order by jr_date,substring(jr_pj_number,'\\\d+$')::numeric"; - } - $ret=$this->db->get_array($sql,array($p_from,$p_to)); - return $ret; + $ret=$this->db->get_array($sql,array($p_from,$p_to)); + return $ret; } /** *@brief return the used VAT code with a rate > 0 diff --git a/include/impress_inc.php b/include/impress_inc.php index 591845883..b2ff470a8 100644 --- a/include/impress_inc.php +++ b/include/impress_inc.php @@ -25,177 +25,6 @@ */ require_once('class_periode.php'); -/*! - * \brief - * \param $p_cn database connection - * \param $p_jr_id jrn.jr_id not centralized - * or jr_op_id normal ledger centralized or jr_c_op_id if GL and centralized - * \param $p_jrn_id id of the ledger (0 for GL) - * \param $p_exercice - * \param $p_which LAST or FIRST - * \param $p_type CENT for centralized otherwise empty - * - * - * \return array sum(HTVA) sum(TVAC) sum (each TVA) - */ -function get_rappel_simple ($p_cn,$p_jrn_id,$p_jrn_type,$p_from,&$arap) -{ - if ( $p_jrn_type !='VEN' && $p_jrn_type != "ACH") - { - echo "ERREUR Journal invalide $p_jrn_type __FILE__ __LINE__"; - exit; - } - // find the last operation of the previous periode - $min=$p_cn->get_value("select max (c_id) from centralized where c_jrn_def=$p_jrn_id ". - " and c_date < (select p_start from parm_periode where p_id = $p_from)"); - if ($min == "" ) return 0; - // Find Exercice - $periode=new Periode($p_cn,$p_from); - $Exercice=$periode->get_exercice(); - - $a_Tva=$p_cn->get_array("select tva_id,tva_label,tva_poste from tva_rate where tva_rate != 0.0000 order by tva_id"); - - // Compute VAT - foreach ($a_Tva as $line_tva) - { - list ($deb,$cred)=explode(',',$line_tva['tva_poste']); - if ( $p_jrn_type == 'ACH' ) - $ctva=$deb; - else - $ctva=$cred; - $sum_deb=$p_cn->get_value("select sum(j_montant) from (select distinct c_internal,j_montant ". - " from jrnx join centralized on (j_grpt=c_grp) ". - " where c_id < $min and j_poste = '$ctva' and j_debit='t' and ". - " c_jrn_def=$p_jrn_id and j_tech_per in ". - " (select p_id from parm_periode where p_exercice='$Exercice') ) as w"); - - $sum_cred=$p_cn->get_value("select sum(j_montant) from (select distinct c_internal,j_montant ". - " from jrnx join centralized on (j_grpt=c_grp) ". - " where c_id < $min and j_poste = '$ctva' and j_debit='f' and ". - " c_jrn_def=$p_jrn_id and j_tech_per in ". - " (select p_id from parm_periode where p_exercice='$Exercice') ) as w"); - - - - $ix=$line_tva['tva_label']; - $arap[$ix]=($p_jrn_type=='ACH')?$sum_deb-$sum_cred:$sum_cred-$sum_deb; - } - // Previous period - $previous=$p_cn->get_value("select max(p_id) from parm_periode where ". - "p_end < (select p_end from parm_periode where p_id=$p_from) ". - " and p_start <= (select p_start from parm_periode where p_id=$p_from)"); - - $j=new Acc_Ledger($p_cn,$p_jrn_id); - $a=$j->get_rowSimple($previous,$previous,$cent='on'); - $total_tvac=0.0; - $total_htva=0.0; - foreach ($a as $line) { - $total_tvac+=$line['TVAC']; - $total_htva+=$line['HTVA']; - } - return array($total_tvac,$total_htva); -} -/*! - * \brief Get the amount on each page - * - * \param $p_cn - * \param $p_jrnx_id jrnx.j_id - * \param $p_jrn_id jr_def_id - * \param $which LAST or FIRST - * \param $p_type valeur JRN GL-CENTRAL GL-NOCENTRAL - * \return array sum (deb) sum(cred) - * - */ -function get_rappel($p_cn,$p_jrnx_id,$p_jrn_id,$p_exercice,$which,$p_type,$p_central) -{ - if ( $which == LAST) - $cmp="<="; - else - $cmp="<"; - - if ( $p_type == 1 ) { - // Vue filtree => Journaux - if ( $p_central == 0 ) { // Vue non centralisée - return array(0,0); - } // p_central == 0 - - // Vue filtree => Journaux & Jrn centralisé - if ( $p_central == 1 ) { - $c_line=$p_cn->count_sql("select * from centralized left join parm_periode on c_periode=p_id ". - " where c_jrn_def=$p_jrn_id and p_exercice='".$p_exercice."'". - " and c_order $cmp $p_jrnx_id "); - - if ($c_line == 0 ) { return array (0,0); } - $sql="select sum(c_montant) as tot_amount ". - " from centralized ". - " left join parm_periode on c_periode=p_id ". - " inner join jrn on jr_grpt_id=c_grp ". - " where c_jrn_def=$p_jrn_id and ". - " p_exercice='".$p_exercice."'". - " and c_order $cmp $p_jrnx_id " ; - $Res=$p_cn->exec_sql($sql." and c_debit='t' "); - if ( Database::num_row($Res) == 0 ) - $deb=0; - else { - $line=Database::fetch_array($Res,0); - $deb=$line['tot_amount']; - } - - $Res=$p_cn->exec_sql($sql." and c_debit='f' "); - if ( Database::num_row($Res) == 0 ) - $cred=0; - else { - - $line=Database::fetch_array($Res,0); - $cred=$line['tot_amount']; - } - $a=array($deb,$cred); - return $a; - - } - } // Type = jrn - if ($p_type==0 ) { // Si Grand Livre, prendre donnée centralisée{ - if ( $p_central == 1) { - $c_line=$p_cn->count_sql("select * from centralized left join parm_periode on c_periode=p_id ". - "where p_exercice='".$p_exercice."'". - " and c_id $cmp $p_jrnx_id "); - - if ($c_line == 0 ) { return array (0,0); } - $sql="select sum(c_montant) as tot_amount ". - " from centralized ". - " left join parm_periode on c_periode=p_id ". - " where ". - " p_exercice='".$p_exercice."'". - " and c_order $cmp $p_jrnx_id " ; - $Res=$p_cn->exec_sql($sql." and c_debit='t' "); - if ( Database::num_row($Res) == 0 ) - $deb=0; - else { - $line=Database::fetch_array($Res,0); - $deb=$line['tot_amount']; - } - - $Res=$p_cn->exec_sql($sql." and c_debit='f' "); - if ( Database::num_row($Res) == 0 ) - $cred=0; - else { - - $line=Database::fetch_array($Res,0); - $cred=$line['tot_amount']; - } - $a=array($deb,$cred); - return $a; - } // central == 1 - else // Donnée non centralisée => pas de rappel - { - if ($p_central== 0) { // Si Grand Livre, prendre donnée non centralisée{ - return array(0,0); - } - }//else - } // if type==0 - -} - /*! \brief Purpose Parse a formula * * \param $p_cn connexion diff --git a/include/impress_jrn.inc.php b/include/impress_jrn.inc.php index 9b3b22385..bae2c5a81 100644 --- a/include/impress_jrn.inc.php +++ b/include/impress_jrn.inc.php @@ -96,10 +96,6 @@ $periode_end=$cn->make_array("select p_id,to_char(p_end,'DD-MM-YYYY') from parm_ $w->selected=(isset($_GET['to_periode']))?$_GET['to_periode']:''; print td('Jusque ').$w->input('to_periode',$periode_end); print ""; -$centralise=new ICheckBox(); -print td("Depuis les journaux centralisés"); -$centralise->selected=(isset($_GET['cent']))?true:false; -print td($centralise->input('cent')); $a=array( array('value'=>0,'label'=>'Detaillé'), array('value'=>1,'label'=>'Simple') @@ -114,7 +110,7 @@ echo ''; print HtmlInput::submit('bt_html','Visualisation'); echo ''; - echo ' Attention : en-cas d\'impression de journaux centralisés, dans le PDF, les montants débit et crédit calculés par page sont la somme des montants de la page uniquement. Si une opération est sur 2 pages ces montants diffèreront évidemment. Ces montants doivent être égaux sur la dernière page. Pour vérifier la balance, utilisez la balance des comptes ou Avancé->Vérification'; + //----------------------------------------------------- @@ -124,7 +120,6 @@ echo ''; //----------------------------------------------------- if ( isset( $_REQUEST['bt_html'] ) ) { require_once("class_acc_ledger.php"); - $p_cent=( isset ( $_GET ['cent']) )?'on':'off'; $d=var_export($_GET,true); $Jrn=new Acc_Ledger($cn,$_GET['jrn_id']); @@ -132,15 +127,14 @@ require_once("class_acc_ledger.php"); if ( $_GET['p_simple']==0 ) { $Row=$Jrn->get_row( $_GET['from_periode'], - $_GET['to_periode'], - $p_cent); + $_GET['to_periode'] + ); } else { $Row=$Jrn->get_rowSimple($_GET['from_periode'], - $_GET['to_periode'], - $p_cent); - // var_dump($Row); + $_GET['to_periode'] + ); } $rep=""; $hid=new IHidden(); @@ -155,7 +149,6 @@ require_once("class_acc_ledger.php"); HtmlInput::submit('bt_pdf',"Export PDF"). $hid->input("type","jrn"). $hid->input("p_action","impress"). - $hid->input("central",$p_cent). $hid->input("jrn_id",$Jrn->id). $hid->input("from_periode",$_GET['from_periode']). $hid->input("to_periode",$_GET['to_periode']); @@ -166,7 +159,6 @@ require_once("class_acc_ledger.php"); HtmlInput::submit('bt_csv',"Export CSV"). $hid->input("type","jrn"). $hid->input("p_action","impress"). - $hid->input("central",$p_cent). $hid->input("jrn_id",$Jrn->id). $hid->input("from_periode",$_GET['from_periode']). $hid->input("to_periode",$_GET['to_periode']); @@ -187,10 +179,6 @@ require_once("class_acc_ledger.php"); //--- foreach ( $Jrn->row as $op ) { echo ""; - // centralized - if ( $p_cent == 'on') { - echo "".$op['j_id'].""; - } echo "".$op['internal']."". "".$op['j_date']."". "".$op['poste']."". @@ -257,8 +245,8 @@ require_once("class_acc_ledger.php"); // show the saldo $solde=$Jrn->get_solde( $_GET['from_periode'], - $_GET['to_periode'], - $p_cent); + $_GET['to_periode'] + ); echo "solde débiteur:".$solde[0]."
"; echo "solde créditeur:".$solde[1]; diff --git a/include/verif_bilan.inc.php b/include/verif_bilan.inc.php index faeb8b72a..49b3c9182 100644 --- a/include/verif_bilan.inc.php +++ b/include/verif_bilan.inc.php @@ -31,18 +31,18 @@ $User=new User($cn); echo '
'; $User->db=$cn; - $sql_year=" and c_periode in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')"; + $sql_year=" and j_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')"; echo '
    '; - $deb=$cn->get_value("select sum (c_montant) from centralized where c_debit='t' $sql_year "); - $cred=$cn->get_value("select sum (c_montant) from centralized where c_debit='f' $sql_year "); + $deb=$cn->get_value("select sum (j_montant) from jrnx where j_debit='t' $sql_year "); + $cred=$cn->get_value("select sum (j_montant) from jrnx where j_debit='f' $sql_year "); if ( $cred == $deb ) { $result =' OK ';} else { $result =' NON OK ';} - printf ('
  1. Solde Grand Livre centralisé: debit %f credit %f %s
  2. ',$deb,$cred,$result); + printf ('
  3. Solde Grand Livre : debit %f credit %f %s
  4. ',$deb,$cred,$result); $sql="select jrn_def_id,jrn_def_name from jrn_def"; $res=$cn->exec_sql($sql); @@ -50,15 +50,15 @@ $User=new User($cn); foreach ($jrn as $l) { $id=$l['jrn_def_id']; $name=$l['jrn_def_name']; - $deb=$cn->get_value("select sum (c_montant) from centralized where c_debit='t' and c_jrn_def=$id $sql_year "); - $cred=$cn->get_value("select sum (c_montant) from centralized where c_debit='f' and c_jrn_def=$id $sql_year "); + $deb=$cn->get_value("select sum (j_montant) from jrnx where j_debit='t' and j_jrn_def=$id $sql_year "); + $cred=$cn->get_value("select sum (j_montant) from jrnx where j_debit='f' and j_jrn_def=$id $sql_year "); if ( $cred == $deb ) { $result =' OK ';} else { $result =' NON OK ';} - printf ('
  5. Journal %s Solde centralisé: debit %f credit %f %s
  6. ',$name,$deb,$cred,$result); + printf ('
  7. Journal %s Solde : debit %f credit %f %s
  8. ',$name,$deb,$cred,$result); } echo '
';