diff --git a/doc/function.txt b/doc/function.txt index 6032dd2be..47e5fccfb 100644 --- a/doc/function.txt +++ b/doc/function.txt @@ -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 diff --git a/html/form.php b/html/form.php index a2692627b..a846029c2 100644 --- a/html/form.php +++ b/html/form.php @@ -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 '
'; + AddForm($cn,$HTTP_POST_VARS); + echo "
"; +} ShowMenuComptaForm($_SESSION['g_dossier']); @@ -87,11 +92,6 @@ if ( isset ($_POST["update"]) ) { UpdateForm($cn,$HTTP_POST_VARS); echo ""; } -if ( isset ($_POST["record"] )) { - echo '
'; - AddForm($cn,$HTTP_POST_VARS); - echo "
"; -} //echo '
'; diff --git a/html/form_csv.php b/html/form_csv.php new file mode 100644 index 000000000..e70f25587 --- /dev/null +++ b/html/form_csv.php @@ -0,0 +1,58 @@ +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; +?> diff --git a/html/form_pdf.php b/html/form_pdf.php new file mode 100644 index 000000000..6f4d426b9 --- /dev/null +++ b/html/form_pdf.php @@ -0,0 +1,65 @@ +$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(); + +?> diff --git a/html/user_impress.php b/html/user_impress.php index a55fe00bd..7860f5033 100644 --- a/html/user_impress.php +++ b/html/user_impress.php @@ -45,8 +45,9 @@ echo "
"; $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; diff --git a/include/ac_common.php b/include/ac_common.php index f403af716..4a0f11641 100644 --- a/include/ac_common.php +++ b/include/ac_common.php @@ -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']; +} ?> diff --git a/include/class_form.php b/include/class_form.php new file mode 100644 index 000000000..26737d27d --- /dev/null +++ b/include/class_form.php @@ -0,0 +1,66 @@ +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; + } +} +?> \ No newline at end of file diff --git a/include/constant.php b/include/constant.php index 42e98fe7f..f49b74708 100644 --- a/include/constant.php +++ b/include/constant.php @@ -23,7 +23,7 @@ // $Revision$ define ("phpcompta_password","dany"); -define ("DEBUG","false"); +define ("DEBUG","true"); // securite correspond a la table // action diff --git a/include/impress_form.php b/include/impress_form.php index 4899aa3d0..80cdc6e09 100644 --- a/include/impress_form.php +++ b/include/impress_form.php @@ -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 '
'; + $t=($_POST['from_periode']==$_POST['to_periode'])?"":" -> ".getPeriodeName($cn,$_POST['to_periode'],'p_end'); + echo '

'.$Form->id." ".$Form->name. + " - ".getPeriodeName($cn,$_POST['from_periode'],'p_start'). + " ".$t. + '

'; + echo ""; + echo ''; + echo '"; + + echo '"; + echo '"; + + echo ""; + + echo "
'. + $submit->Submit('bt_other',"Autre Formulaire"). + $hid->IOValue("type","form")."
'. + $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 "
'. + $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 "
"; + if ( count($Form->row ) == 0 ) + exit; + + echo ""; + echo "". + "". + "". + ""; + + foreach ( $Form->row as $op ) { + echo "". + "". + "". + ""; + + } + echo "
Description montant
".$op['desc']."".sprintf("% 8.2f",$op['montant'])."
"; + echo "
"; + 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 '
'; +echo '
'; +echo ''; +$w=new widget("select"); +$w->table=1; +$w->label="Choississez le formulaire"; +print $w->IOValue("form_id",$ret); +print ''; +print ''; +$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 ""; +echo '
'; +print $w->Submit('bt_html','Impression'); + +echo '
'; +echo '
'; +?> diff --git a/include/impress_inc.php b/include/impress_inc.php index 59dc80682..560bf1d50 100644 --- a/include/impress_inc.php +++ b/include/impress_inc.php @@ -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; diff --git a/include/user_menu.php b/include/user_menu.php index 814cbf23f..37096183d 100644 --- a/include/user_menu.php +++ b/include/user_menu.php @@ -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 '7 Produits'; echo ""; } +/* function + * Purpose : + * + * parm : + * - + * gen : + * - + * return: + * - + * + */ +function ShowMenuComptaForm($p_dossier) { + $cn=DbConnect($p_dossier); + echo ''; +} +?> \ No newline at end of file