Change Name for class_jrn (new: class_acc_ledger) and operation (new:class_anc_operation) fix bug for direct writing

This commit is contained in:
sparkyx 2007-10-15 07:17:33 +00:00
parent 93cc7a5398
commit f7097c31fc
32 changed files with 785 additions and 66 deletions

View file

@ -29,7 +29,7 @@ include_once ("postgres.php");
require_once('class_dossier.php');
$gDossier=dossier::id();
include("class_jrn.php");
include("class_acc_ledger.php");
$cn=DbConnect($gDossier);

View file

@ -28,10 +28,10 @@
*/
require_once('constant.php');
require_once('postgres.php');
require_once('class_operation.php');
require_once('class_anc_operation.php');
$cn=DbConnect(dossier::id);
$op=new operation($cn);
$op=new Anc_Operation($cn);
$op->pa_id=$_GET['pa_id'];
$array=$op->get_list($_GET['from'],$_GET['to']);
$length=count($array);

View file

@ -4,8 +4,8 @@ header("Content-type: text/xml charset=\"ISO8859-1\"",true);
require_once ('postgres.php');
require_once ('debug.php');
require_once ('jrn.php');
require_once ('class_operation.php');
require_once ('class_anc_operation.php');
$cn=DbConnect($_SESSION['g_dossier']);
$op=new operation($cn);
$op=new Anc_Operation($cn);
$op->get_xml_jrn_detail();
?>

View file

