housekeeping : remove deprecated files

This commit is contained in:
Dany De Bontridder 2010-07-03 23:34:25 +00:00
parent 9c9a234c0d
commit 76ce776d76
4 changed files with 0 additions and 1972 deletions

View file

@ -1,461 +0,0 @@
<?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
*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
/*! \file
* \brief in a popup window manage the removal of the operations
*/
include_once ("ac_common.php");
include_once("user_common.php");
require_once('class_database.php');
include_once("jrn.php");
require_once("class_itext.php");
require_once("class_ibutton.php");
require_once("class_acc_ledger.php");
require_once("class_acc_operation.php");
require_once ('class_periode.php');
require_once('class_acc_reconciliation.php');
/* Admin. Dossier */
include_once ("class_user.php");
require_once('class_dossier.php');
$gDossier=dossier::id();
$cn=new Database($gDossier);
$User=new User($cn);
$User->Check();
$User->check_dossier(dossier::id());
if ($User->check_action(GEOP,0) == 0 ) {
alert("Cette action n'est pas autorisée");
echo '<script>window.close();<script>';
}
html_page_start($User->theme,"onLoad='window.focus();'");
echo JS_LEDGER;
if ( isset( $_REQUEST['p_jrn'] )) {
$p_jrn=$_GET['p_jrn'];
}
// Check privilege
if ( $User->check_jrn($_GET['p_jrn']) != 'W') {
alert("Vous ne pouvez pas accèder en écriture à ce journal");
echo '<script>window.close();</script>';
exit -1;
}
$operation=new Acc_Operation($cn);
list ($l_array,$max_deb,$max_cred)=$operation->get_data($_GET['jrn_op']);
extract ($l_array,EXTR_PREFIX_ALL,'e_');
foreach ($l_array as $key=>$element) { ${"e_".$key}=$element;}
// cancel an operation
if ( isset ($_POST['annul']) ) {
/* Confirm it first */
if ( ! isset ( $_POST['confirm'])) {
?>
<p>
<h2 class="info">Confirmation</h2>
<br>
<p><span class="error">Attention: l'effacement d'une op&eacute;ration peut rompre la s&eacute;quence de la num&eacute;rotation des factures surtout celles g&eacute;n&eacute;r&eacute;es automatiquement ainsi que celle des pièces justificatives, soyez tr&egrave;s prudent quand vous effacez. La pi&egrave;ce jointe sera elle aussi effac&eacute;e. Si vous utilisez la comptabilit&eacute; analytique les op&eacute;rations li&eacute;es seront effac&eacute;es.
</span>
</p>
<p> Voulez-vous vraiment annuler cette information soit par une remise &agrave; z&eacute;ro des montants
soit par son &eacute;criture inverse ?
</p>
<span >
<FORM METHOD="POST" ACTION="annulation.php?p_jrn=<?php echo $_GET['p_jrn'];?>&jrn_op=<?php echo $_GET['jrn_op'];?>">
<?php echo dossier::hidden(); ?>
<INPUT TYPE="HIDDEN" NAME="annul">
<INPUT TYPE="HIDDEN" NAME="p_id" value="<?php echo $_POST['p_id']; ?>">
Date pour l'écriture inverse
<?
$idate=new IDate("idate");
echo $idate->input();
?>
<span class="notice">Une écriture inverse sera faite si vous utilisez le mode strict ou si vous êtes dans une période fermée</span>
<br>
<INPUT TYPE="SUBMIT" class="button" NAME="confirm" value="Oui">
</FORM>
<FORM METHOD="GET" ACTION="annulation.php">
<?php echo dossier::hidden(); ?>
<INPUT TYPE="HIDDEN" NAME="p_jrn" value="<?php echo $_REQUEST['p_jrn']; ?>">
<INPUT TYPE="HIDDEN" NAME="p_id" value="<?php echo $_REQUEST['p_id']; ?>">
<INPUT TYPE="HIDDEN" NAME="jrn_op" value="<?php echo $_REQUEST['jrn_op']; ?>">
<INPUT TYPE="SUBMIT" class="button" NAME="not_confirm" value="non">
</form>
</span>
<?php
return;
} // end confirm'
// Remove is confirmed
if ( isset ($_POST['p_id'])) {
$p_id=$_POST['p_id'];
if ($p_id != -1 ) { // A
// Test whether date of the operation is in a closed periode
// get the period_id
$p=$cn->exec_sql("select jr_tech_per from jrn where jr_grpt_id=$1",array($_REQUEST['jrn_op']));
$period_id=Database::fetch_result($p,0,0);
// thanks jrn_op (jrn.jr_id) we find out the concerned ledger
$sql="select jr_def_id from jrn where jr_grpt_id=".$_REQUEST['jrn_op'];
$r=$cn->exec_sql($sql);
$nJrn=Database::fetch_result($r,0,0);
$per=new Periode($cn);
$per->set_jrn($nJrn);
$per->set_periode($period_id);
$own=new Own($cn);
// Check the period_id
if ( $per->is_open() == 0 || $own->MY_STRICT=='Y')
{
if ( isDate($_POST['idate'])== 0 ) {
alert(_('Date invalide'));
echo create_Script('window.close()');
exit();
}
// Find the periode of idate
try {
$periode=new Periode($cn);
$periode->find_periode($_POST['idate']);
} catch (Exception $e){
alert(_('Période ou date incorrecte'));
echo create_Script('window.close()');
exit();
}
// if this periode is closed => end
if ($periode->is_open()==0) {
alert(_('Cette période est fermée'));
echo create_Script('window.close()');
exit();
}
try
{
// if the operation is in a closed or centralized period
// the operation is voided thanks the opposite operation
$cn->start();
$grp_new=$cn->get_next_seq('s_grpt');
$seq=$cn->get_next_seq("s_jrn");
$oJrn=new Acc_Ledger($cn,$l_array['jr_def_id']);
$p_internal=$oJrn->compute_internal_code($seq);
$sql= "insert into jrn (
jr_id,jr_def_id,jr_montant,jr_comment,
jr_date,jr_grpt_id,jr_internal
,jr_tech_per, jr_valid
) select $seq,jr_def_id,jr_montant,'Annulation '||jr_comment,
to_date($1,'DD.MM.YYYY'),$grp_new,'$p_internal',
".$periode->p_id.", true
from
jrn
where jr_grpt_id=$2";
$Res=$cn->exec_sql($sql,array($_POST['idate'],$_POST['p_id']));
// Check return code
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
// Make also the change into jrnx
$sql= "insert into jrnx (
j_date,j_montant,j_poste,j_grpt,
j_jrn_def,j_debit,j_text,j_internal,j_tech_user,j_tech_per,j_qcode
) select now(),j_montant,j_poste,$grp_new,
j_jrn_def,not (j_debit),j_text,'$p_internal','".$User->id."',
".$periode->p_id.",j_qcode
from
jrnx
where j_grpt=".$_POST['p_id'];
$Res=$cn->exec_sql($sql);
// Check return code
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
// Mark the operation invalid into the ledger
// to avoid to nullify twice the same op.
$sql="update jrn set jr_comment='Annule : '||jr_comment where jr_grpt_id=".$_POST['p_id'];
$Res=$cn->exec_sql($sql);
// Check return code
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
// Set the record to A (annulate) in quant_sold and quand_purchase
$Res=$cn->exec_sql("update quant_sold set ".
" qs_valid='A' where qs_internal='".$l_array['jr_internal']."'"
);
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
$Res=$cn->exec_sql("update quant_purchase set ".
" qp_valid='A' where qp_internal='".$l_array['jr_internal']."'"
);
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
// Add a "concerned operation to bound these op.together
//
$rec=new Acc_Reconciliation ($cn);
$rec->set_jr_id($seq);
$rec->insert($l_array['jr_id']);
// Check return code
if ( $Res == false ) { throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));}
// the table stock must updated
// also in the stock table
$sql="delete from stock_goods where sg_id = any ( select sg_id
from stock_goods natural join jrnx where j_grpt=".$_POST['p_id'].")";
$Res=$cn->exec_sql($sql);
// Check return code
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
}
catch (Exception $e)
{
$cn->rollback();
$msg="D&eacute;sol&eacute; mais il n a pas &eacute;t&eacute; possible d'annuler ".
"cette op&eacute;ration";
echo "<SCRIPT>alert('$msg');</SCRIPT>";
echo '<span class="error">'.
'Erreur : '.
__FILE__.':'.__LINE__.' '.
$e->getMessage();
echo '<p>';
echo 'Postez ce message sur '.
'<A HREF="http://www.phpcompta.org/pmwiki.php/Forum/Forum">'.
'le forum de www.phpcompta.org</A> '.
'</p>';
$p_id=-1;
exit(-1);
}
$cn->commit();
// close the window
echo '<h2 class="info"> Op&eacute;ration Annul&eacute;e</h2>';
?>
<script>
window.close();
self.opener.RefreshMe();
</script>
<?php
} else {
// operation is not in a closed period
// Check only if a line is valid or not
if ( isValid($cn,$p_id) == 1 ) {
try
{
// Start Sql
$cn->start();
$sql="insert into del_action(del_name,del_time) values ($1,now());";
$cn->exec_sql($sql,array($_SESSION['g_user']));
// Set the record to A (annulate) in quant_sold and quand_purchase
// delete from the rapt table
$sql="delete from jrn_rapt where jr_id = any (select jr_id from jrn ".
" where jr_grpt_id = ".$_POST['p_id'].")";
$Res=$cn->exec_sql($sql);
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
$Res=$cn->exec_sql("delete from quant_sold ".
" where qs_internal='".$l_array['jr_internal']."'"
);
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
$Res=$cn->exec_sql("delete from quant_purchase ".
" where qp_internal='".$l_array['jr_internal']."'"
);
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
if ( isset($l_array['jr_pj']) && $l_array['jr_pj'] != "")
{
$Res=$cn->lo_unlink($l_array['jr_pj']);
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__.
"Echec Effacement lob [ $sql ]"));
}
// delete from the stock table
$sql="delete from stock_goods where sg_id = any ( select sg_id
from stock_goods natural join jrnx where j_grpt=".$_POST['p_id'].")";
$Res=$cn->exec_sql($sql);
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
// delete from CA
$sql="delete from operation_analytique where j_id in (select j_id from";
$sql.=" jrnx where j_grpt=".$_POST['p_id'].")";
$Res=$cn->exec_sql($sql);
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
// delete from jrnx & jrn
$sql="delete from jrnx where j_grpt=".$_POST['p_id'];
$Res=$cn->exec_sql($sql);
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
// build the sql stmt for jrn
$sql= "delete from jrn where jr_grpt_id=".$_POST['p_id'];
$Res=$cn->exec_sql($sql);
if ( $Res == false)
throw (new Exception(__FILE__.__LINE__." sql a echoue [ $sql ]"));
}
catch (Exception $e)
{
$cn->rollback();
$msg="Desole mais il n a pas ete possible d'annuler ".
"cette operation";
echo "<SCRIPT>alert('$msg');</SCRIPT>";
echo '<span class="error">'.
'Erreur : '.
__FILE__.':'.__LINE__.' '.
$e->getMessage();
echo '<p>';
echo 'Postez ce message sur '.
'<A HREF="http://www.phpcompta.org/pmwiki.php/Forum/Forum">'.
'le forum de www.phpcompta.org</A> '.
'</p>';
$p_id=-1;
exit(-1);
}
$cn->commit();
echo '<h2 class="info"> Op&eacute;ration Annul&eacute;e</h2>';
?>
<script>
window.close();
self.opener.RefreshMe();
</script>
<?php
}// if isValid
} // else if period is closed
}//B p_id == -1
} // if Post['p_id']
}//confirm
//}// if annul
echo '<div align="center"> Op&eacute;ration '.$l_array['jr_internal'].'</div>
<div>
<form action="'.$_SERVER['REQUEST_URI'].'" method="post" >';
$a=new IText();
$a->setReadOnly(false);
echo '<div style="border-style:solid;border-width:1pt;">';
$a->size=40;
echo 'Description :'.$a->input("comment",$e_comment);
echo '</DIV>';
if ( isset ($e_ech) ) {
echo "<DIV> Echeance $e_ech </DIV>";
}
echo '<table width="95%">';
for ( $i = 0; $i < $max_deb;$i++) {
echo '<tr style="background-color:#BFC2D5;">';
if ( ${"e_qcode_deb".$i} == "-" ) {
$poste=new Acc_Account($cn,${"e_class_deb$i"});
$lib=$poste->get_lib();
} else {
$fiche=new Fiche($cn);
$fiche->get_by_qcode(${"e_qcode_deb".$i},false);
$lib=$fiche->getName();
}
echo td(${"e_class_deb$i"}).td(${"e_qcode_deb".$i}).td($lib).td("<B>".${"e_mont_deb$i"}."</B>").td(_('Débit'));
echo '</tr>';
}
for ( $i = 0; $i < $max_cred;$i++) {
if ( ${"e_qcode_cred".$i} == "-" ) {
$poste=new Acc_Account($cn,${"e_class_cred$i"});
$lib=$poste->get_lib();
} else {
$fiche=new Fiche($cn);
$fiche->get_by_qcode(${"e_qcode_cred".$i},false);
$lib=$fiche->getName();
}
echo '<tr>';
echo td(${"e_class_cred$i"}).td(${"e_qcode_cred".$i}).td($lib).td("<B>".${"e_mont_cred$i"}."</B>").td(_('Crédit'));
echo '</tr>';
}
echo '</table>';
/* concerned operation */
$rec=new Acc_Reconciliation($cn);
$rec->set_jr_id($e_jr_id);
$a=$rec->get();
if ( $a != null ) {
foreach ($a as $key => $element) {
echo "operation concern&eacute;e <br>";
$operation=new Acc_Operation($cn);
$operation->jr_id=$element;
$w=new IButton();
$w->label=$operation->get_internal();
$w->javascript="modifyOperation('".$element."',".dossier::id().
','.$_REQUEST['p_jrn'].",'S')";
echo $w->input().'<br>';
}//for
}// if ( $a != null ) {
echo dossier::hidden().
'
<input type="hidden" name="p_id" value="'.$_GET['jrn_op'].'">
<input type="submit" class="button" name="annul" value="Mise &agrave; z&eacute;ro ou effacement">
<input type="button" class="button" name="cancel" value="Retour" onClick="window.close();">
</form>';
html_page_stop();
?>

