In progress : operation detail in a html popup
This commit is contained in:
parent
37aa4eb51b
commit
1072e0863b
12 changed files with 372 additions and 20 deletions
114
html/ajax_ledger.php
Normal file
114
html/ajax_ledger.php
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<?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
|
||||
* \brief answer to the ajax request for the ledger
|
||||
* it means :
|
||||
- detail of an operation (expert, user and analytic view)
|
||||
- removal of an operation
|
||||
- load a receipt document
|
||||
- for reconcialiation
|
||||
- update of analytic content
|
||||
*/
|
||||
require_once('class_database.php');
|
||||
require_once('class_user.php');
|
||||
require_once('class_acc_operation.php');
|
||||
require_once('class_acc_ledger.php');
|
||||
require_once ('class_fiche.php');
|
||||
require_once('function_javascript.php');
|
||||
echo js_include('scripts.js');
|
||||
echo js_include('prototype.js');
|
||||
echo js_include('effects.js');
|
||||
echo js_include('dragdrop.js');
|
||||
|
||||
/**
|
||||
*@todo Check if we receive the needed data (jr_id...)
|
||||
*/
|
||||
$action=$_REQUEST['act'];
|
||||
$jr_id=$_REQUEST['jr_id'];
|
||||
$div=$_REQUEST['div']; /* the div source and target for javascript */
|
||||
/**
|
||||
*@todo if $_SESSION['g_user'] is not set : echo a warning
|
||||
*/
|
||||
|
||||
$cn=new Database(dossier::id());
|
||||
|
||||
// check if the user is valid and can access this folder
|
||||
$User=new User($cn);
|
||||
$User->check();
|
||||
if ( $User->check_dossier(dossier::id(),true)=='X' ) exit();
|
||||
|
||||
|
||||
// check if the user can access the ledger where the operation is (view) and
|
||||
// if he can modify it
|
||||
$op=new Acc_Operation($cn);
|
||||
$op->jr_id=$_GET['jr_id'];
|
||||
$ledger=$op->get_ledger();
|
||||
$access=$User->get_ledger_access($ledger);
|
||||
if ( $access == 'X' ) exit();
|
||||
$html=var_export($_REQUEST,true);
|
||||
|
||||
switch ($action) {
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// DE Detail
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
case 'de':
|
||||
$op->get(); /* get detail op (D/C) */
|
||||
$obj=$op->get_quant(); /* return an obj. ACH / FIN or VEN or null if nothing is found*/
|
||||
$oLedger=new Acc_Ledger($cn,$ledger);
|
||||
|
||||
if ( $obj == null ) {
|
||||
/* only the details */
|
||||
ob_start();
|
||||
require_once('template/ledger_detail_misc.php');
|
||||
$html=ob_get_contents();
|
||||
ob_clean();
|
||||
} elseif ( $obj->signature=='ACH') {
|
||||
ob_start();
|
||||
require_once('template/ledger_detail_ach.php');
|
||||
$html=ob_get_contents();
|
||||
ob_clean();
|
||||
} elseif ($obj->signature=='FIN') {
|
||||
ob_start();
|
||||
require_once('template/ledger_detail_fin.php');
|
||||
$html=ob_get_contents();
|
||||
ob_clean();
|
||||
}elseif ( $obj->signature=='VEN') {
|
||||
ob_start();
|
||||
require_once('template/ledger_detail_ach.php');
|
||||
$html=ob_get_contents();
|
||||
ob_clean();
|
||||
}
|
||||
echo $html;
|
||||
exit();
|
||||
break;
|
||||
|
||||
}
|
||||
$html=escape_xml($html);
|
||||
header('Content-type: text/xml; charset=UTF-8');
|
||||
echo <<<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<data>
|
||||
<ctl>$div</ctl>
|
||||
<code>$html</code>
|
||||
</data>
|
||||
EOF;
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
* compute the sum, add a row at the table..
|
||||
*
|
||||
*/
|
||||
|
||||
var layer=1;
|
||||
/**
|
||||
* @brief update the list of available predefined operation when we change the ledger.
|
||||
*/
|
||||
|
|
@ -440,12 +440,14 @@ return true;
|
|||
* \param p_vue easy or expert view of the operation
|
||||
*/
|
||||
|
||||
function modifyOperation(p_value,p_dossier,p_jrn,p_vue)
|
||||
{
|
||||
|
||||
var win=window.open('modify_op.php?action=update&p_jrn='+p_jrn+'&line='+p_value+'&p_view='+p_vue+'&gDossier='+p_dossier,'','toolbar=no,width=720,height=510,scrollbars=yes,resizable=yes');
|
||||
win.focus();
|
||||
}
|
||||
function modifyOperation(p_value,dossier)
|
||||
{
|
||||
layer++;id='det'+layer;
|
||||
var popup={'id':id,'cssclass':'op_detail','html':'<div class="op_detail_title"><div style="float:right;top:0"><A style="background-color:blue;color:white;text-decoration:none" HREF="#" onclick="removeDiv(\''+id+'\');">Fermer</A></div>Détail opérations</div><div style="border:0;width:100%;height:100%"><iframe id="if'+id+'" style="padding:0;margin:0;border:0;width:100%;height:auto%" src="ajax_ledger?gDossier='+dossier+'&act=de&jr_id='+p_value+'&div='+id+'"</iframe></div>','drag':true};
|
||||
|
||||
add_div(popup);
|
||||
g(id).style.top=posY;
|
||||
}
|
||||
|
||||
/*!\brief
|
||||
* \param p_value jrn.jr_id
|
||||
|
|
|
|||
|
|
@ -398,9 +398,15 @@ function add_div(obj) {
|
|||
elt.setAttribute('className',obj.cssclass); /* IE */
|
||||
}
|
||||
if (obj.html) { elt.innerHTML=obj.html;}
|
||||
|
||||
var bottom_div=document.body;
|
||||
bottom_div.appendChild(elt);
|
||||
} catch (e) { alert(e.message);}
|
||||
if ( obj.drag ) {
|
||||
new Draggable(obj.id,{starteffect:function(){
|
||||
new Effect.Highlight(obj.id,{scroll:window,queue:'end'}); } }
|
||||
);
|
||||
}
|
||||
} catch (e) { alert("add_div"+e.message);}
|
||||
}
|
||||
/**
|
||||
* remove a object created with add_div
|
||||
|
|
@ -432,11 +438,7 @@ function show_box(obj) {
|
|||
} else {
|
||||
show(obj.id);
|
||||
}
|
||||
if ( obj.drag ) {
|
||||
new Draggable(obj.id,{starteffect:function(){
|
||||
new Effect.Highlight(obj.id,{scroll:window,queue:'end'}); } }
|
||||
);
|
||||
}
|
||||
|
||||
var action=new Ajax.Request (
|
||||
obj.callback,
|
||||
{
|
||||
|
|
@ -460,11 +462,14 @@ function success_box(req,json)
|
|||
if ( a.length == 0 ) { var rec=req.responseText;alert ('erreur :'+rec);}
|
||||
var name_ctl=a[0].firstChild.nodeValue;
|
||||
var code_html=getNodeText(html[0]);
|
||||
|
||||
code_html=unescape_xml(code_html);
|
||||
g(name_ctl).innerHTML=code_html;
|
||||
g(name_ctl).style.height='auto';
|
||||
g(name_ctl).style.width='auto';
|
||||
}
|
||||
catch (e) {
|
||||
alert(e.message);}
|
||||
alert("success_box"+e.message);}
|
||||
try{
|
||||
code_html.evalScripts();}
|
||||
catch(e){
|
||||
|
|
@ -473,4 +478,4 @@ function success_box(req,json)
|
|||
|
||||
function error_box () {
|
||||
alert('IBOX : error_box ajax not implemented');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -833,3 +833,20 @@ h2.gest_name {
|
|||
color:#403a8d;
|
||||
|
||||
}
|
||||
div.op_detail {
|
||||
background-color:#EDF3FF;
|
||||
font-size:10;
|
||||
font-family:helvetica,arial,sans-serif;
|
||||
padding:0;
|
||||
margin:0;
|
||||
overflow:none;
|
||||
|
||||
position:absolute;width:500;height:200;left:20%;
|
||||
border:1px solid darkblue;
|
||||
}
|
||||
div.op_detail_title {
|
||||
background-color:grey;
|
||||
width:500;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ form {
|
|||
.noprint {
|
||||
display:none;
|
||||
}
|
||||
|
||||
.button {
|
||||
display:none;
|
||||
}
|
||||
div.recherche_form {
|
||||
display:none;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ $array=array(
|
|||
array(28,'Extension'),
|
||||
array(29,'ITVA popup'),
|
||||
array(30,'Ereg and preg_match'),
|
||||
array(31,'IBOX')
|
||||
array(31,'IBOX'),
|
||||
array(32,'Acc_Operation & children')
|
||||
);
|
||||
$r='<form method="get">';
|
||||
$r.='<select name="test_select" >';
|
||||
|
|
@ -261,6 +262,10 @@ case 31:
|
|||
require_once('class_ibox.php');
|
||||
IBox::test_me();
|
||||
break;
|
||||
case 32:
|
||||
require_once('class_acc_operation.php');
|
||||
Acc_Operation::test_me();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
* remove or save accountant writing to these table.
|
||||
*/
|
||||
require_once ('class_user.php');
|
||||
require_once('class_acc_ledger.php');
|
||||
|
||||
/*! \brief this file match the tables jrn & jrnx the purpose is to
|
||||
* remove or save accountant writing to these table.
|
||||
*
|
||||
|
|
@ -54,6 +56,16 @@ class Acc_Operation
|
|||
$this->periode=$user->get_periode();
|
||||
$this->jr_id=0;
|
||||
}
|
||||
/**
|
||||
*@brief retrieve the grpt_id from jrn for a jr_id
|
||||
*@return jrn.jr_grpt_id or an empty string if not found
|
||||
*/
|
||||
function seek_group()
|
||||
{
|
||||
$ret=$this->db->get_value('select jr_grpt_id from jrn where jr_id=$1',
|
||||
array($this->jr_id));
|
||||
return $ret;
|
||||
}
|
||||
/**
|
||||
*@brief Insert into the table Jrn
|
||||
*The needed data are :
|
||||
|
|
@ -414,5 +426,164 @@ Array
|
|||
}
|
||||
return array($l_array,$deb,$cred);
|
||||
}
|
||||
/**
|
||||
*@brief retrieve data from jrnx and jrn
|
||||
*@return return an object
|
||||
*@note
|
||||
*@see
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
function get() {
|
||||
$ret=new Acc_Misc($this->db,$this->jr_id);
|
||||
$ret->get();
|
||||
return $ret;
|
||||
}
|
||||
/**
|
||||
*@brief retrieve data from the table QUANT_*
|
||||
*@return return an object or null if there is no
|
||||
* data from the QUANT table
|
||||
*@see Acc_Sold Acc_Purchase Acc_Fin Acc_Detail Acc_Misc
|
||||
*/
|
||||
function get_quant() {
|
||||
$ledger_id=$this->get_ledger();
|
||||
if ( $ledger_id=='') throw new Exception('Journal non trouvé');
|
||||
$oledger=new Acc_Ledger($this->db,$ledger_id);
|
||||
|
||||
switch($oledger->get_type()) {
|
||||
case 'VEN':
|
||||
$ret=new Acc_Sold($this->db,$this->jr_id);
|
||||
break;
|
||||
case 'ACH':
|
||||
$ret=new Acc_Purchase($this->db,$this->jr_id);
|
||||
break;
|
||||
case 'FIN':
|
||||
$ret=new Acc_Fin($this->db,$this->jr_id);
|
||||
break;
|
||||
default:
|
||||
return $this->get();
|
||||
}
|
||||
$ret->get();
|
||||
return $ret;
|
||||
}
|
||||
static function test_me() {
|
||||
$_SESSION['g_user']='phpcompta';
|
||||
$_SESSION['g_pass']='dany';
|
||||
|
||||
$cn=new Database(dossier::id());
|
||||
$a=new Acc_Operation($cn);
|
||||
$a->jr_id=11;
|
||||
$b=$a->get_quant();
|
||||
var_dump($b->det);
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
class Acc_Detail extends Acc_Operation {
|
||||
function __construct($p_cn,$p_jrid=0) {
|
||||
parent::__construct($p_cn);
|
||||
$this->jr_id=$p_jrid;
|
||||
}
|
||||
/**
|
||||
*@brief retrieve some common data from jrnx / jrn as
|
||||
* the datum, the comment,...
|
||||
*/
|
||||
function get() {
|
||||
$sql="SELECT jr_id, jr_def_id, jr_montant, jr_comment, jr_date, jr_grpt_id,
|
||||
jr_internal, jr_tech_date, jr_tech_per, jrn_ech, jr_ech, jr_rapt,
|
||||
jr_valid, jr_opid, jr_c_opid, jr_pj, jr_pj_name, jr_pj_type,
|
||||
jr_pj_number, jr_mt
|
||||
FROM jrn where jr_id=$1";
|
||||
$array=$this->db->get_array($sql,array($this->jr_id));
|
||||
if ( count($array) == 0 ) throw new Exception('Aucune ligne trouvée');
|
||||
foreach ($array[0] as $key=>$val) {
|
||||
$this->det->$key=$val;
|
||||
}
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
*@brief this class manage data from the JRNX and JRN
|
||||
* table
|
||||
*@note Data member are the column of the table
|
||||
*/
|
||||
class Acc_Misc extends Acc_Detail
|
||||
{
|
||||
var $signature; /*!< signature of the obj ODS */
|
||||
var $array; /*!< an array containing the data from JRNX */
|
||||
function __construct($p_cn,$p_jrid=0) {
|
||||
parent::__construct($p_cn,$p_jrid);
|
||||
$this->signature='ODS';
|
||||
}
|
||||
function get() {
|
||||
parent::get();
|
||||
$sql="SELECT j_id, j_date, j_montant, j_poste, j_grpt, j_rapt, j_jrn_def,
|
||||
j_debit, j_text, j_centralized, j_internal, j_tech_user, j_tech_date,
|
||||
j_tech_per, j_qcode
|
||||
FROM jrnx where j_grpt = $1";
|
||||
$this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
*@brief this class manage data from the QUANT_SOLD
|
||||
* table
|
||||
*@note Data member are the column of the table
|
||||
*/
|
||||
class Acc_Sold extends Acc_Detail
|
||||
{
|
||||
function __construct($p_cn,$p_jrid=0) {
|
||||
parent::__construct($p_cn,$p_jrid);
|
||||
$this->signature='SOLD';
|
||||
}
|
||||
function get() {
|
||||
parent::get();
|
||||
$sql="SELECT qs_id, qs_internal, qs_fiche, qs_quantite, qs_price, qs_vat,
|
||||
qs_vat_code, qs_client, qs_valid, j_id
|
||||
FROM quant_sold where j_id in (select j_id from jrnx where j_grpt=$1)";
|
||||
$this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
*@brief this class manage data from the QUANT_PURCHASE
|
||||
* table
|
||||
*@note Data member are the column of the table
|
||||
|
||||
*/
|
||||
class Acc_Purchase extends Acc_Detail
|
||||
{
|
||||
function __construct($p_cn,$p_jrid=0) {
|
||||
parent::__construct($p_cn,$p_jrid);
|
||||
$this->signature='PURCHASE';
|
||||
}
|
||||
|
||||
function get() {
|
||||
parent::get();
|
||||
$sql="SELECT qp_id, qp_internal, j_id, qp_fiche, qp_quantite, qp_price, qp_vat,
|
||||
qp_vat_code, qp_nd_amount, qp_nd_tva, qp_nd_tva_recup, qp_supplier,
|
||||
qp_valid, qp_dep_priv
|
||||
FROM quant_purchase where j_id in (select j_id from jrnx where j_grpt=$1)";
|
||||
$this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
*@brief this class manage data from the QUANT_FIN
|
||||
* table
|
||||
*@note Data member are the column of the table
|
||||
*/
|
||||
class Acc_Fin extends Acc_Detail
|
||||
{
|
||||
function __construct($p_cn,$p_jrid=0) {
|
||||
parent::__construct($p_cn,$p_jrid);
|
||||
$this->signature='FIN';
|
||||
}
|
||||
|
||||
function get() {
|
||||
parent::get();
|
||||
$sql="SELECT qf_id, qf_bank, jr_id, qf_other, qf_amount
|
||||
FROM quant_fin where jr_id = $1";
|
||||
$this->det->array=$this->db->get_array($sql,array($this->jr_id));
|
||||
}
|
||||
}
|
||||
|
|
@ -658,11 +658,11 @@ where
|
|||
|
||||
$dossier=$cn->get_value("select priv_priv from jnt_use_dos join priv_user on (priv_jnt=jnt_id) where dos_id=$1 and use_id=$2",
|
||||
array($p_dossier_id,$this->id));
|
||||
if ( $dossier=='X' || $dossier=='') {
|
||||
if ( ! $silent) alert(_('Dossier non accessible'));
|
||||
exit();
|
||||
$dossier=($dossier=='')?'X':$dossier;
|
||||
if ( $dossier=='X') {
|
||||
if ( ! $silent) { alert(_('Dossier non accessible')); exit();}
|
||||
}
|
||||
return $dossier;
|
||||
return $dossier;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
1
include/template/ledger_detail_ach.php
Normal file
1
include/template/ledger_detail_ach.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
<h2> ACHAT </h2>
|
||||
28
include/template/ledger_detail_fin.php
Normal file
28
include/template/ledger_detail_fin.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<? html_page_start($_SESSION['g_theme']);?>
|
||||
<div class="content">
|
||||
<h2> <? echo $oLedger->get_name(); ?></h2>
|
||||
<?
|
||||
$bk=new Fiche($cn,$obj->det->array[0]['qf_bank']);
|
||||
echo $bk->getName();
|
||||
echo $bk->get_quick_code();
|
||||
?>
|
||||
<table>
|
||||
<tr>
|
||||
<? echo td('Date').td($obj->det->jr_date);?>
|
||||
</tr>
|
||||
<tr>
|
||||
<?
|
||||
|
||||
$bk=new Fiche($cn,$obj->det->array[0]['qf_other']);
|
||||
echo td($bk->getName());
|
||||
echo td($bk->get_quick_code());
|
||||
?>
|
||||
<tr>
|
||||
<? echo td('Libellé').td($obj->det->jr_comment);?>
|
||||
</tr>
|
||||
<tr>
|
||||
<? echo td('montant').td($obj->det->array[0]['qf_amount'],' class="inum"');?>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
4
include/template/ledger_detail_misc.php
Normal file
4
include/template/ledger_detail_misc.php
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<h2> MISC </h2>
|
||||
<? var_dump($_REQUEST);
|
||||
|
||||
?>
|
||||
1
include/template/ledger_detail_ven.php
Normal file
1
include/template/ledger_detail_ven.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
<h2> VENTE </h2>
|
||||
Loading…
Add table
Add a link
Reference in a new issue