diff --git a/html/poste_csv.php b/html/poste_csv.php index 04db280df..fa5e9055d 100644 --- a/html/poste_csv.php +++ b/html/poste_csv.php @@ -38,16 +38,16 @@ $cn=DbConnect($gDossier); $User=new User($cn); $User->Check(); -if ( isset ( $_POST['poste_fille']) ) +if ( isset ( $_REQUEST['poste_fille']) ) { //choisit de voir tous les postes - $a_poste=get_array($cn,"select pcm_val from tmp_pcmn where pcm_val::text like '".$_POST["poste_id"]."%'"); + $a_poste=get_array($cn,"select pcm_val from tmp_pcmn where pcm_val::text like '".$_REQUEST["poste_id"]."%'"); } else { - $a_poste=get_array($cn,"select pcm_val from tmp_pcmn where pcm_val = '".$_POST['poste_id']."'"); + $a_poste=get_array($cn,"select pcm_val from tmp_pcmn where pcm_val = '".$_REQUEST['poste_id']."'"); } -if ( ! isset ($_POST['oper_detail'])) { +if ( ! isset ($_REQUEST['oper_detail'])) { if ( count($a_poste) == 0 ) exit; @@ -55,8 +55,8 @@ if ( ! isset ($_POST['oper_detail'])) { { $Poste=new Acc_Account_Ledger($cn,$pos['pcm_val']); $Poste->get_name(); - list($array,$tot_deb,$tot_cred)=$Poste->get_row( $_POST['from_periode'], - $_POST['to_periode'] + list($array,$tot_deb,$tot_cred)=$Poste->get_row( $_REQUEST['from_periode'], + $_REQUEST['to_periode'] ); if ( count($Poste->row ) == 0 ) continue; @@ -98,8 +98,8 @@ if ( ! isset ($_POST['oper_detail'])) { { $Poste=new Acc_Account_Ledger($cn,$pos['pcm_val']); $Poste->get_name(); - list($array,$tot_deb,$tot_cred)=$Poste->get_row( $_POST['from_periode'], - $_POST['to_periode'] + list($array,$tot_deb,$tot_cred)=$Poste->get_row( $_REQUEST['from_periode'], + $_REQUEST['to_periode'] ); if ( count($Poste->row ) == 0 ) continue; @@ -127,7 +127,7 @@ if ( ! isset ($_POST['oper_detail'])) { $a['description'], $r['j_montant'], $r['debit']); - printf("\n"); + printf("\r\n"); } diff --git a/html/quick_code_csv.php b/html/quick_code_csv.php index 304d47fb3..a05f3dd2e 100644 --- a/html/quick_code_csv.php +++ b/html/quick_code_csv.php @@ -48,6 +48,9 @@ if ( count($Fiche->row ) == 0 ) echo "Aucune donnée"; return; } + + +if ( ! isset ($_REQUEST['oper_detail'])) { echo '"Qcode";'. "\"Code interne\";". "\"Date\";". @@ -55,21 +58,48 @@ echo '"Qcode";'. "\"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"); + + } +}else { + echo '"Poste";"Qcode";"internal"'; + echo '"Date";'. + "\"Description\";". + "\"Montant\";". + "\"D/C\""; + + printf("\r\n"); + + foreach ( $Fiche->row as $op ) { + $acc=new Acc_Operation($cn); + $acc->jr_id=$op['jr_id']; + $result= $acc->get_jrnx_detail(); + foreach ( $result as $r) { + printf('"%s";"%s";"%s";"%s";"%s";%12.2f;"%s"', + $r['j_poste'], + $r['j_qcode'], + $r['jr_internal'], + $r['j_date'], + $a['description'], + $r['j_montant'], + $r['debit']); + printf("\r\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); + $diff=abs($tot_deb-$tot_cred); printf( '"'."$solde_type".'"'.";". sprintf("%8.4f",$diff).";". diff --git a/include/class_acc_account_ledger.php b/include/class_acc_account_ledger.php index a7d43c2a4..7b9c8d3e7 100644 --- a/include/class_acc_account_ledger.php +++ b/include/class_acc_account_ledger.php @@ -221,9 +221,8 @@ function get_solde_detail($p_cond="") { function HtmlTable() { $this->get_name(); - - list($array,$tot_deb,$tot_cred)=$this->get_row( $_POST['from_periode'], - $_POST['to_periode'] + list($array,$tot_deb,$tot_cred)=$this->get_row( $_REQUEST['from_periode'], + $_REQUEST['to_periode'] ); if ( count($this->row ) == 0 ) @@ -289,12 +288,12 @@ function get_solde_detail($p_cond="") { widget::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'])) + $hid->IOValue("poste_id",$_REQUEST['poste_id']). + $hid->IOValue("from_periode",$_REQUEST['from_periode']). + $hid->IOValue("to_periode",$_REQUEST['to_periode']); + if (isset($_REQUEST['poste_fille'])) echo $hid->IOValue('poste_fille','on'); - if (isset($_POST['oper_detail'])) + if (isset($_REQUEST['oper_detail'])) echo $hid->IOValue('oper_detail','on'); echo ""; @@ -304,12 +303,12 @@ function get_solde_detail($p_cond="") { widget::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'])) + $hid->IOValue("poste_id",$_REQUEST['poste_id']). + $hid->IOValue("from_periode",$_REQUEST['from_periode']). + $hid->IOValue("to_periode",$_REQUEST['to_periode']); + if (isset($_REQUEST['poste_fille'])) echo $hid->IOValue('poste_fille','on'); - if (isset($_POST['oper_detail'])) + if (isset($_REQUEST['oper_detail'])) echo $hid->IOValue('oper_detail','on'); echo ""; diff --git a/include/class_acc_operation.php b/include/class_acc_operation.php index 878e13770..94fb192c5 100644 --- a/include/class_acc_operation.php +++ b/include/class_acc_operation.php @@ -212,7 +212,7 @@ function get_internal() { $r.=$a; $csv.='"'.$a.'"'; - $csv.="\n\r"; + $csv.="\r\n"; $r.=''; $r.=''; diff --git a/include/class_customer.php b/include/class_customer.php index 9f23b0653..a35d3f831 100644 --- a/include/class_customer.php +++ b/include/class_customer.php @@ -22,7 +22,7 @@ require_once("constant.php"); require_once("postgres.php"); require_once("class_parm_code.php"); require_once("class_widget.php"); - +require_once('class_periode.php'); require_once('class_fiche.php'); require_once('class_acc_account_ledger.php'); require_once('user_common.php'); @@ -195,7 +195,7 @@ where */ function Summary($p_search) { - $str_dossier=dossier::get(); + $str_dossier=dossier::get(); $p_search=FormatString($p_search); $url=urlencode($_SERVER['REQUEST_URI']); $script=$_SERVER['PHP_SELF']; @@ -208,6 +208,13 @@ where $bar=jrn_navigation_bar($offset,$all_client,$_SESSION['g_pagesize'],$page); // set a filter ? $search=""; + + $user=new User($this->cn); + $exercice=$user->get_exercice(); + $tPeriode=new Periode($this->cn); + list($max,$min)=$tPeriode->get_limit($exercice); + + if ( trim($p_search) != "" ) { $search=" and f_id in @@ -229,7 +236,7 @@ where Total débit Total crédit Solde -Action +Action '; echo_debug(__FILE__,__LINE__,$step_client); if ( sizeof ($step_client ) == 0 ) @@ -269,6 +276,10 @@ where $r.=sprintf('Financier', $script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$url); + $r.=sprintf('Operation', + $script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$max->p_id,$min->p_id); + $r.=''; $r.=""; diff --git a/include/class_fiche.php b/include/class_fiche.php index 15e1e15f9..3b6b79853 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -860,7 +860,7 @@ class fiche { "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 ". + "j_debit, jr_internal,jr_id ". " 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. @@ -881,7 +881,65 @@ class fiche { $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 HtmlTableDetail($p_array=null) + { + if ( $p_array == null) + $p_array=$_REQUEST; + $name=$this->getName(); + + list($array,$tot_deb,$tot_cred)=$this->get_row( $p_array['from_periode'], + $p_array['to_periode'] + ); + + if ( count($this->row ) == 0 ) + return; + + $rep=""; + + echo '

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

'; + echo ""; + echo "". + "". + "". + "". + "". + "". + ""; + + foreach ( $this->row as $op ) { + echo "". + "". + "". + "". + "". + "". + ""; + $ac=new Acc_Operation($this->cn); + $ac->jr_id=$op['jr_id']; + echo $ac->display_jrnx_detail(1); + + } + $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']."".""."
$solde_type". + "$diff$tot_deb$tot_cred
"; + + return; + } /*! * \brief HtmlTable, display a HTML of a card for the asked period * \param none @@ -891,7 +949,7 @@ class fiche { function HtmlTable($p_array=null) { if ( $p_array == null) - $p_array=$_POST; + $p_array=$_REQUEST; $name=$this->getName(); @@ -946,7 +1004,7 @@ class fiche { function HtmlTableHeader($p_array=null) { if ( $p_array == null) - $p_array=$_POST; + $p_array=$_REQUEST; $submit=new widget(); $hid=new widget("hidden"); @@ -968,6 +1026,9 @@ class fiche { dossier::hidden(). $hid->IOValue("from_periode",$p_array['from_periode']). $hid->IOValue("to_periode",$p_array['to_periode']); + if (isset($p_array['oper_detail'])) + echo $hid->IOValue('oper_detail','on'); + echo ""; echo '
'. @@ -978,6 +1039,8 @@ class fiche { $hid->IOValue("f_id",$this->id). $hid->IOValue("from_periode",$p_array['from_periode']). $hid->IOValue("to_periode",$p_array['to_periode']); + if (isset($p_array['oper_detail'])) + echo $hid->IOValue('oper_detail','on'); echo "
"; echo ""; diff --git a/include/class_periode.php b/include/class_periode.php index 4aa2ae6d6..e782b942e 100644 --- a/include/class_periode.php +++ b/include/class_periode.php @@ -35,6 +35,8 @@ class Periode { var $p_id; /*!< pk of parm_periode */ var $status; /*!< status is CL for closed, OP for open and CE for centralized */ + var $p_start; /*!< start of the periode */ + var $p_end; /*!< end of the periode */ function __construct($p_cn) { $this->cn=$p_cn; } @@ -265,6 +267,39 @@ class Periode { } return 0; } + /*!\brief load data from database + */ + function load() { + $row=get_array($this->cn,"select p_start,p_end,p_exercice,p_closed,p_central from parm_periode where p_id=$1", + array($this->p_id)); + if ($row == null ) return; + + $this->p_start=$row['p_start']; + $this->p_end=$row['p_end']; + $this->p_exercice=$row['p_exercice']; + $this->p_closed=$row['p_closed']; + $this->p_central=$row['p_central']; + } + + /*!\brief return the max and the min periode of the exercice given + *in parameter + *\param $p_exercice is the exercice + *\return an array of Periode object + */ + function get_limit($p_exercice) { + + $max=getDbValue($this->cn,"select p_id from parm_periode where p_exercice=$1 order by p_start asc",array($p_exercice)); + $min=getDbValue($this->cn,"select p_id from parm_periode where p_exercice=$1 order by p_start desc",array($p_exercice)); + $rMax=new Periode($this->cn); + $rMax->p_id=$max; + $rMax->load(); + $rMin=new Periode($this->cn); + $rMin->p_id=$min; + $rMin->load(); + return array($rMax,$rMin); + } + + static function test_me() { $cn=DbConnect(dossier::id()); $obj=new Periode($cn); diff --git a/include/class_supplier.php b/include/class_supplier.php index 48013e164..ae44f4b7d 100644 --- a/include/class_supplier.php +++ b/include/class_supplier.php @@ -22,7 +22,7 @@ require_once("constant.php"); require_once("postgres.php"); require_once("class_parm_code.php"); require_once("class_widget.php"); - +require_once('class_periode.php'); require_once('class_fiche.php'); require_once('class_acc_account_ledger.php'); require_once('user_common.php'); @@ -92,6 +92,11 @@ class Supplier extends fiche{ $bar=jrn_navigation_bar($offset,$all_supplier,$_SESSION['g_pagesize'],$page); // set a filter ? $search=""; + $user=new User($this->cn); + $exercice=$user->get_exercice(); + $tPeriode=new Periode($this->cn); + list($max,$min)=$tPeriode->get_limit($exercice); + if ( trim($p_search) != "" ) { $search=" and f_id in @@ -113,7 +118,7 @@ class Supplier extends fiche{ Total débit Total crédit Solde -Action +Action '; if ( sizeof ($step_supplier ) == 0 ) return $r; @@ -151,6 +156,9 @@ class Supplier extends fiche{ $r.=sprintf('Financier', $script,$supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$url); + $r.=sprintf('Operation', + $script,$supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$max->p_id,$min->p_id); $r.=''; diff --git a/include/impress_poste.inc.php b/include/impress_poste.inc.php index 573258277..dc40441ac 100644 --- a/include/impress_poste.inc.php +++ b/include/impress_poste.inc.php @@ -37,7 +37,9 @@ include_once("postgres.php"); echo '
'; echo JS_SEARCH_POSTE; echo JS_SEARCH_CARD; -echo '
'; +echo ''; +echo widget::hidden('p_action','impress'); +echo widget::hidden('type','poste'); echo dossier::hidden(); echo ''; $span=new widget("span"); @@ -95,30 +97,30 @@ echo ''; // First time in html // after in pdf or cvs //----------------------------------------------------- -if ( isset( $_POST['bt_html'] ) ) { +if ( isset( $_REQUEST['bt_html'] ) ) { require_once("class_acc_account_ledger.php"); $go=0; // we ask a poste_id - if ( strlen(trim($_POST['poste_id'])) != 0 && isNumber($_POST['poste_id']) ) + if ( strlen(trim($_GET['poste_id'])) != 0 && isNumber($_GET['poste_id']) ) { - if ( isset ($_POST['poste_fille']) ) + if ( isset ($_GET['poste_fille']) ) { - $parent=$_POST['poste_id']; + $parent=$_GET['poste_id']; $a_poste=get_array($cn,"select pcm_val from tmp_pcmn where pcm_val::text like '$parent%' order by pcm_val::text"); $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 ) + elseif ( CountSql($cn,'select * from tmp_pcmn where pcm_val='.FormatString($_GET['poste_id'])) != 0 ) { - $Poste=new Acc_Account_Ledger($cn,$_POST['poste_id']);$go=1; + $Poste=new Acc_Account_Ledger($cn,$_GET['poste_id']);$go=1; } } - if ( strlen(trim($_POST['f_id'])) != 0 ) + if ( strlen(trim($_GET['f_id'])) != 0 ) { require_once("class_fiche.php"); // thanks the qcode we found the poste account $fiche=new fiche($cn); - $qcode=$fiche->get_by_qcode($_POST['f_id']); + $qcode=$fiche->get_by_qcode($_GET['f_id']); $p=$fiche->strAttribut(ATTR_DEF_ACCOUNT); if ( $p != "- ERROR -") { $go=2; @@ -138,11 +140,11 @@ if ( isset( $_POST['bt_html'] ) ) { // Detail //---------------------------------------------------------------------- Acc_Account_Ledger::HtmlTableHeader(); - $Poste->get_row( $_POST['from_periode'], $_POST['to_periode']); + $Poste->get_row( $_GET['from_periode'], $_GET['to_periode']); if ( empty($Poste->row)) exit(); $Poste->load(); echo '
'; - echo ''; + echo ''; foreach ($Poste->row as $a) { $detail=$a; @@ -151,7 +153,7 @@ if ( isset( $_POST['bt_html'] ) ) { $op=new Acc_Operation($cn); $op->jr_id=$a['jr_id']; - $op->poste=$_POST['poste_id']; + $op->poste=$_GET['poste_id']; echo $op->display_jrnx_detail(1); } echo '

'. $_POST['poste_id'].' '.$Poste->label.'

'. $_GET['poste_id'].' '.$Poste->label.'

'; @@ -164,11 +166,20 @@ if ( isset( $_POST['bt_html'] ) ) { // A QuickCode is given if ( $go == 2) { - echo '
'; - $fiche->HtmlTableHeader(); - $fiche->HtmlTable($qcode); - $fiche->HtmlTableHeader(); - echo "
"; + if ( ! isset($_REQUEST['oper_detail']) ) { + echo '
'; + $fiche->HtmlTableHeader(); + $fiche->HtmlTable(); + $fiche->HtmlTableHeader(); + echo "
"; + } else { + // Detail // + echo '
'; + $fiche->HtmlTableHeader(); + $fiche->HtmlTableDetail(); + $fiche->HtmlTableHeader(); + + } exit; } @@ -182,7 +193,7 @@ if ( isset( $_POST['bt_html'] ) ) { if ( ! isset ($_REQUEST['oper_detail'])) { - $Poste=new Acc_Account_Ledger($cn,$_POST['poste_id']); + $Poste=new Acc_Account_Ledger($cn,$_GET['poste_id']); echo Acc_Account_Ledger::HtmlTableHeader(); foreach ($a_poste as $poste_id ) @@ -202,7 +213,7 @@ if ( isset( $_POST['bt_html'] ) ) { { $Poste=new Acc_Account_Ledger ($cn,$poste_id['pcm_val']); $Poste->load(); - $Poste->get_row( $_POST['from_periode'], $_POST['to_periode']); + $Poste->get_row( $_GET['from_periode'], $_GET['to_periode']); if ( empty($Poste->row)) continue; echo '

'. $poste_id['pcm_val'].' '.$Poste->label.'

'; diff --git a/include/postgres.php b/include/postgres.php index 8e2c54e70..685732d66 100644 --- a/include/postgres.php +++ b/include/postgres.php @@ -410,10 +410,16 @@ function GetModeleId($p_cn,$p_modname) { * in a array * \param $p_cn database connection * \param $p_sql sql query + * \param $p_array if not null we use ExecSqlParam */ -function get_array($p_cn,$p_sql) { +function get_array($p_cn,$p_sql,$p_array=null) { echo_debug('postgres.php',__LINE__,"get_array"); - $r=ExecSql($p_cn,$p_sql); + if ( $p_array == null ) { + + $r=ExecSql($p_cn,$p_sql); + } else { + $r=ExecSqlParam($p_cn,$p_sql,$p_array); + } if ( ($Max= pg_NumRows($r)) == 0 ) return null; $array=pg_fetch_all($r); echo_debug('postgres.php',__LINE__,var_export($array,true)); @@ -475,12 +481,18 @@ function save_upload_document ($cn,$seq) { /*!\brief return the value of the sql, the sql will return only one value * with the value * \param $p_cn database connection - * \param $p_sql the sql stmt example :select s_value from document_state where s_id=2 + * \param $p_sql the sql stmt example :select s_value from + * document_state where s_id=2 + * \param $p_array if not null we use execSqlParam * \return only the first value */ -function getDbValue($p_cn,$sql) +function getDbValue($p_cn,$sql,$p_array=null) { - $ret=ExecSql($p_cn,$sql); + if ( $p_array == null ) + $ret=ExecSql($p_cn,$sql); + else + $ret=ExecSqlParam($p_cn,$sql,$p_array); + if ( pg_NumRows($ret) == 0 ) return ""; $r=pg_fetch_row($ret,0); return $r[0];