@ -91,6 +91,7 @@ echo ShowItem(array(
array('?p_action=facture&'.$str_dossier,'Vente/Facture'),
array('?p_action=fournisseur&'.$str_dossier,'Fournisseur'),
array('?p_action=depense&'.$str_dossier,'Achat/Dépense'),
array('?p_action=quick_writing&'.$str_dossier,'Ecriture rapide'),
array('?p_action=impress&'.$str_dossier,'Impression'),
array('?p_action=stock&'.$str_dossier,'Stock'),
array('?p_action=bank&'.$str_dossier,'Banque'),
@ -167,6 +168,10 @@ if ( $p_action == 'bank')
{
require_once("bank.inc.php");
}
if ( $p_action=='quick_writing') {
require_once ('quick_writing.inc.php');
}
//-----------------------------------------------------
// Impression
if ( $p_action == 'impress')

View file

@ -63,6 +63,8 @@ if ( $action == 'fiche') {
if ( $action == 'stock') {
require_once('stock.inc.php');
}
if ( $action=='quick_writing') {
require_once ('quick_writing.inc.php');
}
html_page_stop();
?>

View file

@ -90,7 +90,7 @@ if ( isset($_POST['add_fiche'])) {
// Prob : ajout de fiche mais si plusieur cat possible ???
// Get the field from database
// if e_type contains a list of value
if ( $e_type != 'cred' and $e_type != 'deb') {
if ( $e_type != 'cred' and $e_type != 'deb' && $e_type!='filter') {
// $list['fiche']=$e_type;
$sql="select fd_id from fiche_def where frd_id in ($e_type)";
$Res=ExecSql($cn,$sql);
@ -115,7 +115,16 @@ if ( isset($_POST['add_fiche'])) {
$get='jrn_def_fiche_cred';
$sql="select $get as fiche from jrn_def where jrn_def_id=".$_GET['p_jrn'];
}
if ($e_type=='filter') {
$get_cred='jrn_def_fiche_cred';
$get_deb='jrn_def_fiche_deb';
$sql="select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_id=".$_GET['p_jrn'];
}
$Res=ExecSql($cn,$sql);

View file

@ -131,12 +131,29 @@ if (
elseif ( $e_type == 'all' ) {
$sql="select * from vw_fiche_attr where true";
}
elseif ($e_type=='filter') {
$get='jrn_def_fiche_cred';
$list_cred=get_list_fiche($cn,$get,$_GET['p_jrn']);
$get='jrn_def_fiche_deb';
$list_deb=get_list_fiche($cn,$get,$_GET['p_jrn']);
$list_fiche=$list_cred.','.$list_deb;
if ( $list_fiche == ',' )
exit("Vous n'avez pas bien configure ce journal, vous devez aller dans Avance->Journal et indiquez les fiches utilisables");
$sql="select * from vw_fiche_attr where fd_id in ( $list_fiche )";
}
// if e_type contains a list of value for filtering on fiche_def_ref.frd_id
else{
$list_fiche=$e_type;
$sql="select * from vw_fiche_attr where frd_id in ( $list_fiche )";
// $sql="select * from vw_fiche_attr ";
}
// e_fic_search contains the pattern
if (strlen(trim($e_fic_search) ) == 0 ) {

View file

@ -27,6 +27,15 @@ if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1)
case 'all':
$filter_card="";
break;
case 'filter':
$get_cred='jrn_def_fiche_cred';
$get_deb='jrn_def_fiche_deb';
$filter_jrn=Getdbvalue($cn,"select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_id=$jrn");
$filter_card="and fd_id in ($filter_jrn)";
break;
default:
$filter_card="and frd_id in ($d)";
}

View file

@ -31,7 +31,7 @@ $gDossier=dossier::id();
include_once ("postgres.php");
include_once("check_priv.php");
include("class_jrn.php");
include("class_acc_ledger.php");
$cn=DbConnect($gDossier);
$rep=DbConnect();
@ -47,7 +47,7 @@ if ( $User->CheckAction($cn,IMP) == 0 ||
$p_cent=( isset ( $_GET['central']) )?$_GET['central']:'off';
$Jrn=new jrn($cn,$_GET['jrn_id']);
$Jrn=new Acc_Ledger($cn,$_GET['jrn_id']);
$Jrn->GetName();
$jrn_type=$Jrn->get_type();

View file

@ -35,7 +35,7 @@ include_once("postgres.php");
include_once("class.ezpdf.php");
include_once("impress_inc.php");
include_once("preference.php");
include_once("class_jrn.php");
include_once("class_acc_ledger.php");
include_once("check_priv.php");
require_once ('header_print.php');
@ -48,7 +48,7 @@ if ($_GET['central'] == 'on' ) {
$centr=" centralisé ";
$l_centr=1;
}
$Jrn=new jrn($cn,$_GET['jrn_id']);
$Jrn=new Acc_Ledger($cn,$_GET['jrn_id']);
$Jrn->GetName();
$User=new cl_user(DbConnect());

View file

@ -233,23 +233,23 @@ if ( isset($_POST['update_record']) ) {
if ( $own->MY_ANALYTIC == "ob") {
$tab=0; $row=1;
while (1) {
if ( !isset ($_POST['nb_t'.$tab]))
break;
$tot_tab=0;
for ($i_row=0;$i_row <= MAX_COMPTE;$i_row++) {
if ( ! isset($_POST['val'.$tab.'l'.$i_row]))
continue;
$tot_tab+=$_POST['val'.$tab.'l'.$i_row];
}
print_r ( "\$tot_tab $tot_tab \$_POST['amount_t'.$tab ".$_POST['amount_t'.$tab]);
if ( $tot_tab != $_POST['amount_t'.$tab]) {
echo "Erreur montant CA";
echo "Op&eacute;ration annul&eacute;e";
return;
}
$tot_tab=0;
$tab++;
if ( !isset ($_POST['nb_t'.$tab]))
break;
$tot_tab=0;
for ($i_row=0;$i_row <= MAX_COMPTE;$i_row++) {
if ( ! isset($_POST['val'.$tab.'l'.$i_row]))
continue;
$tot_tab+=$_POST['val'.$tab.'l'.$i_row];
}
print_r ( "\$tot_tab $tot_tab \$_POST['amount_t'.$tab ".$_POST['amount_t'.$tab]);
if ( $tot_tab != $_POST['amount_t'.$tab]) {
echo "Erreur montant CA";
echo "Op&eacute;ration annul&eacute;e";
return;
}
$tot_tab=0;
$tab++;
}
}
@ -269,7 +269,7 @@ if ( isset($_POST['update_record']) ) {
echo_debug(__FILE__.':'.__LINE__,"array is ",$row_ca);
if ( ereg("^[6,7]+",$row_ca['j_poste'])) {
echo_debug(__FILE__.':'.__LINE__,"count is ",$count);
$op=new operation($cn);
$op=new Anc_Operation($cn);
$op->delete_by_jid($row_ca['j_id']);
$op->j_id=$row_ca['j_id'];
$op->oa_debit=$row_ca['j_debit'];

View file

@ -18,7 +18,7 @@
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
require_once('class_jrn.php');
require_once('class_acc_ledger.php');
require_once('user_form_fin.php');
require_once('jrn.php');
require_once("class_document.php");
@ -335,7 +335,7 @@ if ( $p_jrn != -1 )
exit -1;
}
$jrn=new jrn($cn, $p_jrn);
$jrn=new Acc_Ledger($cn, $p_jrn);
echo_debug('depense.inc.php',__LINE__,"Blank form");
// Submit button in the form
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">

View file

@ -27,7 +27,7 @@
* accountancy.
*
*/
require_once('class_operation.php');
require_once('class_anc_operation.php');
require_once('class_plananalytic.php');
require_once('ac_common.php');
require_once('class_widget.php');

View file

@ -28,7 +28,7 @@
*/
require_once("class_poste_analytic.php");
require_once ("class_widget.php");
require_once ("class_operation.php");
require_once ("class_anc_operation.php");
require_once ("class_groupop.php");
@ -66,7 +66,7 @@ if ( isset($_GET['see'])) {
// and exit
//-----------------------------
echo JS_AJAX_OP;
$a=new operation($cn);
$a=new Anc_Operation($cn);
echo '
<div class="u_redcontent">
@ -118,7 +118,7 @@ if ( isset($_POST['save'])) {
}
if ( isset($_GET['new'])) {
//show the form for entering a new operation
//show the form for entering a new Anc_Operation
//------------------------------------------
$a=new groupop($cn);

View file

@ -19,19 +19,31 @@
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
require_once('class_fiche.php');
require_once('class_user.php');
require_once ('class_widget.php');
require_once ('class_dossier.php');
require_once ('class_own.php');
require_once ('class_anc_operation.php');
require_once ('class_acc_operation.php');
require_once ('class_poste.php');
require_once ('class_pre_op_advanced.php');
require_once ('jrn.php');
/*!\brief Class for jrn
*
*/
class jrn {
class Acc_Ledger {
var $id;
var $name;
var $db;
var $row;
var $type;
function jrn ($p_cn,$p_id){
var $nb; /*!< default number of rows by
default 10 */
function Acc_Ledger ($p_cn,$p_id){
$this->id=$p_id;
$this->db=$p_cn;
$this->row=null;
$this->nb=10;
}
/*!
* \brief Return the type of a ledger (ACH,VEN,ODS or FIN) or GL
@ -634,5 +646,410 @@ class jrn {
$response=array($deb,$cred);
return $response;
}
/*!
* \brief Show a select list of the ledger you can access in
* writing, the security is taken in care but show the readable AND
* writable ledger
* \param
* \param
* \param
*
*
* \return object widget select
*/
function select_ledger() {
$user=new cl_user($this->db);
$array=$user->get_ledger();
$idx=0;
$ret=array();
foreach ( $array as $value) {
$ret[$idx]['value']=$value['jrn_def_id'];
$ret[$idx]['label']=$value['jrn_def_name'];
$idx++;
}
$select=new widget("select");
$select->name='p_jrn';
$select->value=$ret;
$select->selected=$this->id;
return $select;
}
/*!
* \brief retrieve the jrn_def_fiche and return them into a array
* index deb, cred
* \param
* \param
* \param
*
*
* \return return an array ('deb'=> ,'cred'=>)
*/
function get_fiche_def() {
$sql="select jrn_def_fiche_deb as deb,jrn_def_fiche_cred as cred ".
" from jrn_def where ".
" jrn_def_id = ".$this->id;
$r=ExecSql($this->db,$sql);
$res=pg_fetch_all($r);
if ( empty($res) ) return null;
print_r($res);
return $res[0];
}
/*!
* \brief retrieve the jrn_def_class_deb and return it
*
* \param
* \param
* \param
*
*
* \return return an string
*/
function get_class_def() {
$sql="select jrn_def_class_cred ".
" from jrn_def where ".
" jrn_def_id = ".$this->id;
print_r($sql);
$r=ExecSql($this->db,$sql);
$res=pg_fetch_all($r);
print_r($res);
if ( empty($res) ) return null;
return $res[0];
}
/*!
* \brief show the result of the array
* \param $p_array array from the form
* \param
* \param
*
*
* \return string
*/
function show_summary($p_array) {
$this->id=$p_array['p_jrn'];
if ( empty($p_array)) return 'Aucun r&eacute;sultat';
extract($p_array);
$ret="";
$ret.="<table>";
$ret.="<tr><td>Date : </td><td>$date</td></tr>";
$ret.="<tr><td>Description </td><td>$desc</td></tr>";
$ret.='</table>';
$ret.="<table>";
$ret.="<tr>";
$ret.="<th> Quick Code ou ";
$ret.="Poste </th>";
$ret.="<th> Montant </th>";
$ret.="<th> D&eacute;bit</th>";
$ret.="</tr>";
$own=new own($this->db);
$hidden=new widget('hidden');
$ret.=$hidden->IOValue('date',$date);
$ret.=$hidden->IOValue('desc',$desc);
// For predefined operation
$ret.=$hidden->IOValue('e_comm',$desc);
$ret.=$hidden->IOValue('jrn_type',$this->get_type());
$ret.=$hidden->IOValue('p_jrn',$this->id);
$ret.=$hidden->IOValue('nb_item',$this->nb);
$ret.=dossier::hidden();
for ($i=0;$i<$this->nb;$i++) {
$ret.="<tr>";
if ( trim(${'qc_'.$i})!="") {
$oqc=new fiche($this->db);
$oqc->GetByQCode(${'qc_'.$i},false);
$ret.="<td>".${'qc_'.$i}.' - '.
$oqc->strAttribut(ATTR_DEF_NAME).$hidden->IOValue('qc_'.$i,${'qc_'.$i}).
'</td>';
}
if ( trim(${'qc_'.$i})=="" && trim(${'poste'.$i}) != "") {
$oposte=new poste($this->db,${'poste'.$i});
$ret.="<td>".${"poste".$i}." - ".
$oposte->GetName().$hidden->IOValue('poste'.$i,${'poste'.$i}).
'</td>';
}
if ( trim(${'qc_'.$i})=="" && trim(${'poste'.$i}) == "")
continue;
$ret.="<td>".${"amount".$i}.$hidden->IOValue('amount'.$i,${'amount'.$i})."</td>";
$ret.="<td>";
$ret.=(isset(${"ck$i"}))?"D":"C";
$ret.=(isset(${"ck$i"}))?$hidden->IOValue('ck'.$i,${'ck'.$i}):"";
$ret.="</td>";
// CA
if ( $own->MY_ANALYTIC!='nu') // use of AA
{
// show form
$op=new Anc_Operation($this->db);
$null=($own->MY_ANALYTIC=='op')?1:0;
$ret.='<td>';
$ret.=$op->display_form_plan(null,$null,1,$i,round(${'amount'.$i},2));
$ret.='</td>';
}
$ret.="</tr>";
}
$ret.="</table>";
return $ret;
}
/*!
* \brief Show the form to encode your operation
* \param $p_array if you correct or use a predef operation
* \param $p_readonly 1 for readonly 0 for writable
* \param
*
*
* \return a string containing the form
*/
function show_form($p_array=null,$p_readonly=0)
{
if ( $p_readonly == 1 )
return $this->show_summary($p_array);
if ( $p_array != null )
extract($p_array);
$ret="";
// Load the javascript
$ret.=JS_SEARCH_CARD;
$ret.=JS_SEARCH_POSTE;
$ret.=JS_AJAX_FICHE;
//
$ret.="<table>";
$ret.= '<tr><td>';
$wDate=new widget('js_date','Date','date');
$wDate->table=1;
$wDate->readonly=$p_readonly;
$wDate->value=(isset($date))?$date:'';
$ret.=$wDate->IOValue();
$ret.= '</td></tr>';
$ret.= '<tr><td>';
$wDescription=new widget('text',"Description",'desc');
$wDescription->readonly=$p_readonly;
$wDescription->table=1;
$wDescription->value=(isset($desc))?$desc:'';
$ret.=$wDescription->IOValue();
$ret.= '</td></tr>';
$ret.= '</table>';
// $nb_row=(isset($nb))?$nb:$this->GetDefLine();
$nb_row=$this->nb;
$hidden=new widget('hidden','nb','nb');
$hidden->value=$nb_row;
$ret.=$hidden->IOValue();
$ret.=dossier::hidden();
$ret.=$hidden->IOValue('p_jrn',$this->id);
$ret.=$hidden->IOValue('jrn_type',$this->get_type());
$ret.='<table border="2">';
$ret.='<tr>'.
'<th colspan="5">Quickcode</th>'.
'<th colspan="3">Poste</th>'.
'<th> Montant</th>'.
'<th>D&eacute;bit</th>'.
'</tr>';
for ($i = 0 ;$i<$nb_row;$i++){
// Quick Code
$quick_code=new widget('js_search');
$quick_code->name='qc_'.$i;
$quick_code->value=(isset(${'qc_'.$i}))?${'qc_'.$i}:"";
$quick_code->readonly=$p_readonly;
$quick_code->extra2=$this->id;
$quick_code->extra='filter';
$qc_span=new widget('span','','qc_'.$i.'_label');
// Account
$poste=new widget('js_search_poste');
$poste->name='poste'.$i;
$poste->value=(isset(${'poste'.$i}))?${"poste".$i}:'';
$poste->readonly=$p_readonly;
$poste->extra=$this->id;
$poste->extra2=$this->get_class_def();
echo "get_class_Def returns";
print_r($poste->extra2);
$poste_span=new widget('span','','poste'.$i.'_label');
// Amount
$amount=new widget('text');
$amount->name='amount'.$i;
$amount->value=(isset(${'amount'.$i}))?${"amount".$i}:'';
$amount->readonly=$p_readonly;
// D/C
$deb=new widget('checkbox');
$deb->name='ck'.$i;
$deb->value=(isset(${'ck'.$i}))?${"ck".$i}:'';
$deb->readonly=$p_readonly;
$ret.='<tr>';
$ret.='<td>'.$quick_code->IOValue().'</td>';
$ret.='<td>'.$qc_span->IOValue().'</td>';
$ret.='<td>'.$poste->IOValue().'</td>';
$ret.='<td>'.$poste_span->IOValue().'</td>';
$ret.='<td>'.$amount->IOValue().'</td>';
$ret.='<td>'.$deb->IOValue().'</td>';
$ret.='</tr>';
// If readonly == 1 then show CA
}
$ret.='</table>';
return $ret;
}
/*!
* \brief save the operation into the jrnx,jrn, ,
* CA and pre_def
* \param
* \param
* \param
*
*
* \return
*/
function save ($p_array) {
extract ($p_array);
try {
StartSql($this->db) ;
$seq=NextSequence($this->db,'s_grpt');
$internal=SetInternalCode($this->db,$seq,$this->id);
$group=NextSequence($this->db,"s_oa_group");
$own=new own($this->db);
$tot_amount=0;
for ($i=0;$i<$this->nb;$i++)
{
if ( ! isset (${'qc_'.$i}) && ! isset(${'poste'.$i}))
continue;
$acc_op=new Acc_Operation($this->db);
$quick_code="";
// First we save the jrnx
if ( isset(${'qc_'.$i})) {
$qc=new fiche($this->db);
$qc->GetByQCode(${'qc_'.$i},false);
$poste=$qc->strAttribut(ATTR_DEF_ACCOUNT);
$quick_code=${'qc_'.$i};
}
else {
$poste=${'poste'.$i};
}
$acc_op->date=$date;
$acc_op->desc=$desc;
$acc_op->amount=${'amount'.$i};
$acc_op->grpt=$seq;
$acc_op->poste=$poste;
$acc_op->jrn=$this->id;
$acc_op->type=(isset (${'ck'.$i}))?'d':'c';
$acc_op->qcode=$quick_code;
$j_id=$acc_op->insert_jrnx();
$tot_amount+=round($acc_op->amount,2);
if ( $own->MY_ANALYTIC != "nu" )
{
// for each item, insert into operation_analytique */
$op=new Anc_Operation($this->db);
$op->oa_group=$group;
$op->j_id=$j_id;
$op->oa_date=$date;
$op->oa_debit=($acc_op->type=='d' )?'t':'f';
$op->oa_description=$desc;
$op->save_form_plan($p_array,$i);
}
}
$acc_end=new Acc_Operation($this->db);
$acc_end->date=$date;
$acc_end->desc=$desc;
$acc_end->grpt=$seq;
$acc_end->jrn=$this->id;
if ( $acc_end->insert_jrn() == false )
throw new Exception('Balance incorrecte');
ExecSql($this->db,"update jrn set jr_internal='".$internal."' where ".
" jr_grpt_id = ".$seq);
// Save now the predef op
//------------------------
if ( isset($save_opd)) {
$opd=new Pre_Op_Advanced($this->db);
$opd->name=(trim($desc)=='')?$internal:$desc;
$opd->get_post();
$opd->save();
}
} catch (Exception $e) {
Rollback($this->db);
echo 'OPERATION ANNULEE ';
echo '<hr>';
echo __FILE__.__LINE__.$e->getMessage();
exit();
}
Commit($this->db);
}
/*!
* \brief get all the data from request and build the object
* \param
* \param
* \param
*
*
* \return
*/
function get_request()
{
$this->id=$_REQUEST['p_jrn'];
}
/*!
* \brief this function is intended to test this class
* \param
* \param
* \param
*
*
* \return
*/
static function test_me()
{
html_page_start();
$cn=DbConnect(dossier::id());
$_SESSION['g_user']='phpcompta';
$_SESSION['g_pass']='phpcompta';
$id=(isset ($_POST['p_jrn']))?$_POST['p_jrn']:-1;
$a=new Acc_Ledger($cn,$id);
echo '<FORM method="post">';
echo $a->select_ledger()->IOValue();
echo widget::submit_button('go','Test it');
echo '</form>';
if ( isset($_POST['go'])) {
echo "Ok ";
echo '<form method="post">';
echo $a->show_form();
echo widget::submit_button('post_id','Try me');
echo '</form>';
}
if ( isset($_POST['post_id' ])) {
echo '<form method="post">';
echo $a->show_form($_POST,1);
echo widget::submit_button('save_it',"Sauver");
echo '</form>';
}
if ( isset($_POST['save_it' ])) {
$array=$_POST;
$array['save_opd']=1;
$a->save($array);
}
}
}

View file

@ -0,0 +1,118 @@
<?php
/*
* This file is part of PhpCompta.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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 this file match the tables jrn & jrnx the purpose is to
remove or save accountant writing to these table.
*/
require_once ('class_user.php');
/* \brief
*
*/
class Acc_Operation
{
var $db; /*!< database connx */
var $jrn_id; /*!< jrn_def_id */
var $debit; /*!< debit or credit */
var $user; /*!< current user */
var $jrn; /*!< the ledger to use */
var $poste; /*!< account */
var $date; /*!< the date */
var $periode; /*!< periode to use */
var $amount; /*!< amount of the operatoin */
var $grpt; /*!< the group id */
/*!
* \brief constructor set automatically the attributes user and periode
* \param $p_cn the databse connection
*/
function Acc_operation($p_cn) {
$this->db=$p_cn;
$this->qcode="";
$this->user=$_SESSION['g_user'];
$user=new cl_user($this->db);
$this->periode=$user->GetPeriode();
}
/* **************************************************
*\brief Insert into the table Jrn
*
*
* \return nothing
*
*/
function insert_jrnx()
{
if ( $this->poste == "") return true;
$debit=($this->type=='c')?'false':'true';
$sql=sprintf("select insert_jrnx
('%s',abs(%.2f),%d,%d,%d,%s,'%s',%d,upper('%s'))",
$this->date,round($this->amount,2),
$this->poste,$this->grpt,$this->jrn,
$debit,$this->user,$this->periode,$this->qcode);
$Res=ExecSql($this->db,$sql);
if ( $Res==false) return $Res;
$this->jrnx_id=GetSequence($this->db,'s_jrn_op');
return $this->jrnx_id;
}
/*!
**************************************************
*\brief Insert into the table Jrn, the amount is computed from jrnx thanks the
* group id ($p_grpt)
*
* \return nothing
*
*/
function insert_jrn()
{
$p_comment=FormatString($this->desc);
// retrieve the value from jrnx
//
$montant_deb=getDBValue($this->db,"select sum(j_montant) from jrnx where j_debit='t' and j_grpt=".$this->grpt);
$montant_cred=getDBValue($this->db,"select sum(j_montant) from jrnx where j_debit='f' and j_grpt=".$this->grpt);
echo_debug('InsertJrn',__LINE__,"debit = $montant_deb credit = $montant_cred ");
$amount=-1.0000;
if ( $montant_deb == $montant_cred ) {
$amount=$montant_deb;
} else {
echo "Erreur : balance incorrecte : d&eacute;bit = $montant_deb cr&eacute;dit = $montant_cred";
return false;
}
// if amount == -1then the triggers will throw an error
//
$sql=sprintf("insert into jrn (jr_def_id,jr_montant,jr_comment,jr_date,jr_ech,jr_grpt_id,jr_tech_per)
values ( %d,abs(%.2f),'%s',to_date('%s','DD.MM.YYYY'),null,%d,%d)",
$this->jrn, $amount,$p_comment,$this->date,$this->grpt,$this->periode);
$Res=ExecSql($this->db,$sql);
if ( $Res == false) return false;
return GetSequence($this->db,'s_jrn');
}
}

View file

@ -28,7 +28,7 @@
*/
require_once ('class_plananalytic.php');
require_once ('class_print_ca.php');
require_once ('class_operation.php');
require_once ('class_anc_operation.php');
/*!
* \brief manage the CA listing
*
@ -97,7 +97,7 @@ class list_ca extends print_ca {
*/
function get_data()
{
$op=new operation ($this->db);
$op=new Anc_Operation ($this->db);
$op->pa_id=$this->pa_id;
$array=$op->get_list($this->from,$this->to,$this->from_poste,$this->to_poste);
return $array;

View file

@ -0,0 +1,109 @@
<?php
/*
* This file is part of PhpCompta.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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
*/
require_once ('class_pre_operation.php');
/*---------------------------------------------------------------------- */
/*!\brief concerns the operation for VEN ledger
/*---------------------------------------------------------------------- */
class Pre_Op_Advanced extends Pre_operation_detail {
var $op;
function get_post() {
echo_debug(__FILE__.':'.__LINE__.'- ','get_post');
parent::get_post();
// For advanced we use +5000
$this->operation->p_jrn+=5000;
extract($_POST);
for ($i=0;$i<$this->operation->nb_item;$i++) {
$this->{'poste'.$i}=(isset($_POST['qc_'.$i]))?$_POST['qc_'.$i]:$_POST['poste'.$i];
$this->{"amount".$i}=$_POST['amount'.$i];
$this->{"ck".$i}=($_POST['ck'.$i]=='c')?'t':'f';
}
}
/*!
* \brief save the detail and op in the database
*
*/
function save() {
try {
StartSql($this->db);
if ($this->operation->save() == false )
return;
// save the selling
for ($i=0;$i<$this->operation->nb_item;$i++) {
$sql=sprintf('insert into op_predef_detail (opd_poste,opd_amount,'.
'opd_debit,od_id)'.
' values '.
"('%s',%.2f,%d,%f,'%s',%d)",
$this->{"poste".$i},
$this->{"amount".$i},
$this->{"ck".$i},
$this->operation->od_id
);
ExecSql($this->db,$sql);
}
} catch (Exception $e) {
echo ($e->getMessage());
Rollback($this->db);
}
}
/*!\brief compute an array accordingly with the FormVenView function
*/
function compute_array() {
$count=0;
$a_op=$this->operation->load();
$array=$this->operation->compute_array($a_op);
$p_array=$this->load();
foreach ($p_array as $row) {
if ( $row['opd_debit']=='t') {
$array+=array('e_client'=>$row['opd_poste']);
} else {
$array+=array("e_march".$count=>$row['opd_poste'],
"e_march".$count."_sell"=>$row['opd_amount'],
"e_march".$count."_tva_id"=>$row['opd_tva_id'],
"e_quant".$count=>$row['opd_quantity']
);
$count++;
}
}
return $array;
}
/*!\brief load the data from the database and return an array
* \return an array
*/
function load() {
$sql="select opd_id,opd_poste,opd_amount,opd_tva_id,opd_debit,".
" opd_quantity from op_predef_detail where od_id=".$this->operation->od_id.
" order by opd_id";
$res=ExecSql($this->db,$sql);
$array=pg_fetch_all($res);
return $array;
}
function set_od_id($p_id) {
$this->operation->od_id=$p_id;
}
}

View file

@ -135,8 +135,35 @@ class cl_user {
return $ret;
}
function getJrn() {
/*!
* \brief get all the available ledgers for the current user
* \param none
* \param
* \param
*
*
* \return an array
*/
function get_ledger() {
if ( $this->admin != 1) {
$sql="select jrn_def_id,jrn_def_type,
jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
jrn_deb_max_line,jrn_cred_max_line
from jrn_def join jrn_type on jrn_def_type=jrn_type_id
join user_sec_jrn on uj_jrn_id=jrn_def_id
where
uj_login='".$this->id."'
and uj_priv !='X'
order by jrn_Def_id";
}else {
$sql="select jrn_def_id,jrn_def_type,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line,
jrn_type_id,jrn_desc,'W' as uj_priv
from jrn_def join jrn_type on jrn_def_type=jrn_type_id
order by jrn_Def_id";
}
$res=ExecSql($this->db,$sql);
$array=pg_fetch_all($res);
return $array;
}
/*!
**************************************************

View file

@ -33,7 +33,7 @@ define ("domaine","rel3");
define ("MAX_COMPTE",4);
define ("DEBUG","false");
define ("DEBUG","true");
// securite correspond a la table
// action
@ -170,6 +170,10 @@ define ("JS_SEARCH_CARD","
define ("JS_CONCERNED_OP",'
<script type="text/javascript" language="javascript" src="js/jrn_concerned.js">
</script>');
define ('JS_CALENDAR','
<script type="text/javascript" language="javascript" src="js/jrn_concerned.js">
</script>');
// One line calculator
define ("JS_CALC_LINE",'
<div style="border:outset black 3px; position:float; float:right;background-color:white;font-family:sans-serif;font-size:9pt;">

View file

@ -18,7 +18,7 @@
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
require_once('class_jrn.php');
require_once('class_acc_ledger.php');
require_once('user_form_ach.php');
require_once('jrn.php');
require_once("class_document.php");
@ -313,7 +313,7 @@ if ( $p_jrn != -1 )
exit -1;
}
$jrn=new jrn($cn, $p_jrn);
$jrn=new Acc_Ledger($cn, $p_jrn);
echo_debug('depense.inc.php',__LINE__,"Blank form");
// Submit button in the form
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">

View file

@ -18,7 +18,7 @@
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
require_once('class_jrn.php');
require_once('class_acc_ledger.php');
require_once('user_form_ven.php');
require_once('jrn.php');
require_once("class_document.php");
@ -302,7 +302,7 @@ if ( $p_jrn != -1 )
exit -1;
}
$jrn=new jrn($cn, $p_jrn);
$jrn=new Acc_Ledger($cn, $p_jrn);
echo_debug('facture.inc.php.php',__LINE__,"Blank form");
// Show an empty form of invoice
$form=FormVenInput($cn,$p_jrn,$User->GetPeriode(),null,false,$jrn->GetDefLine());

View file

@ -404,7 +404,7 @@ function GetRappelSimple ($p_cn,$p_jrn_id,$p_jrn_type,$p_from,&$arap)
"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 jrn($p_cn,$p_jrn_id);
$j=new Acc_Ledger($p_cn,$p_jrn_id);
$a=$j->GetRowSimple($previous,$previous,$cent='on');
$total_tvac=0.0;
$total_htva=0.0;

View file

@ -32,12 +32,12 @@ $gDossier=dossier::id();
// after in pdf or cvs
//-----------------------------------------------------
if ( isset( $_POST['bt_html'] ) ) {
include("class_jrn.php");
include("class_acc_ledger.php");
$p_cent=( isset ( $_POST['cent']) )?'on':'off';
// $POST=from_periode, to_periode, jrn_id, cent
$d=var_export($_POST,true);
echo_debug('impress_jrn.php',__LINE__,$d);
$Jrn=new jrn($cn,$_POST['jrn_id']);
$Jrn=new Acc_Ledger($cn,$_POST['jrn_id']);
$Jrn->GetName();
if ( $_POST['p_simple']==0 )
{

View file

@ -27,7 +27,7 @@ require_once('class_fiche.php');
require_once ('class_gestion_sold.php');
require_once ('class_gestion_purchase.php');
require_once ('class_plananalytic.php');
require_once ('class_operation.php');
require_once ('class_anc_operation.php');
/*!
* \brief Display the form to UPDATE account operation in the expert view
*
@ -1107,7 +1107,7 @@ function GetDataJrnJrIdUser ($p_cn,$p_jr_id) {
function display_table_ca($p_cn,$p_seq,$p_jid,$p_own,$p_mode,$p_amount) {
echo_debug(__FILE__.':'.__LINE__,'parameter $p_cn,$p_seq,$p_jid,$p_own,$p_mode',"$p_cn,$p_seq,$p_jid,p_own,$p_mode");
$op=new operation($p_cn);
$op=new Anc_Operation($p_cn);
$array=$op->get_by_jid($p_jid) ;
echo_debug(__FILE__.':'.__LINE__,"display_table_ca \$p_jid",$p_jid);
echo_debug(__FILE__.':'.__LINE__,"display_table_ca \$array",$array);

View file

@ -26,7 +26,7 @@ require_once("user_form_ach.php");
require_once ("preference.php");
require_once ("user_common.php");
require_once("class_widget.php");
require_once("class_jrn.php");
require_once("class_acc_ledger.php");
require_once ('class_own.php');
$own=new own($cn);
@ -71,7 +71,7 @@ if ( $action == 'new' ) {
// Submit button in the form
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer" ID="SubmitButton">';
$jrn=new jrn($cn, $_GET['p_jrn']);
$jrn=new Acc_Ledger($cn, $_GET['p_jrn']);
$r=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$submit,false,$jrn->getDefLine());
//--------------------
// predef op.

View file

@ -27,7 +27,7 @@ echo_debug('user_action_fin.php',__LINE__,"include user_action_fin.php");
require_once("user_form_fin.php");
include_once("class_widget.php");
require_once("class_parm_code.php");
require_once("class_jrn.php");
require_once("class_acc_ledger.php");
require_once ('class_pre_op_fin.php');
$cn=DbConnect($gDossier);
@ -75,7 +75,7 @@ if ( $action == 'new' ) {
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
// add a one-line calculator
$p_jrn=$_GET['p_jrn'];
$jrn=new jrn($cn, $p_jrn);
$jrn=new Acc_Ledger($cn, $p_jrn);
$r=FormFin($cn,$p_jrn,$User->GetPeriode(),$submit,null,false,$jrn->GetDefLine());
echo '<div class="u_redcontent">';

View file

@ -26,7 +26,7 @@
echo_debug('user_action_ven.php',__LINE__,"include user_action_ven.php");
require_once("user_form_ven.php");
include_once("class_widget.php");
require_once("class_jrn.php");
require_once("class_acc_ledger.php");
require_once('class_dossier.php');
$gDossier=dossier::id();
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) {
@ -92,7 +92,7 @@ if ( $action == 'insert_vente' ) {
// We want a blank form
if ( $blank==1)
{
$jrn=new jrn($cn, $_GET['p_jrn']);
$jrn=new Acc_Ledger($cn, $_GET['p_jrn']);
echo_debug('user_action_ven.php',__LINE__,"Blank form");
// Show an empty form of invoice
$form=FormVenInput($cn,$_GET['p_jrn'],$User->GetPeriode(),null,false,$jrn->GetDefLine());

View file

@ -30,7 +30,7 @@ require_once("user_common.php");
require_once("class_parm_code.php");
require_once ('class_plananalytic.php');
require_once ('class_own.php');
require_once ('class_operation.php');
require_once ('class_anc_operation.php');
require_once ('class_pre_op_ach.php');
/*!
@ -671,7 +671,7 @@ function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_pi
if ( $own->MY_ANALYTIC!='nu') // use of AA
{
// show form
$op=new operation($p_cn);
$op=new Anc_Operation($p_cn);
$null=($own->MY_ANALYTIC=='op')?1:0;
$p_mode=($p_piece)?1:0;
$r.='<td>';
@ -907,7 +907,7 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
if ( $own->MY_ANALYTIC != "nu" )
{
// for each item, insert into operation_analytique */
$op=new operation($p_cn);
$op=new Anc_Operation($p_cn);
$op->oa_group=$group;
$op->j_id=$j_id;
$op->oa_date=$e_date;

View file

@ -27,7 +27,7 @@ require_once("fiche_inc.php");
require_once("user_common.php");
require_once ('class_plananalytic.php');
require_once ('class_own.php');
require_once ('class_operation.php');
require_once ('class_anc_operation.php');
require_once ('class_pre_op_ods.php');
/*! \file
* \brief Functions for the ledger of misc. operation
@ -207,7 +207,7 @@ $r.="<FORM NAME=\"form_detail\" enctype=\"multipart/form-data\"".
if ( $own->MY_ANALYTIC!='nu') // use of AA
{
// show form
$op=new operation($p_cn);
$op=new Anc_Operation($p_cn);
$null=($own->MY_ANALYTIC=='op')?1:0;
$r.='<td>';
$p_mode=($p_saved)?0:1;
@ -384,7 +384,7 @@ function RecordODS($p_cn,$p_array,$p_user,$p_jrn)
if ( $own->MY_ANALYTIC != "nu" )
{
// for each item, insert into operation_analytique */
$op=new operation($p_cn);
$op=new Anc_Operation($p_cn);
$op->oa_group=$group;
$op->j_id=$j_id;
$op->oa_date=$e_date;

View file

@ -28,7 +28,7 @@ require_once("fiche_inc.php");
require_once("user_common.php");
require_once ("class_own.php");
require_once ("class_plananalytic.php");
require_once ('class_operation.php');
require_once ('class_anc_operation.php');
require_once ('class_pre_op_ven.php');
require_once ('class_own.php');
@ -574,7 +574,7 @@ function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form'
if ( $own->MY_ANALYTIC!='nu') // use of AA
{
// show form
$op=new operation($p_cn);
$op=new Anc_Operation($p_cn);
$null=($own->MY_ANALYTIC=='op')?1:0;
$r.='<td>';
$p_mode=($p_doc=="form")?1:0;
@ -767,7 +767,7 @@ function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
if ( $own->MY_ANALYTIC != "nu" )
{
// for each item, insert into operation_analytique */
$op=new operation($p_cn);
$op=new Anc_Operation($p_cn);
$op->oa_group=$group;
$op->j_id=$j_id;
$op->oa_date=$e_date;

View file

@ -174,6 +174,8 @@ function ShowMenuCompta($p_high="")
array("user_jrn.php?jrn_type=ACH&".$str_dossier,"Dépense"),
array("user_jrn.php?jrn_type=FIN&".$str_dossier,"Financier"),
array("user_jrn.php?jrn_type=ODS&".$str_dossier,"Op. Diverses"),
array('compta.php?p_action=quick_writing&'.$str_dossier,'Ecriture rapide'),
array("compta.php?p_action=impress&".$str_dossier,"Impression","Impression",5),
array("compta.php?p_action=fiche&".$str_dossier,"Fiche","Ajouter, modifier ou effacer des fiches",6),
array("user_advanced.php?".$str_dossier,"Avancé","Opérations délicates"),