remove obsolete
This commit is contained in:
parent
c477c9e259
commit
cb2272beb6
19 changed files with 14 additions and 6156 deletions
|
|
@ -1,274 +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
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/*!\file
|
||||
* \brief definition of the class periode
|
||||
*/
|
||||
/*!
|
||||
* \brief For the periode tables parm_periode and jrn_periode
|
||||
*/
|
||||
require_once ('ac_common.php');
|
||||
require_once ('debug.php');
|
||||
require_once ('postgres.php');
|
||||
class Periode {
|
||||
var $cn; /*!< database connection */
|
||||
var $jrn_def_id; /*!< the jr, 0 means all the ledger*/
|
||||
var $p_id; /*!< pk of parm_periode */
|
||||
var $status; /*!< status is CL for closed, OP for
|
||||
open and CE for centralized */
|
||||
function __construct($p_cn) {
|
||||
$this->cn=$p_cn;
|
||||
}
|
||||
function set_jrn($p_jrn) {
|
||||
$this->jrn_def_id=$p_jrn;
|
||||
}
|
||||
function set_periode($pp_id){
|
||||
$this->p_id=$pp_id;
|
||||
}
|
||||
function is_closed() {
|
||||
if ( $this->jrn_def_id != 0 )
|
||||
$sql="select status from jrn_periode ".
|
||||
" where jrn_def_id=".$this->jrn_def_id.
|
||||
" and p_id =".$this->p_id;
|
||||
else
|
||||
$sql="select p_closed as status from parm_periode ".
|
||||
" where ".
|
||||
" p_id =".$this->p_id;
|
||||
$res=ExecSql($this->cn,$sql);
|
||||
$status=pg_fetch_result($res,0,0);
|
||||
echo_debug(__FILE__.':'.__LINE__.'- is_closed','return ',$status);
|
||||
if ( $status == 'CL' || $status=='t' ||$status=='CE')
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
function is_open() {
|
||||
if ( $this->jrn_def_id != 0 )
|
||||
$sql="select status from jrn_periode ".
|
||||
" where jrn_def_id=".$this->jrn_def_id.
|
||||
" and p_id =".$this->p_id;
|
||||
else
|
||||
$sql="select p_closed as status from parm_periode ".
|
||||
" where ".
|
||||
" p_id =".$this->p_id;
|
||||
$res=ExecSql($this->cn,$sql);
|
||||
$status=pg_fetch_result($res,0,0);
|
||||
if ( $status == 'OP' || $status=='f' )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
function is_centralized() {
|
||||
if ( $this->jrn_def_id != 0 )
|
||||
$sql="select status from jrn_periode ".
|
||||
" where jrn_def_id=".$this->jrn_def_id.
|
||||
" and p_id =".$this->p_id;
|
||||
else
|
||||
$sql="select p_centralized as status from parm_periode ".
|
||||
" where ".
|
||||
" p_id =".$this->p_id;
|
||||
$res=ExecSql($this->cn,$sql);
|
||||
$status=pg_fetch_result($res,0,0);
|
||||
if ( $status == 'CE' || $status=='t' )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
function close() {
|
||||
if ( $this->jrn_def_id == 0 ) {
|
||||
ExecSql($this->cn,"update parm_periode set p_closed=true where p_id=".
|
||||
$this->p_id);
|
||||
ExecSql($this->cn,"update jrn_periode set status='CL' ".
|
||||
" where p_id = ".$this->p_id);
|
||||
|
||||
return;
|
||||
}else {
|
||||
ExecSql($this->cn,"update jrn_periode set status='CL' ".
|
||||
" where jrn_def_id=".$this->jrn_def_id." and ".
|
||||
" p_id = ".$this->p_id);
|
||||
/* if all ledgers have this periode closed then synchro with
|
||||
the table parm_periode
|
||||
*/
|
||||
$nJrn=CountSql( $this->cn,"select * from jrn_periode where ".
|
||||
" p_id=".$this->p_id);
|
||||
$nJrnPeriode=CountSql( $this->cn,"select * from jrn_periode where ".
|
||||
" p_id=".$this->p_id." and status='CL'");
|
||||
|
||||
if ( $nJrnPeriode==$nJrn)
|
||||
ExecSql($this->cn,"update parm_periode set p_closed=true where p_id=".$this->p_id);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
function centralized() {
|
||||
if ( $this->jrn_def_id == 0 ) {
|
||||
ExecSql($this->cn,"update parm_periode set p_central=true");
|
||||
return;
|
||||
}else {
|
||||
ExecSql($this->cn,"update jrn_periode set status='CE' ".
|
||||
" where ".
|
||||
" p_id = ".$this->p_id);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
/*!
|
||||
* \brief Show all the periode and their status
|
||||
*
|
||||
* \param $p_cn database connection
|
||||
*
|
||||
* \return nothing
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
function display_form_periode() {
|
||||
$str_dossier=dossier::get();
|
||||
|
||||
if ( $this->jrn_def_id==0 ) {
|
||||
$Res=ExecSql($this->cn,"select p_id,to_char(p_start,'DD.MM.YYYY') as date_start,to_char(p_end,'DD.MM.YYYY') as date_end,p_central,p_closed,p_exercice
|
||||
from parm_periode order by p_start,p_end");
|
||||
$Max=pg_NumRows($Res);
|
||||
echo '<TABLE ALIGN="CENTER">';
|
||||
echo "</TR>";
|
||||
echo '<TH> Date début </TH>';
|
||||
echo '<TH> Date fin </TH>';
|
||||
echo '<TH> Exercice </TH>';
|
||||
echo "</TR>";
|
||||
|
||||
for ($i=0;$i<$Max;$i++) {
|
||||
$l_line=pg_fetch_array($Res,$i);
|
||||
echo '<TR>';
|
||||
echo '<TD ALIGN="CENTER"> '.$l_line['date_start'].'</TD>';
|
||||
echo '<TD ALIGN="CENTER"> '.$l_line['date_end'].'</TD>';
|
||||
echo '<TD ALIGN="CENTER"> '.$l_line['p_exercice'].'</TD>';
|
||||
|
||||
if ( $l_line['p_closed'] == 't' ) {
|
||||
$closed=($l_line['p_central']=='t')?'<TD>Centralisée</TD>':'<TD>Fermée</TD>';
|
||||
$change='<TD></TD>';
|
||||
$remove='<TD></TD>';
|
||||
} else {
|
||||
$closed='<TD class="mtitle">';
|
||||
$closed.='<A class="mtitle" HREF="?p_action=periode&action=closed&p_per='.$l_line['p_id'].'&'.$str_dossier.'"> Cloturer</A>';
|
||||
$change='<TD class="mtitle">';
|
||||
$change.='<A class="mtitle" HREF="?p_action=periode&action=change_per&p_per='.
|
||||
$l_line['p_id']."&p_date_start=".$l_line['date_start'].
|
||||
"&p_date_end=".$l_line['date_end']."&p_exercice=".
|
||||
$l_line['p_exercice']."&$str_dossier\"> Changer</A>";
|
||||
$remove='<TD class="mtitle">';
|
||||
$remove.='<A class="mtitle" HREF="?p_action=periode&action=delete_per&p_per='.
|
||||
$l_line['p_id']."&$str_dossier\"> Efface</A>";
|
||||
|
||||
}
|
||||
echo "$closed";
|
||||
echo $change;
|
||||
|
||||
echo $remove;
|
||||
|
||||
echo '</TR>';
|
||||
|
||||
}
|
||||
echo '<TR> <FORM ACTION="?p_action=periode" METHOD="POST">';
|
||||
echo dossier::hidden();
|
||||
echo '<TD> <INPUT TYPE="text" NAME="p_date_start" SIZE="10"></TD>';
|
||||
echo '<TD> <INPUT TYPE="text" NAME="p_date_end" SIZE="10"></TD>';
|
||||
echo '<TD> <INPUT TYPE="text" NAME="p_exercice" SIZE="10"></TD>';
|
||||
echo '<TD> <INPUT TYPE="SUBMIT" NAME="add_per" Value="Ajout"</TD>';
|
||||
echo '<TD></TD>';
|
||||
echo '<TD></TD>';
|
||||
echo '</FORM></TR>';
|
||||
|
||||
echo '</TABLE>';
|
||||
|
||||
} else {
|
||||
$Res=ExecSql($this->cn,"select p_id,to_char(p_start,'DD.MM.YYYY') as date_start,to_char(p_end,'DD.MM.YYYY') as date_end,status,p_exercice
|
||||
from parm_periode join jrn_periode using (p_id) where jrn_def_id=".$this->jrn_def_id."
|
||||
order by p_start,p_end");
|
||||
$Max=pg_NumRows($Res);
|
||||
$r=ExecSql($this->cn,'select jrn_Def_name from jrn_Def where jrn_Def_id='.
|
||||
$this->jrn_def_id);
|
||||
$jrn_name=pg_fetch_result($r,0,0);
|
||||
echo '<h2> Journal '.$jrn_name.'</h2>';
|
||||
echo '<TABLE ALIGN="CENTER">';
|
||||
echo "</TR>";
|
||||
echo '<TH> Date début </TH>';
|
||||
echo '<TH> Date fin </TH>';
|
||||
echo '<TH> Exercice </TH>';
|
||||
echo "</TR>";
|
||||
|
||||
for ($i=0;$i<$Max;$i++) {
|
||||
$l_line=pg_fetch_array($Res,$i);
|
||||
echo '<TR>';
|
||||
echo '<TD ALIGN="CENTER"> '.$l_line['date_start'].'</TD>';
|
||||
echo '<TD ALIGN="CENTER"> '.$l_line['date_end'].'</TD>';
|
||||
echo '<TD ALIGN="CENTER"> '.$l_line['p_exercice'].'</TD>';
|
||||
|
||||
if ( $l_line['status'] != 'OP' ) {
|
||||
$closed=($l_line['status']=='CE')?'<TD>Centralisee</TD>':'<TD>Fermée</TD>';
|
||||
} else {
|
||||
$closed='<TD class="mtitle">';
|
||||
$closed.='<A class="mtitle" HREF="?p_action=periode&action=closed&p_per='.$l_line['p_id'].'&'.$str_dossier.'&jrn_def_id='.$this->jrn_def_id.'"> Cloturer</A>';
|
||||
$closed.='</td>';
|
||||
}
|
||||
echo "$closed";
|
||||
|
||||
echo '</TR>';
|
||||
|
||||
}
|
||||
echo '</TABLE>';
|
||||
|
||||
}
|
||||
}
|
||||
function insert($p_date_start,$p_date_end,$p_exercice) {
|
||||
if (isDate($p_date_start) == null ||
|
||||
isDate($p_date_end) == null ||
|
||||
strlen (trim($p_exercice)) == 0 ||
|
||||
(string) $p_exercice != (string)(int) $p_exercice)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
$p_id=NextSequence($this->cn,'s_periode');
|
||||
$sql=sprintf(" insert into parm_periode(p_id,p_start,p_end,p_closed,p_exercice)".
|
||||
"values (%d,to_date('%s','DD.MM.YYYY'),to_date('%s','DD.MM.YYYY')".
|
||||
",'f','%s')",
|
||||
$p_id,
|
||||
$p_date_start,
|
||||
$p_date_end,
|
||||
$p_exercice);
|
||||
try {
|
||||
StartSql($this->cn);
|
||||
$Res=ExecSql($this->cn,$sql);
|
||||
$Res=ExecSql($this->cn,"insert into jrn_periode (jrn_def_id,p_id,status) ".
|
||||
"select jrn_def_id,$p_id,'OP' from jrn_def");
|
||||
Commit($this->cn);
|
||||
} catch (Exception $e) {
|
||||
Rollback($this->cn);
|
||||
echo_debug(__FILE__.':'.__LINE__.'- Periode insert','Exception ',$e);
|
||||
echo_debug(__FILE__.':'.__LINE__.'- Periode insert','Exception ',$e->getMessage());
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static function test_me() {
|
||||
$cn=DbConnect(dossier::id());
|
||||
$obj=new Periode($cn);
|
||||
$obj->set_jrn(1);
|
||||
$obj->display_form_periode();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
php_value include_path .:../../include:../include:addon
|
||||
php_flag magic_quotes_gpc off
|
||||
php_flag session.auto_start on
|
||||
php_value session.save_path /tmp
|
||||
php_value max_execution_time 240
|
||||
php_value memory_limit 12M
|
||||
# for php 5 php_value upload_tmp_dir /tmp
|
||||
AddDefaultCharset utf-8
|
||||
php_value session.use_trans_sid 1
|
||||
php_value error_reporting 10239
|
||||
|
|
@ -1,170 +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
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/*!\file
|
||||
*
|
||||
* \brief confirm the removal of a template , folder and remove it if confirmed
|
||||
*
|
||||
*/
|
||||
include_once("postgres.php");
|
||||
include_once("debug.php");
|
||||
include_once("ac_common.php");
|
||||
|
||||
$rep=DbConnect();
|
||||
include_once ("class_user.php");
|
||||
$User=new User($rep);
|
||||
html_page_start($User->theme,'onLoad="window.focus();"');
|
||||
$User->Check();
|
||||
if ($User->admin != 1) {
|
||||
|
||||
print "<H2 class=\"error\"> Désolé mais vous n' êtes pas administrateur</H2>";
|
||||
|
||||
html_page_stop();
|
||||
return;
|
||||
}
|
||||
if ( ! isset ($_REQUEST['p_type'] ) ||
|
||||
! isset ($_REQUEST['PHPSESSID']) ||
|
||||
! isset ($_REQUEST['ob_id']))
|
||||
{
|
||||
print '<H2 CLASS="error">';
|
||||
print "Désolé vous n'avez pas appelé cette fonction avec les bons paramètres";
|
||||
print '</H2>';
|
||||
print '<hr><INPUT TYPE="BUTTON" VALUE="Fermez la fenêtre" onclick="window.close();">';
|
||||
return;
|
||||
}
|
||||
$cn=DbConnect();
|
||||
|
||||
switch($_REQUEST['p_type'])
|
||||
{
|
||||
case 'db':
|
||||
$msg="dossier";
|
||||
$name=getDbValue($cn,"select dos_name from ac_dossier where dos_id=".$_REQUEST['ob_id']);
|
||||
if ( strlen(trim($name)) == 0 )
|
||||
{
|
||||
echo "<h2 class=\"error\"> $msg inexistant</h2>";
|
||||
print '<hr><INPUT TYPE="BUTTON" VALUE="Fermez la fenêtre" onclick="window.close();">';
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'mod':
|
||||
$msg="modèle";
|
||||
$name=getDbValue($cn,"select mod_name from modeledef where mod_id=".$_REQUEST['ob_id']);
|
||||
if ( strlen(trim($name)) == 0 )
|
||||
{
|
||||
echo "<h2 class=\"error\"> $msg inexistant</h2>";
|
||||
print '<hr><INPUT TYPE="BUTTON" VALUE="Fermez la fenêtre" onclick="window.close();">';
|
||||
return;
|
||||
}
|
||||
if ( $_REQUEST['ob_id'] < 3 ) {
|
||||
echo "<h2 class=\"error\">Désolé mais vous ne pouvez pas effacer les modèles de base</H2>";
|
||||
print '<hr><INPUT TYPE="BUTTON" VALUE="Fermez la fenêtre" onclick="window.close();">';
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
print '<H2 CLASS="error">';
|
||||
print "Désolé mais que voulez-vous effacer ? ";
|
||||
print '</H2>';
|
||||
print '<hr><INPUT TYPE="BUTTON" VALUE="Fermez la fenêtre" onclick="window.close();">';
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if ( isset($_POST['remove']) )
|
||||
{
|
||||
// Check if the radio is checked
|
||||
// if yes removed the template and show a confirmation message
|
||||
if ( isset($_POST['confirm']) )
|
||||
{
|
||||
switch( $_POST['p_type'] )
|
||||
{
|
||||
// Drop Modele
|
||||
case 'mod':
|
||||
$sql="drop database ".domaine."mod".$_POST['ob_id'];
|
||||
ob_start();
|
||||
if ( pg_query($cn,$sql)==false) {
|
||||
ob_end_clean();
|
||||
|
||||
echo "<h2 class=\"error\">
|
||||
Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord</h2>";
|
||||
print '<hr><INPUT TYPE="BUTTON" VALUE="Fermez la fenêtre" onclick="window.close();">';
|
||||
exit;
|
||||
}
|
||||
ob_flush();
|
||||
$sql="delete from modeledef where mod_id=".$_POST['ob_id'];
|
||||
ExecSql($cn,$sql);
|
||||
print '<h2 class="info">';
|
||||
print "Voilà le modèle $name est effacé";
|
||||
print "<h2>";
|
||||
print '<hr><INPUT TYPE="BUTTON" VALUE="Fermez la fenêtre" onclick="window.close();">';
|
||||
break;
|
||||
case 'db':
|
||||
$sql="drop database ".domaine."dossier".$_POST['ob_id'];
|
||||
ob_start();
|
||||
if ( pg_query($cn,$sql)==false) {
|
||||
ob_end_clean();
|
||||
|
||||
echo "<h2 class=\"error\">
|
||||
Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord</h2>";
|
||||
print '<hr><INPUT TYPE="BUTTON" VALUE="Fermez la fenêtre" onclick="window.close();">';
|
||||
exit;
|
||||
}
|
||||
ob_flush();
|
||||
$sql="delete from priv_user where priv_id in (select jnt_id from jnt_use_dos where dos_id=".$_REQUEST['ob_id'].")";
|
||||
ExecSql($cn,$sql);
|
||||
$sql="delete from jnt_use_dos where dos_id=".$_REQUEST['ob_id'];
|
||||
ExecSql($cn,$sql);
|
||||
$sql="delete from ac_dossier where dos_id=".$_REQUEST['ob_id'];
|
||||
ExecSql($cn,$sql);
|
||||
print '<h2 class="info">';
|
||||
print "Voilà le modèle $name est effacé";
|
||||
print "<h2>";
|
||||
print '<hr><INPUT TYPE="BUTTON" VALUE="Fermez la fenêtre" onclick="window.close();">';
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<h2 class="info">';
|
||||
print "$msg $name n'est pas effacé";
|
||||
print '</h2>';
|
||||
print "<hr>";
|
||||
print "Vous n'avez pas coché la case";
|
||||
print '<hr><INPUT TYPE="BUTTON" VALUE="Fermez la fenêtre" onclick="window.close();">';
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<h2 class=\"info\"> Confirmer vous l'effacement du $msg $name ? <h2> ";
|
||||
?>
|
||||
<FORM METHOD="POST" ACTION="confirm_remove.php">
|
||||
<INPUT TYPE="HIDDEN" NAME="ob_id" value="<?php echo $_REQUEST['ob_id'];?>" >
|
||||
<INPUT TYPE="HIDDEN" NAME="p_type" value="<?php echo $_REQUEST['p_type'];?>" >
|
||||
<INPUT TYPE="CHECKBOX" NAME="confirm" VALUE="UNCHECKED"> Cochez cette case si vous voulez vraiment effacer <?php echo $name;?>
|
||||
<INPUT TYPE="SUBMIT" NAME="remove" value="Oui">
|
||||
<hr>
|
||||
<input type="button" name="close" value="Annuler" onclick="window.close();">
|
||||
</FORM>
|
||||
<?php
|
||||
}
|
||||
|
|
@ -1,96 +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
|
||||
*/
|
||||
/* $Revision$ */
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
/*! \file
|
||||
* \brief Send the final balance in CSV this balance is used to open an exercice
|
||||
*/
|
||||
|
||||
include_once ("ac_common.php");
|
||||
require_once("class_acc_account_ledger.php");
|
||||
header('Content-type: application/csv');
|
||||
header('Content-Disposition: attachment;filename="export_ouv.csv"',FALSE);
|
||||
require_once('class_dossier.php');
|
||||
$gDossier=dossier::id();
|
||||
|
||||
include_once ("postgres.php");
|
||||
/* Admin. Dossier */
|
||||
$rep=DbConnect();
|
||||
include_once ("class_user.php");
|
||||
$User=new User($rep);
|
||||
$User->Check();
|
||||
|
||||
include_once ("check_priv.php");
|
||||
|
||||
include_once ("user_menu.php");
|
||||
|
||||
$cn=DbConnect($gDossier);
|
||||
|
||||
$User->can_request($cn,EXP_IMP_ECR);
|
||||
|
||||
if ( !isset ($_GET['p_periode'])) {
|
||||
echo 'Erreur : aucune periode demandée';
|
||||
exit(0);
|
||||
}
|
||||
$sql_from=get_array($cn,"select min(p_id) from parm_periode where p_exercice=".$_GET['p_periode']);
|
||||
|
||||
$sql_to=get_array($cn,"select max(p_id) from parm_periode where p_exercice=".$_GET['p_periode']);
|
||||
|
||||
$ret=get_array($cn,"select distinct j_poste::text
|
||||
from jrnx inner join tmp_pcmn on (pcm_val=j_poste)
|
||||
where
|
||||
j_tech_per >= ".$sql_from[0]['min']." and
|
||||
j_tech_per <= ".$sql_to[0]['max']." and j_poste::text not like '7%'
|
||||
and j_poste::text not like '6%'
|
||||
order by j_poste::text");
|
||||
if ( $ret == null ) {echo 'Rien à exporter'; exit();}
|
||||
printf ("OUVERTURE\n");
|
||||
// check if the account are balanced
|
||||
$sum=0;
|
||||
foreach ($ret as $poste_id) {
|
||||
|
||||
$Poste=new Acc_Account_Ledger($cn,$poste_id['j_poste']);
|
||||
// fill the object
|
||||
$Poste->load();
|
||||
// build sql stmt
|
||||
$sql="j_tech_per >=". $sql_from[0]['min']." and j_tech_per <=".$sql_to[0]['max'];
|
||||
$result=$Poste->get_solde_detail($sql );
|
||||
$Poste->label=str_replace(';','',$Poste->label);
|
||||
|
||||
if ( $result['solde'] == 0 ) continue;
|
||||
if ( $result['debit'] > $result ['credit'] ) {
|
||||
printf ("d;%d;%s;%12.4f\n",$Poste->id,$Poste->label,$result['solde']);
|
||||
$sum+=$result['solde'];
|
||||
} else {
|
||||
printf ("c;%d;%s;%12.4f\n",$Poste->id,$Poste->label,$result['solde']);
|
||||
$sum-=$result['solde'];
|
||||
}
|
||||
}
|
||||
// $sum must be equal to 0
|
||||
// $sum > 0 then deb is too big
|
||||
// $sum < 0 then cred is too big
|
||||
// rounded problem
|
||||
if ( round($sum,4) != 0.0 )
|
||||
{
|
||||
printf("ATTENTION : COMPTE NON EQUILIBRE\n ");
|
||||
$msg = ($sum > 0)?" Debit plus grand de $sum":"Credit plus grand de $sum";
|
||||
printf ("DIFFERENCE = $msg \n");
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,147 +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
|
||||
*/
|
||||
|
||||
/*! \file
|
||||
* \brief Print the ledger in pdf
|
||||
*/
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
// $Revision$
|
||||
require_once('class_dossier.php');
|
||||
$gDossier=dossier::id();
|
||||
|
||||
include_once("jrn.php");
|
||||
include_once("ac_common.php");
|
||||
include_once("postgres.php");
|
||||
include_once("class.ezpdf.php");
|
||||
include_once("impress_inc.php");
|
||||
include_once("preference.php");
|
||||
require_once('class_acc_ledger.php');
|
||||
|
||||
echo_debug('send_jrn_pdf.php',__LINE__,"imp pdf journaux");
|
||||
$l_Db=sprintf("dossier%d",$gDossier);
|
||||
$cn=DbConnect($gDossier);
|
||||
$l_type="JRN";
|
||||
$centr=" Non centralisé";
|
||||
$l_centr=0;
|
||||
if ( isset ($_POST['central']) ) {
|
||||
$centr=" centralisé ";
|
||||
$l_centr=1;
|
||||
}
|
||||
$oJrn=new Acc_Ledger($cn,$_GET['p_id']);
|
||||
$name=$oJrn->get_name().$centr;
|
||||
$ret="";
|
||||
$pdf=& new Cezpdf("A4");
|
||||
$pdf->selectFont('./addon/fonts/Helvetica.afm');
|
||||
|
||||
$offset=0;$limit=25;$step=25;
|
||||
$rap_deb=0;$rap_cred=0;
|
||||
while (1) {
|
||||
$a=0;
|
||||
list ($a_jrn,$tot_deb,$tot_cred)=get_dataJrnPdf($cn,$_GET,$limit,$offset);
|
||||
echo_debug('send_jrn_pdf.php',__LINE__,"Total debit $tot_deb,credit $tot_cred");
|
||||
|
||||
if ( $a_jrn==null) break;
|
||||
$offset+=$step;
|
||||
foreach ($a_jrn as $key=>$element) {
|
||||
echo_debug('send_jrn_pdf.php',__LINE__,"$key => $element");
|
||||
foreach ($element as $c1=>$c2)
|
||||
echo_debug('send_jrn_pdf.php',__LINE__,"Array is $c1 => $c2");
|
||||
}
|
||||
$first_id=$a_jrn[0]['j_id'];
|
||||
$Exercice=get_exercice($cn,$a_jrn[0]['periode']);
|
||||
|
||||
|
||||
list($rap_deb,$rap_cred)=get_rappel($cn,$first_id,$_GET["p_id"],$Exercice,FIRST,
|
||||
$_GET['filter'],
|
||||
$l_centr
|
||||
);
|
||||
echo_debug('send_jrn_pdf.php',__LINE__,"MONTANT $rap_deb,$rap_cred");
|
||||
echo_debug('send_jrn_pdf.php',__LINE__," list($rap_deb,$rap_cred)=get_rappel($cn,$first_id,".$_GET["p_id"].",$Exercice,FIRST)");
|
||||
$pdf->ezText($name_jrn,30);
|
||||
|
||||
if ( $l_centr == 1 ) {
|
||||
// si centralisé montre les montants de rappel
|
||||
$str_debit=sprintf( "report Débit % 10.2f",$rap_deb);
|
||||
$str_credit=sprintf("report Crédit % 10.2f",$rap_cred);
|
||||
$pdf->ezText($str_debit,12,array('justification'=>'right'));
|
||||
$pdf->ezText($str_credit,12,array('justification'=>'right'));
|
||||
}
|
||||
|
||||
$pdf->ezTable($a_jrn,
|
||||
array ('internal'=>'Opération',
|
||||
'j_date' => 'Date',
|
||||
'poste'=>'Poste',
|
||||
'description' => 'Description',
|
||||
'deb_montant'=> 'Débit',
|
||||
'cred_montant'=>'Crédit')," ",
|
||||
array('shaded'=>0,'showHeadings'=>1,'width'=>500,
|
||||
'cols'=>array('deb_montant'=> array('justification'=>'right'),
|
||||
'cred_montant'=> array('justification'=>'right'))));
|
||||
$a=1;
|
||||
// Total Page
|
||||
$apage=array(array('deb'=>sprintf("%8.2f",$tot_deb),'cred'=>$tot_cred));
|
||||
foreach ($apage as $key=>$element) echo_debug('send_jrn_pdf.php',__LINE__,"apage $key => $element");
|
||||
$pdf->ezTable($apage,
|
||||
array (
|
||||
'deb'=> 'Total Débit',
|
||||
'cred'=>'Total Crédit')," ",
|
||||
array('shaded'=>0,'showHeadings'=>1,'width'=>200,
|
||||
'xPos'=>'right','xOrientation'=>'left',
|
||||
'cols'=>array('deb'=> array('justification'=>'right'),
|
||||
'cred'=> array('justification'=>'right'))));
|
||||
|
||||
$count=count($a_jrn)-1;
|
||||
$last_id=$a_jrn[$count]['j_id'];
|
||||
$Exercice=get_exercice($cn,$a_jrn[$count]['periode']);
|
||||
if ( $l_centr == 1) {
|
||||
// Montant de rappel si centralisé
|
||||
list($rap_deb,$rap_cred)=get_rappel($cn,$last_id,$_GET["p_id"],$Exercice,LAST,$_GET['filter'],$l_centr);
|
||||
$str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb);
|
||||
$str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred);
|
||||
$pdf->ezText($str_debit,12,array('justification'=>'right'));
|
||||
$pdf->ezText($str_credit,12,array('justification'=>'right'));
|
||||
}
|
||||
//New page
|
||||
$pdf->ezNewPage();
|
||||
}
|
||||
if ( $a == 1 ) {
|
||||
$apage=array('deb'=>$tot_deb,'cred'=>$tot_cred);
|
||||
$pdf->ezTable($apage,
|
||||
array (
|
||||
'deb'=> 'Total Débit',
|
||||
'cred'=>'Total Crédit')," ",
|
||||
array('shaded'=>0,'showHeadings'=>1,'width'=>500,
|
||||
'cols'=>array('deb'=> array('justification'=>'right'),
|
||||
'cred'=> array('justification'=>'right'))));
|
||||
$count=count($a_jrn)-1;
|
||||
$last_id=$a_jrn[$count]['j_id'];
|
||||
$Exercice=get_exercice($cn,$a_jrn[$count]['periode']);
|
||||
|
||||
list($rap_deb,$rap_cred)=get_rappel($cn,$last_id,$_GET["p_id"],$Exercice,LAST,$l_GET['filter'],$l_centr);
|
||||
$str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb);
|
||||
$str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred);
|
||||
$pdf->ezText($str_debit,12,array('justification'=>'right'));
|
||||
$pdf->ezText($str_credit,12,array('justification'=>'right'));
|
||||
|
||||
}
|
||||
$pdf->ezStream();
|
||||
|
||||
?>
|
||||
|
|
@ -1,97 +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
|
||||
*/
|
||||
/*! \file
|
||||
* \brief Print the account in pdf
|
||||
*/
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
// $Revision$
|
||||
|
||||
include_once("jrn.php");
|
||||
include_once("ac_common.php");
|
||||
include_once("postgres.php");
|
||||
include_once("class.ezpdf.php");
|
||||
include_once("impress_inc.php");
|
||||
require_once("poste.php");
|
||||
echo_debug('send_poste_pdf.php',__LINE__,"imp pdf journaux");
|
||||
$cn=DbConnect($g_dossier);
|
||||
foreach ($_POST as $key=>$element) {
|
||||
${"$key"}=$element;
|
||||
}
|
||||
if ( isset ( $all_poste) ){ //choisit de voir tous les postes
|
||||
$r_poste=ExecSql($cn,"select pcm_val from tmp_pcmn where pcm_val = any ".
|
||||
" (select j_poste from jrnx) order by pcm_val::text");
|
||||
$nPoste=pg_numRows($r_poste);
|
||||
for ( $i=0;$i<$nPoste;$i++) {
|
||||
$t_poste=pg_fetch_array($r_poste,$i);
|
||||
$poste[]=$t_poste['pcm_val'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ret="";
|
||||
$pdf=& new Cezpdf();
|
||||
$pdf->selectFont('./addon/fonts/Helvetica.afm');
|
||||
$cond=CreatePeriodeCond($periode);
|
||||
//$rap_deb=0;$rap_cred=0;
|
||||
for ( $i =0;$i<count($poste);$i++) {
|
||||
|
||||
list($array,$tot_deb,$tot_cred)=get_dataPoste($cn,$poste[$i],$cond);
|
||||
// don't print empty account
|
||||
if ( count($array) == 0 ) {
|
||||
continue;
|
||||
}
|
||||
$Libelle=sprintf("(%s) %s ",$poste[$i],GetPosteLibelle($cn,$poste[$i],1));
|
||||
|
||||
// $pdf->ezText($Libelle,30);
|
||||
$pdf->ezTable($array,
|
||||
array ('jr_internal'=>'Opération',
|
||||
'j_date' => 'Date',
|
||||
'jrn_name'=>'Journal',
|
||||
'description'=>'Description',
|
||||
'deb_montant'=> 'Montant',
|
||||
'cred_montant'=> 'Montant'
|
||||
),$Libelle,
|
||||
array('shaded'=>0,'showHeadings'=>1,'width'=>500,
|
||||
'cols'=>array('montant'=> array('justification'=>'right'),
|
||||
)));
|
||||
$str_debit=sprintf("Débit % 12.2f",$tot_deb);
|
||||
$str_cred=sprintf("Crédit % 12.2f",$tot_cred);
|
||||
$diff_solde=$tot_deb-$tot_cred;
|
||||
if ( $diff_solde < 0 ) {
|
||||
$solde=" C ";
|
||||
$diff_solde*=-1;
|
||||
} else
|
||||
{
|
||||
$solde=" D ";
|
||||
}
|
||||
$str_solde=sprintf(" Solde %s %12.2f",$solde,$diff_solde);
|
||||
|
||||
$pdf->ezText($str_debit,10,array('justification'=>'right'));
|
||||
$pdf->ezText($str_cred,10,array('justification'=>'right'));
|
||||
$pdf->ezText($str_solde,14,array('justification'=>'right'));
|
||||
|
||||
//New page
|
||||
//$pdf->ezNewPage();
|
||||
}
|
||||
|
||||
$pdf->ezStream();
|
||||
|
||||
?>
|
||||
|
|
@ -242,6 +242,20 @@ tr.odd {
|
|||
tr {
|
||||
font-size:10px;
|
||||
}
|
||||
|
||||
tr.odd:hover td
|
||||
{
|
||||
text-decoration:none;
|
||||
background-color:blue;
|
||||
color:white;
|
||||
}
|
||||
tr.even:hover td
|
||||
{
|
||||
text-decoration:none;
|
||||
background-color:blue;
|
||||
color:white;
|
||||
}
|
||||
|
||||
td.odd{
|
||||
background-color:#DDE6FF ;
|
||||
border-size:0px;
|
||||
|
|
|
|||
|
|
@ -1,154 +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
|
||||
*/
|
||||
/* $Revision$ */
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
/*! \file
|
||||
* \brief Manage the table parm_code which contains the custom parameter
|
||||
* for the module accountancy
|
||||
*/
|
||||
/*!
|
||||
* \brief Manage the table parm_code which contains the custom parameter
|
||||
* for the module accountancy
|
||||
*/
|
||||
|
||||
class parm_code {
|
||||
var $db; /*!< $db database connection */
|
||||
var $p_code; /*!< $p_code parm_code.p_code primary key */
|
||||
var $p_value; /*!< $p_value parm_code.p_value */
|
||||
var $p_comment; /*!< $p_comment parm_code.p_comment */
|
||||
// constructor
|
||||
function parm_code($p_cn,$p_id=-1)
|
||||
{
|
||||
$this->db=$p_cn;
|
||||
$this->p_code=$p_id;
|
||||
if ( $p_id != -1 )
|
||||
$this->Get();
|
||||
}
|
||||
/*!
|
||||
**************************************************
|
||||
* \brief
|
||||
* Load all parmCode
|
||||
* return an array of parm_code object
|
||||
*
|
||||
* \return array
|
||||
*/
|
||||
|
||||
function LoadAll() {
|
||||
$sql="select * from parm_code order by p_code";
|
||||
$Res=ExecSql($this->db,$sql);
|
||||
$r= pg_fetch_all($Res);
|
||||
$idx=0;
|
||||
$array=array();
|
||||
|
||||
if ( $r === false ) return null;
|
||||
foreach ($r as $row )
|
||||
{
|
||||
$o=new parm_code($this->db,$row['p_code']);
|
||||
$array[$idx]=$o;
|
||||
$idx++;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
/*!
|
||||
**************************************************
|
||||
* \brief update a parm_object into the database
|
||||
* p_code is _not_ updatable
|
||||
* \return
|
||||
* nothing
|
||||
*/
|
||||
function Save()
|
||||
{
|
||||
// if p_code=="" nothing to save
|
||||
if ( $this->p_code== -1) return;
|
||||
$this->p_comment=FormatString($this->p_comment);
|
||||
$this->p_value=FormatString($this->p_value);
|
||||
$this->p_code=FormatString($this->p_code);
|
||||
$sql="update parm_code set ".
|
||||
"p_comment='".$this->p_comment."' ".
|
||||
",p_value='".$this->p_value."' ".
|
||||
"where p_code='".$this->p_code."'";
|
||||
$Res=ExecSql($this->db,$sql);
|
||||
}
|
||||
/*!
|
||||
**************************************************
|
||||
* \brief Display an object, with the <TD> tag
|
||||
*
|
||||
* \return
|
||||
* string
|
||||
*/
|
||||
function Display()
|
||||
{
|
||||
$r="";
|
||||
$r.= '<TD>'.$this->p_code.'</TD>';
|
||||
$r.= '<TD>'.$this->p_comment.'</TD>';
|
||||
$r.= '<TD>'.$this->p_value.'</TD>';
|
||||
|
||||
return $r;
|
||||
}
|
||||
/*!
|
||||
**************************************************
|
||||
* \brief Display a form to enter info about
|
||||
* a parm_code object with the <TD> tag
|
||||
*
|
||||
* \return string
|
||||
*/
|
||||
function Input()
|
||||
{
|
||||
$comment=new widget("text");
|
||||
$comment->name='p_comment';
|
||||
$comment->value=$this->p_comment;
|
||||
$value=new widget("text");
|
||||
$value->name='p_value';
|
||||
$value->value=$this->p_value;
|
||||
$poste=new widget("text");
|
||||
$poste->SetReadOnly(true);
|
||||
$poste->name='p_code';
|
||||
$poste->value=$this->p_code;
|
||||
$r="";
|
||||
$r.= '<TD>'.$poste->IOValue().'</TD>';
|
||||
$r.= '<TD>'.$comment->IOValue().'</TD>';
|
||||
$r.= '<TD>'.$value->IOValue().'</TD>';
|
||||
|
||||
return $r;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
**************************************************
|
||||
* \brief
|
||||
* Complete a parm_code object thanks the p_code
|
||||
*
|
||||
* \return array
|
||||
*/
|
||||
|
||||
function Get() {
|
||||
if ( $this->p_code == -1 ) return "p_code non initialisé";
|
||||
$sql=sprintf("select * from parm_code where p_code='%s' ",
|
||||
$this->p_code);
|
||||
$Res=ExecSql($this->db,$sql);
|
||||
|
||||
if ( pg_NumRows($Res) == 0 ) return 'INCONNU';
|
||||
$row= pg_fetch_array($Res,0);
|
||||
$this->p_value=$row['p_value'];
|
||||
$this->p_comment=$row['p_comment'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,350 +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
|
||||
*/
|
||||
/* $Revision$ */
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
/*! \file
|
||||
* \brief Create, view, modify and parse report
|
||||
*/
|
||||
|
||||
require_once('class_rapport_row.php');
|
||||
require_once('class_widget.php');
|
||||
require_once('impress_inc.php');
|
||||
|
||||
/*!
|
||||
* \brief Class rapport Create, view, modify and parse report
|
||||
*/
|
||||
|
||||
class Rapport {
|
||||
|
||||
var $db; /*!< $db database connx */
|
||||
var $id; /*!< $id formdef.fr_id */
|
||||
var $name; /*!< $name report's name */
|
||||
var $aRapport_row; /*!< array of rapport_row */
|
||||
var $nb;
|
||||
/*!\brief Constructor */
|
||||
function __construct($p_cn,$p_id=0) {
|
||||
$this->db=$p_cn;
|
||||
$this->id=$p_id;
|
||||
$this->name='Nouveau';
|
||||
$this->aRapport_row=null;
|
||||
}
|
||||
/*!\brief Return the report's name
|
||||
*/
|
||||
function get_name() {
|
||||
$ret=execSql($this->db,"select fr_label from formdef where fr_id=".$this->id);
|
||||
if (pg_NumRows($ret) == 0) return $this->name;
|
||||
$a=pg_fetch_array($ret,0);
|
||||
$this->name=$a['fr_label'];
|
||||
return $this->name;
|
||||
}
|
||||
/*!\brief return all the row and parse formula
|
||||
* from a report
|
||||
* \param $p_start start periode
|
||||
* \param $p_end end periode
|
||||
* \param $p_type_date type of the date : periode or calendar
|
||||
*/
|
||||
|
||||
function get_row($p_start,$p_end,$p_type_date) {
|
||||
|
||||
$Res=ExecSql($this->db,"select fo_id ,
|
||||
fo_fr_id,
|
||||
fo_pos,
|
||||
fo_label,
|
||||
fo_formula,
|
||||
fr_label from form
|
||||
inner join formdef on fr_id=fo_fr_id
|
||||
where fr_id =".$this->id.
|
||||
"order by fo_pos");
|
||||
$Max=pg_NumRows($Res);
|
||||
if ($Max==0) { $this->row=0;return null;}
|
||||
$col=array();
|
||||
for ($i=0;$i<$Max;$i++) {
|
||||
$l_line=pg_fetch_array($Res,$i);
|
||||
$col[]=ParseFormula($this->db,
|
||||
$l_line['fo_label'],
|
||||
$l_line['fo_formula'],
|
||||
$p_start,
|
||||
$p_end,
|
||||
true,
|
||||
$p_type_date
|
||||
);
|
||||
|
||||
} //for ($i
|
||||
$this->row=$col;
|
||||
return $col;
|
||||
}
|
||||
/*!
|
||||
* \brief Display a form for encoding a new report or update one
|
||||
*
|
||||
* \param $p_line number of line
|
||||
*
|
||||
*/
|
||||
function form($p_line=0) {
|
||||
$search_poste=new widget('JS_SEARCH_POSTE');
|
||||
$search_poste->extra='not';
|
||||
$r="";
|
||||
if ($p_line == 0 ) $p_line=count($this->aRapport_row);
|
||||
$r.= dossier::hidden();
|
||||
$r.= widget::hidden('line',$p_line);
|
||||
$r.= widget::hidden('fr_id',$this->id);
|
||||
$wForm=new widget("text");
|
||||
$r.="Nom du rapport : ";
|
||||
$r.=$wForm->IOValue('form_nom',$this->name);
|
||||
|
||||
$r.= '<TABLE id="rap1">';
|
||||
$r.= "<TR>";
|
||||
$r.= "<TH> Position </TH>";
|
||||
$r.= "<TH> Texte </TH>";
|
||||
$r.= "<TH> Formule</TH>";
|
||||
|
||||
$r.= '</TR>';
|
||||
$wName=new widget("text");
|
||||
$wName->size=50;
|
||||
$wPos=new widget("text");
|
||||
$wPos->size=3;
|
||||
$wForm=new widget("text");
|
||||
$wForm->size=35;
|
||||
for ( $i =0 ; $i < $p_line;$i++) {
|
||||
|
||||
$r.= "<TR>";
|
||||
|
||||
$r.= "<TD>";
|
||||
$wPos->value=( isset($this->aRapport_row[$i]->fo_pos))?$this->aRapport_row[$i]->fo_pos:$i+1;
|
||||
$r.=$wPos->IOValue("pos".$i);
|
||||
$r.= '</TD>';
|
||||
|
||||
|
||||
$r.= "<TD>";
|
||||
$wName->value=( isset($this->aRapport_row[$i]->fo_label))?$this->aRapport_row[$i]->fo_label:"";
|
||||
$r.=$wName->IOValue("text".$i);
|
||||
$r.= '</TD>';
|
||||
|
||||
$r.= "<TD>";
|
||||
$wForm->value=( isset($this->aRapport_row[$i]->fo_formula))?$this->aRapport_row[$i]->fo_formula:"";
|
||||
$r.=$wForm->IOValue("form".$i);
|
||||
|
||||
$r.= '</TD>';
|
||||
|
||||
$r.= "</TR>";
|
||||
}
|
||||
|
||||
$r.= "</TABLE>";
|
||||
$wButton=new widget("button");
|
||||
$wButton->javascript=' rapport_add_row();';
|
||||
$wButton->label="Ajout d'une ligne";
|
||||
$r.=$wButton->IOValue();
|
||||
return $r;
|
||||
|
||||
}
|
||||
/*!\brief save into form and form_def
|
||||
*/
|
||||
function save() {
|
||||
|
||||
if ( strlen(trim($this->name)) == 0 )
|
||||
return;
|
||||
if ( $this->id == 0 )
|
||||
$this->insert();
|
||||
else
|
||||
$this->update();
|
||||
|
||||
}
|
||||
function insert() {
|
||||
try {
|
||||
startSql($this->db);
|
||||
$ret_sql=ExecSqlParam($this->db,
|
||||
"insert into formdef (fr_label) values($1) returning fr_id",
|
||||
array($this->name)
|
||||
);
|
||||
$this->id=pg_fetch_result($ret_sql,0,0);
|
||||
$ix=1;
|
||||
foreach ( $this->aRapport_row as $row) {
|
||||
if ( strlen(trim($row->get_parameter("name"))) != 0 &&
|
||||
strlen(trim($row->get_parameter("formula"))) != 0 )
|
||||
{
|
||||
$ix=($row->get_parameter("position")!="")?$row->get_parameter("position"):$ix;
|
||||
$row->set_parameter("position",$ix);
|
||||
$ret_sql=ExecSqlParam($this->db,
|
||||
"insert into form (fo_fr_id,fo_pos,fo_label,fo_formula)".
|
||||
" values($1,$2,$3,$4)",
|
||||
array($this->id,
|
||||
$row->fo_pos,
|
||||
$row->fo_label,
|
||||
$row->fo_formula)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
Rollback($this->db);
|
||||
echo $e->getMessage();
|
||||
}
|
||||
Commit($this->db);
|
||||
|
||||
}
|
||||
function update() {
|
||||
try {
|
||||
startSql($this->db);
|
||||
$ret_sql=ExecSqlParam($this->db,
|
||||
"update formdef set fr_label=$1 where fr_id=$2",
|
||||
array($this->name,$this->id));
|
||||
$ret_sql=ExecSqlParam($this->db,
|
||||
"delete from form where fo_fr_id=$1",
|
||||
array($this->id));
|
||||
$ix=0;
|
||||
|
||||
foreach ( $this->aRapport_row as $row) {
|
||||
if ( strlen(trim($row->get_parameter("name"))) != 0 &&
|
||||
strlen(trim($row->get_parameter("formula"))) != 0 )
|
||||
{
|
||||
|
||||
$ix=($row->get_parameter("position")!="")?$row->get_parameter("position"):$ix;
|
||||
$row->set_parameter("position",$ix);
|
||||
$ret_sql=ExecSqlParam($this->db,
|
||||
"insert into form (fo_fr_id,fo_pos,fo_label,fo_formula)".
|
||||
" values($1,$2,$3,$4)",
|
||||
array($this->id,
|
||||
$row->fo_pos,
|
||||
$row->fo_label,
|
||||
$row->fo_formula)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception $e) {
|
||||
Rollback($this->db);
|
||||
echo $e->getMessage();
|
||||
}
|
||||
Commit($this->db);
|
||||
}
|
||||
/*!\brief fill a form thanks an array, usually it is $_POST
|
||||
*\param $p_array keys = fr_id, form_nom,textXX, formXX, posXX where
|
||||
XX is an number
|
||||
*/
|
||||
function from_array($p_array) {
|
||||
$this->id=(isset($p_array['fr_id']))?$p_array['fr_id']:0;
|
||||
$this->name=(isset($p_array['form_nom']))?$p_array['form_nom']:"";
|
||||
$ix=0;
|
||||
|
||||
$rr=new Rapport_Row();
|
||||
$rr->set_parameter("form_id",$this->id);
|
||||
$rr->set_parameter('database',$this->db);
|
||||
|
||||
$this->aRapport_row=$rr->from_array($p_array);
|
||||
|
||||
|
||||
}
|
||||
/*!\brief the fr_id MUST be before called
|
||||
*/
|
||||
|
||||
|
||||
function load() {
|
||||
$sql=ExecSqlParam($this->db,
|
||||
"select fr_label from formdef where fr_id=$1",
|
||||
array($this->id));
|
||||
if ( pg_NumRows($sql) == 0 ) return;
|
||||
$this->name=pg_fetch_result($sql,0,0);
|
||||
$sql=ExecSqlParam($this->db,
|
||||
"select fo_id,fo_pos,fo_label,fo_formula ".
|
||||
" from form ".
|
||||
" where fo_fr_id=$1 order by fo_pos",
|
||||
array($this->id));
|
||||
$f=pg_fetch_all($sql);
|
||||
$array=array();
|
||||
if ( ! empty($f) ) {
|
||||
foreach ($f as $r) {
|
||||
$obj=new Rapport_Row();
|
||||
$obj->set_parameter("name",$r['fo_label']);
|
||||
$obj->set_parameter("id",$r['fo_id']);
|
||||
$obj->set_parameter("position",$r['fo_pos']);
|
||||
$obj->set_parameter("formula",$r['fo_formula']);
|
||||
$obj->set_parameter('database',$this->db);
|
||||
$obj->set_parameter('form_id',$this->id);
|
||||
$array[]=clone $obj;
|
||||
}
|
||||
}
|
||||
$this->aRapport_row=$array;
|
||||
|
||||
}
|
||||
function delete() {
|
||||
$ret=ExecSqlParam($this->db,
|
||||
"delete from formdef where fr_id=$1",
|
||||
array($this->id)
|
||||
);
|
||||
}
|
||||
/*!\brief get a list from formdef of all defined form
|
||||
*
|
||||
*\return array of object rapport
|
||||
*
|
||||
*/
|
||||
function get_list()
|
||||
{
|
||||
$sql="select fr_id,fr_label from formdef order by fr_label";
|
||||
$ret=ExecSql($this->db,$sql);
|
||||
if ( pg_NumRows($ret) == 0 ) return array();
|
||||
$array=pg_fetch_all($ret);
|
||||
$obj=array();
|
||||
foreach ($array as $row) {
|
||||
$tmp=new Rapport($this->db);
|
||||
$tmp->id=$row['fr_id'];
|
||||
$tmp->name=$row['fr_label'];
|
||||
$obj[]=clone $tmp;
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
/*!\brief To make a SELECT button with the needed value, it is used
|
||||
*by the SELECT widget
|
||||
*\return string with html code
|
||||
*/
|
||||
function make_array() {
|
||||
$sql=make_array($this->db,"select fr_id,fr_label from formdef order by fr_label");
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function test_me() {
|
||||
$cn=DbConnect(dossier::id());
|
||||
$a=new Rapport($cn);
|
||||
print_r($a->get_list());
|
||||
$array=array("text0"=>"test1",
|
||||
"form0"=>"7%",
|
||||
"text1"=>"test2",
|
||||
"form1"=>"6%",
|
||||
"fr_id"=>110,
|
||||
"form_nom"=>"Tableau"
|
||||
);
|
||||
$a->from_array($array);
|
||||
print_r($a);
|
||||
echo '<form method="post">';
|
||||
echo $a->form(10);
|
||||
echo '<INPUT TYPE="submit" value="Enregistre" name="update">';
|
||||
/* Add a line should be a javascript see comptanalytic */
|
||||
// $r.= '<INPUT TYPE="submit" value="Ajoute une ligne" name="add_line">';
|
||||
echo '<INPUT TYPE="submit" value="Efface ce rapport" name="del_form">';
|
||||
|
||||
echo "</FORM>";
|
||||
if ( isset ($_POST['update'])) {
|
||||
$b=new Rapport($cn);
|
||||
$b->from_array($_POST);
|
||||
echo '<hr>';
|
||||
print_r($b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,111 +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
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/*!\file
|
||||
* \brief this class maps the table form, which is a child table for formdef
|
||||
*/
|
||||
|
||||
/*!\brief manipulate the form_def's child table (form) */
|
||||
class Rapport_Row
|
||||
{
|
||||
private static $variable=array(
|
||||
"name"=>"fo_label",
|
||||
"formula"=>"fo_formula",
|
||||
"id"=>"fo_id",
|
||||
"position"=>"fo_pos",
|
||||
"form_id"=>"fo_fr_id",
|
||||
"database"=>"db"
|
||||
);
|
||||
function __construct ($p_name=null,$p_formula=null) {
|
||||
$this->set_parameter("id",0);
|
||||
|
||||
$this->set_parameter("name",$p_name);
|
||||
$this->set_parameter("formula",$p_formula);
|
||||
}
|
||||
public function get_parameter($p_string) {
|
||||
if ( array_key_exists($p_string,self::$variable) ) {
|
||||
$idx=self::$variable[$p_string];
|
||||
return $this->$idx;
|
||||
}
|
||||
else
|
||||
exit (__FILE__.":".__LINE__.'Erreur attribut inexistant');
|
||||
}
|
||||
public function set_parameter($p_string,$p_value) {
|
||||
if ( array_key_exists($p_string,self::$variable) ) {
|
||||
$idx=self::$variable[$p_string];
|
||||
$this->$idx=$p_value;
|
||||
}
|
||||
else
|
||||
exit (__FILE__.":".__LINE__."$p_string ".'Erreur attribut inexistant');
|
||||
|
||||
|
||||
}
|
||||
public function get_info() {
|
||||
return var_export(self::$variable,true);
|
||||
}
|
||||
/*!\brief Convert an array into an array of row_rapport object
|
||||
* the fo_id is 0, position = 0, the fo_frd_id (form_id) is
|
||||
* the one of the current object, the db is also the current one
|
||||
*\param $p_array contains the value
|
||||
*\return an array of Rapport_Row object
|
||||
*/
|
||||
public function from_array($p_array) {
|
||||
extract ($p_array);
|
||||
$ret=array();
|
||||
$ix=0;
|
||||
$found=0;
|
||||
foreach ( $p_array as $r) {
|
||||
|
||||
if ( isset(${'form'.$ix}) && isset ( ${'text'.$ix} )) {
|
||||
$obj=new Rapport_Row( ${'text'.$ix},${'form'.$ix});
|
||||
if ( isset(${'pos'.$ix}) && isNumber(${'pos'.$ix})==1 )
|
||||
$obj->set_parameter("position",$ix);
|
||||
else {
|
||||
$obj->set_parameter("position",$found);
|
||||
$found++;
|
||||
}
|
||||
$obj->fo_id=0;
|
||||
$obj->fo_fr_id=$this->fo_fr_id;
|
||||
$obj->db=$this->db;
|
||||
|
||||
$ret[]=clone $obj;
|
||||
}
|
||||
$ix++;
|
||||
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
function test_me()
|
||||
{
|
||||
$cn=DbConnect(dossier::id());
|
||||
$a=new Rapport_Row();
|
||||
$array=array("text0"=>"test1",
|
||||
"form0"=>"7%",
|
||||
"text1"=>"test2",
|
||||
"form1"=>"6%"
|
||||
);
|
||||
|
||||
$b=$a->from_array($array);
|
||||
print_r($b);
|
||||
echo $a->get_info();
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
*/
|
||||
/* $Revision$ */
|
||||
/*!\file
|
||||
*\brief this file is called by the main page of "gestion"
|
||||
*/
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
require_once('class_acc_ledger.php');
|
||||
require_once('user_form_ach.php');
|
||||
require_once('jrn.php');
|
||||
require_once("class_document.php");
|
||||
require_once("class_fiche.php");
|
||||
require_once("check_priv.php");
|
||||
require_once ('class_pre_op_ach.php');
|
||||
/*!\brief the purpose off this file encode expense and to record them
|
||||
*
|
||||
*/
|
||||
$tag_list='<td class="mtitle"><A class="mtitle" HREF="commercial.php?liste&p_action=depense&sa=list&'.$str_dossier.'">Liste</A></td>';
|
||||
$tag_list_sel='<td class="selectedcell">Liste</td>';
|
||||
$tag_unpaid='<td class="mtitle"><A class="mtitle" HREF="commercial.php?liste&p_action=depense&sa=unpaid&'.$str_dossier.'">Non Paye</A></td>';
|
||||
$tag_unpaid_sel='<td class="selectedcell">Non Paye</td>';
|
||||
|
||||
$msg_tva='<i>Si le montant de TVA est égal à 0, il sera automatiquement calculé</i>';
|
||||
|
||||
// First we show the menu
|
||||
// If nothing is asked the propose a blank form
|
||||
// to enter a new invoice
|
||||
if ( ! isset ($_REQUEST['p_jrn'])) {
|
||||
// no journal are selected so we select the first one
|
||||
$p_jrn=GetFirstJrnIdForJrnType(dossier::id(),'ACH');
|
||||
|
||||
} else
|
||||
{
|
||||
$p_jrn=$_REQUEST['p_jrn'];
|
||||
}
|
||||
// for the back button
|
||||
$retour="";
|
||||
$h_url="";
|
||||
|
||||
if ( isset ($_REQUEST['url']))
|
||||
{
|
||||
$retour=widget::button_href('Retour',urldecode($_REQUEST['url']));
|
||||
|
||||
$h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
|
||||
}
|
||||
|
||||
$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
|
||||
//--------------------------------------------------------------------------------
|
||||
// use a predefined operation
|
||||
//--------------------------------------------------------------------------------
|
||||
if ( $sub_action=="use_opd" ) {
|
||||
echo '<div class="u_subtmenu">';
|
||||
echo ShowMenuJrnUser($gDossier,
|
||||
'ACH',
|
||||
$p_jrn,
|
||||
$tag_list.$tag_unpaid);
|
||||
echo '</div>';
|
||||
|
||||
$op=new Pre_op_ach($cn);
|
||||
$op->set_od_id($_REQUEST['pre_def']);
|
||||
$p_post=$op->compute_array();
|
||||
echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post);
|
||||
// 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">';
|
||||
|
||||
$form=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$p_post,$submit,false,$p_post['nb_item']);
|
||||
// $form=FormAchInput($cn,$p_jrn,$User->get_periode(),$_POST,$submit,false,$nb_item);
|
||||
|
||||
echo '<div class="content">';
|
||||
echo $form;
|
||||
//--------------------
|
||||
// predef op.
|
||||
echo '<form method="GET">';
|
||||
$op=new Pre_operation($cn);
|
||||
$op->p_jrn=$p_jrn;
|
||||
$op->od_direct='f';
|
||||
|
||||
$hid=new widget("hidden");
|
||||
echo $hid->IOValue("p_action","depense");
|
||||
echo dossier::hidden();
|
||||
echo $hid->IOValue("p_jrn",$p_jrn);
|
||||
echo $hid->IOValue("jrn_type","ACH");
|
||||
echo $hid->IOValue("sa","use_opd");
|
||||
|
||||
if ($op->count() != 0 )
|
||||
echo widget::submit('use_opd','Utilisez une op.prédéfinie');
|
||||
echo $op->show_button();
|
||||
|
||||
echo '</form>';
|
||||
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
// If a list of depense is asked
|
||||
//
|
||||
if ( $sub_action == "list")
|
||||
{
|
||||
// show the menu with the list item selected
|
||||
echo '<div class="u_subtmenu">';
|
||||
echo ShowMenuJrnUser($gDossier,'ACH',0,$tag_list_sel.$tag_unpaid);
|
||||
echo '</div>';
|
||||
// Ask to update payment
|
||||
if ( isset ( $_GET['paid']))
|
||||
{
|
||||
// reset all the paid flag because the checkbox is post only
|
||||
// when checked
|
||||
foreach ($_GET as $name=>$paid)
|
||||
{
|
||||
list($ad) = sscanf($name,"set_jr_id%d");
|
||||
if ( $ad == null ) continue;
|
||||
$sql="update jrn set jr_rapt='' where jr_id=$ad";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
||||
}
|
||||
// set a paid flag for the checked box
|
||||
foreach ($_GET as $name=>$paid)
|
||||
{
|
||||
list ($id) = sscanf ($name,"rd_paid%d");
|
||||
|
||||
if ( $id == null ) continue;
|
||||
|
||||
$paid=($paid=='on')?'paid':'';
|
||||
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '<div class="content">';
|
||||
|
||||
|
||||
|
||||
echo '<form method= "GET" action="commercial.php">';
|
||||
echo dossier::hidden();
|
||||
$hid=new widget("hidden");
|
||||
|
||||
$hid->name="p_action";
|
||||
$hid->value="depense";
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
$hid->name="sa";
|
||||
$hid->value="list";
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
|
||||
$w=new widget("select");
|
||||
// filter on the current year
|
||||
$filter_year=" where p_exercice='".$User->get_exercice()."'";
|
||||
|
||||
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1);
|
||||
// User is already set User=new User($cn);
|
||||
$current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode();
|
||||
$w->selected=$current;
|
||||
|
||||
echo 'Période '.$w->IOValue("p_periode",$periode_start);
|
||||
$qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
|
||||
echo JS_SEARCH_CARD;
|
||||
$w=new widget('js_search_only');
|
||||
$w->name='qcode';
|
||||
$w->value=$qcode;
|
||||
$w->label='';
|
||||
$w->extra='all';
|
||||
$w->table=0;
|
||||
$sp= new widget("span");
|
||||
echo $w->IOValue();
|
||||
echo $sp->IOValue("qcode_label","QuickCode",$qcode);
|
||||
|
||||
echo widget::submit('gl_submit','Rechercher');
|
||||
|
||||
echo '<br>'.$retour;
|
||||
|
||||
// Show list of sell
|
||||
// Date - date of payment - Customer - amount
|
||||
if ( $current != -1 )
|
||||
{
|
||||
$filter_per=" and jr_tech_per=".$current;
|
||||
}
|
||||
else
|
||||
{
|
||||
$filter_per=" and jr_tech_per in (select p_id from parm_periode where p_exercice=".
|
||||
$User->get_exercice().")";
|
||||
}
|
||||
|
||||
$sql=SQL_LIST_ALL_INVOICE." $filter_per and jr_def_type='ACH'" ;
|
||||
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
|
||||
|
||||
$l="";
|
||||
// check if qcode contains something
|
||||
if ( $qcode != "" )
|
||||
{
|
||||
// add a condition to filter on the quick code
|
||||
$l=" and jr_grpt_id in (select j_grpt from jrnx where j_qcode='$qcode') ";
|
||||
}
|
||||
/* security */
|
||||
$available_ledger=" and ".$User->get_ledger_sql();
|
||||
|
||||
list($max_line,$list)=ListJrn($cn,0,
|
||||
"where jrn_def_type='ACH' $filter_per $l $available_ledger"
|
||||
,null,$offset,1);
|
||||
$bar=jrn_navigation_bar($offset,$max_line,$step,$page);
|
||||
|
||||
echo "<hr> $bar";
|
||||
echo $list;
|
||||
echo "$bar <hr>";
|
||||
if ( $max_line !=0 )
|
||||
echo widget::submit('paid','Mise à jour paiement');
|
||||
echo '</FORM>';
|
||||
echo $retour;
|
||||
|
||||
echo '</div>';
|
||||
|
||||
exit();
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Unpaid
|
||||
if ( $sub_action == 'unpaid' ) {
|
||||
echo '<div class="u_subtmenu">';
|
||||
echo ShowMenuJrnUser($gDossier,
|
||||
'ACH',
|
||||
0,
|
||||
$tag_list.$tag_unpaid_sel);
|
||||
echo '</div>';
|
||||
|
||||
// Ask to update payment
|
||||
if ( isset ( $_POST['paid']))
|
||||
{
|
||||
// reset all the paid flag because the checkbox is post only
|
||||
// when checked
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list($ad) = sscanf($name,"set_jr_id%d");
|
||||
if ( $ad == null ) continue;
|
||||
$sql="update jrn set jr_rapt='' where jr_id=$ad";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
||||
}
|
||||
// set a paid flag for the checked box
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list ($id) = sscanf ($name,"rd_paid%d");
|
||||
|
||||
if ( $id == null ) continue;
|
||||
$paid=($paid=='on')?'paid':'';
|
||||
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
}
|
||||
|
||||
}
|
||||
/* security put a filter on the ledger */
|
||||
$available_ledger=$User->get_ledger_sql();
|
||||
|
||||
// Show list of unpaid sell
|
||||
// Date - date of payment - Customer - amount
|
||||
$sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and $available_ledger ".
|
||||
" and jrn_def_type='ACH'";
|
||||
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
|
||||
list ($max_line,$list)=ListJrn($cn,0,$sql,null,$offset,1);
|
||||
// $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page);
|
||||
|
||||
|
||||
$sql=SQL_LIST_UNPAID_INVOICE." and jrn_def_type='ACH' and $available_ledger";
|
||||
list ($max_line2,$list2)=ListJrn($cn,0,$sql,null,$offset,1);
|
||||
|
||||
// Get the max line
|
||||
$m=($max_line2>$max_line)?$max_line2:$max_line;
|
||||
$bar2=jrn_navigation_bar($offset,$m,$step,$page);
|
||||
|
||||
echo '<div class="u_redcontent">';
|
||||
echo '<h2 class="info"> Echeance dépassée </h2>';
|
||||
echo '<FORM METHOD="POST">';
|
||||
echo dossier::hidden();
|
||||
echo $bar2;
|
||||
echo $list;
|
||||
|
||||
|
||||
echo '<h2 class="info"> Non Payée </h2>';
|
||||
echo $list2;
|
||||
echo $bar2;
|
||||
$hid=new widget();
|
||||
echo '<hr>';
|
||||
if ( $m != 0 )
|
||||
echo widget::submit('paid','Mise à jour paiement');
|
||||
echo '</form>';
|
||||
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
echo '<div class="u_subtmenu">';
|
||||
echo ShowMenuJrnUser($gDossier,
|
||||
'ACH',
|
||||
$p_jrn,
|
||||
$tag_list.$tag_unpaid);
|
||||
echo '</div>';
|
||||
//-----------------------------------------------------
|
||||
// if we request to add an item
|
||||
// the $_POST['add_item'] is set
|
||||
// or if we ask to correct the invoice
|
||||
if ( isset ($_POST['add_item']) || isset ($_POST["correct"]) )
|
||||
{
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
|
||||
$nb_item=$_POST['nb_item'];
|
||||
if ( isset ($_POST['add_item']))
|
||||
$nb_item++;
|
||||
// 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">';
|
||||
|
||||
$form=FormAchInput($cn,$p_jrn,$User->get_periode(),$_POST,$submit,false,$nb_item);
|
||||
echo '<div class="content">';
|
||||
echo $form;
|
||||
echo $msg_tva;
|
||||
echo JS_CALC_LINE;
|
||||
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
// we want to save the invoice
|
||||
//
|
||||
if ( isset($_POST['save']))
|
||||
{
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
$nb_number=$_POST["nb_item"];
|
||||
if ( form_verify_input ($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number) == true ) {
|
||||
// we save the expense
|
||||
list ($internal,$c)=RecordSell($cn,$_POST,$User,$p_jrn);
|
||||
$form=FormAchView($cn,$p_jrn,$User->get_periode(),$_POST,"",$_POST['nb_item'],false);
|
||||
echo '<div class="content">';
|
||||
echo '<h2 class="info"> Opération '.$internal.' enregistré</h2>';
|
||||
echo $form;
|
||||
echo '<hr>';
|
||||
echo '</form>';
|
||||
echo '<A class="mtitle" href="commercial.php?p_action=depense&p_jrn='.$p_jrn.'&'.dossier::get().'">
|
||||
<input type="button" Value="Autre dépense"></A>';
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$submit='<INPUT TYPE="SUBMIT" name="save" value="Confirmer" onClick="return verify_ca(\'error\');" >';
|
||||
if ( $own->MY_ANALYTIC != "nu" )
|
||||
$submit.='<input type="button" value="verifie CA" onClick="verify_ca(\'ok\');">';
|
||||
$submit.='<INPUT TYPE="SUBMIT" name="correct" value="Corriger">';
|
||||
$form=FormAchView($cn,$p_jrn,$User->get_periode(),$_POST,$submit,$nb_number,true);
|
||||
echo '<div class="content">';
|
||||
echo $form;
|
||||
echo '<hr>';
|
||||
echo '</form>';
|
||||
return;
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
// we show the confirmation screen
|
||||
//
|
||||
if ( isset ($_POST['view_invoice']) )
|
||||
{
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) < 1 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
$nb_number=$_POST["nb_item"];
|
||||
$submit='<INPUT TYPE="SUBMIT" name="save" value="Confirmer">';
|
||||
$submit.='<INPUT TYPE="SUBMIT" name="correct" value="Corriger">';
|
||||
if ( form_verify_input ($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number) == true ) {
|
||||
// Should use a read only view instead of FormAch
|
||||
// where we can check
|
||||
$form=FormAchView($cn,$p_jrn,$User->get_periode(),$_POST,$submit,$nb_number);
|
||||
} else {
|
||||
// if something goes wrong, correct it
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
$form=FormAchInput($cn,$p_jrn,$User->get_periode(),$_POST,$submit, false, $nb_number);
|
||||
}
|
||||
|
||||
echo '<div class="content">';
|
||||
echo $form;
|
||||
echo '</div>';
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// By default we add a new invoice
|
||||
if ( $p_jrn != -1 )
|
||||
{
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) {
|
||||
exit -1;
|
||||
}
|
||||
|
||||
$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">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer" ID="SubmitButton">';
|
||||
// Show an empty form of invoice
|
||||
$form=FormAchInput($cn,$p_jrn,$User->get_periode(),null,$submit,false,$jrn->getDefLine());
|
||||
echo '<div class="content">';
|
||||
echo $form;
|
||||
echo $msg_tva;
|
||||
//--------------------
|
||||
// predef op.
|
||||
echo '<form method="GET">';
|
||||
$op=new Pre_operation($cn);
|
||||
$op->p_jrn=$p_jrn;
|
||||
$op->od_direct='f';
|
||||
|
||||
$hid=new widget("hidden");
|
||||
echo $hid->IOValue("p_action","depense");
|
||||
echo dossier::hidden();
|
||||
echo $hid->IOValue("p_jrn",$p_jrn);
|
||||
echo $hid->IOValue("jrn_type","ACH");
|
||||
echo $hid->IOValue("sa","use_opd");
|
||||
|
||||
if ($op->count() != 0 )
|
||||
echo widget::submit('use_opd','Utilisez une op.prédéfinie');
|
||||
echo $op->show_button();
|
||||
|
||||
echo '</form>';
|
||||
|
||||
echo JS_CALC_LINE;
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
|
@ -1,455 +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
|
||||
*/
|
||||
/* $Revision$ */
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
require_once('class_acc_ledger.php');
|
||||
require_once('user_form_ven.php');
|
||||
require_once('jrn.php');
|
||||
require_once("class_document.php");
|
||||
require_once("class_fiche.php");
|
||||
require_once("check_priv.php");
|
||||
require_once('class_acc_ledger_info.php');
|
||||
|
||||
$tag_list='<td class="mtitle"><A class="mtitle" HREF="commercial.php?liste&p_action=facture&sa=list&'.$str_dossier.'">Liste</A>';
|
||||
$tag_list_sel='<td class="selectedcell">Liste</td>';
|
||||
$tag_unpaid='</td><td class="mtitle"><A class="mtitle" href="commercial.php?liste&p_action=facture&sa=unpaid&'.$str_dossier.'">Non paye</A></TD>';
|
||||
$tag_unpaid_sel='<td class="selectedcell">Non paye</td>';
|
||||
|
||||
/*!\file
|
||||
* \brief the purpose off this file is to create invoices, to record them and to generate
|
||||
* them, and of course to save them into the database
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// First we show the menu
|
||||
// If nothing is asked the propose a blank form
|
||||
// to enter a new invoice
|
||||
if ( ! isset ($_REQUEST['p_jrn'])) {
|
||||
// no journal are selected so we select the first one
|
||||
$p_jrn=GetFirstJrnIdForJrnType($gDossier,'VEN');
|
||||
} else
|
||||
{
|
||||
$p_jrn=$_REQUEST['p_jrn'];
|
||||
}
|
||||
// for the back button
|
||||
$retour="";
|
||||
$h_url="";
|
||||
|
||||
if ( isset ($_REQUEST['url']))
|
||||
{
|
||||
$retour=widget::button_href('Retour',urldecode($_REQUEST['url']));
|
||||
|
||||
$h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
|
||||
}
|
||||
|
||||
$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
|
||||
//-----------------------------------------------------
|
||||
// If a list of invoice is asked
|
||||
//
|
||||
if ( $sub_action == "list")
|
||||
{
|
||||
// Check privilege
|
||||
/* if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) < 1 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
*/
|
||||
// show the menu with the list item selected
|
||||
echo '<div class="u_subtmenu">';
|
||||
echo ShowMenuJrnUser($gDossier,'VEN',0,$tag_list_sel.$tag_unpaid);
|
||||
echo '</div>';
|
||||
// Ask to update payment
|
||||
if ( isset ( $_GET['paid']))
|
||||
{
|
||||
// reset all the paid flag because the checkbox is post only
|
||||
// when checked
|
||||
foreach ($_GET as $name=>$paid)
|
||||
{
|
||||
list($ad) = sscanf($name,"set_jr_id%d");
|
||||
if ( $ad == null ) continue;
|
||||
$sql="update jrn set jr_rapt='' where jr_id=$ad";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
||||
}
|
||||
// set a paid flag for the checked box
|
||||
foreach ($_GET as $name=>$paid)
|
||||
{
|
||||
list ($id) = sscanf ($name,"rd_paid%d");
|
||||
|
||||
if ( $id == null ) continue;
|
||||
|
||||
$paid=($paid=='on')?'paid':'';
|
||||
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '<div class="content">';
|
||||
echo $retour;
|
||||
|
||||
|
||||
echo '<form method= "GET" action="commercial.php">';
|
||||
echo dossier::hidden();
|
||||
|
||||
$hid=new widget("hidden");
|
||||
|
||||
$hid->name="p_action";
|
||||
$hid->value="facture";
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
$hid->name="sa";
|
||||
$hid->value="list";
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
|
||||
$w=new widget("select");
|
||||
// Add filter on the year
|
||||
$filter_year=" where p_exercice='".$User->get_exercice()."'";
|
||||
|
||||
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') ".
|
||||
" from parm_periode $filter_year order by p_start,p_end",1);
|
||||
// User is already set User=new User($cn);
|
||||
$current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode();
|
||||
$w->selected=$current;
|
||||
|
||||
echo 'Période '.$w->IOValue("p_periode",$periode_start);
|
||||
$qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
|
||||
|
||||
echo JS_SEARCH_CARD;
|
||||
$w=new widget('js_search_only');
|
||||
$w->name='qcode';
|
||||
$w->value=$qcode;
|
||||
$w->label='';
|
||||
$w->extra='all';
|
||||
$w->table=0;
|
||||
$sp= new widget("span");
|
||||
|
||||
echo $sp->IOValue("qcode_label","",$qcode);
|
||||
echo $w->IOValue();
|
||||
echo widget::submit('gl_submit','Rechercher');
|
||||
// Show list of sell
|
||||
// Date - date of payment - Customer - amount
|
||||
if ( $current == -1) {
|
||||
$cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')";
|
||||
} else {
|
||||
$cond=" and jr_tech_per=".$current;
|
||||
}
|
||||
$sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_type='VEN'" ;
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
|
||||
|
||||
$l="";
|
||||
// check if qcode contains something
|
||||
if ( $qcode != "" )
|
||||
{
|
||||
$qcode=Formatstring($qcode);
|
||||
// add a condition to filter on the quick code
|
||||
$l=" and jr_grpt_id in (select j_grpt from jrnx where j_qcode=upper('$qcode')) ";
|
||||
}
|
||||
/* security */
|
||||
$available_ledger=$User->get_ledger_sql();
|
||||
|
||||
echo_debug(__FILE__.':'.__LINE__.' - available_ledger','',$available_ledger);
|
||||
list($max_line,$list)=ListJrn($cn,0,"where jrn_def_type='VEN' $cond $l and $available_ledger "
|
||||
,null,$offset,1);
|
||||
$bar=jrn_navigation_bar($offset,$max_line,$step,$page);
|
||||
|
||||
echo "<hr> $bar";
|
||||
echo $list;
|
||||
echo "$bar <hr>";
|
||||
if ( $max_line !=0 )
|
||||
echo widget::submit('paid','Mise à jour paiement');
|
||||
echo '</FORM>';
|
||||
echo $retour;
|
||||
|
||||
echo '</div>';
|
||||
|
||||
exit();
|
||||
}
|
||||
if ( $sub_action=="unpaid") {
|
||||
echo '<div class="u_subtmenu">';
|
||||
echo ShowMenuJrnUser($gDossier,'VEN',0,$tag_list.$tag_unpaid_sel);
|
||||
echo '</div>';
|
||||
|
||||
// Ask to update payment
|
||||
if ( isset ( $_POST['paid']))
|
||||
{
|
||||
// reset all the paid flag because the checkbox is post only
|
||||
// when checked
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list($ad) = sscanf($name,"set_jr_id%d");
|
||||
if ( $ad == null ) continue;
|
||||
$sql="update jrn set jr_rapt='' where jr_id=$ad";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
||||
}
|
||||
// set a paid flag for the checked box
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list ($id) = sscanf ($name,"rd_paid%d");
|
||||
|
||||
if ( $id == null ) continue;
|
||||
$paid=($paid=='on')?'paid':'';
|
||||
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Show list of unpaid sell
|
||||
// Date - date of payment - Customer - amount
|
||||
// Nav. bar
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
|
||||
/* security put a filter on the ledger */
|
||||
$available_ledger=$User->get_ledger_sql();
|
||||
|
||||
|
||||
$sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jrn_def_type='VEN' and $available_ledger";
|
||||
list($max_line,$list)=ListJrn($cn,0,$sql,null,$offset,1);
|
||||
$sql=SQL_LIST_UNPAID_INVOICE." and ".$available_ledger.
|
||||
" and jrn_def_type='VEN'";
|
||||
list($max_line2,$list2)=ListJrn($cn,0,$sql,null,$offset,1);
|
||||
|
||||
// Get the max line
|
||||
$m=($max_line2>$max_line)?$max_line2:$max_line;
|
||||
$bar2=jrn_navigation_bar($offset,$m,$step,$page);
|
||||
|
||||
echo '<div class="u_redcontent">';
|
||||
echo '<FORM METHOD="POST">';
|
||||
echo dossier::hidden();
|
||||
echo $bar2;
|
||||
echo '<h2 class="info"> Echeance dépassée </h2>';
|
||||
echo $list;
|
||||
echo '<h2 class="info"> Non Payée </h2>';
|
||||
echo $list2;
|
||||
echo $bar2;
|
||||
// Add hidden parameter
|
||||
$hid=new widget("hidden");
|
||||
|
||||
$hid->name="sa";
|
||||
$hid->value="unpaid";
|
||||
echo $hid->IOValue();
|
||||
|
||||
$hid->name="p_action";
|
||||
$hid->value="facture";
|
||||
echo $hid->IOValue();
|
||||
echo '<hr>';
|
||||
|
||||
if ( $m != 0 )
|
||||
echo widget::submit('paid','Mise à jour paiement');
|
||||
|
||||
echo '</FORM>';
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
echo '<div class="u_subtmenu">';
|
||||
echo ShowMenuJrnUser($gDossier,'VEN',$p_jrn,$tag_list.$tag_unpaid);
|
||||
echo '</div>';
|
||||
//--------------------------------------------------------------------------------
|
||||
// use a predefined operation
|
||||
//--------------------------------------------------------------------------------
|
||||
if ( $sub_action=="use_opd" ) {
|
||||
$op=new Pre_op_ven($cn);
|
||||
$op->set_od_id($_REQUEST['pre_def']);
|
||||
$p_post=$op->compute_array();
|
||||
echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post);
|
||||
$form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$p_post,false,$p_post['nb_item']);
|
||||
echo '<div class="content">';
|
||||
echo $form;
|
||||
|
||||
//--------------------
|
||||
// predef op.
|
||||
echo '<form method="GET">';
|
||||
$op=new Pre_operation($cn);
|
||||
$op->p_jrn=$p_jrn;
|
||||
$op->od_direct='f';
|
||||
$hid=new widget("hidden");
|
||||
echo $hid->IOValue("p_action","facture");
|
||||
echo dossier::hidden();
|
||||
echo $hid->IOValue("p_jrn",$p_jrn);
|
||||
echo $hid->IOValue("jrn_type","VEN");
|
||||
echo $hid->IOValue("sa","use_opd");
|
||||
|
||||
if ($op->count() != 0 )
|
||||
echo widget::submit('use_opd','Utilisez une op.prédéfinie');
|
||||
echo $op->show_button();
|
||||
|
||||
echo '</form>';
|
||||
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
// if we request to add an item
|
||||
// the $_POST['add_item'] is set
|
||||
// or if we ask to correct the invoice
|
||||
if ( isset ($_POST['add_item']) || isset ($_POST["correct_new_invoice"]) )
|
||||
{
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
|
||||
$nb_item=$_POST['nb_item'];
|
||||
if ( isset ($_POST['add_item']))
|
||||
$nb_item++;
|
||||
$form=FormVenInput($cn,$p_jrn,$User->get_periode(),$_POST,false,$nb_item);
|
||||
echo '<div class="content">';
|
||||
echo $form;
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
// we want to save the invoice and to generate a invoice
|
||||
//
|
||||
if ( isset($_POST['record_and_print_invoice']))
|
||||
{
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
$nb_number=$_POST['nb_item'];
|
||||
// First we save the invoice, the internal code will be used to change the description
|
||||
// and upload the file
|
||||
if ( form_verify_input($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number)== true) {
|
||||
list ($internal,$e)=RecordInvoice($cn,$_POST,$User,$p_jrn);
|
||||
$form=FormVenteView($cn,$p_jrn,$User->get_periode(),$_POST,$_POST['nb_item'],'noform','');
|
||||
|
||||
echo '<div class="content">';
|
||||
echo '<h2 class="info"> Opération '.$internal.' enregistré</h2>';
|
||||
echo $form;
|
||||
echo '<hr>';
|
||||
|
||||
// Show the details of the encoded invoice
|
||||
// and the url of the invoice
|
||||
if ( isset($_POST['gen_invoice']))
|
||||
{
|
||||
$doc=new Document($cn);
|
||||
$doc->f_id=$_POST['e_client'];
|
||||
$doc->md_id=$_POST['gen_doc'];
|
||||
$doc->ag_id=0;
|
||||
$str_file=$doc->Generate();
|
||||
// Move the document to the jrn
|
||||
$doc->MoveDocumentPj($internal);
|
||||
// Update the comment with invoice number
|
||||
$sql="update jrn set jr_comment='Facture ".$doc->d_number."' where jr_internal='$internal'";
|
||||
ExecSql($cn,$sql);
|
||||
/* Save the additional information into jrn_info */
|
||||
$obj=new Acc_Ledger_Info($cn);
|
||||
$jr_id=$obj->search_id_internal($internal);
|
||||
if (strlen(trim($_POST['bon_comm'] )) != 0 ) {
|
||||
$obj->set_type('BON_COMMANDE');
|
||||
$obj->set_value($_POST['bon_comm']);
|
||||
$obj->insert();
|
||||
}
|
||||
if (strlen(trim($_POST['other_info'] )) != 0 ) {
|
||||
$obj->set_type('OTHER');
|
||||
$obj->set_value($_POST['other_info']);
|
||||
$obj->insert();
|
||||
}
|
||||
echo $str_file;
|
||||
}
|
||||
} else {
|
||||
|
||||
echo("A cause d'erreur la facture ne peut-ètre validé ");
|
||||
$form=FormVenteView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number,"form");
|
||||
|
||||
}
|
||||
|
||||
echo '</form>';
|
||||
// Button return
|
||||
printf ('<A class="mtitle" href="?jrn_type=VEN&p_jrn=%d&p_action=facture&%s"><input type="Button" value="Autre Facture"></A>',
|
||||
$p_jrn,dossier::get());
|
||||
exit();
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
// we show the confirmation screen it is proposed here to generate the
|
||||
// invoice
|
||||
if ( isset ($_POST['view_invoice']) )
|
||||
{
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) < 1 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
$nb_number=$_POST["nb_item"];
|
||||
if ( form_verify_input($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number) == true)
|
||||
{
|
||||
$form=FormVenteView($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number);
|
||||
|
||||
} else {
|
||||
// Check failed : invalid date or quantity
|
||||
echo_error("Cannot validate ");
|
||||
$form=FormVenInput($cn,$p_jrn,$User->get_periode(),$_POST,false,$nb_number);
|
||||
}
|
||||
|
||||
echo '<div class="content">';
|
||||
echo $form;
|
||||
echo '</div>';
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// By default we add a new invoice
|
||||
if ( $p_jrn != -1 )
|
||||
{
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) {
|
||||
exit -1;
|
||||
}
|
||||
|
||||
$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->get_periode(),null,false,$jrn->GetDefLine());
|
||||
echo '<div class="content">';
|
||||
echo $form;
|
||||
|
||||
//--------------------
|
||||
// predef op.
|
||||
echo '<form method="GET">';
|
||||
$op=new Pre_operation($cn);
|
||||
$op->p_jrn=$p_jrn;
|
||||
$op->od_direct='f';
|
||||
$hid=new widget("hidden");
|
||||
echo $hid->IOValue("p_action","facture");
|
||||
echo dossier::hidden();
|
||||
echo $hid->IOValue("p_jrn",$p_jrn);
|
||||
echo $hid->IOValue("jrn_type","VEN");
|
||||
echo $hid->IOValue("sa","use_opd");
|
||||
|
||||
if ($op->count() != 0 )
|
||||
echo widget::submit('use_opd','Utilisez une op.prédéfinie');
|
||||
echo $op->show_button();
|
||||
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
|
@ -1,404 +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 included file for the ledger of expenses
|
||||
*/
|
||||
echo_debug('user_action_ach.php',__LINE__,"include user_action_ach.php");
|
||||
require_once("user_form_ach.php");
|
||||
require_once ("preference.php");
|
||||
require_once ("user_common.php");
|
||||
require_once("class_widget.php");
|
||||
require_once("class_acc_ledger.php");
|
||||
require_once ('class_own.php');
|
||||
|
||||
$own=new own($cn);
|
||||
|
||||
$cn=DbConnect($gDossier);
|
||||
|
||||
$msg_tva='<i>Si le montant de TVA est égal à 0, il sera automatiquement calculé</i>';
|
||||
|
||||
if ( ! isset ($_REQUEST['action'])){
|
||||
exit;
|
||||
}
|
||||
$action=$_REQUEST['action'];
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// use a predefined operation
|
||||
//--------------------------------------------------------------------------------
|
||||
if ( $action=="use_opd" ) {
|
||||
$op=new Pre_op_ach($cn);
|
||||
$op->set_od_id($_REQUEST['pre_def']);
|
||||
$p_post=$op->compute_array();
|
||||
echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post);
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer" ID="SubmitButton">';
|
||||
|
||||
$form=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$p_post,$submit,false,$p_post['nb_item']);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $form;
|
||||
|
||||
//--------------------
|
||||
// predef op.
|
||||
echo '<form method="GET">';
|
||||
$op->set('ledger',$_GET['p_jrn']);
|
||||
$op->set('ledger_type',"ACH");
|
||||
$op->set('direct','f');
|
||||
|
||||
echo $op->form_get();
|
||||
|
||||
echo '</form>';
|
||||
|
||||
echo "<div>".JS_CALC_LINE."</div>";
|
||||
echo "</div>";
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
|
||||
// action = new
|
||||
if ( $action == 'new' ) {
|
||||
// We request a new form
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
|
||||
if ( isset($_GET['blank'] )) {
|
||||
// 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 Acc_Ledger($cn, $_GET['p_jrn']);
|
||||
$r=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,false,$jrn->getDefLine());
|
||||
//--------------------
|
||||
// predef op.
|
||||
$op=new Pre_operation_detail($cn);
|
||||
$op->set('ledger',$_GET['p_jrn']);
|
||||
$op->set('ledger_type',"ACH");
|
||||
$op->set('direct','f');
|
||||
|
||||
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $r;
|
||||
echo $msg_tva;
|
||||
//--------------------
|
||||
// predef op.
|
||||
echo '<form method="GET">';
|
||||
echo $op->form_get();
|
||||
echo '</form>';
|
||||
|
||||
echo "<div>".JS_CALC_LINE."</div>";
|
||||
echo "</div>";
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Add an item
|
||||
if ( isset ($_POST['add_item'])) {
|
||||
// Add a line
|
||||
$nb_number=$_POST["nb_item"];
|
||||
$nb_number++;
|
||||
|
||||
// submit button in the form
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
|
||||
$r=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,false,
|
||||
$nb_number);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $r;
|
||||
echo $msg_tva;
|
||||
|
||||
echo "<div>".JS_CALC_LINE."<div>";
|
||||
echo "</div>";
|
||||
}
|
||||
// Correct it
|
||||
if ( isset ($_POST['correct'])) {
|
||||
// Get number of lines
|
||||
$nb_number=$_POST["nb_item"];
|
||||
|
||||
// submit button in the form
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
|
||||
$r=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,false, $nb_number);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $r;
|
||||
echo $msg_tva;
|
||||
|
||||
echo "<div>".JS_CALC_LINE."<div>";
|
||||
echo "</div>";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// View the charge and show a submit button to save it
|
||||
if ( isset ($_POST['view_invoice']) and
|
||||
! isset ($_POST['save'])) {
|
||||
$nb_number=$_POST["nb_item"];
|
||||
$submit='<INPUT TYPE="SUBMIT" name="save" value="Confirmer" onClick="verify_ca(\'error\');">';
|
||||
if ( $own->MY_ANALYTIC != "nu" )
|
||||
$submit.='<input type="button" value="verifie CA" onClick="verify_ca(\'ok\');">';
|
||||
$submit.='<INPUT TYPE="SUBMIT" name="correct" value="Corriger">';
|
||||
if ( form_verify_input ($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number) == true ) {
|
||||
// Should use a read only view instead of FormAch
|
||||
// where we can check
|
||||
$r=FormAchView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,$nb_number);
|
||||
} else {
|
||||
// if something goes wrong, correct it
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
$r=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit, false, $nb_number);
|
||||
}
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $r;
|
||||
echo $msg_tva;
|
||||
|
||||
echo "<div>".JS_CALC_LINE."<div>";
|
||||
echo "</div>";
|
||||
}
|
||||
// Save the charge into database
|
||||
if ( isset($_POST['save'] )) {
|
||||
// Get number of lines
|
||||
$nb_number=$_POST["nb_item"];
|
||||
if (form_verify_input ($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number)
|
||||
== true ) {
|
||||
list($internal,$comment)=RecordSell($cn,$_POST,$User,$_GET['p_jrn']);
|
||||
|
||||
// submit button in the form
|
||||
$submit='<h2 class="info">Opération '.$internal.' </h2>';
|
||||
$r=FormAchView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,"",$nb_number,false);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $submit;
|
||||
echo $r;
|
||||
echo "</div>";
|
||||
}else {
|
||||
$submit='<INPUT TYPE="SUBMIT" name="save" value="Confirmer" onClick="return verify_ca(\'error\');">';
|
||||
if ( $own->MY_ANALYTIC != "nu" )
|
||||
$submit.='<input type="button" value="verifie CA" onClick="verify_ca(\'ok\');">';
|
||||
|
||||
$submit.='<INPUT TYPE="SUBMIT" name="correct" value="Corriger">';
|
||||
|
||||
$r=FormAchView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,$nb_number);
|
||||
echo '<div class="u_redcontent">';
|
||||
// echo $submit;
|
||||
echo $r;
|
||||
echo "</div>";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if ( $action == 'voir_jrn' ) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
?>
|
||||
<div class="u_redcontent">
|
||||
<form method= "get" action="user_jrn.php">
|
||||
|
||||
<?php
|
||||
echo dossier::hidden();
|
||||
$hid=new widget("hidden");
|
||||
|
||||
$hid->name="p_jrn";
|
||||
$hid->value=$p_jrn;
|
||||
echo $hid->IOValue();
|
||||
|
||||
$hid->name="jrn_type";
|
||||
$hid->value=$jrn_type;
|
||||
echo $hid->IOValue();
|
||||
|
||||
$hid->name="action";
|
||||
$hid->value="voir_jrn";
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
$w=new widget("select");
|
||||
$w->name="p_periode";
|
||||
// filter on the current year
|
||||
$filter_year=" where p_exercice='".$User->get_exercice()."'";
|
||||
|
||||
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1);
|
||||
$User=new User($cn);
|
||||
$current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode();
|
||||
$w->selected=$current;
|
||||
|
||||
echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider');
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
// Ask to update payment
|
||||
if ( isset ( $_POST['paid']))
|
||||
{
|
||||
// reset all the paid flag because the checkbox is post only
|
||||
// when checked
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list($ad) = sscanf($name,"set_jr_id%d");
|
||||
if ( $ad == null ) continue;
|
||||
$sql="update jrn set jr_rapt='' where jr_id=$ad";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
||||
}
|
||||
// set a paid flag for the checked box
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list ($id) = sscanf ($name,"rd_paid%d");
|
||||
|
||||
if ( $id == null ) continue;
|
||||
|
||||
$paid=($paid=='on')?'paid':'';
|
||||
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Show list of sell
|
||||
echo_debug ("user_action_ach.php");
|
||||
// Date - date of payment - Customer - amount
|
||||
if ( $current == -1) {
|
||||
$cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')";
|
||||
} else {
|
||||
$cond=" and jr_tech_per=".$current;
|
||||
}
|
||||
|
||||
$sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$_GET['p_jrn'];
|
||||
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
|
||||
|
||||
list ($max_ligne,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
|
||||
$bar=jrn_navigation_bar($offset,$max_ligne,$step,$page);
|
||||
echo '<form method="POST">';
|
||||
echo dossier::hidden();
|
||||
|
||||
echo "<hr> $bar";
|
||||
echo $list;
|
||||
echo "$bar <hr>";
|
||||
$hid=new widget();
|
||||
if ( $max_ligne != 0 )
|
||||
echo widget::submit('paid','Mise à jour paiement');
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
if ( $action == 'voir_jrn_non_paye' ) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
// Ask to update payment
|
||||
if ( isset ( $_POST['paid']))
|
||||
{
|
||||
// reset all the paid flag because the checkbox is post only
|
||||
// when checked
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list($ad) = sscanf($name,"set_jr_id%d");
|
||||
if ( $ad == null ) continue;
|
||||
$sql="update jrn set jr_rapt='' where jr_id=$ad";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
||||
}
|
||||
// set a paid flag for the checked box
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list ($id) = sscanf ($name,"rd_paid%d");
|
||||
|
||||
if ( $id == null ) continue;
|
||||
$paid=($paid=='on')?'paid':'';
|
||||
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Show list of unpaid sell
|
||||
// Date - date of payment - Customer - amount
|
||||
$sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$_GET['p_jrn'] ;
|
||||
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
|
||||
list ($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
|
||||
// $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page);
|
||||
|
||||
|
||||
$sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$_GET['p_jrn'] ;
|
||||
list ($max_line2,$list2)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
|
||||
|
||||
// Get the max line
|
||||
$m=($max_line2>$max_line)?$max_line2:$max_line;
|
||||
$bar2=jrn_navigation_bar($offset,$m,$step,$page);
|
||||
|
||||
echo '<div class="u_redcontent">';
|
||||
echo '<h2 class="info"> Echeance dépassée </h2>';
|
||||
echo '<FORM METHOD="POST">';
|
||||
echo dossier::hidden();
|
||||
echo $bar2;
|
||||
echo $list;
|
||||
|
||||
|
||||
echo '<h2 class="info"> Non Payée </h2>';
|
||||
echo $list2;
|
||||
echo $bar2;
|
||||
$hid=new widget();
|
||||
echo '<hr>';
|
||||
if ( $m != 0 )
|
||||
echo widget::submit('paid','Mise à jour paiement');
|
||||
echo '</form>';
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//Search
|
||||
if ( $action == 'search' ) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
|
||||
// PhpSessid
|
||||
$sessid=$_REQUEST['PHPSESSID'];
|
||||
// Search modules
|
||||
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
|
||||
// display a search box
|
||||
$search_box=u_ShowMenuRecherche($cn,$_GET['p_jrn'],$sessid,$_POST);
|
||||
echo '<DIV class="u_redcontent">';
|
||||
echo $search_box;
|
||||
// if nofirst is set then show result
|
||||
if ( isset ($_GET['nofirst'] ) ) {
|
||||
list ($max_line,$a)=ListJrn($cn,$_GET['p_jrn'],"",$_POST);
|
||||
echo $a;
|
||||
}
|
||||
echo '</DIV>';
|
||||
}
|
||||
require_once("user_update.php");
|
||||
?>
|
||||
|
|
@ -1,310 +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 included file for the financial ledger
|
||||
*/
|
||||
|
||||
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_acc_parm_code.php");
|
||||
require_once("class_acc_ledger.php");
|
||||
require_once ('class_pre_op_fin.php');
|
||||
|
||||
$cn=DbConnect($gDossier);
|
||||
|
||||
if ( ! isset ($_GET['action']) && ! isset ($_POST["action"]) ) {
|
||||
return;
|
||||
}
|
||||
include_once ("preference.php");
|
||||
include_once ("user_common.php");
|
||||
if ( ! isset($_REQUEST['action'])) {
|
||||
echo "Aucune Action demandée";
|
||||
exit();
|
||||
}
|
||||
|
||||
$action=$_REQUEST['action'];
|
||||
//--------------------------------------------------------------------------------
|
||||
// use a predefined operation
|
||||
//--------------------------------------------------------------------------------
|
||||
if ( $action=="use_opd" ) {
|
||||
$op=new Pre_op_fin($cn);
|
||||
$op->set_od_id($_REQUEST['pre_def']);
|
||||
$p_post=$op->compute_array();
|
||||
echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post);
|
||||
// submit button in the form
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">'.
|
||||
'<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
|
||||
$form=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$p_post,false,$p_post['nb_item']);
|
||||
echo '<div class="content">';
|
||||
echo $form;
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
// action = new
|
||||
//-----------------------------------------------------
|
||||
if ( $action == 'new' ) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
|
||||
// We request a new form
|
||||
if ( isset($_GET['blank'] )) {
|
||||
// Submit button in the form
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
// add a one-line calculator
|
||||
$p_jrn=$_GET['p_jrn'];
|
||||
$jrn=new Acc_Ledger($cn, $p_jrn);
|
||||
|
||||
$r=FormFin($cn,$p_jrn,$User->get_periode(),$submit,null,false,$jrn->GetDefLine());
|
||||
echo '<div class="content">';
|
||||
echo $r;
|
||||
echo "<div>";
|
||||
//--------------------
|
||||
// predef op.
|
||||
echo '<form method="GET">';
|
||||
$op=new Pre_operation($cn);
|
||||
$op->p_jrn=$_GET['p_jrn'];
|
||||
$op->od_direct='f';
|
||||
|
||||
$hid=new widget("hidden");
|
||||
echo $hid->IOValue("action","use_opd");
|
||||
echo dossier::hidden();
|
||||
echo $hid->IOValue("p_jrn",$_GET['p_jrn']);
|
||||
echo $hid->IOValue("jrn_type","FIN");
|
||||
|
||||
if ($op->count() != 0 )
|
||||
echo widget::submit('use_opd','Utilisez une op.prédéfinie');
|
||||
echo $op->show_button();
|
||||
|
||||
echo '</form>';
|
||||
|
||||
echo "<h4>On-line calculator</h4>".JS_CALC_LINE."</div>";
|
||||
|
||||
echo "</div>";
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Add an item
|
||||
if ( isset ($_POST['add_item'])) {
|
||||
// Add a line
|
||||
$nb_number=$_POST["nb_item"];
|
||||
$nb_number++;
|
||||
|
||||
// submit button in the form
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
|
||||
$r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
|
||||
echo '<div class="content">';
|
||||
echo $r;
|
||||
echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."</div>";
|
||||
|
||||
echo "</div>";
|
||||
}
|
||||
// Correct it
|
||||
if ( isset ($_POST['correct'])) {
|
||||
// Get number of lines
|
||||
$nb_number=$_POST["nb_item"];
|
||||
|
||||
// submit button in the form
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
|
||||
$r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $r;
|
||||
echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."</div>";
|
||||
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
|
||||
// View the charge and show a submit button to save it
|
||||
if ( isset ($_POST['view_invoice']) ) {
|
||||
$nb_number=$_POST["nb_item"];
|
||||
$r=form_verify_input($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number);
|
||||
// if something goes wrong correct it
|
||||
if ( $r == null )
|
||||
{
|
||||
// submit button in the form
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
|
||||
$r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
|
||||
}
|
||||
else
|
||||
{
|
||||
$submit='<INPUT TYPE="SUBMIT" name="save" value="Confirmer">';
|
||||
$submit.='<INPUT TYPE="SUBMIT" name="correct" value="Corriger">';
|
||||
|
||||
$r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,true,$nb_number);
|
||||
}
|
||||
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $r;
|
||||
echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."</div>";
|
||||
echo "</div>";
|
||||
}
|
||||
// Save the charge into database
|
||||
if ( isset($_POST['save'] )) {
|
||||
$internal=RecordFin($cn,$_POST,$User,$_GET['p_jrn']);
|
||||
// Get number of lines
|
||||
$nb_number=$_POST["nb_item"];
|
||||
|
||||
// submit button in the form
|
||||
//$submit='<h2 class="info">Enregistré '.$r.'</h2>';
|
||||
$submit="";
|
||||
$r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,true, $nb_number,true);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo '<h2 class="info">Enregistré '.$internal.'</h2>';
|
||||
echo $submit;
|
||||
echo $r;
|
||||
echo "</div>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
// see jrn
|
||||
//-----------------------------------------------------
|
||||
if ( $action == 'voir_jrn' ) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
?>
|
||||
<div class="content">
|
||||
|
||||
<form method= "get" action="user_jrn.php">
|
||||
|
||||
<?php
|
||||
echo dossier::hidden();
|
||||
$hid=new widget("hidden");
|
||||
|
||||
$hid->name="p_jrn";
|
||||
$hid->value=$p_jrn;
|
||||
echo $hid->IOValue();
|
||||
|
||||
$hid->name="action";
|
||||
$hid->value="voir_jrn";
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
$hid->name="jrn_type";
|
||||
$hid->value=$jrn_type;
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
$w=new widget("select");
|
||||
// filter on the current year
|
||||
$filter_year=" where p_exercice='".$User->get_exercice()."'";
|
||||
|
||||
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1);
|
||||
$User=new User($cn);
|
||||
$current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode();
|
||||
$w->selected=$current;
|
||||
|
||||
echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider');
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
// Show list of sell
|
||||
echo_debug ("user_action_jrn.php");
|
||||
if ( $current == -1) {
|
||||
$cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')";
|
||||
} else {
|
||||
$cond=" and jr_tech_per=".$current;
|
||||
}
|
||||
|
||||
// Date - date of payment - Customer - amount
|
||||
$sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$_GET['p_jrn'];
|
||||
|
||||
// Nav. bar
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
|
||||
// SQL
|
||||
list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset);
|
||||
|
||||
$bar=jrn_navigation_bar($offset,$max_line,$step,$page);
|
||||
|
||||
echo $bar;
|
||||
echo $list;
|
||||
echo $bar;
|
||||
echo '</div>';
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
// balance
|
||||
//-----------------------------------------------------
|
||||
if ( $action == 'solde' ) {
|
||||
require_once("poste.php");
|
||||
// find the bank account
|
||||
// NOTE : those values are in a table because
|
||||
// they are _national_ parameters
|
||||
$banque=new Acc_Parm_Code($cn,'BANQUE');
|
||||
$caisse=new Acc_Parm_Code($cn,'CAISSE');
|
||||
$vir_interne=new Acc_Parm_Code($cn,'VIREMENT_INTERNE');
|
||||
$accountSql="select distinct pcm_val::text,pcm_lib from
|
||||
tmp_pcmn
|
||||
where pcm_val::text like '".$banque->p_value."%' or pcm_val::text like '".$vir_interne->p_value."%'
|
||||
or pcm_val::text like '".$caisse->p_value."%'
|
||||
order by pcm_val::text";
|
||||
$ResAccount=ExecSql($cn,$accountSql);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo "<table>";
|
||||
// for each account
|
||||
for ( $i = 0; $i < pg_NumRows($ResAccount);$i++) {
|
||||
// get the saldo
|
||||
$l=pg_fetch_array($ResAccount,$i);
|
||||
$m=get_solde($cn,$l['pcm_val'],' and j_tech_per in (select '.
|
||||
'p_id from parm_periode where p_exercice='.$User->get_exercice().') ');
|
||||
// print the result if the saldo is not equal to 0
|
||||
if ( $m != 0.0 ) {
|
||||
echo "<tr>";
|
||||
echo "<TD>".
|
||||
$l['pcm_val'].
|
||||
"</TD>".
|
||||
"<TD>".
|
||||
$l['pcm_lib'].
|
||||
"</TD>"."<TD>".
|
||||
$m.
|
||||
"</TD>"."</TR>";
|
||||
}
|
||||
}// for
|
||||
echo "</table>";
|
||||
echo "</div>";
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
require_once("user_update.php");
|
||||
|
||||
|
||||
?>
|
||||
|
|
@ -1,296 +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 included file for the miscellaneous operation ledger
|
||||
*/
|
||||
|
||||
echo_debug('user_action_ods.php',__LINE__,"include user_action_ods.php");
|
||||
include_once("user_form_ods.php");
|
||||
include_once("class_widget.php");
|
||||
require_once('class_dossier.php');
|
||||
require_once ('class_pre_operation.php');
|
||||
require_once ('class_pre_op_ods.php');
|
||||
require_once ('class_own.php');
|
||||
require_once ('class_acc_ledger.php');
|
||||
|
||||
$gDossier=dossier::id();
|
||||
|
||||
$cn=DbConnect($gDossier);
|
||||
$own=new own($cn);
|
||||
if ( ! isset ($_GET['action']) && ! isset ($_POST["action"]) ) {
|
||||
exit;
|
||||
|
||||
}
|
||||
include_once ("preference.php");
|
||||
include_once ("user_common.php");
|
||||
|
||||
|
||||
$action=(isset($_GET['action']))?$_GET['action']:$_POST['action'];
|
||||
//--------------------------------------------------------------------------------
|
||||
// use a predefined operation
|
||||
//--------------------------------------------------------------------------------
|
||||
if ( $action=="use_opd" ) {
|
||||
$op=new Pre_op_ods($cn);
|
||||
$op->set_od_id($_REQUEST['pre_def']);
|
||||
$p_post=$op->compute_array();
|
||||
echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post);
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout poste">'.
|
||||
'<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Confirmer">';
|
||||
|
||||
// $form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$p_post,false,$p_post['nb_item']);
|
||||
$form=FormODS($cn,$_REQUEST['p_jrn'],$User->get_periode(),$submit,$p_post,false,$p_post['nb_item']);
|
||||
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $form;
|
||||
//--------------------
|
||||
// predef op.
|
||||
echo '<form method="GET">';
|
||||
$op=new Pre_operation_detail($cn);
|
||||
$op->set('ledger',$_GET['p_jrn']);
|
||||
$op->set('ledger_type',"ODS");
|
||||
$op->set('direct','f');
|
||||
echo $op->form_get();
|
||||
|
||||
echo '</form>';
|
||||
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
|
||||
// action = new
|
||||
if ( $action == 'new' ) {
|
||||
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_REQUEST['p_jrn']) != 2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
// We request a new form
|
||||
if ( isset($_GET['blank'] )) {
|
||||
// Submit button in the form
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout poste">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Confirmer">';
|
||||
// add a one-line calculator
|
||||
$jrn=new Acc_Ledger($cn,$_GET['p_jrn']);
|
||||
$prop=$jrn->get_propertie();
|
||||
$line=$prop['jrn_deb_max_line'];
|
||||
$r=FormODS($cn,$_REQUEST['p_jrn'],$User->get_periode(),$submit,null,false,$line);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $r;
|
||||
echo "<div>";
|
||||
//--------------------
|
||||
// predef op.
|
||||
echo '<form method="GET">';
|
||||
$op=new Pre_operation_detail($cn);
|
||||
$op->set('ledger',$_GET['p_jrn']);
|
||||
$op->set('ledger_type',"ODS");
|
||||
$op->set('direct','f');
|
||||
echo $op->form_get();
|
||||
|
||||
echo '</form>';
|
||||
|
||||
|
||||
echo "<h4>On-line calculator</h4>".JS_CALC_LINE."<div>";
|
||||
echo "</div>";
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Add an item
|
||||
if ( isset ($_POST['add_item'])) {
|
||||
// Add a line
|
||||
$nb_number=$_POST["nb_item"];
|
||||
$nb_number++;
|
||||
|
||||
// submit button in the form
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout Poste">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
|
||||
$r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $r;
|
||||
echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."<div>";
|
||||
echo "</div>";
|
||||
}
|
||||
// Correct it
|
||||
if ( isset ($_POST['correct'])) {
|
||||
// Get number of lines
|
||||
$nb_number=$_POST["nb_item"];
|
||||
|
||||
// submit button in the form
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout Poste">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
|
||||
$r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $r;
|
||||
echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."<div>";
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
|
||||
// View the charge and show a submit button to save it
|
||||
// TODO: the name 'view_invoice' should be changed to something more self-explaining, like
|
||||
// 'submit_od', no?
|
||||
if ( isset ($_POST['view_invoice']) ) {
|
||||
$nb_number=$_POST["nb_item"];
|
||||
$submit='<INPUT TYPE="SUBMIT" name="save" value="Confirmer" onClick="return verify_ca(\'error\');">';
|
||||
if ( $own->MY_ANALYTIC != "nu" )
|
||||
$submit.='<input type="button" value="verifie CA" onClick="verify_ca(\'ok\');">';
|
||||
$submit.='<INPUT TYPE="SUBMIT" name="correct" value="Corriger">';
|
||||
|
||||
$r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,true,$nb_number);
|
||||
|
||||
// if something goes wrong, correct it
|
||||
if ( $r == null ) {
|
||||
// submit button in the form
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout Poste">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
|
||||
$r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
|
||||
}else {
|
||||
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout Poste">
|
||||
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer">';
|
||||
|
||||
|
||||
}
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $r;
|
||||
echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."<div>";
|
||||
echo "</div>";
|
||||
}
|
||||
// Save the change into database
|
||||
if ( isset($_POST['save'] )) {
|
||||
$r=RecordODS($cn,$_POST,$User,$_POST['p_jrn']);
|
||||
// Get number of lines
|
||||
$nb_number=$_POST["nb_item"];
|
||||
if ( $r != null ) {
|
||||
// submit button in the form
|
||||
$submit='<h2 class="info">Recorded'.$r.'</h2>';
|
||||
|
||||
$r.=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,true, $nb_number,true);
|
||||
}else {
|
||||
// CA incorrecte
|
||||
$submit='<INPUT TYPE="SUBMIT" name="save" value="Confirmer" onClick="return verify_ca(\'error\');">';
|
||||
if ( $own->MY_ANALYTIC != "nu" )
|
||||
$submit.='<input type="button" value="verifie CA" onClick="verify_ca(\'ok\');">';
|
||||
$submit.='<INPUT TYPE="SUBMIT" name="correct" value="Corriger">';
|
||||
|
||||
$r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,true,$nb_number);
|
||||
|
||||
}
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $r;
|
||||
echo "</div>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if ( $action == 'voir_jrn' ) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_REQUEST['p_jrn']) < 1 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
|
||||
// Show list of cells
|
||||
echo_debug ("user_action_ods.php");
|
||||
// Date - date of payment - Customer - amount
|
||||
?>
|
||||
<div class="u_redcontent">
|
||||
|
||||
<form method= "get" action="user_jrn.php">
|
||||
|
||||
<?php
|
||||
echo dossier::hidden();
|
||||
$hid=new widget("hidden");
|
||||
|
||||
$hid->name="p_jrn";
|
||||
$hid->value=$p_jrn;
|
||||
echo $hid->IOValue();
|
||||
|
||||
$hid->name="action";
|
||||
$hid->value="voir_jrn";
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
$hid->name="jrn_type";
|
||||
$hid->value=$jrn_type;
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
|
||||
$w=new widget("select");
|
||||
// filter on the current year
|
||||
$filter_year=" where p_exercice='".$User->get_exercice()."'";
|
||||
|
||||
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1);
|
||||
$User=new User($cn);
|
||||
$current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode();
|
||||
$w->selected=$current;
|
||||
|
||||
echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider');
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
if ( $current == -1) {
|
||||
$cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')";
|
||||
} else {
|
||||
$cond=" and jr_tech_per=".$current;
|
||||
}
|
||||
|
||||
$sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$_GET['p_jrn'] ;
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
|
||||
list ($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset);
|
||||
$bar=jrn_navigation_bar($offset,$max_line,$step,$page);
|
||||
echo $bar;
|
||||
echo $list;
|
||||
echo $bar;
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//Search
|
||||
if ( $action == 'search' ) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) <1 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
|
||||
// PhpSessid
|
||||
$sessid=(isset ($_POST['PHPSESSID']))?$_POST['PHPSESSID']:$_GET['PHPSESSID'];
|
||||
|
||||
// display a search box
|
||||
$search_box=u_ShowMenuRecherche($cn,$_GET['p_jrn'],$sessid,$_POST);
|
||||
echo '<DIV class="u_redcontent">';
|
||||
echo $search_box;
|
||||
// if nofirst is set then show result
|
||||
if ( isset ($_GET['nofirst'] ) ) {
|
||||
list ($max_line,$a)=ListJrn($cn,$_GET['p_jrn'],"",$_POST);
|
||||
echo $a;
|
||||
}
|
||||
echo '</DIV>';
|
||||
}
|
||||
require_once("user_update.php");
|
||||
?>
|
||||
|
|
@ -1,381 +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 Manage the ledger of type VEN
|
||||
*/
|
||||
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_acc_ledger.php");
|
||||
require_once('class_dossier.php');
|
||||
$gDossier=dossier::id();
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
|
||||
$cn=DbConnect($gDossier);
|
||||
|
||||
// default action is insert_vente
|
||||
if ( ! isset ($_REQUEST['action'])) {
|
||||
exit;
|
||||
} else {
|
||||
$action=$_REQUEST['action'];
|
||||
$blank=(isset($_GET["blank"]))?1:0;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
// use a predefined operation
|
||||
//--------------------------------------------------------------------------------
|
||||
if ( $action=="use_opd" ) {
|
||||
$op=new Pre_op_ven($cn);
|
||||
$op->set_od_id($_REQUEST['pre_def']);
|
||||
|
||||
$p_post=$op->compute_array();
|
||||
echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post);
|
||||
$form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$p_post,false,$p_post['nb_item']);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $form;
|
||||
|
||||
//--------------------
|
||||
// predef op.
|
||||
echo '<form method="GET">';
|
||||
$op->set('ledger',$_GET['p_jrn']);
|
||||
$op->set('ledger_type',"VEN");
|
||||
$op->set('direct','f');
|
||||
|
||||
echo $op->form_get();
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
exit();
|
||||
}
|
||||
if ( $action == 'insert_vente' ) {
|
||||
|
||||
// Add item
|
||||
if (isset($_POST["add_item"]) ) {
|
||||
echo_debug('user_action_ven.php',__LINE__,"Add an item");
|
||||
$nb_number=$_POST["nb_item"];
|
||||
$nb_number++;
|
||||
|
||||
$form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,false,$nb_number);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $form;
|
||||
echo '</div>';
|
||||
|
||||
} // add an item
|
||||
|
||||
// We want to see the encoded invoice
|
||||
if ( isset ($_POST["view_invoice"])) {
|
||||
$nb_number=$_POST["nb_item"];
|
||||
if ( form_verify_input($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number) == true)
|
||||
{
|
||||
$form=FormVenteView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number);
|
||||
// Check failed : invalid date or quantity
|
||||
} else {
|
||||
echo_debug(__FILE__.':'.__LINE__," Impossible d'accepter le formulaire");
|
||||
$form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,false,$nb_number);
|
||||
}
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $form;
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
// We want a blank form
|
||||
if ( $blank==1)
|
||||
{
|
||||
$jrn=new Acc_Ledger($cn, $_GET['p_jrn']);
|
||||
$op=new Pre_op_ven($cn);
|
||||
echo_debug('user_action_ven.php',__LINE__,"Blank form");
|
||||
// Show an empty form of invoice
|
||||
$form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),null,false,$jrn->GetDefLine());
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $form;
|
||||
//--------------------
|
||||
// predef op.
|
||||
|
||||
echo '<form method="GET">';
|
||||
$op->set('ledger',$_REQUEST['p_jrn']);
|
||||
$op->set('ledger_type',"VEN");
|
||||
$op->set('direct','f');
|
||||
echo $op->form_get();
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Save the invoice
|
||||
if ( isset($_POST["record_invoice"])) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$User,$_GET['p_jrn']) != 2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
|
||||
// echo "RECORD INVOICE";
|
||||
list($internal,$comment)=RecordInvoice($cn,$_POST,$User,$_GET['p_jrn']);
|
||||
}
|
||||
if (isset ($_POST['correct_new_invoice'])) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
|
||||
$nb=$_POST['nb_item'];
|
||||
$form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,false,$nb);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $form;
|
||||
echo '</div>';
|
||||
}
|
||||
// Save and print the invoice
|
||||
if ( isset($_POST["record_and_print_invoice"])) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
|
||||
$nb_number=$_POST["nb_item"];
|
||||
echo_debug(__FILE__.':'.__LINE__.'- record_and_print_invoice');
|
||||
if ( form_verify_input($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number)== true) {
|
||||
echo '<div class="u_redcontent">';
|
||||
list($internal,$comment)=RecordInvoice($cn,$_POST,$User,$_GET['p_jrn']);
|
||||
echo '<h2 class="info">Opération '.$internal.' </h2>';
|
||||
$form=FormVenteView($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number,'noform',$comment);
|
||||
echo '</div>';
|
||||
} else {
|
||||
|
||||
echo("A cause d'erreur la facture ne peut-ètre validé ");
|
||||
$form=FormVenteView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number,"form");
|
||||
}
|
||||
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $form;
|
||||
echo "</div> ";
|
||||
}
|
||||
|
||||
|
||||
if ( $action == 'voir_jrn' ) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
// Extract the page number we want
|
||||
$debut=(isset($_REQUEST['p_page']))?$_REQUEST['p_page']:0;
|
||||
|
||||
|
||||
?>
|
||||
<div class="u_redcontent">
|
||||
|
||||
<form method= "get" action="user_jrn.php">
|
||||
|
||||
<?php
|
||||
echo dossier::hidden();
|
||||
$hid=new widget("hidden");
|
||||
|
||||
$hid->name="p_jrn";
|
||||
$hid->value=$p_jrn;
|
||||
echo $hid->IOValue();
|
||||
|
||||
$hid->name="action";
|
||||
$hid->value="voir_jrn";
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
$hid->name="jrn_type";
|
||||
$hid->value=$jrn_type;
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
|
||||
$w=new widget("select");
|
||||
|
||||
// filter on the current year
|
||||
$filter_year=" where p_exercice='".$User->get_exercice()."'";
|
||||
|
||||
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1);
|
||||
// User is already set User=new User($cn);
|
||||
$current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode();
|
||||
$w->selected=$current;
|
||||
|
||||
echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider');
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
// Ask to update payment
|
||||
if ( isset ( $_POST['paid']))
|
||||
{
|
||||
// reset all the paid flag because the checkbox is post only
|
||||
// when checked
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list($ad) = sscanf($name,"set_jr_id%d");
|
||||
if ( $ad == null ) continue;
|
||||
$sql="update jrn set jr_rapt='' where jr_id=$ad";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
||||
}
|
||||
// set a paid flag for the checked box
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list ($id) = sscanf ($name,"rd_paid%d");
|
||||
|
||||
if ( $id == null ) continue;
|
||||
|
||||
$paid=($paid=='on')?'paid':'';
|
||||
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
}
|
||||
|
||||
}
|
||||
// Show list of sell
|
||||
// Date - date of payment - Customer - amount
|
||||
if ( $current == -1) {
|
||||
$cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')";
|
||||
} else {
|
||||
$cond=" and jr_tech_per=".$current;
|
||||
}
|
||||
|
||||
$sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$_GET['p_jrn'] ;
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
|
||||
|
||||
list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
|
||||
$bar=jrn_navigation_bar($offset,$max_line,$step,$page);
|
||||
|
||||
echo "<hr>$bar";
|
||||
echo '<form method="POST">';
|
||||
echo dossier::hidden();
|
||||
$hid=new widget("hidden");
|
||||
|
||||
$hid->name="p_jrn";
|
||||
$hid->value=$p_jrn;
|
||||
echo $hid->IOValue();
|
||||
|
||||
$hid->name="action";
|
||||
$hid->value="voir_jrn";
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
$hid->name="jrn_type";
|
||||
$hid->value=$jrn_type;
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
echo $list;
|
||||
if ( $max_line !=0 )
|
||||
echo widget::submit('paid','Mise à jour paiement');
|
||||
echo '</FORM>';
|
||||
echo "$bar <hr>";
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
if ( $action == 'voir_jrn_non_paye' ) {
|
||||
// Check privilege
|
||||
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
// Ask to update payment
|
||||
if ( isset ( $_POST['paid']))
|
||||
{
|
||||
// reset all the paid flag because the checkbox is post only
|
||||
// when checked
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list($ad) = sscanf($name,"set_jr_id%d");
|
||||
if ( $ad == null ) continue;
|
||||
$sql="update jrn set jr_rapt='' where jr_id=$ad";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
||||
}
|
||||
// set a paid flag for the checked box
|
||||
foreach ($_POST as $name=>$paid)
|
||||
{
|
||||
list ($id) = sscanf ($name,"rd_paid%d");
|
||||
|
||||
if ( $id == null ) continue;
|
||||
$paid=($paid=='on')?'paid':'';
|
||||
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Show list of unpaid sell
|
||||
// Date - date of payment - Customer - amount
|
||||
// Nav. bar
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
|
||||
|
||||
$sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$_GET['p_jrn'] ;
|
||||
list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
|
||||
$sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$_GET['p_jrn'] ;
|
||||
list($max_line2,$list2)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
|
||||
|
||||
// Get the max line
|
||||
$m=($max_line2>$max_line)?$max_line2:$max_line;
|
||||
$bar2=jrn_navigation_bar($offset,$m,$step,$page);
|
||||
|
||||
echo '<div class="u_redcontent">';
|
||||
echo '<FORM METHOD="POST">';
|
||||
echo dossier::hidden();
|
||||
echo $bar2;
|
||||
echo '<h2 class="info"> Echeance dépassée </h2>';
|
||||
echo $list;
|
||||
echo '<h2 class="info"> Non Payée </h2>';
|
||||
echo $list2;
|
||||
echo $bar2;
|
||||
// Add hidden parameter
|
||||
$hid=new widget("hidden");
|
||||
|
||||
$hid->name="p_jrn";
|
||||
$hid->value=$p_jrn;
|
||||
echo $hid->IOValue();
|
||||
|
||||
$hid->name="action";
|
||||
$hid->value="voir_jrn_non_paye";
|
||||
echo $hid->IOValue();
|
||||
|
||||
|
||||
$hid->name="jrn_type";
|
||||
$hid->value=$jrn_type;
|
||||
echo $hid->IOValue();
|
||||
|
||||
echo '<hr>';
|
||||
|
||||
if ( $m != 0 )
|
||||
echo widget::submit('paid','Mise à jour paiement');
|
||||
|
||||
echo '</FORM>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
require_once("user_update.php");
|
||||
?>
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,501 +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
|
||||
*/
|
||||
/* $Revision$ */
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
require_once("class_widget.php");
|
||||
require_once("constant.php");
|
||||
require_once("preference.php");
|
||||
require_once("fiche_inc.php");
|
||||
require_once("user_common.php");
|
||||
require_once ('class_pre_operation.php');
|
||||
require_once ('class_acc_ledger.php');
|
||||
require_once ('class_periode.php');
|
||||
/*! \file
|
||||
* \brief Functions for the financial ledger
|
||||
*/
|
||||
/*!
|
||||
**************************************************
|
||||
* \brief verify if the data to insert are valid
|
||||
*
|
||||
*
|
||||
* \param $p_cn database connection
|
||||
* \param $p_jrn concerned ledger
|
||||
* \param $p_periode User periode
|
||||
* \param $p_array array with the post data
|
||||
* \param $p_number number of items
|
||||
*
|
||||
* \return:
|
||||
*/
|
||||
function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number)
|
||||
{
|
||||
foreach ($p_array as $name=>$content) {
|
||||
${"$name"}=$content;
|
||||
}
|
||||
// Verify the date
|
||||
if ( isDate($e_date) == null ) {
|
||||
echo_error('user_form_fin.php',__LINE__,"Invalid date $e_date");
|
||||
echo "<SCRIPT> alert('INVALID DATE $e_date !!!!');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Check if the fiche is in the jrn
|
||||
if (IsFicheOfJrn($p_cn , $p_jrn, $e_bank_account,'deb') == 0 )
|
||||
{
|
||||
$msg="Mauvais compte en banque";
|
||||
echo_error('user_form_fin.php',__LINE__,$msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// Check if the card has a valid account
|
||||
if ( CheckPoste($p_cn,$e_bank_account) == null )
|
||||
return null;
|
||||
$empty=0;
|
||||
// check if all e_march are in fiche
|
||||
for ($i=0;$i<$p_number;$i++) {
|
||||
if ( trim(${"e_other$i"}) == "" ) {
|
||||
// nothing to do
|
||||
$empty++;
|
||||
continue;
|
||||
}
|
||||
// Check amount
|
||||
if ( isNumber(${"e_other".$i."_amount"}) == 0) {
|
||||
$msg="Montant invalide !!! ";
|
||||
echo_error('user_form_fin.php',__LINE__,$msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// Check
|
||||
if ( isFicheOfJrn($p_cn,$p_jrn,${"e_other$i"},'cred') == 0 ) {
|
||||
$msg="Fiche inexistante !!! ";
|
||||
echo_error('user_form_fin.php',__LINE__,$msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// Check if the card has a valid account
|
||||
if ( CheckPoste($p_cn,${"e_other".$i}) == null )
|
||||
return null;
|
||||
}
|
||||
if ( $empty == $p_number) {
|
||||
$msg="Aucune fiche n'est donnee ";
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// Verify the userperiode
|
||||
|
||||
// p_periode contient la periode par default
|
||||
list ($l_date_start,$l_date_end)=get_periode($p_cn,$p_periode);
|
||||
|
||||
// Date dans la periode active
|
||||
echo_debug ('user_form_fin',__LINE__,"date start periode $l_date_start date fin periode $l_date_end date demande $e_date");
|
||||
if ( cmpDate($e_date,$l_date_start)<0 ||
|
||||
cmpDate($e_date,$l_date_end)>0 )
|
||||
{
|
||||
$msg="Not in the active periode please change your preference";
|
||||
echo_debug('user_form_fin.php',__LINE__,$msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// Periode ferm�
|
||||
$per=new Periode($p_cn);
|
||||
$per->set_jrn($p_jrn);
|
||||
$per->set_periode($p_periode);
|
||||
if ( $per->is_open()==0 )
|
||||
{
|
||||
$msg="Cette periode est fermee pour ce journal";
|
||||
echo_debug('user_form_fin.php',__LINE__,$msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Display the form for financial
|
||||
* Used to show detail, encode a new fin op
|
||||
* or update one
|
||||
*
|
||||
* \param $p_cn database connection
|
||||
* \param $p_jrn ledger id (jr_id)
|
||||
* \param $p_submit contains the submit string
|
||||
* \param $p_array (default=null) containing the $_POST
|
||||
* \param $p_view_only (default=true) true if we cannot change it (no right or centralized op)
|
||||
* \param $p_item number of article (default=4)
|
||||
* \param $p_save (default false) if the operation is already recorded
|
||||
*
|
||||
*
|
||||
* \return string with the form, in readonly or writable mode
|
||||
*/
|
||||
function FormFin($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=true,$p_item=4,$p_save=false)
|
||||
{
|
||||
include_once("poste.php");
|
||||
if ( $p_array != null ) {
|
||||
// array contains old value
|
||||
foreach ( $p_array as $a=>$v) {
|
||||
${"$a"}=$v;
|
||||
}
|
||||
}
|
||||
// The date
|
||||
list ($l_date_start,$l_date_end)=get_periode($p_cn,$p_periode);
|
||||
$flag=(isset($e_date))?1:0;
|
||||
// $e_date=( ! isset($e_date) ) ? substr($l_date_start,2,8):$e_date;
|
||||
$e_date=( ! isset($e_date) ) ? $l_date_start:$e_date;
|
||||
// Comment
|
||||
$e_comment=(isset($e_comment))?$e_comment:"";
|
||||
|
||||
$r="";
|
||||
if ( $pview_only == false) {
|
||||
$r.=JS_SEARCH_CARD;
|
||||
$r.=JS_CONCERNED_OP;
|
||||
}
|
||||
// Compute href
|
||||
// $href=basename($_SERVER['PHP_SELF']);
|
||||
$href=basename($_SERVER['PHP_SELF']);
|
||||
switch ($href)
|
||||
{
|
||||
// user_jrn.php module "Comptable"
|
||||
case 'user_jrn.php':
|
||||
$href="user_jrn.php?action=new&p_jrn=$p_jrn";
|
||||
break;
|
||||
// commercial.php module "Gestion"
|
||||
case 'commercial.php':
|
||||
$href="commercial.php?p_action=bank&p_jrn=$p_jrn";
|
||||
break;
|
||||
default:
|
||||
echo_error('user_form_fin.php',__LINE__,'Erreur invalid request uri');
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
$r.="<FORM NAME=\"form_detail\" enctype=\"multipart/form-data\" ACTION=\"$href\" METHOD=\"POST\">";
|
||||
$r.=dossier::hidden();
|
||||
$hid=new widget('hidden');
|
||||
$r.=$hid->IOValue('p_jrn',$p_jrn);
|
||||
$r.='<fieldset>';
|
||||
$r.='<legend>Banque</legend>';
|
||||
$r.='<TABLE>';
|
||||
$Date=new widget("js_date");
|
||||
$Date->SetReadOnly($pview_only);
|
||||
$Date->table=1;
|
||||
$r.="<tr>";
|
||||
$r.=$Date->IOValue("e_date",$e_date,"Date");
|
||||
$r.="</tr>";
|
||||
|
||||
|
||||
include_once("fiche_inc.php");
|
||||
$r.='<INPUT TYPE="HIDDEN" name="nb_item" value="'.$p_item.'">';
|
||||
|
||||
// bank_account operation
|
||||
// Save old value and set a new one
|
||||
$e_bank_account=( isset ($e_bank_account) )?$e_bank_account:"";
|
||||
$e_bank_account_label="";
|
||||
|
||||
// retrieve e_bank_account_label
|
||||
if ( $e_bank_account != "" ) {
|
||||
$a_client=GetFicheAttribut($p_cn,$e_bank_account);
|
||||
if ( $a_client != null)
|
||||
$e_bank_account_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp'];
|
||||
}
|
||||
// search widget
|
||||
$W1=new widget("js_search");
|
||||
$W1->readonly=$pview_only;
|
||||
$W1->label="Banque";
|
||||
$W1->name="e_bank_account";
|
||||
$W1->value=$e_bank_account;
|
||||
$W1->extra=FICHE_TYPE_FIN; // credits
|
||||
$W1->extra2=$p_jrn;
|
||||
$r.="<TR>".$W1->IOValue()."</TD>";
|
||||
$Span=new widget ("span");
|
||||
$Span->SetReadOnly($pview_only);
|
||||
$r.="<TD>".$Span->IOValue("e_bank_account_label",$e_bank_account_label)."</TD>";
|
||||
|
||||
$r.="</TABLE>";
|
||||
|
||||
|
||||
|
||||
// ComputeBanqueSaldo
|
||||
//
|
||||
if ( $pview_only == true ) {
|
||||
$solde=get_solde($p_cn,GetFicheAttribut($p_cn,$e_bank_account,ATTR_DEF_ACCOUNT));
|
||||
$r.=" <b> Solde = ".$solde." </b>";
|
||||
$new_solde=$solde;
|
||||
}
|
||||
$r.='</fieldset>';
|
||||
// Start the div for item to move money
|
||||
$r.="<DIV>";
|
||||
$r.='<H2 class="info">détails opérations</H2>';
|
||||
$r.='<TABLE>';
|
||||
$r.="<TR>";
|
||||
$r.="<th></TH>";
|
||||
$r.="<th>code</TH>";
|
||||
$r.="<th>Dénomination</TH>";
|
||||
$r.="<th>Description</TH>";
|
||||
$r.="<th>Montant</TH>";
|
||||
$r.='<th colspan="2"> Op. Concernée(s)</th>';
|
||||
$r.="</TR>";
|
||||
// Parse each " tiers"
|
||||
for ($i=0; $i < $p_item; $i++) {
|
||||
$tiers=(isset(${"e_other".$i}))?${"e_other".$i}:"";
|
||||
$tiers_label="";
|
||||
$tiers_amount=(isset(${"e_other$i"."_amount"}))?round(${"e_other$i"."_amount"},2):0;
|
||||
|
||||
$tiers_comment=(isset (${"e_other$i"."_comment"}))?${"e_other$i"."_comment"}:"";
|
||||
// If $tiers has a value
|
||||
if ( $tiers != "" )
|
||||
{
|
||||
// retrieve the tva label and name
|
||||
$a_fiche=GetFicheAttribut($p_cn, $tiers);
|
||||
if ( $a_fiche != null ) {
|
||||
$tiers_label=$a_fiche['vw_name'];
|
||||
}
|
||||
}
|
||||
${"e_other$i"."_amount"}=(isset (${"e_other$i"."_amount"}))?${"e_other$i"."_amount"}:0;
|
||||
|
||||
$W1=new widget("js_search");
|
||||
$W1->label="";
|
||||
$W1->name="e_other".$i;
|
||||
$W1->value=$tiers;
|
||||
$W1->extra='cred'; // credits
|
||||
$W1->extra2=$p_jrn;
|
||||
$W1->readonly=$pview_only;
|
||||
$r.="<TR>".$W1->IOValue()."</TD>";
|
||||
// label
|
||||
$other=new widget("span");
|
||||
$r.="<TD>";
|
||||
$r.=$other->IOValue("e_other$i"."_label", $tiers_label);
|
||||
// Comment
|
||||
$wComment=new widget("text");
|
||||
$wComment->table=1;
|
||||
$wComment->SetReadOnly($pview_only);
|
||||
$r.=$wComment->IOValue("e_other$i"."_comment",$tiers_comment);
|
||||
// amount
|
||||
$wAmount=new widget("text");
|
||||
$wAmount->table=1;
|
||||
$wAmount->size=7;
|
||||
$wAmount->SetReadOnly($pview_only);
|
||||
$r.=$wAmount->IOValue("e_other$i"."_amount",$tiers_amount);
|
||||
// concerned
|
||||
${"e_concerned".$i}=(isset(${"e_concerned".$i}))?${"e_concerned".$i}:"";
|
||||
$wConcerned=new widget("js_concerned");
|
||||
$wConcerned->SetReadOnly($pview_only);
|
||||
$wConcerned->extra=0;
|
||||
$wConcerned->table=1;
|
||||
$wConcerned->extra2='paid';
|
||||
$r.=$wConcerned->IOValue("e_concerned".$i,${"e_concerned".$i});
|
||||
$r.='</TR>';
|
||||
// if not recorded the new amount must be recalculate
|
||||
// if recorded the old amount is recalculated
|
||||
if ( $pview_only == true)
|
||||
$new_solde=($p_save==false)?$new_solde+$tiers_amount:$new_solde-$tiers_amount;
|
||||
}
|
||||
|
||||
$r.="</TABLE>";
|
||||
|
||||
if ( $pview_only==true && $p_save==false) {
|
||||
// check for upload piece
|
||||
$file=new widget("file");
|
||||
$file->table=1;
|
||||
$r.="<hr>";
|
||||
$r.= "<table>";
|
||||
$r.="<TR>".$file->IOValue("pj","","Pièce justificative")."</TR>";
|
||||
$r.="</table>";
|
||||
$r.="<hr>";
|
||||
$chk=new widget('checkbox');
|
||||
$chk->selected=false;
|
||||
$r.="Sauvez l'opération ?";
|
||||
$r.=$chk->IOValue('opd_save');
|
||||
|
||||
$name=new widget('text');
|
||||
$r.='nom de l\' opération ?'.$name->IOValue('predef');
|
||||
|
||||
}
|
||||
// Set correctly the REQUEST param for jrn_type
|
||||
$h=new widget('hidden');
|
||||
$h->name='jrn_type';
|
||||
$h->value='FIN';
|
||||
$r.=$h->IOValue();
|
||||
|
||||
$r.=$p_submit;
|
||||
$r.="</DIV>";
|
||||
$r.="</FORM>";
|
||||
|
||||
// if view_only is true
|
||||
//Put the new saldo here (old saldo - operation)
|
||||
if ( $pview_only==true) {
|
||||
$solde=round($solde,2);
|
||||
$new_solde=round($new_solde,2);
|
||||
|
||||
// if not recorded the new amount must be recalculate
|
||||
if ( $p_save == false) {
|
||||
$r.=" <b> Ancien Solde = ".$solde." </b><br>";
|
||||
$op=$new_solde-$solde;
|
||||
$r.="<b> Montant opération =".$op."</b><br>";
|
||||
$r.=" <b> Nouveau Solde = ".$new_solde." </b><br>";
|
||||
}
|
||||
// if recorded the old amount is recalculated
|
||||
if ($p_save == true ) {
|
||||
$op=$solde-$new_solde;
|
||||
$r.=" <b> Ancien Solde = ".$new_solde." </b><br>";
|
||||
$r.="<b> Montant opération =".$op."</b><br>";
|
||||
$r.=" <b> Nouveau Solde = ".$solde." </b><br>";
|
||||
}
|
||||
}
|
||||
|
||||
return $r;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
**************************************************
|
||||
* \brief Record an invoice in the table jrn &
|
||||
* jrnx
|
||||
*
|
||||
*
|
||||
* \param $p_cn Database connection
|
||||
* \param $p_array contains all the invoice data
|
||||
* e_date => e : 01.01.2003
|
||||
* e_bank_account => e : 3
|
||||
* \param $p_user userid
|
||||
* \param $p_jrn current folder (journal)
|
||||
* \param array e_other$i, e_other$i_amount, e_other$i_label
|
||||
|
||||
* \return true on success
|
||||
*
|
||||
*/
|
||||
function RecordFin($p_cn,$p_array,$p_user,$p_jrn) {
|
||||
$internal_code="";
|
||||
$oid=0;
|
||||
echo_debug('user_form_fin.php',__LINE__,"RecordFin");
|
||||
foreach ( $p_array as $v => $e)
|
||||
{
|
||||
${"$v"}=$e;
|
||||
}
|
||||
// Get the default period
|
||||
$periode=$p_user->get_periode();
|
||||
|
||||
// Debit = banque
|
||||
$poste_bq=GetFicheAttribut($p_cn,$e_bank_account,ATTR_DEF_ACCOUNT);
|
||||
try
|
||||
{
|
||||
StartSql($p_cn);
|
||||
$amount=0.0;
|
||||
// Credit = goods
|
||||
for ( $i = 0; $i < $nb_item;$i++) {
|
||||
// if tiers is set and amount != 0 insert it into the database
|
||||
// and quit the loop ?
|
||||
if ( ${"e_other$i"."_amount"} == 0 || strlen(trim(${"e_other$i"}))==0 ) continue;
|
||||
$poste=GetFicheAttribut($p_cn,${"e_other$i"},ATTR_DEF_ACCOUNT);
|
||||
|
||||
// round it
|
||||
${"e_other$i"."_amount"}=round( ${"e_other$i"."_amount"},2);
|
||||
|
||||
$amount+=${"e_other$i"."_amount"};
|
||||
// Record a line for the bank
|
||||
// Compute the j_grpt
|
||||
$seq=NextSequence($p_cn,'s_grpt');
|
||||
// Set Internal code and Comment
|
||||
$oJrn=new Acc_Ledger($p_cn,$p_jrn);
|
||||
$internal=$oJrn->compute_internal_code($seq);
|
||||
|
||||
|
||||
InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste_bq,$e_date,round(${"e_other$i"."_amount"},2),
|
||||
$seq,$periode,$e_bank_account) ;
|
||||
|
||||
|
||||
// Record a line for the other account
|
||||
$j_id=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,
|
||||
round(${"e_other$i"."_amount"},2),$seq,$periode,${"e_other$i"});
|
||||
|
||||
echo_debug('user_form_fin.php',__LINE__," $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,".${"e_other$i"}."_amount".",$seq,$periode);");
|
||||
|
||||
$jr_id=InsertJrn($p_cn,$e_date,'',$p_jrn,FormatString(${"e_other$i"."_comment"}),
|
||||
$seq,$periode);
|
||||
|
||||
if ( trim(${"e_concerned".$i}) != "" ) {
|
||||
if ( strpos(${"e_concerned".$i},',') !== 0 )
|
||||
{
|
||||
$aRapt=split(',',${"e_concerned".$i});
|
||||
foreach ($aRapt as $rRapt) {
|
||||
if ( isNumber($rRapt) == 1 )
|
||||
{
|
||||
InsertRapt($p_cn,$jr_id,$rRapt);
|
||||
}
|
||||
}
|
||||
} else
|
||||
if ( isNumber(${"e_concerned".$i}) == 1 )
|
||||
{
|
||||
InsertRapt($p_cn,$jr_id,${"e_concerned$i"});
|
||||
}
|
||||
}
|
||||
|
||||
// Set Internal code and Comment
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ".
|
||||
" jr_grpt_id = ".$seq);
|
||||
|
||||
$comment=$internal." compte : ".GetFicheName($p_cn,$e_bank_account);
|
||||
if ( FormatString(${"e_other$i"."_comment"}) == null ) {
|
||||
// Update comment if comment is blank
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||
}
|
||||
|
||||
|
||||
if ( $i == 0 )
|
||||
{
|
||||
// first record we upload the files and
|
||||
// keep variable to update other row of jrn
|
||||
if ( isset ($_FILES))
|
||||
$oid=save_upload_document($p_cn,$seq);
|
||||
|
||||
} else {
|
||||
if ( $oid != 0 )
|
||||
{
|
||||
ExecSql($p_cn,"update jrn set jr_pj=".$oid.", jr_pj_name='".$_FILES['pj']['name']."', ".
|
||||
"jr_pj_type='".$_FILES['pj']['type']."' where jr_grpt_id=$seq");
|
||||
}
|
||||
}
|
||||
|
||||
} // for nbitem
|
||||
// Save pre_operatoin
|
||||
// Save the operation
|
||||
if ( isset($_POST['opd_save']) && $_POST['opd_save']=='on' ){
|
||||
echo_debug(__FILE__.':'.__LINE__.'- ','save opd');
|
||||
$opd=new Pre_op_fin($p_cn);
|
||||
$opd->get_post();
|
||||
$opd->operation->name=$_POST['predef'];
|
||||
|
||||
$opd->save();
|
||||
echo_debug(__FILE__.':'.__LINE__.'- ',"opd = ",$opd);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
echo '<span class="error">'.
|
||||
'Erreur dans l\'enregistrement '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$e->getMessage();
|
||||
Rollback($p_cn);
|
||||
exit();
|
||||
|
||||
}
|
||||
Commit($p_cn);
|
||||
return $internal;
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,885 +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
|
||||
*/
|
||||
/* $Revision$ */
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
/*! \file
|
||||
* \brief Functions for the ledger of sold
|
||||
*/
|
||||
require_once("constant.php");
|
||||
require_once("class_widget.php");
|
||||
require_once("preference.php");
|
||||
require_once("fiche_inc.php");
|
||||
require_once("user_common.php");
|
||||
require_once ("class_own.php");
|
||||
require_once ("class_anc_plan.php");
|
||||
require_once ('class_anc_operation.php');
|
||||
require_once ('class_pre_op_ven.php');
|
||||
require_once ('class_own.php');
|
||||
require_once ('class_acc_ledger.php');
|
||||
require_once ('class_periode.php');
|
||||
|
||||
/*! FormVenInput
|
||||
* \brief Display the form for a sell
|
||||
* Used to show detail, encode a new invoice
|
||||
* or update one
|
||||
*
|
||||
*
|
||||
* \param p_array which can be empty
|
||||
* \param the "journal"
|
||||
* \param $p_periode = periode
|
||||
* \param view_only if we cannot change it (no right or centralized op)
|
||||
* \param $p_article number of article
|
||||
* \return string with the form
|
||||
*/
|
||||
function FormVenInput($p_cn,$p_jrn,$p_periode,$p_array=null,$pview_only=true,$p_article=1)
|
||||
{
|
||||
|
||||
if ( $p_array != null ) {
|
||||
// array contains old value
|
||||
foreach ( $p_array as $a=>$v) {
|
||||
${"$a"}=$v;
|
||||
}
|
||||
}
|
||||
// The date
|
||||
list ($l_date_start,$l_date_end)=get_periode($p_cn,$p_periode);
|
||||
// $op_date=( ! isset($e_date) )
|
||||
// ?substr($l_date_start,2,8):$e_date;
|
||||
$op_date=( ! isset($e_date) ) ?$l_date_start:$e_date;
|
||||
$e_ech=(isset($e_ech))?$e_ech:"";
|
||||
$e_comm=(isset($e_comm))?$e_comm:"";
|
||||
// $e_jrn=(isset($e_jrn))?$e_jrn:"";
|
||||
// Save old value and set a new one
|
||||
|
||||
echo_debug('user_form_ven.php',__LINE__,"form_input.php.FormVentep_op_date is $op_date");
|
||||
$r="";
|
||||
if ( $pview_only == false) {
|
||||
$r.=JS_SEARCH_CARD;
|
||||
$r.=JS_SHOW_TVA;
|
||||
$r.=JS_TVA;
|
||||
// Compute href
|
||||
// $href=basename($_SERVER['PHP_SELF']);
|
||||
$href=basename($_SERVER['PHP_SELF']);
|
||||
switch ($href)
|
||||
{
|
||||
// user_jrn.php
|
||||
case 'user_jrn.php':
|
||||
$href="user_jrn.php?action=insert_vente&p_jrn=$p_jrn";
|
||||
break;
|
||||
case 'commercial.php':
|
||||
$href="commercial.php?p_action=facture&p_jrn=$p_jrn";
|
||||
break;
|
||||
default:
|
||||
echo_error('user_form_ven.php',__LINE__,'Erreur invalid request uri');
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
$r.="<FORM NAME=\"form_detail\" ACTION=\"$href\" METHOD=\"POST\">";
|
||||
$r.=dossier::hidden();
|
||||
|
||||
|
||||
}
|
||||
$r.="<fieldset>";
|
||||
$r.="<legend>Detail client </legend>";
|
||||
|
||||
$r.='<TABLE>';
|
||||
// Date
|
||||
//--
|
||||
$Date=new widget("js_date");
|
||||
$Date->SetReadOnly($pview_only);
|
||||
$Date->table=1;
|
||||
$Date->tabindex=1;
|
||||
$r.="<tr>";
|
||||
$r.=$Date->IOValue("e_date",$op_date,"Date");
|
||||
$r.="</tr>";
|
||||
// Payment limit
|
||||
//--
|
||||
$Echeance=new widget("js_date");
|
||||
$Echeance->SetReadOnly($pview_only);
|
||||
$Echeance->table=1;
|
||||
$Echeance->tabindex=2;
|
||||
$r.="<tr>";
|
||||
$r.=$Echeance->IOValue("e_ech",$e_ech,"Echeance");
|
||||
$r.="</tr>";
|
||||
// Comment
|
||||
//--
|
||||
$Commentaire=new widget("text");
|
||||
$Commentaire->table=1;
|
||||
$Commentaire->SetReadOnly($pview_only);
|
||||
$Commentaire->size=80;
|
||||
$Commentaire->tabindex=3;
|
||||
$r.="<tr>";
|
||||
$r.=$Commentaire->IOValue("e_comm",$e_comm,"Description");
|
||||
$r.="</tr>";
|
||||
include_once("fiche_inc.php");
|
||||
// Display the customer
|
||||
//--
|
||||
$fiche='deb';
|
||||
echo_debug('user_form_ven.php',__LINE__,"Client Nombre d'enregistrement ".sizeof($fiche));
|
||||
// Save old value and set a new one
|
||||
//--
|
||||
$e_client=( isset ($e_client) )?$e_client:"";
|
||||
$e_client_label="";
|
||||
|
||||
// retrieve e_client_label
|
||||
//--
|
||||
$a_client=GetFicheAttribut($p_cn,$e_client);
|
||||
if ( $a_client != null)
|
||||
$e_client_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp'];
|
||||
|
||||
|
||||
$W1=new widget("js_search");
|
||||
$W1->label="Client";
|
||||
$W1->name="e_client";
|
||||
$W1->tabindex=3;
|
||||
$W1->value=$e_client;
|
||||
$W1->extra=$fiche; // list of card
|
||||
$W1->extra2=$p_jrn;
|
||||
$r.="<TR>".$W1->IOValue();
|
||||
$client_label=new widget("span");
|
||||
$r.= $client_label->IOValue("e_client_label",$e_client_label)."</TD></TR>";
|
||||
$r.="</TABLE>";
|
||||
|
||||
// Record the current number of article
|
||||
$Hid=new widget('hidden');
|
||||
$r.=$Hid->IOValue("nb_item",$p_article);
|
||||
$e_comment=(isset($e_comment))?$e_comment:"";
|
||||
$r.="</fieldset>";
|
||||
|
||||
// Start the div for item to sell
|
||||
$r.="<DIV>";
|
||||
$r.='<H2 class="info">Détail articles vendus</H2>';
|
||||
$r.='<TABLE>';
|
||||
$r.='<TR>';
|
||||
$r.="<th></th>";
|
||||
$r.="<th>Code</th>";
|
||||
$r.="<th>Dénomination</th>";
|
||||
$r.="<th>prix</th>";
|
||||
$r.="<th>tva</th>";
|
||||
$r.="<th>quantité</th>";
|
||||
$r.='</TR>';
|
||||
// For each article
|
||||
//--
|
||||
for ($i=0;$i< $p_article;$i++) {
|
||||
// Code id, price & vat code
|
||||
//--
|
||||
$march=(isset(${"e_march$i"}))?${"e_march$i"}:"";
|
||||
$march_sell=(isset(${"e_march".$i."_sell"}))?${"e_march".$i."_sell"}:"";
|
||||
$march_tva_id=(isset(${"e_march$i"."_tva_id"}))?${"e_march$i"."_tva_id"}:"";
|
||||
|
||||
$march_tva_label="";
|
||||
$march_label="";
|
||||
|
||||
// retrieve the tva label and name
|
||||
//--
|
||||
$a_fiche=GetFicheAttribut($p_cn, $march);
|
||||
if ( $a_fiche != null ) {
|
||||
if ( $march_tva_id == "" ) {
|
||||
$march_tva_id=$a_fiche['tva_id'];
|
||||
$march_tva_label=$a_fiche['tva_label'];
|
||||
}
|
||||
$march_label=$a_fiche['vw_name'];
|
||||
}
|
||||
|
||||
|
||||
// Show input
|
||||
//--
|
||||
$W1=new widget("js_search");
|
||||
$W1->label="";
|
||||
$W1->name="e_march".$i;
|
||||
$W1->value=$march;
|
||||
$W1->extra='cred'; // credits
|
||||
$W1->extra2=$p_jrn;
|
||||
$W1->readonly=$pview_only;
|
||||
$r.="<TR>".$W1->IOValue()."</TD>";
|
||||
$Span=new widget ("span");
|
||||
$Span->SetReadOnly($pview_only);
|
||||
// card's name, price
|
||||
//--
|
||||
$r.="<TD>".$Span->IOValue("e_march".$i."_label",$march_label)."</TD>";
|
||||
// price
|
||||
$Price=new widget("text");
|
||||
$Price->SetReadOnly($pview_only);
|
||||
$Price->table=1;
|
||||
$Price->size=9;
|
||||
$r.=$Price->IOValue("e_march".$i."_sell",$march_sell);
|
||||
// vat label
|
||||
//--
|
||||
$select_tva=make_array($p_cn,"select tva_id,tva_label from tva_rate order by tva_rate desc",0);
|
||||
$Tva=new widget("select");
|
||||
$Tva->table=1;
|
||||
$Tva->selected=$march_tva_id;
|
||||
$r.=$Tva->IOValue("e_march$i"."_tva_id",$select_tva);
|
||||
|
||||
// quantity
|
||||
//--
|
||||
$quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"1";
|
||||
$Quantity=new widget("text");
|
||||
$Quantity->SetReadOnly($pview_only);
|
||||
$Quantity->table=1;
|
||||
$Quantity->size=9;
|
||||
//$r.=InputType("","TEXT","e_quant".$i,$quant,$pview_only);
|
||||
$r.=$Quantity->IOValue("e_quant".$i,$quant);
|
||||
$r.="</tr>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$r.="</TABLE>";
|
||||
$r.="<hr>";
|
||||
// Set correctly the REQUEST param for jrn_type
|
||||
$h=new widget('hidden');
|
||||
$h->name='jrn_type';
|
||||
$h->value='VEN';
|
||||
$r.=$h->IOValue();
|
||||
|
||||
if ($pview_only == false ) {
|
||||
$r.='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article" TABINDEX="32767">';
|
||||
$r.='<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer" TABINDEX="32767" ID="SubmitButton">';
|
||||
$r.="</DIV>";
|
||||
$r.="</FORM>";
|
||||
$r.=JS_CALC_LINE;
|
||||
} else {
|
||||
$r.="</div>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $r;
|
||||
|
||||
|
||||
}
|
||||
/*! form_verify_input
|
||||
**************************************************
|
||||
* \brief verify if the data to insert are valid
|
||||
*
|
||||
*
|
||||
* \param $p_cn database connection
|
||||
* \param $p_jrn concerned ledger
|
||||
* \param $User periode
|
||||
* \param $array with the post data
|
||||
* \param $p_number number of items
|
||||
*
|
||||
* \return null if error or true if everything is correct
|
||||
*/
|
||||
function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number)
|
||||
{
|
||||
foreach ($p_array as $name=>$content) {
|
||||
${"$name"}=$content;
|
||||
}
|
||||
// Verify the amount for each
|
||||
//
|
||||
// Check for CA
|
||||
$own = new Own($p_cn);
|
||||
|
||||
// Verify the date
|
||||
if ( isDate($e_date) == null ) {
|
||||
echo_error("Invalid date $e_date");
|
||||
echo_debug('user_form_ven.php',__LINE__,"Invalid date $e_date");
|
||||
echo "<SCRIPT> alert('INVALID DATE $e_date !!!!');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// Verify the quantity
|
||||
for ($o = 0;$o < $p_number; $o++) {
|
||||
if ( isNumber(${"e_quant$o"}) == 0 ) {
|
||||
echo_debug('user_form_ven.php',__LINE__,"invalid quantity ".${"e_quant$o"});
|
||||
echo_error("invalid quantity ".${"e_quant$o"});
|
||||
echo "<SCRIPT> alert('INVALID QUANTITY !!!');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// check if vat is correct
|
||||
if ( strlen(trim(${"e_march$o"."_tva_id"})) !=0
|
||||
and
|
||||
${"e_march$o"."_tva_id"} != "-1")
|
||||
{
|
||||
// vat is given we check it now check if valid
|
||||
if (isNumber(${"e_march$o"."_tva_id"}) == 0
|
||||
or CountSql($p_cn,"select tva_id from tva_rate where tva_id=".${"e_march$o"."_tva_id"}) ==0)
|
||||
{
|
||||
$msg="Invalid TVA !!! e_march".$o."_tva_id = ".${"e_march".$o."_tva_id"};
|
||||
echo_error($msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// encode the pa Check only for mandatory CA
|
||||
if ( $own->MY_ANALYTIC!="nu") // use of AA
|
||||
{
|
||||
|
||||
if ( isset (${"amount_t".$o})){
|
||||
|
||||
$hidden_amount=${"amount_t".$o};
|
||||
$ca_amount=0;
|
||||
// first we get the number of row for each item
|
||||
for ($line=1;$line <=${"nb_t".$o};$line++) {
|
||||
$ca_amount+=${"val".$o."l".$line};
|
||||
}
|
||||
|
||||
// compare hidden value and computed
|
||||
if ( round($ca_amount-$hidden_amount,2) != 0 ) {
|
||||
|
||||
$msg="Montant CA est different total marchandise";
|
||||
$msg.="montant encode $ca_amount marchandise $hidden_amount";
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Verify the ech
|
||||
if (strlen($e_ech) != 0 and isNumber($e_ech) == 0 and isDate ($e_ech) == null ) {
|
||||
$msg="Echeance invalide";
|
||||
echo_error($msg); echo_error($msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
|
||||
// if ech is a number of days then compute date limit
|
||||
if ( strlen($e_ech) != 0 and isNumber($e_ech) == 1) {
|
||||
list($day,$month,$year)=explode(".",$e_date);
|
||||
echo_debug('user_form_ven.php',__LINE__," date $e_date = $day.$month.$year");
|
||||
$p_ech=date('d.m.Y',mktime(0,0,0,$month,$day+$e_ech,$year));
|
||||
echo_debug('user_form_ven.php',__LINE__,"p_ech = $e_ech $p_ech");
|
||||
$e_ech=$p_ech;
|
||||
$wHidden=new widget("hidden");
|
||||
$data.=$wHidden->IOValue("e_ech",$e_ech);
|
||||
}
|
||||
|
||||
// Check if the fiche is in the jrn
|
||||
if (IsFicheOfJrn($p_cn , $p_jrn, $e_client,'deb') == 0 )
|
||||
{
|
||||
$msg="Client invalid please recheck";
|
||||
echo_error($msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// Check if the card has a valid account
|
||||
if ( CheckPoste($p_cn,$e_client) == null )
|
||||
return null;
|
||||
|
||||
// check if all e_march are in fiche
|
||||
for ($i=0;$i<$p_number;$i++) {
|
||||
if ( trim(${"e_march$i"}) == "" ) {
|
||||
// no goods to sell
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Check
|
||||
if ( isFicheOfJrn($p_cn,$p_jrn,${"e_march$i"},'cred') == 0 ) {
|
||||
$msg="Fiche inexistante !!! ";
|
||||
echo_error(__FILE__.__LINE__.$msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// Check if the card has a valid account
|
||||
if ( CheckPoste($p_cn,${"e_march$i"}) == null )
|
||||
return null;
|
||||
}
|
||||
// Verify the userperiode
|
||||
|
||||
// p_periode contient la periode par default
|
||||
list ($l_date_start,$l_date_end)=get_periode($p_cn,$p_periode);
|
||||
|
||||
// Date dans la periode active
|
||||
echo_debug ('user_form_ven',__LINE__,"date start periode $l_date_start date fin periode $l_date_end date demande $e_date");
|
||||
if ( cmpDate($e_date,$l_date_start)<0 ||
|
||||
cmpDate($e_date,$l_date_end)>0 )
|
||||
{
|
||||
$msg="Not in the active periode please change your preference";
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// Periode ferm�
|
||||
$per=new Periode($p_cn);
|
||||
$per->set_jrn($p_jrn);
|
||||
$per->set_periode($p_periode);
|
||||
|
||||
// Periode ferme
|
||||
if ( $per->is_open()==0)
|
||||
{
|
||||
$msg="Cette periode est fermee pour ce journal";
|
||||
echo_error($msg); echo_error($msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*! FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='html',$p_comment='')
|
||||
**************************************************
|
||||
* \brief Show the invoice before inserting it
|
||||
* the database.
|
||||
*
|
||||
*
|
||||
* \param p_cn database connection
|
||||
* \param p_jrn journal
|
||||
* \param p_periode
|
||||
* \param array of value
|
||||
* \param nb of item
|
||||
* \param p_doc type form for a form
|
||||
* \return string
|
||||
*
|
||||
*/
|
||||
|
||||
function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form',$p_comment='')
|
||||
{
|
||||
$own=new own($p_cn);
|
||||
|
||||
$r="";
|
||||
$data="";
|
||||
$head_ca="";
|
||||
// Keep all the data if hidden
|
||||
// and store the array in variables
|
||||
$hidden=new widget("hidden");
|
||||
foreach ($p_array as $name=>$content) {
|
||||
// not the CA data
|
||||
if ( strpos( $name,"ta_")===false &&
|
||||
strpos( $name,"nb_t")===false &&
|
||||
strpos( $name,"val")===false )
|
||||
$data.=$hidden->IOValue($name,$content);
|
||||
${"$name"}=$content;
|
||||
}
|
||||
// Compute href
|
||||
// $href=basename($_SERVER['PHP_SELF']);
|
||||
$href=basename($_SERVER['PHP_SELF']);
|
||||
switch ($href)
|
||||
{
|
||||
// user_jrn.php
|
||||
case 'user_jrn.php':
|
||||
$href="user_jrn.php?action=record&p_jrn=$p_jrn";
|
||||
break;
|
||||
case 'commercial.php':
|
||||
$href="commercial.php?p_action=facture&sa=record&p_jrn=$p_jrn";
|
||||
break;
|
||||
default:
|
||||
echo_error('user_form_ven.php',__LINE__,'Erreur invalid request uri');
|
||||
exit (-1);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
$r.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="'.$href.'">';
|
||||
$r.=dossier::hidden();
|
||||
// start table
|
||||
$r.='<TABLE>';
|
||||
// Show the Date
|
||||
$r.="<tr>";
|
||||
$r.="<TD>Date : $e_date</TD>";
|
||||
$r.="</tr>";
|
||||
// Show the customer Name
|
||||
$r.="<tr>";
|
||||
$r.="<TD>Client : ".getFicheName($p_cn,$e_client)."</TD>";
|
||||
$r.="</tr>";
|
||||
|
||||
// show date limit
|
||||
$r.="<tr>";
|
||||
$r.="<TD> Echeance : $e_ech </TD>";
|
||||
$r.="</tr>";
|
||||
// Show desc
|
||||
$r.="<tr>";
|
||||
$r.="<TD> Description : $e_comm</TD>";
|
||||
$r.="</tr>";
|
||||
|
||||
$sum_with_vat=0.0;
|
||||
$sum_march=0.0;
|
||||
// show all article, price vat and sum
|
||||
$r.="<TR>";
|
||||
$r.="<TH>Article</TH>";
|
||||
$r.="<TH>quantité</TH>";
|
||||
$r.="<TH>prix unit.</TH>";
|
||||
$r.="<TH>taux tva</TH>";
|
||||
$r.="<TH>Montant HTVA</TH>";
|
||||
$r.="<TH>Montant TVA</TH>";
|
||||
$r.="<TH>Total</TH>";
|
||||
$r.="</TR>";
|
||||
for ($i=0;$i<$p_number;$i++) {
|
||||
if ( trim(${"e_march$i"}) == "" ) {
|
||||
// no goods to sell
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the name
|
||||
$fiche_name=getFicheName($p_cn,${"e_march$i"});
|
||||
|
||||
// Quantity
|
||||
$fiche_quant=${"e_quant$i"};
|
||||
|
||||
// No row if there is quantity
|
||||
if ( $fiche_quant == 0.0 ) continue;
|
||||
|
||||
|
||||
// If the price is not a number, retrieve the price from the database
|
||||
if ( isNumber(${"e_march$i"."_sell"}) == 0 ) {
|
||||
$fiche_price=getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_PRIX_VENTE);
|
||||
} else {
|
||||
$fiche_price=${"e_march$i"."_sell"};
|
||||
}
|
||||
|
||||
|
||||
// VAT
|
||||
$vat=(isNumber(${"e_march$i"."_tva_id"})==0)?getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_TVA):${"e_march$i"."_tva_id"};
|
||||
|
||||
// vat label
|
||||
// vat rate
|
||||
$a_vat=GetTvaRate($p_cn,$vat);
|
||||
if ( $a_vat == null ) {
|
||||
$vat_label="";
|
||||
$vat_rate=0.0;
|
||||
} else {
|
||||
$vat_label=$a_vat['tva_label'];
|
||||
$vat_rate=$a_vat['tva_rate'];
|
||||
}
|
||||
$fiche_price=round($fiche_price,2);
|
||||
// Total card without vat
|
||||
$fiche_sum=$fiche_price*$fiche_quant;
|
||||
$fiche_sum=round($fiche_sum,2);
|
||||
|
||||
// Sum of invoice
|
||||
$sum_march+=$fiche_sum;
|
||||
// vat of the card
|
||||
$fiche_amount_vat=round($fiche_price*$fiche_quant*$vat_rate,2);
|
||||
// value card + vat
|
||||
$fiche_with_vat=$fiche_price*$fiche_quant+$fiche_amount_vat;
|
||||
// store in array
|
||||
if ( $vat_label != "") {
|
||||
if ( ! isset($a_sum_tva_cat[$vat_label])) {
|
||||
$a_sum_tva_cat[$vat_label]=0.0;
|
||||
}
|
||||
$a_sum_tva_cat[$vat_label]+=$fiche_amount_vat;
|
||||
}
|
||||
// Sum of invoice vat
|
||||
$sum_with_vat+=$fiche_with_vat;
|
||||
// Show the data
|
||||
$r.='<TR>';
|
||||
$r.='<TD>'.$fiche_name.'</TD>';
|
||||
$r.='<TD ALIGN="CENTER">'.$fiche_quant.'</TD>';
|
||||
$r.='<TD ALIGN="right">'.$fiche_price.'</TD>';
|
||||
$r.="<TD ALIGN=\"RIGHT\"> $vat_label </TD>";
|
||||
$r.='<TD ALIGN="RIGHT">'.round($fiche_sum,2).'</TD>';
|
||||
$r.='<TD ALIGN="RIGHT">'.round($fiche_amount_vat,2).'</TD>';
|
||||
|
||||
$r.='<TD>'.round($fiche_with_vat,2).'</TD>';
|
||||
|
||||
// to show a select list for the analytic
|
||||
// if analytic is op (optionnel) there is a blank line
|
||||
$own = new Own($p_cn);
|
||||
// encode the pa
|
||||
if ( $own->MY_ANALYTIC!='nu') // use of AA
|
||||
{
|
||||
// show form
|
||||
$op=new Anc_Operation($p_cn);
|
||||
$null=($own->MY_ANALYTIC=='op')?1:0;
|
||||
$r.='<td>';
|
||||
$p_mode=($p_doc=="form")?1:0;
|
||||
$r.=$op->display_form_plan($_POST,$null,$p_mode,$i,round($fiche_sum,2));
|
||||
$r.='</td>';
|
||||
}
|
||||
|
||||
$r.="</TR>";
|
||||
}
|
||||
|
||||
// end table
|
||||
$r.='</TABLE> ';
|
||||
$total_vat=0.0;
|
||||
$r.='<DIV style="padding:30px;font-size:14px">';
|
||||
$r.="HTVA =".round( $sum_march,2)." <br>";
|
||||
if ( isset($a_sum_tva_cat) && empty ($a_sum_tva_cat) != true) {
|
||||
foreach ($a_sum_tva_cat as $tva_cat=>$tva_amount) {
|
||||
$r.="Tva ".$tva_cat." =".$tva_amount."<br>";
|
||||
$total_vat+=$tva_amount;
|
||||
}
|
||||
}
|
||||
$r.="TVA =".$total_vat.'<br>';
|
||||
$r.="TTC = ".round($sum_with_vat,2);
|
||||
|
||||
|
||||
$r.="</DIV>";
|
||||
if ( $p_doc == 'form' ) {
|
||||
// Propose to save
|
||||
$chk=new widget('checkbox');
|
||||
$chk->selected=true;
|
||||
$r.="Sauvez l'opération ?";
|
||||
$r.=$chk->IOValue('opd_save');
|
||||
|
||||
|
||||
// check for upload piece
|
||||
$file=new widget("file");
|
||||
$file->table=1;
|
||||
$r.="<hr>";
|
||||
$r.= "<table>";
|
||||
$r.="<TR>".$file->IOValue("pj","","Pièce justificative")."</TR>";
|
||||
$r.="</table>";
|
||||
$r.="<hr>";
|
||||
|
||||
|
||||
// if we were in the management module, appl. propose to generate an invoice
|
||||
// if ( $_SERVER['PHP_SELF'] == '/commercial.php')
|
||||
echo_debug('user_form_ven',__LINE__," _SERVER['PHP_SELF'] ".$_SERVER['PHP_SELF']);
|
||||
if ( basename($_SERVER['PHP_SELF']) == 'commercial.php')
|
||||
{
|
||||
// if a template exists propose to choose an invoice template
|
||||
if ( CountSql($p_cn,
|
||||
"select md_id,md_name from document_modele where md_type=4") > 0 )
|
||||
{
|
||||
$r.='<fieldset> <legend> Génération de facture</legend>';
|
||||
$obj=new widget('TEXT');
|
||||
$r.='Numero de bon de commande : '.$obj->IOValue('bon_comm').'<br>';
|
||||
$r.='Autre information : '.$obj->IOValue('other_info').'<br>';
|
||||
|
||||
$r.='Générer une facture <input type="checkbox" name="gen_invoice" CHECKED>';
|
||||
// We propose to generate the invoice and some template
|
||||
$doc_gen=new widget("select");
|
||||
$doc_gen->name="gen_doc";
|
||||
$doc_gen->value=make_array($p_cn,
|
||||
"select md_id,md_name from document_modele where md_type=4");
|
||||
$r.=$doc_gen->IOValue().'<br>';
|
||||
$r.="</fieldset>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$r.=$data;
|
||||
if ( $sum_with_vat != 0 ) {
|
||||
$r.='<INPUT TYPE="SUBMIT" name="record_and_print_invoice" value="Enregistrer" onClick="return verify_ca(\'error\');">';
|
||||
if ( $own->MY_ANALYTIC != "nu" )
|
||||
$r.='<input type="button" value="verifie CA" onClick="verify_ca(\'ok\');">';
|
||||
}
|
||||
$r.='<INPUT TYPE="SUBMIT" name="correct_new_invoice" value="Corriger">';
|
||||
|
||||
$r.='</FORM>';
|
||||
}
|
||||
return $r;
|
||||
|
||||
}
|
||||
|
||||
/*! RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
|
||||
**************************************************
|
||||
* \brief Record an invoice in the table jrn &
|
||||
* jrnx
|
||||
*
|
||||
* \param $p_cn Database connection
|
||||
* \param $p_array array contains all the invoice data
|
||||
* - e_date => e : 01.01.2003
|
||||
* - e_client => e : 3
|
||||
* - nb_item => e : 3
|
||||
* - e_march0 => e : 6
|
||||
* - e_quant0 => e : 0
|
||||
* - e_march0_sell=>e:1
|
||||
* - e_march1 => e : 6
|
||||
* - e_quant1 => e : 2
|
||||
* - e_march1_sell=>e:1
|
||||
* - e_march2 => e : 7
|
||||
* - e_quant2 => e : 3
|
||||
* - e_march2_sell=>e:1
|
||||
* * V : view_invoice => e : Voir cette facture
|
||||
* * V : record_invoice => e : Sauver
|
||||
* \param $p_periode periode
|
||||
* \param $p_jrn current folder (journal)
|
||||
*
|
||||
* \return array ( internal_code,true on success)
|
||||
*/
|
||||
function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
|
||||
{
|
||||
echo_debug('RecordInvoice',0,"p_array = $p_array");
|
||||
|
||||
foreach ( $p_array as $v => $e)
|
||||
{
|
||||
${"$v"}=$e;
|
||||
}
|
||||
|
||||
// Get the default period
|
||||
$periode=$p_user->get_periode();
|
||||
$amount=0.0;
|
||||
$own=new own($p_cn);
|
||||
$group=NextSequence($p_cn,"s_oa_group");
|
||||
|
||||
// Computing total customer
|
||||
//--
|
||||
for ($i=0;$i<$nb_item;$i++) {
|
||||
// store quantity & goods in array
|
||||
$a_good[$i]=${"e_march$i"};
|
||||
$a_quant[$i]=${"e_quant$i"};
|
||||
$a_price[$i]=0;
|
||||
$a_vat[$i]=${"e_march$i"."_tva_id"};
|
||||
// check whether the price is set or no
|
||||
if ( isNumber(${"e_march$i"."_sell"}) == 0 ) {
|
||||
if ( $a_good[$i] != "" ) {
|
||||
// If the price is not set we have to find it from the database
|
||||
$a_price[$i]=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_PRIX_VENTE);
|
||||
}
|
||||
} else {
|
||||
// The price is valid
|
||||
$a_price[$i]=${"e_march$i"."_sell"};
|
||||
}
|
||||
$a_price[$i]=round($a_price[$i],2);
|
||||
$cost=$a_price[$i]*$a_quant[$i];
|
||||
$amount+=$cost;
|
||||
|
||||
echo_debug('RecordInvoice',__LINE__,"cost = $cost amount = $amount ");
|
||||
}// for
|
||||
echo_debug(__FILE__,__LINE__,"Dossier is ".dossier::id());
|
||||
|
||||
$comm=FormatString($e_comm);
|
||||
// Compute VAT
|
||||
//--
|
||||
$a_vat_new=ComputeTotalVat($p_cn,$a_good,$a_quant,$a_price,$a_vat);
|
||||
$sum_vat=0.0;
|
||||
echo_debug(__FILE__,__LINE__,"Dossier is ".dossier::id());
|
||||
|
||||
if ( $a_vat_new != null ){
|
||||
foreach ( $a_vat_new as $element => $t) {
|
||||
echo_debug('user_form_ven.php',__LINE__," a_vat element $element t $t");
|
||||
$sum_vat+=$t;
|
||||
echo_debug('user_form_ven.php',__LINE__,"sum_vat = $sum_vat");
|
||||
}
|
||||
}
|
||||
// First we add in jrnx
|
||||
|
||||
// Compute the j_grpt
|
||||
$seq=NextSequence($p_cn,'s_grpt');
|
||||
$oJrn=new Acc_Ledger($p_cn,$p_jrn);
|
||||
$internal=$oJrn->compute_internal_code($seq);
|
||||
|
||||
echo_debug(__FILE__,__LINE__,"Dossier is ".dossier::id());
|
||||
// Debit = client
|
||||
$poste=GetFicheAttribut($p_cn,$e_client,ATTR_DEF_ACCOUNT);
|
||||
echo_debug(__FILE__,__LINE__,"Dossier is ".dossier::id());
|
||||
try
|
||||
{
|
||||
StartSql($p_cn);
|
||||
$r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2)+round($sum_vat,2),$seq,$periode,$e_client);
|
||||
|
||||
|
||||
// Credit = goods
|
||||
for ( $i = 0; $i < $nb_item;$i++) {
|
||||
if ( $a_good[$i] == "" ) continue;
|
||||
$poste=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_ACCOUNT);
|
||||
|
||||
// don't record operation of 0
|
||||
if ( $a_price[$i]*$a_quant[$i] == 0 ) continue;
|
||||
|
||||
// record into jrnx
|
||||
$j_id=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($a_price[$i]*$a_quant[$i],2),$seq,$periode,$a_good[$i]);
|
||||
|
||||
/* \brief if the quantity is < 0 then the stock increase (return of
|
||||
* material)
|
||||
*/
|
||||
$nNeg=($a_quant[$i]<0)?-1:1;
|
||||
|
||||
// always save quantity but in withStock we can find
|
||||
// what card need a stock management
|
||||
|
||||
InsertStockGoods($p_cn,$j_id,$a_good[$i],$nNeg*$a_quant[$i],'c') ;
|
||||
if ( $own->MY_ANALYTIC != "nu" )
|
||||
{
|
||||
// for each item, insert into operation_analytique */
|
||||
$op=new Anc_Operation($p_cn);
|
||||
$op->oa_group=$group;
|
||||
$op->j_id=$j_id;
|
||||
$op->oa_date=$e_date;
|
||||
$op->oa_debit=($op->oa_amount < 0 )?'t':'f';
|
||||
echo_debug(__FILE__.':'.__LINE__,"Description is $e_comm");
|
||||
$op->oa_description=FormatString($e_comm);
|
||||
$op->save_form_plan($_POST,$i);
|
||||
}
|
||||
$computed_vat=ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i],$a_vat[$i]);
|
||||
$qs_vat=($a_vat[$i]==-1)?0:$computed_vat;
|
||||
$r=ExecSql($p_cn,"select insert_quant_sold ".
|
||||
"('".$internal."',".$j_id.",'".$a_good[$i]
|
||||
."',".$a_quant[$i].",".$a_price[$i]*$a_quant[$i].
|
||||
",".$qs_vat.
|
||||
",".$a_vat[$i].",'".$e_client."')");
|
||||
|
||||
|
||||
} // end loop
|
||||
|
||||
// Insert Vat
|
||||
|
||||
if ( $a_vat_new != null ) // no vat
|
||||
|
||||
{
|
||||
foreach ($a_vat_new as $tva_id => $tva_amount ) {
|
||||
$poste=GetTvaPoste($p_cn,$tva_id,'c');
|
||||
// if ($tva_amount == 0 ) continue;
|
||||
$r=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($tva_amount,2),$seq,$periode);
|
||||
}
|
||||
}
|
||||
echo_debug('user_form_ven.php',__LINE__,"echeance = $e_ech");
|
||||
$r=InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"Invoice",$seq,$periode);
|
||||
|
||||
// Set Internal code and Comment
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ".
|
||||
" jr_grpt_id = ".$seq);
|
||||
|
||||
$comment=(FormatString($e_comm) == null )?$internal." client : ".GetFicheName($p_cn,$e_client):FormatString($e_comm);
|
||||
|
||||
// Update and set the invoice's comment
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||
|
||||
if ( isset ($_FILES)) {
|
||||
if ( sizeof($_FILES) != 0 )
|
||||
save_upload_document($p_cn,$seq);
|
||||
}
|
||||
|
||||
// save the quantity, then we can make an invoice
|
||||
for ( $i=0;$i < $nb_item;$i++)
|
||||
{
|
||||
// don't record operation of 0
|
||||
if ( $a_price[$i]*$a_quant[$i] == 0 ) continue;
|
||||
|
||||
// insert into the table quant_sold
|
||||
// Note that negative value are also saved but not the vat !
|
||||
if ( $a_vat[$i] == -1) {
|
||||
$computed_vat=0;
|
||||
$vat_code="null";
|
||||
} else {
|
||||
$computed_vat=ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i],$a_vat[$i]);
|
||||
$vat_code=$a_vat[$i];
|
||||
}
|
||||
}
|
||||
// Save the operation
|
||||
if ( isset($_POST['opd_save']) && $_POST['opd_save']=='on' ){
|
||||
echo_debug(__FILE__.':'.__LINE__.'- ','save opd');
|
||||
$opd=new Pre_op_ven($p_cn);
|
||||
$opd->get_post();
|
||||
$opd->save();
|
||||
echo_debug(__FILE__.':'.__LINE__.'- ',"opd = ",$opd);
|
||||
}
|
||||
}//try
|
||||
catch (Exception $e)
|
||||
{
|
||||
echo '<span class="error">'.
|
||||
'Erreur dans l\'enregistrement '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$e->getMessage();
|
||||
Rollback($p_cn);
|
||||
exit();
|
||||
}
|
||||
Commit($p_cn);
|
||||
return array($internal,$comment);
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue