Creation of the interface USER

This commit is contained in:
sparkyx 2004-03-24 13:11:11 +00:00
parent e5ab551ccc
commit 916cfefdd5
24 changed files with 1651 additions and 175 deletions

View file

@ -28,7 +28,6 @@ if ( isset ( $dos ) ) {
echo_debug("admin_dossier = $g_dossier ");
} else {
echo "You must choose a Dossier ";
// phpinfo();
exit -2;
}
include_once ("postgres.php");

View file

@ -166,6 +166,10 @@ if ( isset($_POST['add_record']) ) {
$Res=StartSql($cn);
$seq=GetNextId($cn,'j_grpt')+1;
$s_op=GetNextId($cn,'j_id')+1;
// For the user profile we need the correct sequence id
AlterSequence($cn,'s_jrn_op',$s_op);
$tot_cred=0;
$tot_deb=0;
@ -215,6 +219,7 @@ if ( isset($_POST['add_record']) ) {
$p_rapt="";
if ( trim($p_rapt) != '' ) {
$jrn_id=GetNextJrnId($cn,'jr_id')+1;
if ( ! isset ($p_ech) )
$p_ech="";
$l_date=isDate($p_ech);
@ -225,20 +230,25 @@ if ( isset($_POST['add_record']) ) {
}
$comment=FormatString($p_comment);
$Sql=sprintf("insert into jrn(jr_id,jr_def_id,jr_comment,jr_date,jr_grpt_id,
jr_rapt,jr_montant,jr_tech_per) values(%s,%s,'%s',%s,%d,'%s',%f,%d)",
jr_rapt,jr_montant,jr_tech_per,jr_ech) values(%s,%s,'%s',to_date('%s','DD.MM.YYYY'),%d,'%s',%f,%d,'%s')",
$jrn_id,
$g_jrn,
$comment,
$p_ech,
$p_op_date,
$seq,
$p_rapt, $tot_deb,
$userPref);
$userPref,
$p_ech);
echo_debug($Sql);
$Res=ExecSql($cn,$Sql);
// $l_dest=GetRaptDest($cn,$p_rapt);
if ($Res)
$internal=SetInternalCode($cn,$jrn_id,$g_jrn,$g_dossier);
$internal=SetInternalCode($cn,$seq,$g_jrn);
// For the user profile we need the correct sequence id
AlterSequence($cn,'s_jrn',$jrn_id);
// TODO multiple rapt should be added
$sql=sprintf("update jrn set jr_rapt='%s' where jr_internal='%s'",$internal,$p_rapt);
echo_debug("add $sql");
$Res=ExecSql($cn,$sql);
@ -264,7 +274,7 @@ if ( isset($_POST['add_record']) ) {
echo_debug("Sql $Sql");
$Res=ExecSql($cn,$Sql);
if ($Res)
SetInternalCode($cn,$jrn_id,$g_jrn,$g_dossier);
SetInternalCode($cn,$seq,$g_jrn);
}

View file

