Task 4301 Form (html, pdf, csv) needs more test

This commit is contained in:
sparkyx 2005-06-22 20:32:24 +00:00
parent 419cd9562a
commit 7db5e39189
11 changed files with 529 additions and 17 deletions

View file

@ -17,6 +17,8 @@
************************* File = fiche_new.php ****************
************************* File = fiche.php ****************
************************* File = fiche_search.php ****************
************************* File = form_csv.php ****************
************************* File = form_pdf.php ****************
************************* File = form.php ****************
************************* File = html_balance.php ****************
************************* File = index.php ****************
@ -180,6 +182,19 @@ ac_common.php * gen :
ac_common.php * - none
ac_common.php * return: a double array [value,label]
ac_common.php */
ac_common.php /* function getPeriodeName
ac_common.php **************************************************
ac_common.php * Purpose : Show the periode which found thanks its
ac_common.php * id
ac_common.php *
ac_common.php * parm :
ac_common.php * - $p_cn database connection
ac_common.php * - p_id
ac_common.php * - Start or end
ac_common.php * gen :
ac_common.php * -
ac_common.php * return: string
ac_common.php */
************************* File = balance.php ****************
************************* File = central_inc.php ****************
central_inc.php /* function Centralise
@ -309,6 +324,7 @@ class_fiche.php * gen :
class_fiche.php * - none
class_fiche.php * return: an array of fiche_def object
class_fiche.php */
************************* File = class_form.php ****************
************************* File = class_jrn.php ****************
class_jrn.php /* function GetRow
class_jrn.php * Purpose : Get The data for the pdf printing
@ -1908,6 +1924,142 @@ stock_inc.php * purpose return the quantity of a sg_code for the period
stock_inc.php *
stock_inc.php * Return number or NULL
stock_inc.php */
************************* File = top_menu_compta.php ****************
top_menu_compta.php /* function ShowMenu
top_menu_compta.php * Purpose : Show The login menu
top_menu_compta.php *
top_menu_compta.php * parm :
top_menu_compta.php * - $p_admin 1 if admin
top_menu_compta.php * - $p_item item to add
top_menu_compta.php * gen :
top_menu_compta.php * - none
top_menu_compta.php * return:
top_menu_compta.php * - nothing
top_menu_compta.php *
top_menu_compta.php */
top_menu_compta.php /* function ShowMenuCompta
top_menu_compta.php * Purpose : Montre le menu du haut
top_menu_compta.php *
top_menu_compta.php * parm :
top_menu_compta.php * - dossier
top_menu_compta.php * - $p_user array ($g_UserProperty)
top_menu_compta.php * gen :
top_menu_compta.php * - none
top_menu_compta.php * return:
top_menu_compta.php * - none
top_menu_compta.php *
top_menu_compta.php */
top_menu_compta.php /* function
top_menu_compta.php * Purpose :
top_menu_compta.php *
top_menu_compta.php * parm :
top_menu_compta.php * -
top_menu_compta.php * gen :
top_menu_compta.php * -
top_menu_compta.php * return:
top_menu_compta.php * -
top_menu_compta.php *
top_menu_compta.php */
top_menu_compta.php /* function ShowMenuComptaRight
top_menu_compta.php * Purpose : Display menu on the Right
top_menu_compta.php * (preference, logout and admin)
top_menu_compta.php * parm :
top_menu_compta.php * - $p_dossier the current dossier
top_menu_compta.php * - $p_auser array $g_UserProperty
top_menu_compta.php * - $p_more code
top_menu_compta.php * gen :
top_menu_compta.php * - none
top_menu_compta.php * return:
top_menu_compta.php * - none
top_menu_compta.php *
top_menu_compta.php */
top_menu_compta.php /* function ShowMenuAdminGlobalRight($p_dossier=0)
top_menu_compta.php * Purpose :
top_menu_compta.php * Same as previous : show the right menu
top_menu_compta.php * parm :
top_menu_compta.php * - p_dossier
top_menu_compta.php * gen :
top_menu_compta.php * - none
top_menu_compta.php * return:
top_menu_compta.php * - none
top_menu_compta.php *
top_menu_compta.php */
top_menu_compta.php /* function ShowMenuPcmn($p_start=1)
top_menu_compta.php * Purpose : Show the menu from the pcmn page
top_menu_compta.php *
top_menu_compta.php * parm :
top_menu_compta.php * - $p_start class start
top_menu_compta.php * gen :
top_menu_compta.php * - none
top_menu_compta.php * return:
top_menu_compta.php * - none
top_menu_compta.php *
top_menu_compta.php */
top_menu_compta.php /* function ShowMenuJrn($p_dossier)
top_menu_compta.php * Purpose : Show the menu in the jrn page
top_menu_compta.php *
top_menu_compta.php * parm :
top_menu_compta.php * - $p_dossier
top_menu_compta.php * gen :
top_menu_compta.php * - none
top_menu_compta.php * return:
top_menu_compta.php * - none
top_menu_compta.php *
top_menu_compta.php */
top_menu_compta.php /* function ShowMenuJrnUser($p_dossier,$p_user)
top_menu_compta.php * Purpose : Display and Show the Menu from the jrn encode
top_menu_compta.php * page following the use_usertype (compta,user,...)
top_menu_compta.php *
top_menu_compta.php * parm :
top_menu_compta.php * - $p_dossier
top_menu_compta.php * - $p_auser
top_menu_compta.php * - $p_type (ACH, BQE, VEN)
top_menu_compta.php * - $p_jrn what journal
top_menu_compta.php * gen :
top_menu_compta.php * - none
top_menu_compta.php * return:
top_menu_compta.php * - none
top_menu_compta.php *
top_menu_compta.php */
top_menu_compta.php /* function ShowMenuRecherche
top_menu_compta.php * Purpose :
top_menu_compta.php *
top_menu_compta.php * parm :
top_menu_compta.php * - $p_dossier,
top_menu_compta.php * - $p_jrn jrn id
top_menu_compta.php * - $p_array=null previous search
top_menu_compta.php * gen :
top_menu_compta.php * - none
top_menu_compta.php * return:
top_menu_compta.php * - none
top_menu_compta.php *
top_menu_compta.php */
top_menu_compta.php /* function
top_menu_compta.php * Purpose :
top_menu_compta.php *
top_menu_compta.php * parm :
top_menu_compta.php * -
top_menu_compta.php * gen :
top_menu_compta.php * -
top_menu_compta.php * return:
top_menu_compta.php * -
top_menu_compta.php *
top_menu_compta.php */
top_menu_compta.php /* function ShowMenuJrnUserImp(
top_menu_compta.php *
top_menu_compta.php *
top_menu_compta.php * Purpose : Show the menu of jrn to print
top_menu_compta.php *
top_menu_compta.php * parm :
top_menu_compta.php * - $p_cn, connection
top_menu_compta.php * $p_user, user
top_menu_compta.php * $p_dossier dossier
top_menu_compta.php * gen :
top_menu_compta.php * - none
top_menu_compta.php * return:
top_menu_compta.php * - none
top_menu_compta.php *
top_menu_compta.php */
************************* File = top_menu.php ****************
************************* File = user_action_ach.php ****************
************************* File = user_action_fin.php ****************
@ -2317,6 +2469,17 @@ user_menu.php * return:
user_menu.php * - none
user_menu.php *
user_menu.php */
user_menu.php /* function
user_menu.php * Purpose :
user_menu.php *
user_menu.php * parm :
user_menu.php * -
user_menu.php * gen :
user_menu.php * -
user_menu.php * return:
user_menu.php * -
user_menu.php *
user_menu.php */
************************* File = user_update.php ****************
************************* File = viewjrn.php ****************
viewjrn.php /* function ViewJrn

View file

@ -21,6 +21,8 @@
/* $Revision$ */
include_once ("ac_common.php");
include_once ("user_menu.php");
html_page_start($_SESSION['use_theme']);
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
@ -37,17 +39,20 @@ $User->Check();
include_once("form_inc.php");
include_once ("user_menu.php");
ShowMenuCompta($_SESSION['$g_dossier']);
ShowMenuCompta($_SESSION['g_dossier']);
include ("check_priv.php");
ShowMenuComptaRight($_SESSION['g_dossier'],$User->admin);
$cn=DbConnect($_SESSION['g_dossier']);
if ( $User->CheckAction($cn,FORM)==0){
/* Cannot Access */
NoAccess();
}
echo ShowMenuAdvanced("form.php");
if ( isset ($_POST["record"] )) {
echo '<DIV class="ccontent">';
AddForm($cn,$HTTP_POST_VARS);
echo "</DIV>";
}
ShowMenuComptaForm($_SESSION['g_dossier']);
@ -87,11 +92,6 @@ if ( isset ($_POST["update"]) ) {
UpdateForm($cn,$HTTP_POST_VARS);
echo "</DIV>";
}
if ( isset ($_POST["record"] )) {
echo '<DIV class="ccontent">';
AddForm($cn,$HTTP_POST_VARS);
echo "</DIV>";
}
//echo '<DIV CLASS="ccontent">';

