task #55 : link from customer / supplier to all operation + detail

This commit is contained in:
Dany De Bontridder 2008-03-25 13:22:16 +00:00
parent 56b4a6b47e
commit 84794582b7
10 changed files with 236 additions and 67 deletions

View file

@ -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");
}

View file

@ -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).";".

View file

@ -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 "</form></TD>";
@ -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 "</form></TD>";

View file

@ -212,7 +212,7 @@ function get_internal() {
$r.=$a;
$csv.='"'.$a.'"';
$csv.="\n\r";
$csv.="\r\n";
$r.='</td>';
$r.='</tr>';

View file

@ -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
<th>Total d&eacute;bit</th>
<th>Total cr&eacute;dit</th>
<th>Solde</th>
<th colspan="4">Action </th>
<th colspan="5">Action </th>
</TR>';
echo_debug(__FILE__,__LINE__,$step_client);
if ( sizeof ($step_client ) == 0 )
@ -269,6 +276,10 @@ where
$r.=sprintf('<td><A class="mtitle" HREF="%s?liste&p_action=bank&sa=list&qcode=%s&%s&url=%s&p_periode=-1" title="Financier">Financier</A></td>',
$script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$url);
$r.=sprintf('<td><A class="mtitle" HREF="%s?p_action=impress&type=poste&f_id=%s&%s&from_periode=%s&to_periode=%s&oper_detail=on&bt_html=Visualisation"
title="Operation">Operation</A></td>',
$script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$max->p_id,$min->p_id);
$r.='</TD>';
$r.="</TR>";

View file

@ -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 '<h2 class="info">'.$this->id." ".$name.'</h2>';
echo "<TABLE class=\"result\" width=\"100%\">";
echo "<TR>".
"<TH> Code interne </TH>".
"<TH> Date</TH>".
"<TH> Description </TH>".
"<TH> Débit </TH>".
"<TH> Crédit </TH>".
"</TR>";
foreach ( $this->row as $op ) {
echo "<TR style=\"text-align:center;background-color:lightgrey\">".
"<td >".$op['jr_internal']."</td>".
"<td >".$op['j_date']."</td>".
"<td >".$op['description']."</td>".
"<td >"."</td>".
"<td >"."</td>".
"</TR>";
$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 "<TR>".
"<TD>$solde_type".
"<TD>$diff</TD>".
"<TD></TD>".
"<TD>$tot_deb</TD>".
"<TD>$tot_cred</TD>".
"</TR>";
echo "</table>";
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 "</form></TD>";
echo '<TD><form method="POST" ACTION="quick_code_csv.php">'.
@ -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 "</form></TD>";
echo "</table>";

View file

@ -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);

View file

@ -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{
<th>Total d&eacute;bit</th>
<th>Total cr&eacute;dit</th>
<th>Solde</th>
<th colspan="4">Action </th>
<th colspan="5">Action </th>
</TR>';
if ( sizeof ($step_supplier ) == 0 )
return $r;
@ -151,6 +156,9 @@ class Supplier extends fiche{
$r.=sprintf('<td><A class="mtitle" HREF="%s?liste&p_action=bank&sa=list&'.$str_dossier.'&qcode=%s&url=%s&p_periode=-1" title="Financier">Financier</A></td>',
$script,$supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$url);
$r.=sprintf('<td><A class="mtitle" HREF="%s?p_action=impress&type=poste&f_id=%s&%s&from_periode=%s&to_periode=%s&oper_detail=on&bt_html=Visualisation"
title="Operation">Operation</A></td>',
$script,$supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$max->p_id,$min->p_id);
$r.='</TD>';

View file

@ -37,7 +37,9 @@ include_once("postgres.php");
echo '<div class="u_content">';
echo JS_SEARCH_POSTE;
echo JS_SEARCH_CARD;
echo '<FORM ACTION="?p_action=impress&type=poste" METHOD="POST">';
echo '<FORM action="?" METHOD="GET">';
echo widget::hidden('p_action','impress');
echo widget::hidden('type','poste');
echo dossier::hidden();
echo '<TABLE><TR>';
$span=new widget("span");
@ -95,30 +97,30 @@ echo '</div>';
// 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 '<table "width=70%">';
echo '<tr><td class="mtitle" colspan="5"><h2 class="info">'. $_POST['poste_id'].' '.$Poste->label.'</h2></td></tr>';
echo '<tr><td class="mtitle" colspan="5"><h2 class="info">'. $_GET['poste_id'].' '.$Poste->label.'</h2></td></tr>';
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 '</table>';
@ -164,11 +166,20 @@ if ( isset( $_POST['bt_html'] ) ) {
// A QuickCode is given
if ( $go == 2)
{
echo '<div class="u_content">';
$fiche->HtmlTableHeader();
$fiche->HtmlTable($qcode);
$fiche->HtmlTableHeader();
echo "</div>";
if ( ! isset($_REQUEST['oper_detail']) ) {
echo '<div class="u_content">';
$fiche->HtmlTableHeader();
$fiche->HtmlTable();
$fiche->HtmlTableHeader();
echo "</div>";
} else {
// Detail //
echo '<div class="u_content">';
$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 '<tr><td class="mtitle" colspan="5"><h2 class="info">'. $poste_id['pcm_val'].' '.$Poste->label.'</h2></td></tr>';

View file

@ -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];