@ -31,9 +31,12 @@ include ("check_priv.php");
include_once ("top_menu_compta.php");
ShowMenuCompta($g_dossier,$g_UserProperty);
if ( isset ($g_jrn) ) {
echo_debug("g_jrn is set --> come from user_profile");
$p_id=$g_jrn;
} else {
if (isset ($_GET["p_id"]) ) $p_id=$_GET["p_id"];
if (isset ($_GET["p_id"]) ) {
$p_id=$_GET["p_id"];
}
}
include_once("impress_inc.php");
@ -45,7 +48,7 @@ if ( $g_UserProperty['use_admin'] == 0 ) {
NoAccess();
}
if ( isset ($_GET["type"])) {
if ( $type="jrn") {
if ( $type=="jrn") {
$right=CheckJrn($g_dossier,$g_user,$p_id);
if ($right == 0 ){
/* Cannot Access */
@ -58,13 +61,37 @@ if ( $g_UserProperty['use_admin'] == 0 ) {
$l_Db=sprintf("dossier%d",$g_dossier);
$cn=DbConnect($l_Db);
ShowMenuJrnUserImp($cn,$g_user,$g_dossier);
// if the user has the profile compta show the left menu
if ( $g_UserProperty['use_usertype'] == 'compta')
ShowMenuJrnUserImp($cn,$g_user,$g_dossier);
// if the user has the profile compta show the left menu
if ( $g_UserProperty['use_usertype'] == 'user') {
// Get the jrn_type_id
include_once('jrn.php');
$JrnProp=GetJrnProp($g_dossier,$g_jrn);
$jrn_type=$JrnProp['jrn_def_type'];
// Display available menus
ShowMenuJrnUser($g_dossier,$g_UserProperty,$jrn_type,$g_jrn);
// display jrn's menu
include_once('user_menu.php');
$menu_jrn=u_ShowMenuJrn($cn,$jrn_type);
echo '<div class="searchmenu">';
echo $menu_jrn;
echo '</DIV>';
} // Menu for user's profile
// Ask the period
if ( isset ( $_GET["action"]) ) {
echo_debug(" action is set ");
$a_print=$HTTP_GET_VARS;
$a_print['p_id']=$p_id;
echo '<DIV class="redcontent">';
ViewImp($HTTP_GET_VARS,$cn);
echo '<h2 class="info"> Choississez la période</h2>';
ViewImp($a_print,$cn);
echo '</DIV>';
}//if ( isset ( $_GET["action"] ))

View file

@ -44,28 +44,30 @@ foreach ($l_array as $key=>$element) {
echo_debug("e_$key =$element");
}
echo '<div> Opération '.$l_array['jr_internal']."</div>";
echo '<div align="center"> Opération '.$l_array['jr_internal']."</div>";
echo 'Date : '.$e_op_date;
echo '<div style="border-style:solid;border-width:1pt;">';
echo $e_comment;
echo '</DIV>';
echo 'Date : '.$e_op_date;
if ( isset ($e_ech) ) {
echo "<DIV> Echeance $e_ech </DIV>";
}
for ( $i = 0; $i < $max_deb;$i++) {
$lib=GetPosteLibelle($g_dossier,${"e_class_deb$i"});
echo '<div style="background-color:lightblue;">';
echo '<div style="background-color:#BFC2D5;">';
echo ${"e_class_deb$i"}." $lib "."<B>".${"e_mont_deb$i"}."</B>";
echo "</div>";
}
for ( $i = 0; $i < $max_cred;$i++) {
$lib=GetPosteLibelle($g_dossier,${"e_class_cred$i"});
echo '<div style="background-color:lightgreen;">';
echo '<div style="background-color:#E8F4FF;">';
echo ${"e_class_cred$i"}." $lib "."<B>".${"e_mont_cred$i"}."</B>";
echo '</div>';
}
echo "operation concernée $e_rapt";
echo '<div style="border-style:solid;border-width:1pt;">';
echo $e_comment;
echo '</DIV>';
echo "operation concernée $e_rapt<br><br>
";
?>
<input type="button" onClick="window.close()" value="Fermer">
<?

View file

@ -57,8 +57,8 @@ if ( isset ($_POST["search"]) ) {
$c_comment=" $part pcm_lib like '%$p_comment%'";
$part=" and ";
}
if ( ereg ("^[0-9]*\.[0-9]*$",$p_montant) ||
ereg ("^[0-9]*$",$p_montant) )
if ( strlen($p_montant) != 0 && (ereg ("^[0-9]*\.[0-9]*$",$p_montant) ||
ereg ("^[0-9]*$",$p_montant)) )
{
$c_montant=sprintf(" $part j_montant %s %s",$p_montant_sel,$p_montant);
$part=" and ";
@ -70,7 +70,16 @@ if ( isset ($_POST["search"]) ) {
$condition=$c_comment.$c_montant.$c_date;
echo_debug("condition = $condition");
}
$condition=$condition." $part uj_priv in ('W','R') and uj_login='".$user."'" ;
$condition=$condition." ".$part;
// If the usr is admin he has all right
if ( $g_UserProperty['use_admin'] != 1 ) {
$condition.=" uj_priv in ('W','R') and uj_login='".$g_user."'" ;
} else {
$condition.=" 1=1 ";
}
echo '<FORM ACTION="jrn_search.php" METHOD="POST">';
echo '<TABLE>';
echo '<TR>';

137
html/print_invoice.php Normal file
View file

@ -0,0 +1,137 @@
<?
/*
* 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
*/
/* received parameters
e_date element 01.01.2003
e_client element 3
nb_item element 2
e_march0 element 11
e_quant0 element 1
e_march1 element 6
e_quant1 element 2
e_comment invoice number
*/
// 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");
include_once("fiche_inc.php");
include_once("user_common.php");
echo_debug("imp pdf journaux");
$l_Db=sprintf("dossier%d",$g_dossier);
$cn=DbConnect($l_Db);
foreach ($HTTP_POST_VARS as $key=>$element) {
${"$key"}=$element;
echo_debug("key => $key element $element");
}
$amount=0.0;
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_amount[$i]=GetFicheAttribut($cn,$a_good[$i],ATTR_DEF_PRIX_VENTE)*$a_quant[$i];
$amount+=$a_amount[$i];
$tva=GetTvaRate($cn,GetFicheAttribut($cn,$a_good[$i],ATTR_DEF_TVA));
// Prepare the array to print
$a_good_detail[]=array('id'=>$i+1,
'name'=>GetFicheAttribut($cn,$a_good[$i],ATTR_DEF_NAME),
'quantity'=>$a_quant[$i],
'Unit' =>GetFicheAttribut($cn,$a_good[$i],ATTR_DEF_PRIX_VENTE),
'Total HTVA' => $a_amount[$i],
'tva'=>$tva['tva_label'],
'Total' => $a_amount[$i]+$a_amount[$i]*$a_quant[$i]*$tva['tva_rate']);
}
$a_vat=ComputeVat($cn, $a_good,$a_quant,ATTR_DEF_PRIX_VENTE);
$sum_vat=0.0;
foreach ( $a_vat as $element => $t) {
echo_debug(" a_vat element $element t $t");
$sum_vat+=$t;
echo_debug("sum_vat = $sum_vat");
}
$ret="";
$pdf=& new Cezpdf('a4');
$pdf->selectFont('./addon/fonts/Helvetica.afm');
$pdf->ezSetCmMargins(2,2,2,2);
// Write the date
$pdf->ezText("Date : ".$e_date,10,array('justification'=>'right'));
// write the customer data
$info[0]=array('info'=>GetFicheAttribut($cn,$e_client,ATTR_DEF_NAME));
$info[1]=array('info'=>GetFicheAttribut($cn,$e_client,ATTR_DEF_ADRESS));
$info[2]=array('info'=>GetFicheAttribut($cn,$e_client,ATTR_DEF_CP));
$info[3]=array('info'=>GetFicheAttribut($cn,$e_client,ATTR_DEF_PAYS));
$pdf->ezSetDy(-50);
$pdf->ezTable($info, null, "Informations"
, array('width'=>200,'fontSize'=>12,'shaded'=>0,'xOrientation'=>'left','xPos'=>'right','showHeadings'=>0));
// Write the invoice number
$pdf->ezSetDy(-50);
$pdf->ezText ($e_comment,14,array('justification'=>'center'));
// Write the goods details
$pdf->ezSetDy(-50);
$pdf->ezTable($a_good_detail,null,'Detail invoice',
array('width'=>400,'cols'=>array(
'quantity'=>array('justification'=>'right'),
'Unit'=>array('justification'=>'right'),
'Total HTVA'=>array('justification'=>'right'),
'tva'=>array('justification'=>'right'),
'Total'=>array('justification'=>'right')
)));
// Write the sum detail
$sum_detail[0] = array ('label'=>'Total HTVA ','amount'=>$amount);
$index=1;
foreach ( $a_vat as $element => $t) {
echo_debug(" a_vat element $element t $t");
$a_tva_sum=GetTvaRate($cn,$element);
$sum_detail[++$index]=array('label'=>"tva ". $a_tva_sum['tva_label'],'amount'=>$t);
}
$total=$amount+$sum_vat;
$sum_detail[++$index]=array('label'=>"Total", 'amount'=>$total);
$pdf->ezSetDy(-50);
$pdf->ezTable($sum_detail,null,'',
array('width'=>200,'showHeadings'=>0,'shaded'=>0,'cols'=>array('amount'=>array('justification'=>'right'))));
// wRITE THE DATE LIMIT
$pdf->ezSetDy(-50);
$pdf->ezText(" Limit date : ".$e_ech);
// // Make a file of it
// //$pdfcode=" I don't know whether the prob comes from the ezPdf or from Apache or from Mysql";
// $pdfcode=$pdf->ezOutput();
// $fp=fopen("invoice.pdf","wb+");
// fwrite($fp,$pdfcode);
// fclose ($fp);
$pdf->ezStream();
?>

51
html/show_tva.php Normal file
View file

@ -0,0 +1,51 @@
<?
/*
* 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 ("ac_common.php");
html_page_start($g_UserProperty['use_theme']);
include_once ("postgres.php");
/* Admin. Dossier */
CheckUser();
if ( ! isset ( $g_dossier ) ) {
echo "You must choose a Dossier ";
phpinfo();
exit -2;
}
$l_Db=sprintf("dossier%d",$g_dossier);
$condition="";
$cn=DbConnect($l_Db);
$Res=ExecSql($cn,"select * from tva_rate order by tva_rate desc");
$Max=pg_NumRows($Res);
echo "<TABLE BORDER=\"1\">";
for ($i=0;$i<$Max;$i++) {
$row=pg_fetch_array($Res,$i);
printf("<tr><TD BGCOLOR=\LIGHTGREEN\" >%d</TD><TD>%s</TD><TD>%s</TD></TR>",
$row['tva_id'],
$row['tva_label'],
$row['tva_comment']);
}
echo '</TABLE>';
echo '<INPUT TYPE="BUTTON" Value="Close" onClick=\'window.close()\'>';
html_page_stop();
?>

59
html/user_advanced.php Normal file
View file

@ -0,0 +1,59 @@
<?
/*
* This file is part of WCOMPTA.
*
* 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 WCOMPTA; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Auteur Dany De Bontridder ddebontridder@yahoo.fr
include_once ("ac_common.php");
/* $Revision$ */
html_page_start($g_UserProperty['use_theme']);
if ( ! isset ( $g_dossier ) ) {
echo "You must choose a Dossier ";
phpinfo();
exit -2;
}
include_once ("postgres.php");
/* Admin. Dossier */
CheckUser();
include_once ("postgres.php");
echo_debug ("user is $g_user");
/* CheckUser */
CheckUser();
// We don't check permissions here in fact, permission are tested in the
// functions
// Show the top menus
include_once ("user_menu.php");
include_once ("top_menu_compta.php");
ShowMenuCompta($g_dossier,$g_UserProperty);
// Show the right menus
ShowMenuComptaRight($g_dossier,$g_UserProperty);
// Show the left menu
$left_menu=ShowItem(array(
array('jrn_update.php','Journaux'),
array('central.php','Centralise'),
array('pcmn_update.php?p_start=1','Plan Comptable')),
'V');
echo '<div class="lmenu">';
echo $left_menu;
echo '</DIV>';
?>

View file

@ -17,7 +17,7 @@
*/
function SearchJrn(p_sessid)
{
var win=window.open('jrn_search.php?PHPSESSID='+p_sessid,'Cherche','toolbar=no,width=600,height=600,scrollbar');
var win=window.open('jrn_search.php?PHPSESSID='+p_sessid,'Cherche','toolbar=no,width=600,height=600,scrollbars=yes');
}
function GetIt(p_value) {
self.opener.SetIt(p_value);

View file

@ -110,7 +110,7 @@ function isDate ( $p_date) {
}// !ereg
return $p_date;
}
/* function
/* function formatDate($p_date)
* Purpose :
*
* parm :

View file

@ -84,10 +84,44 @@ define ("ALL_FICHE_DEF_REF", 1000);
// fixed value for attr_def data
define ("ATTR_DEF_ACCOUNT",5);
define ("ATTR_DEF_NAME",1);
define ("ATTR_DEF_PRIX_ACHAT",6);
define ("ATTR_DEF_PRIX_VENTE",7);
define ("ATTR_DEF_PRIX_ACHAT",7);
define ("ATTR_DEF_PRIX_VENTE",6);
define ("ATTR_DEF_TVA",2);
define ("FICHE_TYPE_CLIENT",9);
define ("FICHE_TYPE_VENTE",1);
define ("ATTR_DEF_ADRESS",14);
define ("ATTR_DEF_CP",15);
define ("ATTR_DEF_PAYS",16);
define ("JS_SEARCH_POSTE","<SCRIPT>function SearchPoste(p_sessid)
{
var win=window.open('poste_search.php?PHPSESSID='+p_sessid,'Cherche','toolbar=no,width=600,height=600,scrollbars=yes,resizable=yes');
}
function GetIt() {
window.close();
}
</SCRIPT>"
);
define ("JS_SHOW_TVA","<SCRIPT>function ShowTva(p_sessid)
{
var win=window.open('show_tva.php?PHPSESSID='+p_sessid,'Montre','scrollbar,toolbar=no,width=300,height=300,resizable=yes');
}
function GetIt() {
window.close();
}
</SCRIPT>"
);
define ("JS_VIEW_JRN_DETAIL","<script>function viewDetail(p_value,p_sessid)
{
var win=window.open('jrn_op_detail.php?jrn_op='+p_value+'&PHPSESSID='+p_sessid,'Cherche','toolbar=no,width=400,height=400,scrollbars=yes,resizable=yes');
}
</script>");
// Sql string
define ("SQL_LIST_ALL_INVOICE","");
define ("SQL_LIST_UNPAID_INVOICE"," where (jr_rapt is null or jr_rapt = '')");
define ("SQL_LIST_UNPAID_INVOICE_DATE_LIMIT" ," where (jr_rapt is null or jr_rapt = '')
and to_date(to_char(jr_ech,'DD.MM.YYYY'),'DD.MM.YYYY') < to_date(to_char(now(),'DD.MM.YYYY'),'DD.MM.YYYY')");
?>

View file

@ -19,7 +19,7 @@
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
// $Revision$
/* fucntion GetSqlFiche
/* function GetSqlFiche
***************************************************
* purpose : return the sql string which match the p_type
* permit to have all the sql here
@ -52,7 +52,7 @@ function GetSqlFiche($p_type) {
* - none
* return:
* - none
*
* TODO ADD TEST FOR THE VAT RATE
*/
function AddFiche($p_cn,$p_type,$p_array) {
echo_debug(" AddFiche($p_cn,$p_type,$p_array) ");
@ -160,7 +160,9 @@ function EncodeFiche($p_cn,$p_type,$p_array=null) {
$ch_li='</TR><TR>';
echo '<FORM action="fiche.php" method="post">';
echo '<INPUT TYPE="HIDDEN" name="fiche" value="'.$p_type.'">';
$l_sessid=(isset ($_POST["PHPSESSID"]))?$_POST["PHPSESSID"]:$_GET["PHPSESSID"];
echo JS_SHOW_TVA;
echo "<TABLE>";
if ($p_array == null) {
// Array is null so we display a blank form
@ -183,10 +185,20 @@ function EncodeFiche($p_cn,$p_type,$p_array=null) {
// The number of the attribute
$Hid=sprintf('<INPUT TYPE="HIDDEN" name="ad_id%d" value="%s">',
$i,$l_line['ad_id']);
$but_search_poste="";
// Javascript for searching the account
if ( $l_line ['ad_id'] == ATTR_DEF_ACCOUNT ) {
$but_search_poste='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchPoste(\''.$l_sessid.'\')">';
}
// Javascript for showing the tva
if ( $l_line ['ad_id'] == ATTR_DEF_TVA ) {
$but_search_poste='<INPUT TYPE="BUTTON" VALUE="Montre" OnClick="ShowTva(\''.$l_sessid.'\')">';
}
// content of the attribute
printf ('<TR><TD> %s </TD><TD><INPUT TYPE="TEXT" NAME="av_text%d">%s</TD></TR>',
$l_line['ad_text'], $i,$Hid);
}
printf ('<TR><TD> %s </TD><TD><INPUT TYPE="TEXT" NAME="av_text%d">%s %s</TD></TR>',
$l_line['ad_text'], $i,$Hid,$but_search_poste);
}
echo '</TR>';
echo '</TABLE>';
echo '<INPUT TYPE="HIDDEN" name="inc" value="'.$Max.'">';
@ -217,20 +229,33 @@ function EncodeFiche($p_cn,$p_type,$p_array=null) {
for ($i=0;$i < $Max;$i++) {
// fetch the data
$l_line=pg_fetch_array($Res,$i);
// TODO if ad_id = ATTR_DEF_ACCOUNT SHOW BUTTON FOR SHOWING PCMN
// TODO if ad_id = ATTR_DEF_TVA SHOW BUTTON FOR SHOWING PCMN
// Put also the class in a special variable
// useful when we want to update the PCMN
// TODO permit the update of TMP_PCMN
$but_search_poste="";
if ( $l_line['ad_id'] == ATTR_DEF_ACCOUNT ) {
printf('<INPUT TYPE="HIDDEN" name="class" value="%s">',
$l_line['av_text']);
// Javascript for searching the account
$but_search_poste='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchPoste(\''.$l_sessid.'\')">';
}
// Javascript for showing the tva
if ( $l_line ['ad_id'] == ATTR_DEF_TVA ) {
$but_search_poste='<INPUT TYPE="BUTTON" VALUE="Montre" OnClick="ShowTva(\''.$l_sessid.'\')">';
}
// in hidden we put the jft_id
$Hid=sprintf('<INPUT TYPE="HIDDEN" name="jft_id%d" value="%s">',
$i,$l_line['jft_id']);
printf ('<TR><TD> %s </TD><TD><INPUT TYPE="TEXT" NAME="av_text%d" VALUE="%s">%s</TD></TR>',
$l_line['ad_text'], $i, $l_line['av_text'],$Hid);
printf ('<TR><TD> %s </TD><TD><INPUT TYPE="TEXT" NAME="av_text%d" VALUE="%s">%s %s</TD></TR>',
$l_line['ad_text'], $i, $l_line['av_text'],$Hid,$but_search_poste);
}
echo '</TR>';
@ -405,6 +430,7 @@ function ViewFicheDetail($p_cn,$p_id) {
* - nothing
*
*/
//TODO ADD TEST FOR THE VAT RATE
function UpdateFiche($p_cn,$p_array) {
foreach ( $p_array as $key=> $element) {
echo_debug("$key => $element");
@ -432,7 +458,7 @@ function UpdateFiche($p_cn,$p_array) {
}
// Update the PCMN if needed
$sql="select av_text from attr_value natural join jnt_fic_att_value
where f_id=$fiche and ad_id=5";
where f_id=$fiche and ad_id=".ATTR_DEF_ACCOUNT;
$Res=ExecSql($p_cn,$sql);
if ( pg_NumRows($Res) != 0 ) {
@ -463,12 +489,16 @@ function UpdateFiche($p_cn,$p_array) {
$class=$class_old;
} else // $class=""
{
echo_debug("new account ");
$class=$class_old;
// First we must use a parent
$parent=GetParent($p_cn,$class);
$Res=ExecSql($p_cn,
"insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent)
if ( CountSql($p_cn,"select * from tmp_pcmn where pcm_val=".$class) == 0 ) {
// First we must use a parent
$parent=GetParent($p_cn,$class);
$Res=ExecSql($p_cn,
"insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent)
values ($class,'$f_label',$parent)");
}
}
@ -853,13 +883,11 @@ function getFicheDefName($p_cn,$p_id) {
* - p_cn connextion
* - j_jrn journal_id
* - $p_type : deb or cred
* - $p_fiche_type : fiche_def_ref.frd_id to know what kind of card is asked
* -> Sell, Customer...
* gen :
* - none
* return: array containing the fiche(f_id),fiche(f_label)
*/
function GetFicheJrn($p_cn,$p_jrn,$p_type,$p_fiche_type)
function GetFicheJrn($p_cn,$p_jrn,$p_type)
{
$get="";
if ( $p_type == 'deb' ) {
@ -884,13 +912,14 @@ function GetFicheJrn($p_cn,$p_jrn,$p_type,$p_fiche_type)
echo_warning("No fiche");
return null;
}
$sql="select f_id,av_text as f_label
from fiche natural join jnt_fic_att_value
natural join attr_def
natural join attr_value
natural join fiche_def_ref
natural join fiche_def
where ad_id=1 and
fd_id in (".$list['fiche'].") and frd_id=$p_fiche_type order by f_label";
fd_id in (".$list['fiche'].") order by f_label";
$Res=ExecSql($p_cn,$sql);
$Max=pg_NumRows($Res);
@ -1261,5 +1290,34 @@ function GetParent($p_cn,$p_val)
return $a;
}
}
/* function getFicheAttribut
***************************************************
* Purpose : retourne le tva
*
* parm :
* - p_cn connexion
* - p_id fiche id
* - attribut
* gen :
* - none
* return:
* - string avec nom fiche
*/
function getFicheAttribut($p_cn,$p_id,$p_attr) {
// Retrieve the attribute with the ad_id 1
// 1 is always the name
// TODO replace absolute value by defined value
$Res=ExecSql($p_cn,"select av_text from
attr_value
natural join jnt_fic_att_value
natural join fiche
where
f_id=$p_id and
ad_id=$p_attr");
if ( pg_NumRows($Res) == 0 ) return "Unknown";
$st=pg_fetch_array($Res,0);
return $st['av_text'];
}
?>

View file

@ -19,7 +19,8 @@
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
include_once("preference.php");
include_once("fiche_inc.php");
include_once("user_common.php");
/* function InputType
* Purpose : Create the tag <INPUT TYPE=... Name=...>
*
@ -38,9 +39,20 @@ include_once("preference.php");
function InputType($p_label,$p_type,$p_name,$p_value,$p_viewonly=false,$p_list=null)
{
// View only
if ( $p_viewonly==false)
return "<TD>$p_label</TD><TD>$value</TD>";
if ( $p_viewonly==true) {
if ( strlen($p_label) != 0) {
// name and value are set put the info in a hidden field
$hidden=(strlen($p_name) != 0) ?"<INPUT TYPE=\"hidden\" NAME=\"$p_name\" value=\"$p_value\">":"";
// return
return "<TD>$p_label $hidden </TD><TD>$p_value</TD>";
} else {
// name and value are set put the info in a hidden field
$hidden=(strlen($p_name) != 0) ?"<INPUT TYPE=\"hidden\" NAME=\"$p_name\" value=\"$p_value\">":"";
return "<TD>$p_value $hidden</TD>";
}
}
// Input type == select
if ( strtolower($p_type)=="select" ) {
$r="<TD> $p_label</TD><TD>";
@ -48,7 +60,7 @@ function InputType($p_label,$p_type,$p_name,$p_value,$p_viewonly=false,$p_list=n
foreach ($p_list as $item) {
$selected="";
if ( $p_value == $item[0] ) {
$selected="SELECTED";
$selected="SELECTED";
}
$r.=sprintf('<OPTION VALUE="%s" %s>%s',
$item[0],
@ -68,6 +80,16 @@ function InputType($p_label,$p_type,$p_name,$p_value,$p_viewonly=false,$p_list=n
$p_value);
return $r;
}
// input type == HIDDEN
if ( strtolower($p_type)=="hidden") {
$r=sprintf('<TD> <INPUT TYPE="%s" NAME="%s" VALUE="%s"></TD>',
$p_type,
$p_name,
$p_value);
return $r;
}
}
/* function FormVente
@ -80,52 +102,431 @@ function InputType($p_label,$p_type,$p_name,$p_value,$p_viewonly=false,$p_list=n
* - the "journal"
* - $p_user = $g_user
* - view_only if we cannot change it (no right or centralized op)
* - $p_article number of article
* gen :
* -
* return: string with the form
* TODO Add in parameters the infos about the company for making the invoice
*/
function FormVente($p_cn,$p_jrn,$p_user,$p_array=null,$view_only=true)
function FormVente($p_cn,$p_jrn,$p_user,$p_array=null,$view_only=true,$p_article=1)
{
$userPref=GetUserPeriode($p_cn,$p_user);
if ( $p_array != null ) {
// array contains old value
foreach ( $p_array as $a=>$v) {
${"$a"}=$v;
}
}
// The date
$userPref=GetUserPeriode($p_cn,$p_user);
list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$userPref);
$op_date="01".substr($l_date_start,2,8);
$op_date=( ! isset($e_date) ) ? "01".substr($l_date_start,2,8):$e_date;
$e_ech=(isset($e_ech))?$e_ech:"";
// Save old value and set a new one
echo_debug("form_input.php.FormVentep_op_date is $op_date");
$r="";
if ( $view_only == false) {
$r="<FORM ACTION=user_jrn.php?action=add_invoice>";
$r="<FORM ACTION=\"user_jrn.php?action=insert_vente\" METHOD=\"POST\">";
}
$r.='<TABLE>';
$r.='<TR>'.InputType("Date ","Text","e_date",$op_date,$view_only).'</TR>';
$r.='<TR>'.InputType("Echeance","Text","e_ech",$e_ech,$view_only).'</TR>';
include_once("fiche_inc.php");
// Display the customer
$fiche=GetFicheJrn($p_cn,$p_jrn,'cred',FICHE_TYPE_CLIENT);
$r.='<TR>'.InputType("Client ","SELECT","e_client","",$view_only,$fiche).'</TR>';
// TODO ADD BUTTON NEW CUSTOMER
$fiche=GetFicheJrn($p_cn,$p_jrn,'deb');
echo_debug("Client Nombre d'enregistrement ".sizeof($fiche));
// Save old value and set a new one
$client=( isset ($e_client) )?$e_client:"";
$r.='<TR>'.InputType("Client ","SELECT","e_client",$client,$view_only,$fiche).'</TR>';
$r.="</TABLE>";
// Record the current number of article
$r.='<INPUT TYPE="HIDDEN" name="nb_item" value="'.$p_article.'">';
$e_comment=(isset($e_comment))?$e_comment:"";
// Start the div for item to sell
$r.="<DIV>";
$r.='<H2 class="info">Articles</H2>';
$r.='<TABLE>';
$fiche=GetFicheJrn($p_cn,$p_jrn,'deb',FICHE_TYPE_VENTE);
$r.='<TR>'.InputType("Article","SELECT","e_march","",$view_only,$fiche);
$r.=InputType("Quantité","TEXT","e_quant","1",$view_only);
$fiche=GetFicheJrn($p_cn,$p_jrn,'cred');
echo_debug("Cred Nombre d'enregistrement ".sizeof($fiche));
for ($i=0;$i< $p_article;$i++) {
$march=(isset(${"e_march$i"}))?${"e_march$i"}:"";
$r.='<TR>'.InputType("Article","SELECT","e_march".$i,$march,$view_only,$fiche);
$quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"0";
$r.=InputType("Quantité","TEXT","e_quant".$i,$quant,$view_only);
$r.='</TR>';
}
// TODO Show the price
// TODO PERMIT multi lines
$r.='</TR>';
$r.="</TABLE>";
$r.='<INPUT TYPE="SUBMIT" NAME="add_invoice" VALUE="Voir cette facture">';
$r.='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">';
$r.='<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Voir cette facture">';
$r.="</DIV>";
$r.="</FORM>";
return $r;
}
}
/* function FormVenteView ($p_cn,$p_jrn,$p_user,$p_array,$p_number,$p_doc='html',$p_comment='')
**************************************************
* Purpose : Show the invoice before inserting it
* the database
*
* parm :
* - p_cn database connection
* - p_jrn journal
* - p_user
* - array of value
* - nb of item
* - p_doc type pdf or html
* gen :
* - none
* return:
* - string
* TODO Add test for the date
*/
function FormVenteView ($p_cn,$p_jrn,$p_user,$p_array,$p_number,$p_doc='html',$p_comment='')
{
// TODO Verify the invoice data if verif failed return null and resubmit
$r="";
$data="";
// Keep all the data if hidden
// and store the array in variables
foreach ($p_array as $name=>$content) {
$data.=InputType("","HIDDEN",$name,$content);
${"$name"}=$content;
}
// Verify the date
if ( isDate($e_date) == null ) {
echo_error("Invalid date $e_date");
echo_debug("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("invalid quantity ".${"e_quant$o"});
echo_error("invalid quantity ".${"e_quant$o"});
echo "<SCRIPT> alert('INVALID QUANTITY !!!');</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(" date $e_date = $day.$month.$year");
$p_ech=date('d.m.Y',mktime(0,0,0,$month,$day+$e_ech,$year));
echo_debug("p_ech = $e_ech $p_ech");
$e_ech=$p_ech;
$data.=InputType("","HIDDEN","e_ech",$e_ech);
}
// Verify the userperiode
// userPref contient la periode par default
$userPref=GetUserPeriode($p_cn,$p_user);
list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$userPref);
// Date dans la periode active
echo_debug ("date start periode $l_date_start date fin periode $l_date_end date demandée $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_error($msg); echo_error($msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
}
// Periode fermée
if ( PeriodeClosed ($p_cn,$userPref)=='t' )
{
$msg="This periode is closed please change your preference";
echo_error($msg); echo_error($msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
}
// start table
$r.='<TABLE>';
// Show the Date
$r.="<tr>";
$r.=InputType("Date","text","",$e_date,true);
$r.="</tr>";
// Show the customer Name
$r.="<tr>";
$r.=InputType("Client","text","",getFicheName($p_cn,$e_client),true);
$r.="</tr>";
// show date limit
$r.="<tr>";
$r.=InputType("Date limite","text","",$e_ech,true);
$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++) {
$fiche_name=getFicheName($p_cn,${"e_march$i"});
$fiche_price=getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_PRIX_VENTE);
$fiche_quant=${"e_quant$i"};
// No row if there is quantity
if ( $fiche_quant == 0.0 ) continue;
// VAT
$vat=getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_TVA);
// vat label
// vat rate
$a_vat=GetTvaRate($p_cn,$vat);
if ( $a_vat == null ) {
$vat_label="unknown";
$vat_rate=0.0;
} else {
$vat_label=$a_vat['tva_label'];
$vat_rate=$a_vat['tva_rate'];
}
// Total card without vat
$fiche_sum=$fiche_price*$fiche_quant;
// Sum of invoice
$sum_march+=$fiche_sum;
// vat of the card
$fiche_amount_vat=$fiche_price*$fiche_quant*$vat_rate;
// value card + vat
$fiche_with_vat=$fiche_price*$fiche_quant*(1+$vat_rate);
// 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">'.$fiche_sum.'</TD>';
$r.='<TD ALIGN="RIGHT">'.$fiche_amount_vat.'</TD>';
$r.='<TD>'.$fiche_with_vat.'</TD>';
$r.="</TR>";
}
// end table
$r.='</TABLE> ';
$r.='<DIV style="padding:30px;font-size:14pt">';
$r.="Total HTVA = $sum_march <br>";
$r.="Total = $sum_with_vat";
$r.="</DIV>";
if ( $p_doc == 'html' ) {
$r.='<FORM METHOD="POST" ACTION="user_jrn.php?action=record">';
$r.=$data;
$r.='<INPUT TYPE="SUBMIT" name="record_invoice" value="Sauver">';
$r.='<INPUT TYPE="SUBMIT" name="record_and_print_invoice" value="Sauver & imprimer">';
$r.='</FORM>';
}
if ( $p_doc == 'pdf' ) {
$r.='<FORM METHOD="POST" ACTION="print_invoice.php">';
$r.=$data;
$r.=InputType("","HIDDEN","e_comment",$p_comment);
$r.='<INPUT TYPE="SUBMIT" name="record_invoice" value="Imprimer">';
$r.='</FORM>';
}
return $r;
}
/* function RecordInvoice
**************************************************
* Purpose : Record an invoice in the table jrn &
* jrnx
*
* parm :
* - $p_cn Database connection
* - $p_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_march1 => e : 6
* e_quant1 => e : 2
* e_march2 => e : 7
* e_quant2 => e : 3
V : view_invoice => e : Voir cette facture
V : record_invoice => e : Sauver
* - $p_user userid
* - $p_jrn current folder (journal)
* gen :
* - none
* return:
* true on success
*/
function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
{
foreach ( $p_array as $v => $e)
{
${"$v"}=$e;
}
// Get the default period
$periode=GetUserPeriode($p_cn,$p_user);
$amount=0.0;
// 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"};
$amount+=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_PRIX_VENTE)*$a_quant[$i];
}
$a_vat=ComputeVat($p_cn, $a_good,$a_quant,ATTR_DEF_PRIX_VENTE);
$sum_vat=0.0;
foreach ( $a_vat as $element => $t) {
echo_debug(" a_vat element $element t $t");
$sum_vat+=$t;
echo_debug("sum_vat = $sum_vat");
}
// First we add in jrnx
// Compute the j_grpt
$seq=GetNextId($p_cn,'j_grpt')+1;
// Debit = client
$poste=GetFicheAttribut($p_cn,$e_client,ATTR_DEF_ACCOUNT);
InsertJrnx($p_cn,'d',$p_user,$p_jrn,$poste,$e_date,$amount+$sum_vat,$seq,$periode);
// Credit = goods
for ( $i = 0; $i < $nb_item;$i++) {
$poste=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_ACCOUNT);
InsertJrnx($p_cn,'c',$p_user,$p_jrn,$poste,$e_date,$amount,$seq,$periode);
}
// Insert Vat
if (sizeof($a_vat) != 0 ) // no vat
{
foreach ($a_vat as $tva_id => $tva_amount ) {
$poste=GetTvaPoste($p_cn,$tva_id,'c');
InsertJrnx($p_cn,'c',$p_user,$p_jrn,$poste,$e_date,$tva_amount,$seq,$periode);
}
}
echo_debug("echeance = $e_ech");
InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"Invoice",$amount+$sum_vat,$seq,$periode);
// Set Internal code and Comment
$comment=SetInternalCode($p_cn,$seq,$p_jrn)." client : ".GetFicheName($p_cn,$e_client);
// Update and set the invoice's comment
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
return $comment;
}
/* function FormAch($p_cn,$p_jrn,$p_user,$p_array=null,$view_only=true,$p_article=1)
* Purpose : Display the form for buying
* Used to show detail, encode a new invoice
* or update one
*
* parm :
* - p_array which can be empty
* - the "journal"
* - $p_user = $g_user
* - $p_submit contains the submit string
* - view_only if we cannot change it (no right or centralized op)
* - $p_article number of article
* gen :
* -
* return: string with the form
* TODO Add in parameters the infos about the company for making the invoice
*/
function FormAch($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p_article=1)
{
if ( $p_array != null ) {
// array contains old value
foreach ( $p_array as $a=>$v) {
${"$a"}=$v;
}
}
// The date
$userPref=GetUserPeriode($p_cn,$p_user);
list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$userPref);
$op_date=( ! isset($e_date) ) ? "01".substr($l_date_start,2,8):$e_date;
$e_ech=(isset($e_ech))?$e_ech:"";
// Save old value and set a new one
echo_debug("form_input.php.FormAch p_op_date is $op_date");
$r="";
if ( $view_only == false) {
$r="<FORM ACTION=\"user_jrn.php?action=new\" METHOD=\"POST\">";
}
$r.='<TABLE>';
$r.='<TR>'.InputType("Date ","Text","e_date",$op_date,$view_only).'</TR>';
$r.='<TR>'.InputType("Echeance","Text","e_ech",$e_ech,$view_only).'</TR>';
include_once("fiche_inc.php");
// Display the supplier
// TODO ADD BUTTON NEW SUPPLIER
$fiche=GetFicheJrn($p_cn,$p_jrn,'cred');
// Save old value and set a new one
$customer=( isset ($e_customer) )?$e_customer:"";
$r.='<TR>'.InputType("Fournisseur","SELECT","e_client",$customer,$view_only,$fiche).'</TR>';
$r.="</TABLE>";
// Record the current number of article
$r.='<INPUT TYPE="HIDDEN" name="nb_item" value="'.$p_article.'">';
$e_comment=(isset($e_comment))?$e_comment:"";
// Start the div for item to sell
$r.="<DIV>";
$r.='<H2 class="info">Articles</H2>';
$r.='<TABLE>';
$fiche=GetFicheJrn($p_cn,$p_jrn,'deb');
echo_debug("Cred Nombre d'enregistrement ".sizeof($fiche));
for ($i=0;$i< $p_article;$i++) {
$march=(isset(${"e_march$i"}))?${"e_march$i"}:"";
$r.='<TR>'.InputType("Article","SELECT","e_march".$i,$march,$view_only,$fiche);
$quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"0";
$r.=InputType("Quantité","TEXT","e_quant".$i,$quant,$view_only);
$price=(isset(${"e_price$i"}))?${"e_price$i"}:"0";
$r.=InputType("Prix","TEXT","e_price".$i,$price,$view_only);
$r.='</TR>';
}
$r.="</TABLE>";
$r.=$p_submit;
$r.="</DIV>";
$r.="</FORM>";
return $r;
}

View file

@ -67,7 +67,7 @@ function RecordJrn($p_dossier,$p_user,$p_jrn,$p_MaxDeb,$p_MaxCred,$p_array = nul
}
}
/* Get Jrn's properties */
$l_line=GetJrnProp($p_dossier,$p_jrn);
$l_line=GetJrnProperty($cn,$p_jrn);
if ( $l_line == null ) return;
echo '<DIV class="redcontent">';
echo '<FORM NAME="encoding" ACTION="enc_jrn.php" METHOD="POST">';
@ -572,6 +572,32 @@ function ViewRecord ($p_dossier,$p_jrn,$p_id,$p_MaxDeb,$p_MaxCred,$p_array)
echo ' <A class="mtitle" HREF="enc_jrn.php?action=record&max_deb='.$l_prop['jrn_deb_max_line'].'&max_cred='.$l_prop['jrn_cred_max_line'].'&p_jrn='.$p_jrn.'"> Ajouter</A>';
echo '</TD></TR></TABLE>';
}
/* function GetJrnProperty ($p_cn,$p_jrn)
* Purpose : Get the properties of a journal
*
* parm :
* - p_cn database connection
* - p_jrn the jrn id
* gen :
* - none
* return:
* - an array containing properties
*
*/
function GetJrnProperty($p_cn,$p_jrn)
{
$Res=ExecSql($p_cn,"select jrn_Def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_def_type,
jrn_deb_max_line,jrn_cred_max_line,jrn_def_ech,jrn_def_ech_lib,jrn_def_code,
jrn_def_fiche_deb,jrn_def_fiche_deb
from jrn_Def
where jrn_def_id=$p_jrn");
$Count=pg_NumRows($Res);
if ( $Count == 0 ) {
echo '<DIV="redcontent"><H2 class="error"> Paramètres journaux non trouvés</H2> </DIV>';
return null;
}
return pg_fetch_array($Res,0);
}
/* function GetJrnProp
* Purpose : Get the properties of a journal
*
@ -600,7 +626,7 @@ function GetJrnProp($p_dossier,$p_jrn)
}
return pg_fetch_array($Res,0);
}
/* function
/* function GetNextId($p_cn,$p_name)
* Purpose :
*
* parm :
@ -621,7 +647,7 @@ function GetNextId($p_cn,$p_name) {
$l_res=pg_fetch_array($Res,0);
return $l_res['result'];
}
/* function
/* function GetNextJrnId($p_cn,$p_name)
* Purpose :
*
* parm :
@ -658,6 +684,7 @@ function GetNextJrnId($p_cn,$p_name) {
*/
function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) {
echo_debug("function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) ");
echo JS_VIEW_JRN_DETAIL;
$db=sprintf("dossier%d",$p_dossier);
$l_prop=GetJrnProp($p_dossier,$p_jrn);
echo "<H2 class=\"info\">".$l_prop['jrn_def_name']."( ".$l_prop['jrn_def_code'].")"."</H2>";
@ -687,13 +714,13 @@ function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) {
j_jrn_def=$p_jrn";
$l_and="and ";
if ( ereg("^[0-9]+$", $l_s_montant) || ereg ("^[0-9]+\.[0-9]+$", $l_s_montant) ) {
$sql.=" and j_montant $l_mont_sel $l_s_montant";
$sql.=" and jr_montant $l_mont_sel $l_s_montant";
}
if ( isDate($l_date_start) != null ) {
$sql.=$l_and." j_date >='".$l_date_start."'";
$sql.=$l_and." j_date >= to_date('".$l_date_start."','DD.MM.YYYY')";
}
if ( isDate($l_date_end) != null ) {
$sql.=$l_and." j_date <='".$l_date_end."'";
$sql.=$l_and." j_date <= to_date('".$l_date_end."','DD.MM.YYYY')";
}
$l_s_comment=FormatString($l_s_comment);
if ( $l_s_comment != null ) {
@ -822,6 +849,7 @@ function GetData ($p_cn,$p_grpt) {
j_montant,
j_id,
jr_comment,
to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
to_char(jr_date,'DD.MM.YYYY') as jr_date,
jr_rapt, jr_id,jr_internal
from jrnx inner join jrn on j_grpt=jr_grpt_id where j_grpt=$p_grpt");
@ -857,7 +885,7 @@ function GetData ($p_cn,$p_grpt) {
}
$l_array['jr_internal']=$l_line['jr_internal'];
$l_array['comment']=$l_line['jr_comment'];
$l_array['ech']=$l_line['jr_date'];
$l_array['ech']=$l_line['jr_ech'];
$l_array['rapt']=$l_line['jr_rapt'];
$l_array['jr_id']=$l_line['jr_id'];
}
@ -920,15 +948,17 @@ function GetRaptDest($p_cn,$p_rappt) {
if ( strlen (trim ($l_line['jr_rapt'])) == 0 ) return -1;
return $l_line['jr_rapt'];
}
/* function
* Purpose :
/* function GetAmount
* Purpose : return the sum of jrn where
* the internal_code is the p_id
*
* parm :
* -
* - $p_cn database connection
* - p_id = jrn.jr_internal
* gen :
* -
* return:
* -
* - number
*
*/
function GetAmount($p_cn,$p_id) {
@ -1076,7 +1106,7 @@ function NextJrn($p_cn,$p_type)
*
* parm :
* - $p_cn connection
* - $p_id id in jr_id
* - $p_grpt id in jr_grpt_id
* - $p_jrn jrn id jrn_def_id
* - $p_dossier dossier id
* gen :
@ -1085,14 +1115,14 @@ function NextJrn($p_cn,$p_type)
* -
*
*/
function SetInternalCode($p_cn,$p_id,$p_jrn,$p_dossier)
function SetInternalCode($p_cn,$p_grpt,$p_jrn)
{
$num=CountSql($p_cn,"select * from jrn where jr_def_id=$p_jrn");
$atype=GetJrnProp($p_dossier,$p_jrn);
$atype=GetJrnProperty($p_cn,$p_jrn);
$type=$atype['jrn_def_code'];
$internal_code=sprintf("%s-%08d",$type,$num);
$internal_code=sprintf("%s-%05d",$type,$num);
$Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal_code."' where ".
" jr_id = ".$p_id);
" jr_grpt_id = ".$p_grpt);
return $internal_code;
}

View file

@ -39,7 +39,7 @@ function FormPeriodeMult($p_cn)
$sql="select p_id,to_char(p_start,'DD.MM.YYYY') as p_start,
to_char(p_end,'DD.MM.YYYY') as p_end
from parm_periode
order by p_start";
order by p_exercice,p_start";
$Res=ExecSql($p_cn,$sql);
$Max=pg_NumRows($Res);
$ret='<SELECT NAME="periode[]" SIZE="12" multiple>';
@ -78,7 +78,7 @@ function FormPeriode($p_cn,$l_default=0,$p_type=OPEN,$p_suff="")
$sql="select p_id,to_char(p_start,'DD.MM.YYYY') as p_start,
to_char(p_end,'DD.MM.YYYY') as p_end
from parm_periode where
$sql_closed order by p_start";
$sql_closed order by p_exercice,p_start";
}
if ($p_type==OPEN) {
@ -86,7 +86,7 @@ function FormPeriode($p_cn,$l_default=0,$p_type=OPEN,$p_suff="")
$sql="select p_id,to_char(p_start,'DD.MM.YYYY') as p_start,
to_char(p_end,'DD.MM.YYYY') as p_end
from parm_periode where
$sql_closed order by p_start";
$sql_closed order by p_exercice,p_start";
}
if ($p_type==NOTCENTRALIZED) {
@ -95,7 +95,7 @@ function FormPeriode($p_cn,$l_default=0,$p_type=OPEN,$p_suff="")
from parm_periode where
p_closed=true and p_id not in (
select c_periode from centralized)
order by p_start";
order by p_exercice,p_start";
}
$Res=ExecSql($p_cn,$sql);
$Max=pg_NumRows($Res);
@ -203,7 +203,7 @@ function GetPeriode($p_cn,$p_periode)
return pg_fetch_array($Res,0);
}
/* function
/* function PeriodeClosed($p_cn,$p_periode)
* Purpose :
*
* parm :
@ -211,7 +211,7 @@ function GetPeriode($p_cn,$p_periode)
* gen :
* -
* return:
* - array containing the start date & the end date
* - true if closed
*
*/
function PeriodeClosed($p_cn,$p_periode)

View file

@ -18,45 +18,122 @@
*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
if ( ! isset ($_GET['action']) ) {
echo_debug("include user_action_ven.php");
include_once("form_input.php");
if ( ! isset ($_GET['action']) && ! isset ($_POST["action"]) ) {
return;
}
$dossier=sprintf("dossier%d",$g_dossier);
$cn=DbConnect($dossier);
$action=$_GET['action'];
$action=(isset($_GET['action']))?$_GET['action']:$_POST['action'];
if ( $action == 'insert_vente' ) {
// Check privilege
if ( CheckJrn($g_dossier,$g_user,$g_jrn) != 2 ) {
NoAccess();
exit -1;
}
// Show an empyt form of invoice
include_once("form_input.php");
$form=FormVente($cn,$g_jrn,$g_user,'deb');
echo '<div class="redcontent">';
echo $form;
echo '</div>';
// Add item
if (isset($_POST["add_item"]) ) {
echo_debug("Add an item");
$nb_number=$_POST["nb_item"];
$nb_number++;
$form=FormVente($cn,$g_jrn,$g_user,$HTTP_POST_VARS,false,$nb_number);
echo '<div class="u_redcontent">';
echo $form;
echo '</div>';
}
// We want to see the encoded invoice
if ( isset ($_POST["view_invoice"])) {
$nb_number=$_POST["nb_item"];
$form=FormVenteView($cn,$g_jrn,$g_user,$HTTP_POST_VARS,$nb_number);
// Check failed : invalid date or quantity
if ( $form== null) {
echo_error("Cannot validate ");
$form=FormVente($cn,$g_jrn,$g_user,$HTTP_POST_VARS,false,$nb_number);
}
echo '<div class="u_redcontent">';
echo $form;
echo '</div>';
}
// We want a blank form
if ( isset($_GET["blank"]))
{
echo_debug("Blank form");
// Show an empty form of invoice
$form=FormVente($cn,$g_jrn,$g_user,null,false);
echo '<div class="u_redcontent">';
echo $form;
echo '</div>';
}
}
if ( $action == 'voir_vente' ) {
// Show list of sell
// Date - date of payment - Customer - amount
$list=ListSell();
echo '<div class="redcontent">';
echo $list;
echo '</div>';
// Save the invoice
if ( isset($_POST["record_invoice"])) {
// echo "RECORD INVOICE";
RecordInvoice($cn,$HTTP_POST_VARS,$g_user,$g_jrn);
}
if ( $action == 'voir_vente_non_paye' ) {
// Save and print the invoice
if ( isset($_POST["record_and_print_invoice"])) {
// echo "RECORD AND PRINT INVOICE";
$comment=RecordInvoice($cn,$HTTP_POST_VARS,$g_user,$g_jrn);
$nb_number=$_POST["nb_item"];
$form=FormVenteView($cn,$g_jrn,$g_user,$HTTP_POST_VARS,$nb_number,'pdf',$comment);
echo '<div class="u_redcontent">';
echo $form;
echo "</div> ";
}
if ( $action == 'voir_jrn' ) {
// Show list of sell
// Date - date of payment - Customer - amount
$sql=SQL_LIST_ALL_INVOICE." and jr_tech_per=".GetUserPeriode($cn,$g_user)." and jr_def_id=$g_jrn";
$list=ListJrn($cn,$g_jrn,$sql);
echo '<div class="u_redcontent">';
echo $list;
echo '</div>';
}
if ( $action == 'voir_jrn_non_paye' ) {
// Show list of unpaid sell
// Date - date of payment - Customer - amount
$list=ListSell('filtre');
echo '<div class="redcontent">';
$sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=$g_jrn";
$list=ListJrn($cn,$g_jrn,$sql);
$sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=$g_jrn";
$list2=ListJrn($cn,$g_jrn,$sql);
echo '<div class="u_redcontent">';
echo '<h2 class="info"> Echeance dépassée </h2>';
echo $list;
echo '<h2 class="info"> Non Payée </h2>';
echo $list2;
echo '</div>';
}
if ( $action == 'impress' ) {
// Print list of sell or print the current invoice
}
// if ( $action == 'impress' ) {
// // Print list of sell or print the current invoice
// }
//Search
if ( $action == 'search' ) {
// PhpSessid
$sessid=(isset ($_POST['PHPSESSID']))?$_POST['PHPSESSID']:$_GET['PHPSESSID'];
// display a search box
$search_box=u_ShowMenuRecherche($cn,$g_jrn,$sessid,$HTTP_POST_VARS);
echo '<DIV class="u_redcontent">';
echo $search_box;
// if nofirst is set then show result
if ( isset ($_GET['nofirst'] ) )
ViewJrn($g_dossier,$g_user,$g_jrn,$HTTP_POST_VARS);
echo '</DIV>';
}
?>
?>

274
include/user_common.php Normal file
View file

@ -0,0 +1,274 @@
<?
/*
* 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("postgres.php");
/* function GetTvaRate
**************************************************
* Purpose : Return the rate of the p_tva_id
*
* parm :
* - p_cn database connection
* - p_tva_id tva.tva_id
* gen :
* - none
* return:
* an array containing the rate and the label
* the tva rate or null if a problem occured
*/
function GetTvaRate($p_cn,$p_tva_id) {
$Res=pg_exec($p_cn,"select tva_id,tva_rate,tva_label from tva_rate where tva_id=".$p_tva_id);
if (pg_NumRows($Res) == 0 ) return null;
$r=pg_fetch_array($Res,0);
return $r;
}
/* function ComputeVat($p_cn, $a_good,$a_quant,$p_type);
**************************************************
* Purpose : Compute the vat,
* the fiche.f_id are in a_fiche
* the quantity in a_quant
*
*
* parm :
* - database connection
* - fiche
* - quantity
* - p_type ATTR_DEF_PRIX_VENTE ATTR_DEF_PRIX_ACHAT
* gen :
* -
* return: array
* a[tva_id] = amount vat
*/
function ComputeVat($p_cn, $a_fiche,$a_quant,$p_type) {
echo_debug("ComputeVat $a_fiche $a_quant $p_type");
// foreach goods
for ( $i=0 ; $i < sizeof($a_fiche);$i++) {
// Get the tva_id
$tva_id=GetFicheAttribut($p_cn,$a_fiche[$i],ATTR_DEF_TVA);
// for each fiche find the tva_rate and tva_id
$a_vat=GetTvaRate($p_cn,$tva_id);
// Get the attribut price of the card(fiche)
$amount=GetFicheAttribut($p_cn,$a_fiche[$i],$p_type);
if ( $a_vat != null ) {
$a=$a_vat['tva_id'];
$vat_amount=$amount*$a_vat['tva_rate']*$a_quant[$i];
$r[$a]=isset ( $r[$a] )?$r[$a]+$vat_amount:$vat_amount;
} else {
echo_error("Not vat here in ComputeVat !");
return 0;
}
}
echo_debug(" return $r");
return $r;
}
/* function GetTvaPoste($p_cn,$tva_id,$p_type);
**************************************************
* Purpose : Get the account of tva_rate.tva_poste
* return the credit or the debit account
* parm : connection
* - tva_rate.tva_id
* type ( d or credit)
* gen :
* -
* return:
* return the credit or the debit account
* null if error
*/
function GetTvaPoste($p_cn,$p_tva_id,$p_cred) {
$Res=ExecSql($p_cn,"select tva_poste from tva_rate where tva_id=$p_tva_id");
if ( pg_NumRows($Res) == 0 ) return null;
$a=pg_fetch_array($Res,0);
list ($deb,$cred)=split(",",$a['tva_poste']);
if ( $p_cred=='c' ) return $cred;
if ($p_cred=='d') return $deb;
echo_error ("Invalid $p_cred in GetTvaRate");
return null;
}
/* function InsertJrnx($p_cn,$p_type,$p_user,$p_jrn,$p_poste,$p_date,$p_amount,$p_grpt,$p_periode);
**************************************************
* Purpose : Insert into the table Jrn
*
* parm :
* - $p_cn database connection
* - $p_type debit or credit
* - $p_user the current user
* - $p_jrn the current 'journal' (folder)
* - $p_poste the account
* - $p_date
* - $p_amount amount to insert
* - $p_periode the concerned periode
* gen :
* - none
* return:
* - nothing
*/
function InsertJrnx($p_cn,$p_type,$p_user,$p_jrn,$p_poste,$p_date,$p_amount,$p_grpt,$p_periode)
{
echo_debug ("InsertJrnx param
type = $p_type p_user $p_user p_date $p_date p_poste $p_poste p_amount $p_amount p_grpt = $p_grpt p_periode = $p_periode");
$debit=($p_type=='c')?'false':'true';
$sql=sprintf("insert into jrnx (j_date,j_montant, j_poste,j_grpt, j_jrn_def,j_debit,j_tech_user,j_tech_per)
values (to_date('%s','DD.MM.YYYY'),%.2f,%d,%d,%d,%s,'%s',%d)",
$p_date,$p_amount,$p_poste,$p_grpt,$p_jrn,$debit,$p_user,$p_periode);
echo_debug("InsertJrnx $sql");
$Res=ExecSql($p_cn,$sql);
}
/* function InsertJrn($p_cn,$p_date,$p_jrn,$p_comment,$p_amount,$p_grpt,$p_periode);
**************************************************
* Purpose : Insert into the table Jrnx
*
* parm :
* - $p_cn database connection
* - $p_date date
* - $p_jrn the current 'journal' (folder)
* - $p_poste the account
* - $p_amount amount to insert
* - $p_periode the concerned periode
* gen :
* - none
* return:
* - nothing
*/
function InsertJrn($p_cn,$p_date,$p_echeance,$p_jrn,$p_comment,$p_amount,$p_grpt,$p_periode)
{
echo_debug ("InsertJrn param
p_date $p_date p_poste $p_comment p_amount $p_amount p_grpt = $p_grpt p_periode = $p_periode p_echeance = $p_echeance");
if ( $p_echeance == "" or $p_echeance==null) {
$p_echeance='null';
} else {
$p_echeance=sprintf("to_date('%s','DD.MM.YYYY')",$p_echeance);
}
$sql=sprintf("insert into jrn (jr_def_id,jr_montant,jr_comment,jr_date,jr_ech,jr_grpt_id,jr_tech_per)
values ( %d,%.2f,'%s',to_date('%s','DD.MM.YYYY'),%s,%d,%d)",
$p_jrn, $p_amount,$p_comment,$p_date,$p_echeance,$p_grpt,$p_periode);
echo_debug("InsertJrn $sql");
$Res=ExecSql($p_cn,$sql);
return GetSequence($p_cn,'s_jrn');
}
/* function ListJrn($p_cn,$p_jrn,$p_wherel)
**************************************************
* Purpose : show all the lines of the asked jrn
*
* parm :
* - $p_cn database connection
* - $p_jrn jrn_id jrn.jrn_def_id
* - $p_sql the sql query (where clause)
* gen :
* - none
* return:
*
*/
function ListJrn($p_cn,$p_jrn,$p_where="")
{
// TODO Show modify button but only for no centralized operations
//TODO add a print button but only if type of jrn is VEN !!
$Res=ExecSql($p_cn,"select jr_id ,
jr_montant,
jr_comment,
jr_ech,
jr_date,
jr_grpt_id,
jr_rapt,
jr_internal,
jrn_def_id,
jrn_def_name,
jrn_def_ech,
jrn_def_type
from
jrn join jrn_def on jrn_def_id=jr_def_id
$p_where
order by jr_date");
$r="";
$r.=JS_VIEW_JRN_DETAIL;
$Max=pg_NumRows($Res);
if ($Max==0) return "No row selected";
$r.="<TABLE>";
$l_sessid=(isset($_POST['PHPSESSID']))?$_POST['PHPSESSID']:$_GET['PHPSESSID'];
$r.="<tr>";
$r.="<th> Date </th>";
$r.="<th> Echéance </th>";
$r.="<th> Description</th>";
$r.="<th> Montant </th>";
$r.="<th>Op. Concernée</th>";
$r.="</tr>";
for ($i=0; $i < $Max;$i++) {
$row=pg_fetch_array($Res,$i);
if ( $i % 2 == 0 ) $tr='<TR class="odd">';
else $tr='<TR>';
$r.=$tr;
// date
$r.="<TD>";
$r.=$row['jr_date'];
$r.="</TD>";
// echeance
$r.="<TD>";
$r.=$row['jr_ech'];
$r.="</TD>";
// comment
$r.="<TD>";
$r.=sprintf('<input TYPE="BUTTON" VALUE="%s" onClick="viewDetail(\'%s\',\'%s\')"> %s',
"Détail",$row['jr_grpt_id'],$l_sessid,$row['jr_comment']);
$r.="</span>";
$r.="</TD>";
// Amount
$r.="<TD>";
$r.=$row['jr_montant'];
$r.="</TD>";
// Rapt
$r.="<TD>";
$r.='<A HREF="">';
$r.=$row['jr_rapt'];
$r.="</A>";
$r.="</TD>";
// TODO Add print
// end row
$r.="</tr>";
}
$r.="</table>";
return $r;
}

View file

@ -80,7 +80,7 @@ function GetAvailableFolder($p_user,$p_admin)
$filter="and use_login='$p_user' ";
}
$sql="select dos_id,dos_name,dos_description from ac_users
$sql="select distinct dos_id,dos_name,dos_description from ac_users
natural join jnt_use_dos
natural join ac_dossier
where use_active=1 ".$filter;
@ -150,7 +150,7 @@ function u_ShowMenuCompta($p_dossier)
array("user_jrn.php?JRN_TYPE=FIN","Banque"),
array("user_jrn.php?JRN_TYPE=OD","Op. Diverses"),
array("fiche.php?p_dossier=$p_dossier","Fiche"),
array("not_implemented.php","Avancé"),
array("user_advanced.php","Avancé"),
array("dossier_prefs.php","Paramètre")
);
@ -303,6 +303,75 @@ function u_ShowMenuJrn($p_cn,$p_jrn_type)
$ret.='</TABLE>';
return $ret;
}
/* function u_ShowMenuRecherche ($p_cn,$p_jrn,$p_sessid,$p_array=null)
* Purpose :
*
* parm :
* - $p_cn database connection
* - $p_jrn jrn id
* - $p_array=null previous search
* gen :
* - none
* return:
* - none
*
*/
function u_ShowMenuRecherche($p_cn,$p_jrn,$p_sessid,$p_array=null)
{
echo_debug("u_ShowMenuRecherche($p_cn,$p_jrn,$p_array)");
if ( $p_array != null ) {
foreach ( $p_array as $key=> $element) {
${"p_$key"}=$element;
echo_debug("p_$key =$element;");
}
}
// Find the journal property
$JrnProperty=GetJrnProperty($p_cn,$p_jrn);
$opt='<OPTION VALUE="<="> <=';
$opt.='<OPTION VALUE="<"> <';
$opt.='<OPTION VALUE="="> =';
$opt.='<OPTION VALUE=">"> >';
$opt.='<OPTION VALUE=">="> >=';
if ( ! isset ($p_date_start)) $p_date_start="";
if ( ! isset ($p_date_end)) $p_date_end="";
if ( ! isset ($p_mont_sel))$p_mont_sel="";
if ( ! isset ($p_s_comment))$p_s_comment="";
if ( ! isset ($p_s_montant)) $p_s_montant="";
if ( $p_mont_sel != "" ) $opt.='<OPTION value="'.$p_mont_sel.'" SELECTED> '.$p_mont_sel;
$r="";
$r.= '<div style="border-style:outset;border-width:1pt;">';
$r.= "<B>Recherche</B>";
$r.= '<FORM ACTION="user_jrn.php?p_jrn='.$p_jrn.'&action=search&PHPSESSID='.$p_sessid.'&nofirst" METHOD="POST">';
$r.= '<TABLE>';
$r.= "<TR>";
$r.= '<TD COLSPAN="3"> Date compris entre</TD> ';
$r.= "</TR> <TR>";
$r.= '<TD> <INPUT TYPE="TEXT" NAME="date_start" SIZE="10" VALUE="'.$p_date_start.'"></TD>';
$r.= '<TD> <INPUT TYPE="TEXT" NAME="date_end" size="10" Value="'.$p_date_end.'"></TD>';
$r.= '</TD><TD>';
$r.= "</TR> <TR>";
$r.= "<TD> Montant ";
$r.= ' <SELECT NAME="mont_sel">'.$opt.' </SELECT></TD><TD>';
$r.= ' <INPUT TYPE="TEXT" NAME="s_montant" SIZE="10" VALUE="'.$p_s_montant.'"></TD>';
$r.= "</TR><TR>";
$r.= '<TD colspan="3"> Le commentaire contient </TD>';
$r.= "</TR><TR>";
$r.= '<TD COLSPAN="3"> <INPUT TYPE="TEXT" NAME="s_comment" VALUE="'.$p_s_comment.'"></TD>';
$r.= "</TR><TR>";
$r.= '<TD COLSPAN="3"><INPUT TYPE="SUBMIT" VALUE="Recherche" NAME="viewsearch"></TD>';
$r.= "</TR>";
$r.= "</TABLE>";
$r.= "</FORM>";
$r.= '</div>';
return $r;
}
?>

View file

@ -32,7 +32,7 @@ create table ac_users (
primary key (use_id)
);
insert into ac_users (use_login, use_active,use_pass,use_usertype,use_admin) values (user,1,
insert into ac_users (use_login, use_active,use_pass,use_usertype,use_admin) values ('phpcompta',1,
'b1cc88e1907cde80cb2595fa793b3da9','compta',1);

View file

@ -50,3 +50,18 @@ insert into parm_periode (p_start,p_end,p_exercice) values ('01-10-2003','30-10
insert into parm_periode (p_start,p_end,p_exercice) values ('01-11-2003','30-11-2003','2003');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-12-2003','31-12-2003','2003');
insert into parm_periode (p_start,p_exercice) values ('31-12-2003','2003');
-- for the year 2004
insert into parm_periode (p_start,p_end,p_exercice) values ('01-01-2004','31-01-2004','2004');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-02-2004','28-02-2004','2004');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-03-2004','31-03-2004','2004');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-04-2004','30-04-2004','2004');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-05-2004','31-05-2004','2004');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-06-2004','30-06-2004','2004');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-07-2004','31-07-2004','2004');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-08-2004','31-08-2004','2004');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-09-2004','30-09-2004','2004');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-10-2004','30-10-2004','2004');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-11-2004','30-11-2004','2004');
insert into parm_periode (p_start,p_end,p_exercice) values ('01-12-2004','31-12-2004','2004');
insert into parm_periode (p_start,p_exercice) values ('31-12-2004','2004');

View file

@ -1,54 +1,223 @@
/* $Revision$ */
/*
* 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
*/
drop sequence s_isup;
-- For the fiche dev only
-- Create the sequence
\echo recreate Sequence
\echo try first to drop it, no worry about error messages
\echo drop SEQUENCE s_fiche
drop SEQUENCE s_fiche;
\echo CREATE SEQUENCE s_fiche
CREATE SEQUENCE s_fiche;
\echo drop sequence s_fiche_def_ref
drop sequence s_fiche_def_ref;
\echo create sequence s_fiche_def_ref
create sequence s_fiche_def_ref;
\echo drop sequence s_fdef
drop sequence s_fdef;
drop sequence s_idef;
drop table isupp;
drop table fiche ;
drop table isupp_def ;
drop table fichedef ;
create sequence s_isup;
\echo create sequence s_fdef
create sequence s_fdef;
create sequence s_idef;
\echo drop sequence s_attr_def;
drop sequence s_attr_def;
\echo drop sequence s_attr_def;
drop sequence s_attr_def;
\echo create sequence s_attr_def
create sequence s_attr_def;
\echo drop SEQUENCE s_jnt_fic_att_value
drop SEQUENCE s_jnt_fic_att_value;
\echo CREATE SEQUENCE s_jnt_fic_att_value
CREATE SEQUENCE s_jnt_fic_att_value;
create table fichedef (
fd_id integer not null default nextval('s_fdef') primary key,
fd_label text not null,
fd_class_base text
);
create table fiche (
f_id integer not null references tmp_pcmn(pcm_val) primary key,
f_label text not null,
f_fd_id integer
);
create table isupp_def (
isd_id integer not null default nextval('s_idef') primary key,
isd_label text,
isd_fd_id integer references fichedef(fd_id),
isd_form bool
\echo Drop first the tables and after
\echo recreate them
\echo drop table fiche_def_ref
drop table fiche_def_ref cascade;
\echo CREATE TABLE fiche_def_ref
CREATE TABLE fiche_def_ref (
frd_id integer DEFAULT nextval('s_fiche_def_ref'::text) primary key,
frd_text text,
frd_class_base integer default null
);
create table isupp (
is_id integer not null default nextval('s_isup') primary key,
is_f_id integer references tmp_pcmn(pcm_val),
is_isd_id integer references isupp_def(isd_id),
is_value text
\echo drop TABLE fiche_def
drop TABLE fiche_def cascade;
\echo CREATE TABLE fiche_def
CREATE TABLE fiche_def (
fd_id integer DEFAULT nextval('s_fdef'::text) primary key,
fd_class_base integer,
fd_label text NOT NULL,
fd_create_account bool default false,
frd_id integer NOT NULL references fiche_def_ref(frd_id)
);
\echo drop TABLE attr_value
drop TABLE attr_value cascade;
\echo CREATE TABLE attr_value
CREATE TABLE attr_value (
jft_id integer references jnt_fic_att_value(jft_id),
av_text text
);
\echo drop TABLE attr_def
drop TABLE attr_def cascade;
\echo CREATE TABLE attr_def
CREATE TABLE attr_def (
ad_id integer DEFAULT nextval('s_attr_def'::text) primary key,
ad_text text
);
\echo drop TABLE attr_min
drop TABLE attr_min cascade;
\echo CREATE TABLE attr_min
CREATE TABLE attr_min (
frd_id integer references fiche_def_ref(frd_id),
ad_id integer references attr_def(ad_id)
);
\echo drop TABLE fiche
drop TABLE fiche cascade;
\echo CREATE TABLE fiche
CREATE TABLE fiche (
f_id integer DEFAULT nextval('s_fiche'::text) primary key,
fd_id integer references fiche_def(fd_id)
);
\echo drop TABLE jnt_fic_att_value
drop TABLE jnt_fic_att_value cascade;
\echo CREATE TABLE jnt_fic_att_value
CREATE TABLE jnt_fic_att_value (
jft_id integer DEFAULT nextval('s_jnt_fic_att_value'::text) primary key,
f_id integer references fiche(f_id),
ad_id integer references attr_def(ad_id)
);
\echo drop attr_value
drop table attr_value;
\echo create table attr_value
create table attr_value (
jft_id integer references jnt_fic_att_value(jft_id),
av_text text);
\echo drop table jnt_fic_attr
drop table jnt_fic_attr
;
\echo create table jnt_fic_attr
create table jnt_fic_attr (
fd_id integer references fiche_def(fd_id),
ad_id integer references attr_def(ad_id))
;
--
-- PostgreSQL database dump
--
\connect - phpcompta
SET search_path = public, pg_catalog;
--
-- Data for TOC entry 1 (OID 21236)
-- Name: attr_def; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO attr_def VALUES (1, 'Nom');
INSERT INTO attr_def VALUES (2, 'Taux TVA');
INSERT INTO attr_def VALUES (3, 'Numéro de compte');
INSERT INTO attr_def VALUES (4, 'Nom de la banque');
INSERT INTO attr_def VALUES (5, 'Poste Comptable');
INSERT INTO attr_def VALUES (6, 'Prix vente');
INSERT INTO attr_def VALUES (7, 'Prix achat');
INSERT INTO attr_def VALUES (8, 'Durée Amortissement');
INSERT INTO attr_def VALUES (9, 'Description');
INSERT INTO attr_def VALUES (10, 'Date début');
INSERT INTO attr_def VALUES (11, 'Montant initial');
INSERT INTO attr_def VALUES (12, 'Personne de contact ');
INSERT INTO attr_def VALUES (13, 'numéro de tva ');
INSERT INTO attr_def VALUES (14, 'Adresse ');
INSERT INTO attr_def VALUES (15, 'code postale ');
INSERT INTO attr_def VALUES (16, 'pays ');
INSERT INTO attr_def VALUES (17, 'téléphone ');
INSERT INTO attr_def VALUES (18, 'email ');
--
-- PostgreSQL database dump
--
\connect - phpcompta
SET search_path = public, pg_catalog;
--
-- Data for TOC entry 1 (OID 21206)
-- Name: fiche_def_ref; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO fiche_def_ref VALUES (1, 'Vente Service', 700);
INSERT INTO fiche_def_ref VALUES (2, 'Marchandises achat ', 604);
-- INSERT INTO fiche_def_ref VALUES (2, 'Marchandises Vente & Achat', 604,704);
INSERT INTO fiche_def_ref VALUES (3, 'Achat Service et biens divers', 61);
INSERT INTO fiche_def_ref VALUES (4, 'Banque', 5500);
INSERT INTO fiche_def_ref VALUES (5, 'Prêt > a un an', 17);
INSERT INTO fiche_def_ref VALUES (6, 'Prêt < a un an', 430);
INSERT INTO fiche_def_ref VALUES (8, 'Fournisseurs', 440);
INSERT INTO fiche_def_ref VALUES (9, 'Clients', 400);
INSERT INTO fiche_def_ref VALUES (10, 'Salaire Administrateur', 6200);
INSERT INTO fiche_def_ref VALUES (11, 'Salaire Ouvrier', 6203);
INSERT INTO fiche_def_ref VALUES (12, 'Salaire Employé', 6202);
INSERT INTO fiche_def_ref VALUES (13, 'Dépenses non admises', 674);
INSERT INTO fiche_def_ref VALUES (7, 'Matériel à amortir', 24);
INSERT INTO fiche_def_ref VALUES (14, 'Marchandises Vente ', 704);
--
-- PostgreSQL database dump
--
\connect - phpcompta
SET search_path = public, pg_catalog;
--
-- Data for TOC entry 1 (OID 21244)
-- Name: attr_min; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO attr_min VALUES (1, 1);
INSERT INTO attr_min VALUES (1, 2);
INSERT INTO attr_min VALUES (2, 1);
INSERT INTO attr_min VALUES (2, 2);
INSERT INTO attr_min VALUES (3, 1);
INSERT INTO attr_min VALUES (3, 2);
INSERT INTO attr_min VALUES (4, 1);
INSERT INTO attr_min VALUES (4, 3);
INSERT INTO attr_min VALUES (4, 4);
INSERT INTO attr_min VALUES (4, 12);
INSERT INTO attr_min VALUES (4, 13);
INSERT INTO attr_min VALUES (4, 14);
INSERT INTO attr_min VALUES (4, 15);
INSERT INTO attr_min VALUES (4, 16);
INSERT INTO attr_min VALUES (4, 17);
INSERT INTO attr_min VALUES (4, 18);
INSERT INTO attr_min VALUES (8, 1);
INSERT INTO attr_min VALUES (8, 12);
INSERT INTO attr_min VALUES (8, 13);
INSERT INTO attr_min VALUES (8, 14);
INSERT INTO attr_min VALUES (8, 15);
INSERT INTO attr_min VALUES (8, 16);
INSERT INTO attr_min VALUES (8, 17);
INSERT INTO attr_min VALUES (8, 18);
INSERT INTO attr_min VALUES (9, 1);
INSERT INTO attr_min VALUES (9, 12);
INSERT INTO attr_min VALUES (9, 13);
INSERT INTO attr_min VALUES (9, 14);
INSERT INTO attr_min VALUES (9, 15);
INSERT INTO attr_min VALUES (9, 16);
INSERT INTO attr_min VALUES (9, 17);
INSERT INTO attr_min VALUES (9, 18);
INSERT INTO attr_min VALUES (1, 6);
INSERT INTO attr_min VALUES (1, 7);
INSERT INTO attr_min VALUES (2, 6);
INSERT INTO attr_min VALUES (2, 7);
INSERT INTO attr_min VALUES (3, 7);
INSERT INTO attr_min VALUES (14, 1);

View file

@ -55,7 +55,7 @@ insert into jrn_type values ('OD','Op
insert into jrn_def values (1,'Financier','5* ','5*',null,null,5,5,false,null,'FIN','FIN-01');
insert into jrn_def values (2,'Vente','7*','4*',null,null,1,3,true,'échéance','VEN','VEN-01');
insert into jrn_def values (3,'Achat','6*','4*',1,3,true,'échéance','ACH','ACH-01');
insert into jrn_def values (3,'Achat','6*','4*',null,null,1,3,true,'échéance','ACH','ACH-01');
insert into jrn_def values (4,'Opération Diverses',null,null,null,null,5,5,false,null,'OD','OD-01');
create sequence s_jrnx;
@ -66,8 +66,9 @@ create table jrn (
jr_montant float not null,
jr_comment text ,
jr_date date ,
jr_ech date ,
jr_grpt_id integer not null,
jr_rapt integer,
jr_rapt text,
jr_internal text,
jr_tech_date timestamp not null default now(),
jr_tech_per integer not null

View file

@ -27,18 +27,42 @@ create table jrn_action (
ja_lang text default 'FR',
ja_jrn_type char(3) references jrn_type(jrn_type_id)
);
insert into jrn_action (ja_name,ja_desc,ja_url,ja_action,ja_jrn_type) VALUES (
'Nouvelle','Création d\'une facture','user_jrn.php','action=insert_vente','VEN'
);
insert into jrn_action (ja_name,ja_desc,ja_url,ja_action,ja_jrn_type) VALUES (
'Voir','Voir toutes les factures','user_jrn.php','action=voir_vente','VEN'
);
insert into jrn_action (ja_name,ja_desc,ja_url,ja_action,ja_jrn_type) VALUES (
'Voir Impayés','Voir toutes les factures non payées','user_jrn.php','action=voir_vente_non_paye','VEN'
);
insert into jrn_action (ja_name,ja_desc,ja_url,ja_action,ja_jrn_type) VALUES (
'Impression','Impression du journal','user_jrn.php','action=impress','VEN'
);
insert into jrn_action (ja_name,ja_desc,ja_url,ja_action,ja_jrn_type) VALUES (
'Recherche','Recherche dans le journal','user_jrn.php','action=search_ven','VEN'
);
--
-- PostgreSQL database dump
--
\connect - phpcompta
SET search_path = public, pg_catalog;
--
-- Data for TOC entry 1 (OID 17800)
-- Name: jrn_action; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
-- menu vente
INSERT INTO jrn_action VALUES (2, 'Voir', 'Voir toutes les factures', 'user_jrn.php', 'action=voir_jrn', 'FR', 'VEN');
INSERT INTO jrn_action VALUES (4, 'Voir Impayés', 'Voir toutes les factures non payées', 'user_jrn.php', 'action=voir_jrn_non_paye', 'FR', 'VEN');
INSERT INTO jrn_action VALUES (6, 'Recherche', 'Recherche dans le journal', 'user_jrn.php', 'action=search', 'FR', 'VEN');
INSERT INTO jrn_action VALUES (1, 'Nouvelle', 'Création d''une facture', 'user_jrn.php', 'action=insert_vente&blank', 'FR', 'VEN');
INSERT INTO jrn_action VALUES (5, 'Impression', 'Impression du journal', 'impress.php', 'filter=1&action=viewpdf&type=jrn', 'FR', 'VEN');
-- menu achat
INSERT INTO jrn_action VALUES (10, 'Nouveau', 'Encode un nouvel achat (matériel, marchandises, services et biens divers)', 'user_jrn.php', 'action=new&blank', 'FR', 'ACH');
INSERT INTO jrn_action VALUES (12, 'Voir', 'Voir toutes les factures', 'user_jrn.php', 'action=voir_jrn', 'FR', 'ACH');
INSERT INTO jrn_action VALUES (14, 'Voir Impayés', 'Voir toutes les factures non payées', 'user_jrn.php', 'action=voir_jrn_non_paye', 'FR', 'ACH');
INSERT INTO jrn_action VALUES (16, 'Impression', 'Impression du journal', 'impress.php', 'filter=1&action=viewpdf&type=jrn', 'FR', 'ACH');
INSERT INTO jrn_action VALUES (18, 'Recherche', 'Recherche dans le journal', 'user_jrn.php', 'action=search', 'FR', 'ACH');
-- menu banque
INSERT INTO jrn_action VALUES (20, 'Nouveau', 'Encode un nouvel achat (matériel, marchandises, services et biens divers)', 'user_jrn.php', 'action=new&blank', 'FR', 'FIN');
INSERT INTO jrn_action VALUES (22, 'Voir', 'Voir toutes les factures', 'user_jrn.php', 'action=voir_jrn', 'FR', 'FIN');
INSERT INTO jrn_action VALUES (24, 'Impression', 'Impression du journal', 'impress.php', 'filter=1&action=viewpdf&type=jrn', 'FR', 'FIN');
INSERT INTO jrn_action VALUES (26, 'Recherche', 'Recherche dans le journal', 'user_jrn.php', 'action=search', 'FR', 'FIN');
-- Menu opérations diverses
INSERT INTO jrn_action VALUES (30, 'Nouveau', null, 'user_jrn.php', 'action=new&blank', 'FR', 'OD');
INSERT INTO jrn_action VALUES (32, 'Voir', 'Voir toutes les factures', 'user_jrn.php', 'action=voir_jrn', 'FR', 'OD');
INSERT INTO jrn_action VALUES (34, 'Impression', 'Impression du journal', 'impress.php', 'filter=1&action=viewpdf&type=jrn', 'FR', 'OD');
INSERT INTO jrn_action VALUES (36, 'Recherche', 'Recherche dans le journal', 'user_jrn.php', 'action=search', 'FR', 'OD');

30
sql/tva_rate.sql Normal file
View file

@ -0,0 +1,30 @@
--
-- PostgreSQL database dump
--
SET search_path = public, pg_catalog;
--
-- TOC entry 2 (OID 51704)
-- Name: tva_rate; Type: TABLE; Schema: public; Owner: phpcompta
--
CREATE TABLE tva_rate (
tva_id integer NOT NULL,
tva_label text NOT NULL,
tva_rate double precision DEFAULT 0.0 NOT NULL,
tva_comment text,
tva_poste text
);
--
-- Data for TOC entry 3 (OID 51704)
-- Name: tva_rate; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO tva_rate VALUES (1, '21%', 0.21, 'Tva applicable à tout ce qui bien et service divers', '411,451');
INSERT INTO tva_rate VALUES (3, '0%', 0, 'Tva applicable lors de vente/achat intracommunautaire', '411,451');
INSERT INTO tva_rate VALUES (2, '6%', 0.06, 'Tva applicable aux journaux et livres', '411,451');