58
html/form_csv.php Normal file
View file

@ -0,0 +1,58 @@
<?
/*
* 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
include_once("ac_common.php");
include_once ("postgres.php");
include ('class_user.php');
include("class_form.php");
include("impress_inc.php");
header('Content-type: application/csv');
header('Content-Disposition: attachment;filename="form.csv"',FALSE);
/* Admin. Dossier */
$cn=DbConnect($_SESSION['g_dossier']);
$User=new cl_user($cn);
$User->Check();
$Form=new formulaire($cn,$_POST['form_id']);
$Form->GetName();
$array=$Form->GetRow( $_POST['from_periode'],
$_POST['to_periode']
);
if ( count($Form->row ) == 0 )
exit;
echo "\"Description\"\t,".
"\"Montant\"\t";
foreach ( $Form->row as $op ) {
echo '"'.$op['desc'].'"'."\t,".
sprintf("%8.2f",$op['cmontant'])."\t".
"\n";
}
exit;
?>

65
html/form_pdf.php Normal file
View file

@ -0,0 +1,65 @@
<?
/*
* 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$
include_once("class_form.php");
include_once("ac_common.php");
include_once("postgres.php");
include_once("class.ezpdf.php");
include_once("impress_inc.php");
$cn=DbConnect($_SESSION['g_dossier']);
foreach ($HTTP_POST_VARS as $key=>$element) {
${"$key"}=$element;
}
$ret="";
$pdf=& new Cezpdf();
$pdf->selectFont('./addon/fonts/Helvetica.afm');
$Form=new formulaire($cn,$form_id);
$array=$Form->GetRow($from_periode,$to_periode);
$Libelle=sprintf("(%s) %s ",$Form->id,$Form->GetName());
$pdf->ezText($Libelle,30);
$q=getPeriodeName($cn,$from_periode);
if ( $from_periode != $to_periode){
$periode=sprintf("Période %s à %s",$q,getPeriodeName($cn,$to_periode));
} else {
$periode=sprintf("Période %s",$q);
}
$pdf->ezText($periode,25);
$pdf->ezTable($array,
array ('desc'=>'Description',
'montant' => 'Montant'
),$Libelle,
array('shaded'=>0,'showHeadings'=>1,'width'=>500,
'cols'=>array('montant'=> array('justification'=>'right'),
)));
//New page
//$pdf->ezNewPage();
//}
$pdf->ezStream();
?>

View file

@ -45,8 +45,9 @@ echo "<DIV class=\"u_subtmenu\">";
$p_array=array(array ("user_impress.php?type=jrn","Journaux"),
array("user_impress.php?type=poste","Poste"),
array("user_impress.php?type=fiche","Fiche"),
array("user_impress.php?type=form","Formulaire"),
array('user_impress.php?type=bal','Balance des comptes'),
array("user_impress.php?type=form","Formulaire")
array("user_impress.php?type=bilan","Bilan")
);
$default=( isset ($_GET['type']))?"user_impress.php?type=".$_GET['type']:"";
$result=ShowItem($p_array,'H',"cell","mtitle",$default);
@ -76,6 +77,10 @@ $default=( isset ($_GET['type']))?$_GET['type']:"";
case "form":
include ("impress_form.php");
break;
case "bilan":
include ("impress_bilan.php");
break;
case "bal":
include ("balance.php");
break;

View file

@ -326,5 +326,27 @@ function make_array($p_cn,$p_sql,$p_null=0) {
return $r;
}
/* function getPeriodeName
**************************************************
* Purpose : Show the periode which found thanks its
* id
*
* parm :
* - $p_cn database connection
* - p_id
* - Start or end
* gen :
* -
* return: string
*/
function getPeriodeName($p_cn,$p_id,$pos='p_start') {
if ( $pos != 'p_start' and
$pos != 'p_end')
echo_error(__FILE__."-".__LINE__.' UNDEFINED PERIODE');
$ret=execSql($p_cn,"select to_char($pos,'Mon YYYY') as t from parm_periode where p_id=$p_id");
if (pg_NumRows($ret) == 0) return __FILE__.":".__LINE__." ERROR UNKNOW PERIODE";
$a=pg_fetch_array($ret,0);
return $a['t'];
}
?>