View file

@ -1,345 +0,0 @@
<?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
*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision*/
/*! \file
* \brief show a detailled operation in a popup window
* Update : add a document , change the comment, the concerned op....
*
*/
include_once ("ac_common.php");
include_once("user_common.php");
require_once('class_database.php');
include_once("jrn.php");
require_once ("constant.php");
require_once('class_acc_reconciliation.php');
require_once('class_acc_operation.php');
echo js_include('scripts.js');
echo js_include('prototype.js');
echo js_include('anc_script.js');
/* Admin. Dossier */
$gDossier=dossier::id();
$cn=new Database($gDossier);
include_once ("class_user.php");
$User=new User($cn);
$User->Check();
$User->check_dossier(dossier::id());
html_page_start($User->theme,"onLoad='window.focus();'");
require_once('class_dossier.php');
$acc=new Acc_Operation($cn);
if (isset($_REQUEST['line']))
$acc->jr_id=$_REQUEST ['line'];
else
$acc->jr_id=$_REQUEST ['jr_id'];
$p_jrn=$acc->get_ledger();
if ( isset ( $_GET['action'] ) ) {
$action=$_GET['action'];
}
$p_view=(isset($_REQUEST['p_view']))?$_REQUEST['p_view']:"error";
if ( isset ( $_REQUEST['action'] ) ) {
$action=$_REQUEST['action'];
}
if ( ! isset ( $action )) {
echo_error("modify_op.php No action asked ");
exit();
}
// Javascript
echo JS_LEDGER;
?>
<script language="javascript">
function show_div (p_div) {
// show the div
// hide the div
if ( document.getElementById(p_div) ) {
var a=document.getElementById(p_div);
a.style.display="block";
}
}
function hide_div (p_div) {
// hide the div
if ( document.getElementById(p_div) ) {
var a=document.getElementById(p_div);
a.style.display="none";
}
}
</script>
<?php
//-----------------------------------------------------
if ( $action == 'update' ) {
if ( $User->check_jrn($p_jrn) =='X' ) {
echo ' <script> window.close();</script>';
NoAccess();
exit -1;
}
// p_id is jrn.jr_id
$p_id=$_GET["line"];
$view='<h2 class="error">Erreur vue inconnue</h2>';
// show the detailled operation
if ( $p_view == 'S' )
$view='<div id="simple">';
else
$view='<div id="simple" style="display:none">';
$view.='<h2 class="info2">Vue simple</h2>';
$view.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="modify_op.php">';
$view.=dossier::hidden();
$readonly=($p_view=='E')?0:1;
$view.=ShowOperationUser($cn,$p_id,$readonly);
$view.='<hr>';
$view.='<input type="button" class="button" onclick="hide_div(\'simple\');show_div(\'expert\');" value="Vue expert">';
$view.='<INPUT TYPE="Hidden" name="action" value="update_record">';
$view.="<br>";
$view.="<br>";
$view.="<br>";
if ( $User->check_jrn($p_jrn) == 'W')
$view.=($p_view == 'S')?HtmlInput::submit('update_record','Enregistre'):'';
$view.="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$view.='<input type="button" class="button" value="Fermer" onClick="window.close(); ">';
$view.='</FORM>';
$view.='</div>';
if ( $p_view == 'S' )
$view.='<div id="expert" style="display:none">';
else
$view.='<div id="expert" style="display:block">';
$view.='<h2 class="info2">Vue expert</h2>';
$view.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="modify_op.php">';
$view.=dossier::hidden();
$readonly=($p_view=='S')?0:1;
$view.=ShowOperationExpert($cn,$p_id,$readonly);
$view.='<hr>';
$view.='<input type="button" class="button" onclick="hide_div(\'expert\');show_div(\'simple\')" value="Vue simple">';
$view.='<INPUT TYPE="Hidden" name="action" value="update_record">';
$view.="<br>";
$view.="<br>";
$view.="<br>";
if ( $User->check_jrn($p_jrn) == 'W')
$view.=($p_view == 'E') ?HtmlInput::submit('update_record','Enregistre'):'';
$view.="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$view.='<input type="button" class="button" value="Fermer" onClick="window.close(); ">';
$view.='</div>';
echo $view;
}
//---------------------------------------------------------------------
// action = vue ca
//---------------------------------------------------------------------
if ( $action=="view_ca") {
/*!\todo add security here */
$p_id=$_GET["line"];
$view='<div id="simple">';
$view.='<h2 class="info2">Vue simple</h2>';
$view.=ShowOperationUser($cn,$p_id,0);
$view.='<hr>';
$view.='<input type="button" class="button" onclick="hide_div(\'simple\');show_div(\'expert\');" value="Vue Expert">';
$view.='<input type="button" class="button" value="Fermer" onClick="window.close(); ">';
$view.='</div>';
$view.='<div id="expert" style="display:none">';
$view.='<h2 class="info2">Vue expert</h2>';
$view.=ShowOperationExpert($cn,$p_id,0);
$view.='<hr>';
$view.='<input type="button" class="button" onclick="hide_div(\'expert\');show_div(\'simple\')" value="Vue Simple">';
$view.='<input type="button" class="button" value="Fermer" onClick="window.close(); ">';
$view.='</div>';
echo $view;
exit();
}
//----------------------------------------------------------------------
// update the record and upload files
//----------------------------------------------------------------------
if ( isset($_POST['update_record']) ) {
/* in what ledger are we working */
$acc=new Acc_Operation($cn);
$acc->jr_id=$_POST['jr_id'];
$l=$acc->get_ledger();
if ( $User->check_jrn($l) != 'W' ) {
echo ' <script> window.close();</script>';
NoAccess();
exit -1;
}
try {
// NO UPDATE except rapt & comment && upload pj && PJ Number
$cn->start();
$acc=new Acc_Operation($cn);
$acc->jr_id=$_POST['jr_id'];
/* set the pj */
$acc->pj=$_POST['pj']; $acc->set_pj();
$acc->operation_update_comment($_POST['comment']);
$acc->operation_update_date_limit($_POST['e_ech']);
/* insert now the grouping */
if ( trim($_POST['rapt']) != "" ) {
$rec=new Acc_Reconciliation ($cn);
$rec->set_jr_id($_POST['jr_id']);
if ( strpos($_POST['rapt'],',') != 0 )
{
$aRapt=explode(',',$_POST['rapt']);
/* reconcialition */
foreach ($aRapt as $rRapt) {
if ( isNumber($rRapt) == 1 )
{
// Add a "concerned operation to bound these op.together
//
$rec->insert($rRapt);
}
}
} else
if ( isNumber($_POST['rapt']) == 1 )
{
$rec->insert($_POST['rapt']);
}
}
if ( isset ($_FILES)) {
$cn->save_upload_document($_POST['jr_grpt_id']);
}
if ( isset ($_POST['is_paid'] ))
$Res=$cn->exec_sql("update jrn set jr_rapt='paid' where jr_id=$1",array($_POST['jr_id']));
if ( isset ($_POST['to_remove'] )) {
/*! \note we don't remove the document file if another
* operation needs it.
*/
$ret=$cn->exec_sql("select jr_pj from jrn where jr_id=$1",array($_POST['jr_id']));
if (Database::num_row($ret) != 0) {
$r=Database::fetch_array($ret,0);
$old_oid=$r['jr_pj'];
if (strlen($old_oid) != 0)
{
// check if this pj is used somewhere else
$c=$cn->count_sql("select * from jrn where jr_pj=".$old_oid);
if ( $c == 1 )
$cn->lo_unlink($old_oid);
}
$cn->exec_sql("update jrn set jr_pj=null, jr_pj_name=null, ".
"jr_pj_type=null where jr_id=$1",array($_POST['jr_id']));
}
}
//-------------------------------------
// CA
//------------------------------------
$own = new Own($cn);
if ( $own->MY_ANALYTIC != "nu" )
{
// Check the total only for mandatory
//
// 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];
}
if ( $tot_tab != $_POST['amount_t'.$tab]) {
echo '<script>alert ("Erreur montant dans Comptabilite analytique\n Operation annulee")</script>';
redirect($_SERVER['HTTP_REFERER']);
return;
}
$tot_tab=0;
$tab++;
}
// }
// we need first old the j_id and j_poste
// so we fetch them all from the db
$sql="select j_id,j_poste,to_char(j_date,'DD.MM.YYYY') as j_date,j_debit ".
"from jrn join jrnx on (j_grpt=jr_grpt_id) ".
"where jr_id=$1";
$res=$cn->exec_sql($sql,array($_POST['jr_id']));
$array_jid=Database::fetch_all($res);
// if j_poste match 6 or 7 we insert them
$count=0;
$group=$cn->get_next_seq("s_oa_group");
foreach( $array_jid as $row_ca) {
if ( myereg("^[6,7]+",$row_ca['j_poste'])) {
$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'];
$op->oa_date=$row_ca['j_date'];
$op->oa_group=$group;
$op->oa_description=$_POST['comment'];
$op->save_form_plan($_POST,$count);
$count++;
} //if myereg
}//foreach
}// if ( $own->MY_ANALYTIC != "nu" )
} catch (Exception $e) {
echo '<span class="error">'.
'Erreur dans l\'enregistrement '.
__FILE__.':'.__LINE__.' '.
$e->getMessage();
$cn->rollback();
exit();
}
$cn->commit();
echo ' <script>
window.close();
self.opener.RefreshMe();
</script>';
} // if update_record
//-----------------------------------------------------
if ( $action == 'delete' ) {
$rec=new Acc_Reconciliation ($cn);
$rec->set_jr_id($_GET ['line']);
$rec->remove($_GET['line2']);
echo ' <script>
window.close();
self.opener.RefreshMe();
</script>';
}
html_page_stop();
?>