66
include/class_form.php Normal file
View file

@ -0,0 +1,66 @@
<?
/*
* 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
class formulaire {
var $db;
var $id;
var $name;
function formulaire($p_cn,$p_id) {
$this->db=$p_cn;
$this->id=$p_id;
$this->name='UNDEF';
}
function GetName() {
$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;
}
function GetRow($p_start,$p_end) {
if ( $p_start == $p_end )
$cond=" j_tech_per = $p_start ";
else
$cond = "(j_tech_per >= $p_start and j_tech_per <= $p_end) ";
$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'],$cond);
} //for ($i
$this->row=$col;
return $col;
}
}
?>

View file

@ -23,7 +23,7 @@
// $Revision$
define ("phpcompta_password","dany");
define ("DEBUG","false");
define ("DEBUG","true");
// securite correspond a la table
// action

View file

@ -17,4 +17,106 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
include_once("class_widget.php");
////////////////////////////////////////////////////////////////////////////////
// If print is asked
// First time in html
// after in pdf or cvs
////////////////////////////////////////////////////////////////////////////////
if ( isset( $_POST['bt_html'] ) ) {
include("class_form.php");
$Form=new formulaire($cn,$_POST['form_id']);
$Form->GetName();
$array=$Form->GetRow( $_POST['from_periode'],
$_POST['to_periode']
);
$rep="";
$submit=new widget();
$hid=new widget("hidden");
echo '<div class="u_redcontent">';
$t=($_POST['from_periode']==$_POST['to_periode'])?"":" -> ".getPeriodeName($cn,$_POST['to_periode'],'p_end');
echo '<h2 class="info">'.$Form->id." ".$Form->name.
" - ".getPeriodeName($cn,$_POST['from_periode'],'p_start').
" ".$t.
'</h2>';
echo "<table>";
echo '<TR>';
echo '<TD><form method="GET" ACTION="user_impress.php">'.
$submit->Submit('bt_other',"Autre Formulaire").
$hid->IOValue("type","form")."</form></TD>";
echo '<TD><form method="POST" ACTION="form_pdf.php">'.
$submit->Submit('bt_pdf',"Export PDF").
$hid->IOValue("type","form").
$hid->IOValue("form_id",$Form->id).
$hid->IOValue("from_periode",$_POST['from_periode']).
$hid->IOValue("to_periode",$_POST['to_periode']);
echo "</form></TD>";
echo '<TD><form method="POST" ACTION="form_csv.php">'.
$submit->Submit('bt_csv',"Export CSV").
$hid->IOValue("type","form").
$hid->IOValue("form_id",$Form->id).
$hid->IOValue("from_periode",$_POST['from_periode']).
$hid->IOValue("to_periode",$_POST['to_periode']);
echo "</form></TD>";
echo "</TR>";
echo "</table>";
if ( count($Form->row ) == 0 )
exit;
echo "<TABLE width=\"100%\">";
echo "<TR>".
"<TH> Description </TH>".
"<TH> montant </TH>".
"</TR>";
foreach ( $Form->row as $op ) {
echo "<TR>".
"<TD>".$op['desc']."</TD>".
"<TD align=\"right\">".sprintf("% 8.2f",$op['montant'])."</TD>".
"</TR>";
}
echo "</table>";
echo "</div>";
exit;
}
////////////////////////////////////////////////////////////////////////////////
// Show the jrn and date
////////////////////////////////////////////////////////////////////////////////
include_once('form_input.php');
include_once("postgres.php");
$ret=make_array($cn,"select fr_id,fr_label
from formdef
order by fr_label");
////////////////////////////////////////////////////////////////////////////////
// Form
////////////////////////////////////////////////////////////////////////////////
echo '<div class="redcontent">';
echo '<FORM ACTION="?type=form" METHOD="POST">';
echo '<TABLE><TR>';
$w=new widget("select");
$w->table=1;
$w->label="Choississez le formulaire";
print $w->IOValue("form_id",$ret);
print '</TR>';
print '<TR>';
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode order by p_id");
$w->label="Depuis";
print $w->IOValue('from_periode',$periode_start);
$w->label=" jusqu'à ";
$periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode order by p_id");
print $w->IOValue('to_periode',$periode_end);
print "</TR>";
echo '</TABLE>';
print $w->Submit('bt_html','Impression');
echo '</FORM>';
echo '</div>';
?>

View file

@ -744,17 +744,20 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_cond)
if ( $l_credit==$l_debit) {
$aret=array('desc' => $p_label,
'montant' => '0');
'montant' => '0',
'cmontant'=>0);
}
if ( $l_credit < $l_debit) {
$l2=sprintf("% .2f",$l_debit-$l_credit);
$aret=array('desc' => $p_label,
'montant' => $l2);
'montant' => $l2,
'cmontant'=>$l2);
}
if ( $l_credit>$l_debit) {
$l2=sprintf("(% .2f)",$l_credit-$l_debit);
$aret=array('desc' => $p_label,
'montant' => $l2);
'montant' => $l2,
'cmontant'=> $l_debit-$l_credit);
}
return $aret;

View file

@ -464,7 +464,8 @@ $left_menu=ShowItem(array(
array('jrn_update.php','Journaux'),
array('central.php','Centralise'),
array('pcmn_update.php?p_start=1','Plan Comptable'),
array('stock.php','stock')
array('stock.php','Stock'),
array('form.php','Formulaire')
),
'H',"cell","mtitle",$default);
return $left_menu;
@ -651,5 +652,32 @@ function ShowMenuPcmn($p_start=1)
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=7">7 Produits</A></TD></TR>';
echo "</TABLE>";
}
/* function
* Purpose :
*
* parm :
* -
* gen :
* -
* return:
* -
*
*/
function ShowMenuComptaForm($p_dossier) {
$cn=DbConnect($p_dossier);
echo '<div class="lmenu">';
echo '<TABLE>';
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="form.php?action=add">Ajout</A></TD></TR>';
$Ret=ExecSql($cn,"select fr_id, fr_label
from formdef order by fr_label");
$Max=pg_NumRows($Ret);
for ($i=0;$i<$Max;$i++) {
$l_line=pg_fetch_array($Ret,$i);
printf ('<TR><TD class="mtitle"><A class="mtitle" HREF="form.php?action=view&fr_id=%s">%s</A></TD></TR>',
$l_line['fr_id'],$l_line['fr_label']);
?>
}
echo "</TABLE>";
echo '</div>';
}
?>