View file

@ -1,345 +0,0 @@
<?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
*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision*/
/*! \file
* \brief show a detailled operation in a popup window
* Update : add a document , change the comment, the concerned op....
*
*/
include_once ("ac_common.php");
include_once("user_common.php");
require_once('class_database.php');
include_once("jrn.php");
require_once ("constant.php");
require_once('class_acc_reconciliation.php');
require_once('class_acc_operation.php');
echo js_include('scripts.js');
echo js_include('prototype.js');
echo js_include('anc_script.js');
/* Admin. Dossier */
$gDossier=dossier::id();
$cn=new Database($gDossier);
include_once ("class_user.php");
$User=new User($cn);
$User->Check();
$User->check_dossier(dossier::id());
html_page_start($User->theme,"onLoad='window.focus();'");
require_once('class_dossier.php');
$acc=new Acc_Operation($cn);
if (isset($_REQUEST['line']))
$acc->jr_id=$_REQUEST ['line'];
else
$acc->jr_id=$_REQUEST ['jr_id'];
$p_jrn=$acc->get_ledger();
if ( isset ( $_GET['action'] ) ) {
$action=$_GET['action'];
}
$p_view=(isset($_REQUEST['p_view']))?$_REQUEST['p_view']:"error";
if ( isset ( $_REQUEST['action'] ) ) {
$action=$_REQUEST['action'];
}
if ( ! isset ( $action )) {
echo_error("modify_op.php No action asked ");
exit();
}
// Javascript
echo JS_LEDGER;
?>
<script language="javascript">
function show_div (p_div) {
// show the div
// hide the div
if ( document.getElementById(p_div) ) {
var a=document.getElementById(p_div);
a.style.display="block";
}
}
function hide_div (p_div) {
// hide the div
if ( document.getElementById(p_div) ) {
var a=document.getElementById(p_div);
a.style.display="none";
}
}
</script>
<?php
//-----------------------------------------------------
if ( $action == 'update' ) {
if ( $User->check_jrn($p_jrn) =='X' ) {
echo ' <script> window.close();</script>';
NoAccess();
exit -1;
}
// p_id is jrn.jr_id
$p_id=$_GET["line"];
$view='<h2 class="error">Erreur vue inconnue</h2>';
// show the detailled operation
if ( $p_view == 'S' )
$view='<div id="simple">';
else
$view='<div id="simple" style="display:none">';
$view.='<h2 class="info2">Vue simple</h2>';
$view.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="modify_op.php">';
$view.=dossier::hidden();
$readonly=($p_view=='E')?0:1;
$view.=ShowOperationUser($cn,$p_id,$readonly);
$view.='<hr>';
$view.='<input type="button" class="button" onclick="hide_div(\'simple\');show_div(\'expert\');" value="Vue expert">';
$view.='<INPUT TYPE="Hidden" name="action" value="update_record">';
$view.="<br>";
$view.="<br>";
$view.="<br>";
if ( $User->check_jrn($p_jrn) == 'W')
$view.=($p_view == 'S')?HtmlInput::submit('update_record','Enregistre'):'';
$view.="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$view.='<input type="button" class="button" value="Fermer" onClick="window.close(); ">';
$view.='</FORM>';
$view.='</div>';
if ( $p_view == 'S' )
$view.='<div id="expert" style="display:none">';
else
$view.='<div id="expert" style="display:block">';
$view.='<h2 class="info2">Vue expert</h2>';
$view.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="modify_op.php">';
$view.=dossier::hidden();
$readonly=($p_view=='S')?0:1;
$view.=ShowOperationExpert($cn,$p_id,$readonly);
$view.='<hr>';
$view.='<input type="button" class="button" onclick="hide_div(\'expert\');show_div(\'simple\')" value="Vue simple">';
$view.='<INPUT TYPE="Hidden" name="action" value="update_record">';
$view.="<br>";
$view.="<br>";
$view.="<br>";
if ( $User->check_jrn($p_jrn) == 'W')
$view.=($p_view == 'E') ?HtmlInput::submit('update_record','Enregistre'):'';
$view.="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$view.='<input type="button" class="button" value="Fermer" onClick="window.close(); ">';
$view.='</div>';
echo $view;
}
//---------------------------------------------------------------------
// action = vue ca
//---------------------------------------------------------------------
if ( $action=="view_ca") {
/*!\todo add security here */
$p_id=$_GET["line"];
$view='<div id="simple">';
$view.='<h2 class="info2">Vue simple</h2>';
$view.=ShowOperationUser($cn,$p_id,0);
$view.='<hr>';
$view.='<input type="button" class="button" onclick="hide_div(\'simple\');show_div(\'expert\');" value="Vue Expert">';
$view.='<input type="button" class="button" value="Fermer" onClick="window.close(); ">';
$view.='</div>';
$view.='<div id="expert" style="display:none">';
$view.='<h2 class="info2">Vue expert</h2>';
$view.=ShowOperationExpert($cn,$p_id,0);
$view.='<hr>';
$view.='<input type="button" class="button" onclick="hide_div(\'expert\');show_div(\'simple\')" value="Vue Simple">';
$view.='<input type="button" class="button" value="Fermer" onClick="window.close(); ">';
$view.='</div>';
echo $view;
exit();
}
//----------------------------------------------------------------------
// update the record and upload files
//----------------------------------------------------------------------
if ( isset($_POST['update_record']) ) {
/* in what ledger are we working */
$acc=new Acc_Operation($cn);
$acc->jr_id=$_POST['jr_id'];
$l=$acc->get_ledger();
if ( $User->check_jrn($l) != 'W' ) {
echo ' <script> window.close();</script>';
NoAccess();
exit -1;
}
try {
// NO UPDATE except rapt & comment && upload pj && PJ Number
$cn->start();
$acc=new Acc_Operation($cn);
$acc->jr_id=$_POST['jr_id'];
/* set the pj */
$acc->pj=$_POST['pj']; $acc->set_pj();
$acc->operation_update_comment($_POST['comment']);
$acc->operation_update_date_limit($_POST['e_ech']);
/* insert now the grouping */
if ( trim($_POST['rapt']) != "" ) {
$rec=new Acc_Reconciliation ($cn);
$rec->set_jr_id($_POST['jr_id']);
if ( strpos($_POST['rapt'],',') != 0 )
{
$aRapt=explode(',',$_POST['rapt']);
/* reconcialition */
foreach ($aRapt as $rRapt) {
if ( isNumber($rRapt) == 1 )
{
// Add a "concerned operation to bound these op.together
//
$rec->insert($rRapt);
}
}
} else
if ( isNumber($_POST['rapt']) == 1 )
{
$rec->insert($_POST['rapt']);
}
}
if ( isset ($_FILES)) {
$cn->save_upload_document($_POST['jr_grpt_id']);
}
if ( isset ($_POST['is_paid'] ))
$Res=$cn->exec_sql("update jrn set jr_rapt='paid' where jr_id=$1",array($_POST['jr_id']));
if ( isset ($_POST['to_remove'] )) {
/*! \note we don't remove the document file if another
* operation needs it.
*/
$ret=$cn->exec_sql("select jr_pj from jrn where jr_id=$1",array($_POST['jr_id']));
if (Database::num_row($ret) != 0) {
$r=Database::fetch_array($ret,0);
$old_oid=$r['jr_pj'];
if (strlen($old_oid) != 0)
{
// check if this pj is used somewhere else
$c=$cn->count_sql("select * from jrn where jr_pj=".$old_oid);
if ( $c == 1 )
$cn->lo_unlink($old_oid);
}
$cn->exec_sql("update jrn set jr_pj=null, jr_pj_name=null, ".
"jr_pj_type=null where jr_id=$1",array($_POST['jr_id']));
}
}
//-------------------------------------
// CA
//------------------------------------
$own = new Own($cn);
if ( $own->MY_ANALYTIC != "nu" )
{
// Check the total only for mandatory
//
// 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];
}
if ( $tot_tab != $_POST['amount_t'.$tab]) {
echo '<script>alert ("Erreur montant dans Comptabilite analytique\n Operation annulee")</script>';
redirect($_SERVER['HTTP_REFERER']);
return;
}
$tot_tab=0;
$tab++;
}
// }
// we need first old the j_id and j_poste
// so we fetch them all from the db
$sql="select j_id,j_poste,to_char(j_date,'DD.MM.YYYY') as j_date,j_debit ".
"from jrn join jrnx on (j_grpt=jr_grpt_id) ".
"where jr_id=$1";
$res=$cn->exec_sql($sql,array($_POST['jr_id']));
$array_jid=Database::fetch_all($res);
// if j_poste match 6 or 7 we insert them
$count=0;
$group=$cn->get_next_seq("s_oa_group");
foreach( $array_jid as $row_ca) {
if ( myereg("^[6,7]+",$row_ca['j_poste'])) {
$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'];
$op->oa_date=$row_ca['j_date'];
$op->oa_group=$group;
$op->oa_description=$_POST['comment'];
$op->save_form_plan($_POST,$count);
$count++;
} //if myereg
}//foreach
}// if ( $own->MY_ANALYTIC != "nu" )
} catch (Exception $e) {
echo '<span class="error">'.
'Erreur dans l\'enregistrement '.
__FILE__.':'.__LINE__.' '.
$e->getMessage();
$cn->rollback();
exit();
}
$cn->commit();
echo ' <script>
window.close();
self.opener.RefreshMe();
</script>';
} // if update_record
//-----------------------------------------------------
if ( $action == 'delete' ) {
$rec=new Acc_Reconciliation ($cn);
$rec->set_jr_id($_GET ['line']);
$rec->remove($_GET['line2']);
echo ' <script>
window.close();
self.opener.RefreshMe();
</script>';
}
html_page_stop();
?>

View file

@ -1,821 +0,0 @@
<?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
*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
/*! \file
* \brief work with the ledger
*/
require_once("class_itext.php");
require_once("class_ifile.php");
require_once("class_ihidden.php");
require_once('class_fiche.php');
require_once ('class_gestion_sold.php');
require_once ('class_gestion_purchase.php');
require_once ('class_anc_plan.php');
require_once ('class_anc_operation.php');
require_once ('class_acc_ledger.php');
require_once ('class_acc_operation.php');
require_once ('class_acc_ledger_info.php');
require_once('class_acc_reconciliation.php');
require_once('class_own.php');
/*!
* \brief Display the form to UPDATE account operation in the expert view
*
* \param $p_cn database connection
* \param $jr_id pk of jrn
* \param mode 1 editable, 0 for CA
*
* \return none
*
*
*/
function deprecated_ShowOperationExpert($p_cn,$p_jr_id,$p_mode=1)
{
// own
$own=new own($p_cn);
$gDossier=dossier::id();
$l_array=get_dataJrnJrId($p_cn,$p_jr_id);
if ( $l_array == null ) {
echo_error ("Not data found for UpdateJrn p_jr_id = $p_jr_id");
return ;
}
// Javascript
$r=JS_LEDGER;
// Build the form
$col_vide="<TD></TD>";
$disable=($p_mode==0)?"disabled":"";
$str_dossier=dossier::get();
$count=0;
for ( $i =0 ; $i < sizeof($l_array); $i++) {
$content=$l_array[$i] ;
// for the first line
if ( $i == 0 ) {
$r.="<TABLE>";
$r.="<TR>";
// Date
$r.="<TD><h3>";
$r.=$content['jr_date'];
$r.="</h3></TD>";
// Internal
$r.="<TD><h3>";
$r.=$content['jr_internal'];
$r.="</h3></TD>";
$r.='</tr>';
// for upload document we need the grpt_id
$r.='<Input type="hidden" name="jr_grpt_id" value="'.$content['jr_grpt_id'].'">';
// comment can be changed
$r.="<TD>";
$comment=new IText();
$comment->table=0;
$comment->name="comment";
$comment->readonly=($p_mode==0)?true:false;
$comment->value=$content['jr_comment'];
$comment->size=40;
$r.=$comment->input();
$r.="</TD>";
// pj can be changed
$r.="<TD> PJ Num. ";
$comment=new IText();
$comment->table=0;
$comment->name="pj";
$comment->readonly=($p_mode==0)?true:false;
$comment->value=$content['jr_pj_number'];
$comment->size=10;
$r.=$comment->input();
$r.="</TD>";
if ( $content['jrn_def_type'] == 'ACH' or
$content['jrn_def_type'] == 'VEN' )
{
// Is Paid
$r.="<TD>";
$check=( $content['jr_rapt'] != null )?"CHECKED":"UNCHECKED";
$r.='<TD>Payé <INPUT TYPE="CHECKBOX"'.$disable.' name="is_paid" '.$check.'></TD>';
}
$r.="</TR>";
$r.="</TABLE>";
$r.="<TABLE>";
$r.="<tr>";
$r.='<th colspan="2">Postes</th>';
$r.='<th>Description</th>';
$r.='<th>D&eacute;bit</th>';
$r.='<th>Cr&eacute;dit</th>';
$own = new Own($p_cn);
$r.="</tr>";
}
$r.="<TR>";
if ( $content['j_debit'] == 'f' ) $r.=$col_vide;
// $r.="<TD>".$content['j_debit']."</td>";
$r.="<TD>".$content['j_poste']."</td>";
if ( $content['j_debit'] == 't' ) $r.=$col_vide;
$qc=($content['j_qcode'] != "")?" [".$content['j_qcode']."]":"";
if ( $content['j_text'] == '')
$r.="<TD>".$qc.h($content['vw_name'])."</td>";
else
$r.="<TD>".$qc.h($content['j_text'])."</td>";
if ( $content['j_debit'] == 'f' ) $r.=$col_vide;
$r.="<TD>".$content['j_montant']."</td>";
if ( $content['j_debit'] == 't' ) $r.=$col_vide;
//-- add ca
//
if ( $own->MY_ANALYTIC != "nu" && myereg("^[6,7]+",$content['j_poste']))
{
$r.=display_table_ca($p_cn,$count,$content['j_id'],$own,$p_mode,$content['j_montant']);
$count++;
}
$r.="</TR>";
// }// foreach ($l_array[$i] as $value=>$content)
}// for ( $i =0 ; $i < sizeof($l_array); $i++)
if ( $p_mode == 1) {
$file=new IFile();
$file->table=1;
//doc
if ( $content['jr_pj_name'] != "")
$r.='<TD>Effacer PJ <INPUT TYPE="CHECKBOX" name="to_remove" ></TD>';
}
$r.="<TD>".sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s&%s">%s</A>',
$content['jr_id'],
$content['jr_grpt_id'],
$str_dossier,
$content['jr_pj_name']
)."</TD>";
$r.="</TR></TABLE>";
if ( $p_mode == 1 ) {
$r.="<hr>";
$r.='<h2 class="info2">Document</h2>';
$r.= "<table>";
$r.=tr("<TD>Document</td>".$file->input("pj","","Pièce justificative"));
$r.="</table>";
}
$r.="<hr>";
$r.="</table>";
$r.="Total ".$content['jr_montant']."<br>";
/* count the number of additionnal info */
$acc_jrn_info=new Acc_Ledger_Info($p_cn);
$acc_jrn_info->set_jrn_id($p_jr_id);
/* if additional info > 0 show them */
if ( $acc_jrn_info->count() > 0 ) {
$array=$acc_jrn_info->load_all();
foreach ($array as $row) {
if ( strpos($row->id_type,'BON_COMMANDE') ===0) {
$r.="Num bon de commande : ".$row->ji_value.'<br>';
}
if ( strpos($row->id_type,'OTHER') ===0) {
$r.="Autre info : ".$row->ji_value.'<br>';
}
}
}
if ( $p_mode==1) {
// show all the related operation
$rec=new Acc_Reconciliation($p_cn);
$rec->set_jr_id($content['jr_id']);
$a=$rec->get();
if ( $a != null ) {
$r.="<h2 class=\"info2\">Operation concernée</h2> <br>";
$r.= '<div style="margin-left:30px;">';
foreach ($a as $key => $element) {
$operation=new Acc_operation($p_cn);
$operation->jr_id=$element;
$r.=sprintf ('%s <INPUT class="button" TYPE="BUTTON" VALUE="Détail" onClick="modifyOperation(\'%s\',%d)">',
$operation->get_internal($p_cn,$element),
$element,
$gDossier);
$r.=sprintf('<INPUT class="button" TYPE="button" value="Efface" onClick="dropLink(\'%s\',\'%s\',%d)"><BR>',
$content['jr_id'],$element,$gDossier);
}//for
$r.= "</div>";
}// if ( $a != null )
$search='<INPUT TYPE="BUTTON" class="button" VALUE="Cherche" OnClick="SearchJrn('.$gDossier.",'rapt','".$content['jr_montant']."')\">";
$r.= 'Autre rapprochement :
<INPUT TYPE="TEXT" id="rapt" name="rapt" value="">'.$search;
} // if mode == 1
$r.='<input type="hidden" name="jr_id" value="'.$content['jr_id'].'">';
return $r;
}
/*!
* \brief Display the form to UPDATE account operation in the user view
*
* \param $p_cn database connection
* \param $jr_id pk of jrn
* \param mode 1 editable, 0 for CA
*/
function deprecated_ShowOperationUser($p_cn,$p_jr_id,$p_mode=1)
{
$gDossier=dossier::id();
$l_array=get_dataJrnJrIdUser($p_cn,$p_jr_id);
$str_dossier=dossier::get();
/* if the operation doesn't exist in the quant_xxx table then we
* show the expert view
*/
if ( $l_array == null || empty($l_array) == true) {
// If the operation is not in quant_sold or quant_purchase
// because those tables comes later
$r=ShowOperationExpert($p_cn,$p_jr_id,$p_mode);
return $r;
}
// own
$own=new own($p_cn);
// Javascript
$r=JS_LEDGER;
// Build the form
$col_vide="<TD></TD>";
$content=$l_array[0] ;
// for the first line
$internal=$content['jr_internal'];
$r.='<TABLE width="100%">';
$r.="<TR>";
// Date
$r.='<TD ><h3>';
$r.=$content['jr_date'];
$disable=($p_mode==0)?"disabled":"";
$r.='</h3></td>';
// Limit Date
$ech=new IDate('e_ech');
$ech->value=$content['ech_fmt'];
$r.=td(_('Echéance ').$ech->input());
// Internal
// --
$r.='<td><h3>';
$r.=$content['jr_internal'];
$r.="</h3></TD>";
// for upload document we need the grpt_id
$r.='<Input type="hidden" name="jr_grpt_id" value="'.$content['jr_grpt_id'].'">';
$r.='</tr><tr>';
// comment can be changed
$comment=new IText();
$comment->table=0;
$comment->name="comment";
$comment->readonly=($p_mode==0)?true:false;
$comment->value=$content['jr_comment'];
$comment->size=40;
$r.='<td>'.$comment->input().'</td>';
// pj can be changed
$r.="<TD> PJ Num. ";
$comment=new IText();
$comment->table=0;
$comment->name="pj";
$comment->readonly=($p_mode==0)?true:false;
$comment->value=$content['jr_pj_number'];
$comment->size=10;
$r.=$comment->input();
$r.="</TD>";
// Is Paid
$r.="<TD>";
$check=( $content['jr_rapt'] != null )?"CHECKED":"UNCHECKED";
$r.='<TD>Payé <INPUT TYPE="CHECKBOX" '.$disable.' name="is_paid" '.$check.'></TD>';
$r.="</TR>";
// for others lines
$own=new Own($p_cn);
// for purchase ledger
if ( $content['jrn_def_type'] == 'ACH' )
{
$r.='</table>';
$r.='<table width="100%">';
$client=new Fiche($p_cn,$content['qp_supplier']);
$r.="Client : ".$client->getName();
/* now we get the different lines for this operation thanks */
/* the qp_internal == jr_internal */
$r.='<tr>';
$r.='<th>Nom</th>';
$r.='<th>PU</th>';
$r.='<th>Quantit&eacute;</th>';
$r.='<th> Dep. priv. </th>';
if ( $own->MY_TVA_USE=='Y') {
$r.='<th>tva</th>';
$r.='<th>tva</th>';
$r.='<th>non ded.</th>';
$r.='<th>tva nd</th>';
$r.='<th>tva d impot</th>';
$r.='<th>total htva</th>';
$r.='<th>total tvac</th>';
} else
$r.='<th>total</th>';
$r.='</tr>';
$object=new gestion_purchase($p_cn);
$object->qp_internal=$internal;
$array=$object->get_list();
$tot_tva=0.0;
$tot_amount=0.0;
$tot_nd=0.0;
$tot_tva_nd=0.0;
$tot_tva_nd_recup=0.0;
$tot_dep_priv=0.0;
$i=0;
$i_march=0;
foreach ($array as $row) {
$fiche=new Fiche($p_cn,$row->qp_fiche);
// compute sum
$tot_tva+=$row->qp_vat;
$tot_nd+=$row->qp_nd_amount;
$tot_tva_nd+=$row->qp_nd_tva;
$tot_tva_nd_recup+=$row->qp_nd_tva_recup;
$tot_amount+=$row->qp_price;
$tot_dep_priv+=$row->qp_dep_priv;
// $hid_jid=new IHidden("","p_jid_".$row->j_id,$row->j_id);
$r.=($i%2==0)?"<tr class=\"odd\">":'<tr>'; $i++;
$pu=0.0;
if ( $row->qp_price != 0.0 && $row->qp_price != 0 )
$pu=round(($row->qp_nd_amount+$row->qp_price)/$row->qp_quantite,2);
$r.='<td> '.$fiche->strAttribut(ATTR_DEF_NAME).'</td>';
$r.='<tD>'.$pu.'</td>';
$r.='<td align="right">'.$row->qp_quantite.'</td>';
$r.='<td align="right">'.$row->qp_dep_priv.'</td>';
// do not show TVA field if we don't use them
if ($own->MY_TVA_USE == 'Y' ) {
$r.='<td align="right">'.$row->qp_vat.'</td>';
$r.='<td>'.$row->tva_label.'</td>';
$r.='<td>'.$row->qp_nd_amount.'</td>';
$r.='<td>'.$row->qp_nd_tva.'</td>';
$r.='<td>'.$row->qp_nd_tva_recup.'</td>';
}
$r.='<td align="right">'.sprintf("% 12.2f",$row->qp_price).'</td>';
$r.='<td align="right">'.sprintf("% 12.2f",$row->qp_vat+$row->qp_nd_amount+$row->qp_nd_tva+$row->qp_nd_tva_recup+$row->qp_price).'</td>';
//-- add ca
//
$content['j_poste']=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
// echo "j_poste= ".$content['j_poste'];
if ( $own->MY_ANALYTIC != "nu" && myereg("^[6,7]+",$content['j_poste']))
{
$r.=display_table_ca($p_cn,$i_march,$row->j_id,$own,$p_mode,round($tot_amount,2));
$i_march++;
}
}
// display sum
$r.='<tr><td colspan="8"><hr style="color:blue;"></td></tr>';
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total HTVA</td>'.
'<td style="text-align:right">'.sprintf('% 12.2f',$tot_amount)."</td>".
"</tr>";
if ( $tot_tva != 0 )
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total TVA</td>'.
'<td style="text-align:right;">'.sprintf('%12.2f',$tot_tva)
."</td>".
"</tr>";
if ( $tot_nd !=0 )
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total nd </td>'.
'<td style="font-size:13px;text-align:right;color:green;">'.sprintf('%12.2f',$tot_nd)."</td>".
"</tr>";
if ( $tot_tva_nd !=0 )
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total tva nd</td>'.
'<td style="font-size:13px;text-align:right;color:green;">'.sprintf('%12.2f',$tot_tva_nd)."</td>".
"</tr>";
if ( $tot_tva_nd_recup !=0 )
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total tva nd recup. par impot</td>'.
'<td style="font-size:13px;text-align:right;color:green;">'.sprintf('%12.2f',$tot_tva_nd_recup)."</td>".
"</tr>";
if ( $tot_dep_priv !=0 )
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total tva nd recup. par impot</td>'.
'<td style="font-size:13px;text-align:right;color:green;">'.sprintf('%12.2f',$tot_dep_priv)."</td>".
"</tr>";
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total </td>'.
'<td style="font-size:13px;text-align:right;color:green;">'.sprintf('%12.2f',$tot_dep_priv+$tot_amount+$tot_tva+$tot_tva_nd_recup+$tot_nd+$tot_tva_nd)."</td>".
"</tr>";
}
// for selling ledger
if ( $content['jrn_def_type'] == 'VEN' )
{
$client=new Fiche($p_cn,$content['qs_client']);
$r.="Client : ".$client->getName();
/* now we get the different lines for this operation thanks */
/* the qs_internal == jr_internal */
$r.'</table>';
$r.='<table width="100%">';
$r.='<tr>';
$r.='<th>Nom</th>';
$r.='<th>PU</th>';
$r.='<th>Quantit&eacute;</th>';
if ($own->MY_TVA_USE == 'Y' ) {
$r.='<th>tva</th>';
$r.='<th>code tva</th>';
}
$r.='<th>prix</th>';
$own = new Own($p_cn);
$r.='</tr>';
$object=new gestion_sold($p_cn);
$object->qs_internal=$internal;
$array=$object->get_list();
$tot_tva=0.0;
$tot_amount=0.0;
$i=0;
$i_march=0;
foreach ($array as $row) {
$fiche=new Fiche($p_cn,$row->qs_fiche);
$tot_tva+=$row->qs_vat;
$tot_amount+=$row->qs_price;
$r.=($i%2==0)?"<tr class=\"odd\">":'<tr>'; $i++;
$pu=0.0;
if ( $row->qs_price != 0.0 && $row->qs_price != 0 ) $pu=round($row->qs_price/$row->qs_quantite,2);
$r.=($i%2==0)?"<tr class=\"odd\">":'<tr>'; $i++;
$r.='<td> '.$fiche->strAttribut(ATTR_DEF_NAME).'</td>';
$r.='<td align="right">'.$pu.'</td>';
$r.='<td align="right">'.$row->qs_quantite.'</td>';
if ($own->MY_TVA_USE == 'Y' ) {
$r.='<td align="right">'.$row->qs_vat.'</td>';
$r.='<td align="center">'.$row->tva_label.'</td>';
}
$r.='<td align="right">'.$row->qs_price.'</td>';
//-- add ca
//
$content['j_poste']=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
// echo "j_poste= ".$content['j_poste'];
if ( $own->MY_ANALYTIC != "nu" && myereg("^[6,7]+",$content['j_poste']))
{
$r.=display_table_ca($p_cn,$i_march,$row->j_id,$own,$p_mode,round($row->qs_price,2));
}
$i_march++;
}
$r.='</table>';
$r.='<hr>';
if ($own->MY_TVA_USE == 'Y' ) {
$r.='<table>';
$r.="<tr>".
"<td>"."</td>".
"<td>"."</td>".
"<td>"."</td>".
"<td>Total HTVA</td>".
'<td style="text-align:right;font-size:13px;color:green;">'.sprintf('% 12.2f',$tot_amount)."</td>".
"</tr>";
$r.="<tr>".
"<td>"."</td>".
"<td>"."</td>".
"<td>"."</td>".
"<td>Total TVA</td>".
'<td style="text-align:right;font-size:13px;color:green;">'.sprintf('%12.2f',$tot_tva)
."</td>".
"</tr>";
$r.="<tr>".
"<td>"."</td>".
"<td>"."</td>".
"<td>"."</td>".
"<td>Total </td>".
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_amount+$tot_tva)."</td>".
"</tr>";
} else {
$r.='<table>';
$r.="<tr>".
"<td>"."</td>".
"<td>Total </td>".
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_amount+$tot_tva)."</td>".
"</tr>";
}
}
$r.="</TABLE>";
$file=new IFile();
$file->table=1;
//doc
if ( $p_mode ==1 && $content['jr_pj_name'] != "")
$r.='<tr><TD>Effacer Pj <INPUT TYPE="CHECKBOX" name="to_remove" ></TD>';
$r.="<TD>".sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s&'.$str_dossier.'">%s</A>',
$content['jr_id'],
$content['jr_grpt_id'],
$content['jr_pj_name'])."</TD>";
$r.="</TR></TABLE>";
/* count the number of additionnal info */
$acc_jrn_info=new Acc_Ledger_Info($p_cn);
$acc_jrn_info->set_jrn_id($p_jr_id);
/* if additional info > 0 show them */
if ( $acc_jrn_info->count() > 0 ) {
$array=$acc_jrn_info->load_all();
foreach ($array as $row) {
if ( strpos($row->id_type,'BON_COMMANDE') ===0) {
$r.="Num bon de commande : ".$row->ji_value.'<br>';
}
if ( strpos($row->id_type,'OTHER') ===0) {
$r.="Autre info : ".$row->ji_value.'<br>';
}
}
}
$r.="<hr>";
if ( $p_mode == 1 ) {
$r.='<h2 class="info2">Document</h2>';
$r.= "<table>";
$r.=tr($file->input("pj","","Pièce justificative"));
$r.="</table>";
$r.="<hr>";
$r.="</table>";
$r.="Total ".$content['jr_montant']."<br>";
// show all the related operation
$rec=new Acc_Reconciliation($p_cn);
$rec->set_jr_id($content['jr_id']);
$a=$rec->get();
if ( $a != null ) {
$r.="<h2 class=\"info2\">Operation concernée</h2> <br>";
$r.= '<div style="margin-left:30px;">';
foreach ($a as $key => $element) {
$operation=new Acc_operation($p_cn);
$operation->jr_id=$element;
$r.=sprintf ('%s <INPUT TYPE="BUTTON" class="button" VALUE="Détail" onClick="modifyOperation(\'%s\',%d)">',
$operation->get_internal(),
$element,
$gDossier);
$r.=sprintf('<INPUT TYPE="button" class="button" value="Efface" onClick="dropLink(\'%s\',\'%s\',%d)"><BR>',
$content['jr_id'],$element,$gDossier);
}//for
$r.= "</div>";
}// if ( $a != null )
$search='<INPUT TYPE="BUTTON" class="button" VALUE="Cherche" OnClick="SearchJrn('.$gDossier.",'rapt','".$content['jr_montant']."')\">";
$r.= 'Autre rapprochement :
<INPUT TYPE="TEXT" id="rapt" name="rapt" value="">'.$search;
} // if p_mode==1
$r.='<input type="hidden" name="jr_id" value="'.$content['jr_id'].'">';
// echo $r;
return $r;
}
/*!
* \brief Get data from jrn and jrnx thanks the jr_id
*
*
* \param connection
* \param p_jr_id (jrn.jr_id)
*
*
* \return array
*
*/
function deprecated_get_dataJrnJrId ($p_cn,$p_jr_id) {
$Res=$p_cn->exec_sql("select
j_text,
j_debit,
j_poste,
pcm_lib,
j_montant,
jr_montant,
j_id,
jr_pj_name,
jr_grpt_id,
jr_comment,
to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
to_char(jr_date,'DD.MM.YYYY') as jr_date,
jr_id,jr_internal, jr_rapt,jrn_def_type,
j_qcode,
jr_pj_number
from
jrnx
inner join jrn on j_grpt=jr_grpt_id
inner join jrn_def on jrn_def.jrn_def_id=jrn.jr_def_id
left outer join tmp_pcmn on j_poste=pcm_val
where
jr_id=$p_jr_id
order by j_debit desc,j_id asc");
$MaxLine=Database::num_row($Res);
if ( $MaxLine == 0 ) return null;
for ( $i=0; $i < $MaxLine; $i++) {
$line=Database::fetch_array($Res,$i);
$array['j_debit']=$line['j_debit'];
// is there a name from this j_qcode
//
if ( strlen( $line['j_qcode']) != 0 )
{
$fiche=new Fiche($p_cn);
$fiche->get_by_qcode($line['j_qcode']);
$array['vw_name']=$fiche->getName();
}
else
{
$array['vw_name']=$line['pcm_lib'];
}
$array['j_text']=$line['j_text'];
$array['jr_comment']=$line['jr_comment'];
$array['j_montant']=$line['j_montant'];
$array['jr_id']=$line['jr_id'];
$array['j_id']=$line['j_id'];
$array['jr_date']=$line['jr_date'];
$array['jr_internal']=$line['jr_internal'];
$array['j_poste']=$line['j_poste'];
$array['jr_montant']=$line['jr_montant'];
$array['jr_rapt']=$line['jr_rapt'];
$array['jrn_def_type']=$line['jrn_def_type'];
$array['jr_grpt_id']=$line['jr_grpt_id'];
$array['jr_pj_name']=$line['jr_pj_name'];
$array['j_qcode']=$line['j_qcode'];
$array['jr_pj_number']=$line['jr_pj_number'];
// $array['']=$line[''];
$ret_array[$i]=$array;
}
return $ret_array;
}
/*!
* \brief Get data from quant_sold or quand_purchase for the user
* view mode
*
*
* \param connection
* \param p_jr_id (jrn.jr_id)
*
*
* \return array or null if there is no value
*
*/
function deprecated_get_dataJrnJrIdUser ($p_cn,$p_jr_id) {
$Res=$p_cn->exec_sql("select ".
"*,to_char(jr_ech,'DD-MM-YYYY') as ech_fmt".
" from quant_sold join jrn on (qs_internal=jr_internal) ".
" join jrn_def on (jr_def_id=jrn_def_id) ".
" inner join jrnx on (j_grpt=jr_grpt_id )".
" join tmp_pcmn on (pcm_val=j_poste)".
" where jr_id=$p_jr_id order by jrnx.j_id");
$MaxLine=Database::num_row($Res);
// if no info found in quant_sold try in quant_purchase
if ( $MaxLine == 0 )
{
$Res=$p_cn->exec_sql("select ".
"*,to_char(jr_ech,'DD-MM-YYYY') as ech_fmt".
" from quant_purchase join jrn on (qp_internal=jr_internal)".
" join jrn_def on (jr_def_id=jrn_def_id) ".
" inner join jrnx on (j_grpt=jr_grpt_id) ".
" join tmp_pcmn on (pcm_val=j_poste)".
" where jr_id=$p_jr_id");
$MaxLine=Database::num_row($Res);
if ( $MaxLine == 0 ) return null;
}
for ( $i=0; $i < $MaxLine; $i++) {
$line=Database::fetch_array($Res,$i);
$array['j_debit']=$line['j_debit'];
// is there a name from this j_qcode
//
if ( strlen( $line['j_qcode']) != 0 )
{
$fiche=new Fiche($p_cn);
$fiche->get_by_qcode($line['j_qcode']);
$array['vw_name']=$fiche->getName();
}
else
{
$array['vw_name']=$line['pcm_lib'];
}
if ( isset ($line['qs_client']))
{
/* It is an invoice */
$array['qs_client']=$line['qs_client'];
}
else
{
/* it a purchase */
$array['qp_supplier']=$line['qp_supplier'];
}
$array['jr_comment']=$line['jr_comment'];
$array['j_montant']=$line['j_montant'];
$array['jr_id']=$line['jr_id'];
$array['j_id']=$line['j_id'];
$array['jr_date']=$line['jr_date'];
$array['jr_internal']=$line['jr_internal'];
$array['j_poste']=$line['j_poste'];
$array['jr_montant']=$line['jr_montant'];
$array['jr_rapt']=$line['jr_rapt'];
$array['jrn_def_type']=$line['jrn_def_type'];
$array['jr_grpt_id']=$line['jr_grpt_id'];
$array['jr_pj_name']=$line['jr_pj_name'];
$array['jr_pj_number']=$line['jr_pj_number'];
$array['jrn_ech']=$line['jrn_ech'];
$array['ech_fmt']=$line['ech_fmt'];
// $array['']=$line[''];
$ret_array[$i]=$array;
}
return $ret_array;
}
/*\brief Display a table with analytic accounting in modify_op.php
* (detail of operation )
*\param $p_cn database cnx
*\param $p_seq sequence (nb item)
*\param $p_jid the concerned j_id
*\param $p_own object own
*\param $p_mode readonly or writable
*\param $p_amount amount
*\return string to display
*/
function deprecated_display_table_ca($p_cn,$p_seq,$p_jid,$p_own,$p_mode,$p_amount) {
$op=new Anc_Operation($p_cn);
$array=$op->get_by_jid($p_jid) ;
if ( $array != null ) {
$request=$op->to_request($array,$p_seq);
return "<td>".$op->display_form_plan($request,1,$p_mode,$p_seq,$p_amount)."</td>";
} else {
return '<td>'.$op->display_form_plan(null,1,$p_mode,$p_seq,$p_amount)."</TD>";
}
return "";
}
?>