* vue filtrant : on ne propose les périodes que pour l'année en cours
	* Possibilité de chercher une fiche dans un popup
	* Detail des tiers dans les suivi courrier
	* Génération de document ODS (OpenOffice.org) sur base de modèle que l'on
	  peut charger dans la base de données
This commit is contained in:
sparkyx 2006-06-25 21:01:41 +00:00
parent 76cb0d8e40
commit d8be9bcbd2
24 changed files with 509 additions and 128 deletions

View file

@ -134,7 +134,8 @@ function ExecuteScript($p_cn,$script) {
continue;
}
if ( $flag_function ) {
if ( strpos(strtolower($buffer), "language plpgsql") === false ) {
if ( strpos(strtolower($buffer), "language plpgsql") === false &&
strpos(strtolower($buffer), "language 'plpgsql'") === false ) {
$sql.=$buffer;
continue;
}

View file

@ -537,6 +537,12 @@ insert into parameter (pr_id) values ('MY_TEL');
insert into parameter (pr_id) values ('MY_PAYS');
insert into parameter (pr_id) values ('MY_FAX');
insert into parameter (pr_id) values ('MY_TEL');
insert into parameter (pr_id) values ('MY_PAYS');
insert into parameter (pr_id) values ('MY_FAX');
alter table document add d_state int;
alter table action_gestion add ag_ref text;
update version set val=14;
commit;

View file

@ -113,15 +113,19 @@ if ( isset ( $_POST['search']) ) {
$list_fiche=get_list_fiche($cn,$get,$_GET['p_jrn']);
$sql="select * from vw_fiche_attr where fd_id in ( $list_fiche )";
}
if ( $e_type == 'cred' ) {
elseif ( $e_type == 'cred' ) {
$get='jrn_def_fiche_cred';
$list_fiche=get_list_fiche($cn,$get,$_GET['p_jrn']);
$sql="select * from vw_fiche_attr where fd_id in ( $list_fiche )";
}
// if e_type contains a list of value
if ( $e_type != 'cred' and $e_type != 'deb') {
/*!\brief if $e_type (from widget::extra) equal all, all the card are shown
* without restriction
*/
elseif ( $e_type == 'all' ) {
$sql="select * from vw_fiche_attr where true";
}
// if e_type contains a list of value for filtering on fiche_def_ref.frd_id
else{
$list_fiche=$e_type;
$sql="select * from vw_fiche_attr where frd_id in ( $list_fiche )";
// $sql="select * from vw_fiche_attr ";
@ -145,6 +149,11 @@ if ( isset ( $_POST['search']) ) {
//set focus on first "Select" button.
$row=pg_fetch_array($Res,$i);
// if quick code is empty pass ( it not used for the contact)
if (trim($row['quick_code']) == "")
continue;
if ( $i %2 == 0 )
$class="even";
else

View file

@ -37,4 +37,4 @@ $User=new cl_user(DbConnect());
$User->Check();
// retrieve the document
$doc=new Document($cn,$_REQUEST['d_id']);
$doc->Get();
$doc->Send();

60
html/show_fiche.php Normal file
View file

@ -0,0 +1,60 @@
<?
/*
* This file is part of PhpCompta.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/* !\file
* This file show in a popup window the detail a of card in read only mode
* the parameter are q (for qcode) & PHPSESSID
*/
/* \brief
*
*/
require_once ('class_user.php');
require_once ('class_fiche.php');
require_once ('postgres.php');
require_once ('debug.php');
require_once ('ac_common.php');
require_once('class_widget.php');
$User=new cl_user(DbConnect());
$User->Check();
html_page_start($_SESSION['g_theme'],"onLoad='window.focus();'");
if ( ! isset ($_REQUEST['q'])) {
echo 'appel invalide';
exit();
}
// connect to the database
$cn=DbConnect($_SESSION['g_dossier']);
if ( $User->CheckAction($cn,FICHE_READ) == 0 ){
/* Cannot Access */
echo '<h2 class="error"> Vous n\' avez pas accès</h2>';
return;
}
// Create a object fiche
$f=new fiche($cn);
$f->GetByQCode($_REQUEST['q'],false);
echo $f->Display(true);
?>

View file

@ -104,6 +104,7 @@ function isDate ( $p_date) {
if ( $l_date[2] > 2020 ) {
return null;
}
echo_debug('ac_common.php',__LINE__,' date = '.var_export($l_date,true));
if ( checkdate ($l_date[1],$l_date[0],$l_date[2]) == false) {
return null;
}

View file

@ -43,11 +43,22 @@ function ShowActionList($cn,$retour,$h_url)
<form method="get" action="commercial.php">
<?
$a=(isset($_GET['query']))?$_GET['query']:"";
printf ('<span>Titre : <input type="text" name="query" value="%s"></span>',
printf ('<span>Titre ou référence: <input type="text" name="query" value="%s"></span>',
$a);
$qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
printf ('<span>Tiers QuickCode: <input type="text" name="qcode" value="%s"></span>',
$qcode);
echo JS_SEARCH_CARD;
$w=new widget('js_search_only');
$w->name='qcode';
$w->value=$qcode;
$w->label='Quick Code';
$w->extra='4,9,14,16,8';
$w->table=0;
$sp= new widget("span");
echo $sp->IOValue("qcode_label","",$qcode);
echo $w->IOValue();
// printf ('<span>Tiers QuickCode: <input type="text" name="qcode" value="%s"></span>',
// $qcode);
?>
<input type="submit" name="submit_query" value="recherche">
@ -75,19 +86,21 @@ function ShowActionList($cn,$retour,$h_url)
// show the action in
$act=new action($cn);
$query=(isset ($_REQUEST['query']))?"and ag_title ~* '".FormatString($_REQUEST['query'])."'":"";
$query=(isset ($_REQUEST['query']))?"and (ag_title ~* '".FormatString($_REQUEST['query'])."' or ag_ref ='".trim(FormatString($_REQUEST['query']))."')":"";
$str="";
if ( isset($_REQUEST['qcode'] ))
{
// verify that qcode is not empty
if ( strlen(trim($_REQUEST['qcode'] )) != 0 )
{
$fiche=new Fiche($cn);
$fiche->GetByQCode($_REQUEST['qcode']);
$str=" and f_id= ".$fiche->id;
}
}
$r=$act->myList(ACTION,$query.$str);
echo $r;
}
@ -108,7 +121,7 @@ if (isset($_POST['corr'] ))
// if this page is called from another menu (customer, supplier,...)
// a button back is added
// TODO add function for generating url, hidden tags...
$retour="";
$retour='<A HREF="commercial.php?p_action=suivi_courrier"><input type="button" value="Retour"></A>';
$h_url="";
if ( isset ($_REQUEST['url']))
@ -116,7 +129,17 @@ if ( isset ($_REQUEST['url']))
$retour=sprintf('<A HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
$h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
}
//////////////////////////////////////////////////////////////////////////////////
// Show the detail of an action
if ( $sub_action=='detail' )
{
$act=new action($cn);
$act->ag_id=$_REQUEST['ag_id'];
echo $act->get();
echo $act->display();
echo $retour;
}
//////////////////////////////////////////////////////////////////////
// Show a list of the action
if ( $sub_action == "list" )
@ -134,8 +157,8 @@ if ( $sub_action == "add_action" )
echo '<form name="RTEDemo" action="commercial.php?p_action=suivi_courrier" method="post" onsubmit="return submitForm();">';
echo $h_url;
$date=new widget("text");
$date->name="ag_date";
$date->value=(isset($_POST['ag_date']))?$_POST['ag_date']:"";
$date->name="ag_timestamp";
$date->value=(isset($_POST['ag_timestamp']))?$_POST['ag_timestamp']:"";
echo "<p>Date : ";
echo $date->IOValue()."</p>";
// Tiers
@ -195,7 +218,7 @@ function submitForm() {
//make sure hidden and iframe values are in sync before submitting form
//to sync only 1 rte, use updateRTE(rte)
//to sync all rtes, use updateRTEs
updateRTE('ag_desc');
updateRTE('ag_comment');
//updateRTE();
//change the following line to true to submit form
return true;
@ -210,8 +233,8 @@ initRTE("images/", "", "");
<script language="JavaScript" type="text/javascript">
<!--
//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
<? $a=(isset($_POST['ag_desc']))?FormatString(urldecode($_POST['ag_desc'])):""; ?>
writeRichText('ag_desc', <? printf ("'%s'",$a); ?>, 520, 200, true, false);
<? $a=(isset($_POST['ag_comment']))?FormatString(urldecode($_POST['ag_comment'])):""; ?>
writeRichText('ag_comment', <? printf ("'%s'",$a); ?>, 520, 200, true, false);
<? echo_debug('action.inc',__LINE__, " A = ".$a); ?>
//-->
</script>
@ -228,8 +251,8 @@ writeRichText('ag_desc', <? printf ("'%s'",$a); ?>, 520, 200, true, false);
if ( $sub_action == "save_action_st1" )
{
$act=new action($cn);
$act->ag_desc=$_POST['ag_desc'];
$act->ag_date=$_POST['ag_date'];
$act->ag_comment=$_POST['ag_comment'];
$act->ag_timestamp=$_POST['ag_timestamp'];
$act->d_state=$_POST['d_state'];
$act->dt_id=$_POST['dt_id'];
$act->qcode=$_POST['tiers'];
@ -243,12 +266,14 @@ if ( $sub_action == "save_action_st1" )
if ( $sub_action == "save_action_st2" )
{
$act=new action($cn);
$act->ag_desc=$_POST['ag_desc'];
$act->ag_date=$_POST['ag_date'];
$act->ag_comment=$_POST['ag_comment'];
$act->ag_timestamp=$_POST['ag_timestamp'];
$act->d_state=$_POST['d_state'];
$act->dt_id=$_POST['dt_id'];
$act->qcode=$_POST['tiers'];
$act->ag_title=$_POST['ag_title'];
$act->md_id=(isset($_POST['gen_doc']))?$_POST['gen_doc']:0;
$act->gen=isset($_POST['p_gen'])?'on':'off';

View file

@ -21,6 +21,9 @@
// /* $Revision$ */
/*! \file
* \brief Show the balance and let you print it or export to PDF
* file included by user_impress
*
* some variable are already defined ($cn, $User ...)
*/
include_once ("ac_common.php");
@ -66,15 +69,17 @@ if ( isset ($_POST['view'] ) ) {
echo '<FORM action="user_impress.php?type=bal" method="post">';
$w=new widget("select");
$w->table=1;
// filter on the current year
$filter_year=" where p_exercice='".$User->getExercice()."'";
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode order by p_id");
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
$w->label="Depuis";
if ( isset ($_POST['from_periode']) )
$w->selected=$_POST['from_periode'];
echo $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");
$periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
if ( isset ($_POST['to_periode']) )
$w->selected=$_POST['to_periode'];

View file

@ -47,8 +47,8 @@ require_once("user_common.php");
class action
{
/*! \enum $db database connexion
* \enum $ag_desc description (ag_gestion.ag_desc)
* \enum $ag_date document date (ag_gestion.ag_date)
* \enum $ag_comment description (ag_gestion.ag_comment)
* \enum $ag_timestamp document date (ag_gestion.ag_timestamp)
* \enum $dt_id type of the document (document_type.dt_id)
* \enum $d_state stage of the document (printed, send to client...)
* \enum $d_number number of the document
@ -56,11 +56,11 @@ class action
* \enum $d_mimetype document's filename
* \enum $ag_title title document
* \enum $f_id fiche id
* \enum \todo replace attribut frmo document by an object document
*/
var $db;
var $ag_desc;
var $ag_date;
var $d_lob;
var $ag_comment;
var $ag_timestamp;
var $dt_id;
var $d_state;
var $d_number;
@ -89,8 +89,8 @@ class action
// Date
$date=new widget("text");
$date->readonly=true;
$date->name="ag_date";
$date->value=$this->ag_date;
$date->name="ag_timestamp";
$date->value=$this->ag_timestamp;
// Doc Type
$doc_type=new widget("hidden");
$doc_type->name="dt_id";
@ -101,23 +101,39 @@ class action
// state
// Retrieve the value
$a=ExecSql($this->db,"select s_value from document_state where s_id=".$this->d_state);
$v=pg_fetch_array($a,0);
$str_state=$v[0];
$state=new widget("hidden");
$state->name="d_state";
$state->value=$this->d_state;
// Retrieve the value if there is an attached doc
$doc_ref="";
if ( strlen ($this->d_state) > 0 )
{
$a=ExecSql($this->db,"select s_value from document_state where s_id=".$this->d_state);
$v=pg_fetch_array($a,0);
$str_state=$v[0];
$state=new widget("hidden");
$state->name="d_state";
$state->value=$this->d_state;
$doc=new Document($this->db,$this->d_id);
$doc_ref="<p> Document ".$doc->a_ref().'</p>';
}
else
$str_state="";
// title
$title=new widget("text");
$title->readonly=true;
$title->name="ag_title";
$title->value=FormatString($this->ag_title);
// ag_ref
$ag_ref=new widget("text");
$ag_ref->readonly=true;
$ag_ref->name="ag_ref";
$ag_ref->value=FormatString($this->ag_ref);
// Description
$desc=new widget('textarea');
$desc->name="ag_desc";
$desc->name="ag_comment";
$desc->readonly=" disabled ";
$desc->value=$this->ag_desc;
$desc->value=$this->ag_comment;
// Propose to generate a document
$gen=new widget ("checkbox");
$gen->name="p_gen";
@ -131,15 +147,47 @@ class action
// Preparing the return string
$r.="<p>Date : ".$date->IOValue()."</p>";
$r.="<p>Etat $str_state".$state->IOValue()."</p>";
$r.="<p>Type du document $str_type".$doc_type->IOValue()."</p>";
if ( $str_type != "" )
$r.="<p>Type du document $str_type".$doc_type->IOValue()."</p>";
$r.="<p> Tiers : ".$this->qcode." ".$tiers->strAttribut(1).'</p>';
$r.="<p> Titre : ".$title->IOValue();
$r.="<p>Description :".urldecode($desc->IOValue())."</p>";
$r.="<p> Titre : ".$title->IOValue().' Ref :'.$ag_ref->IOValue();
$r.=$doc_ref;
$r.="<p>Description :".urldecode(urldecode($desc->IOValue()))."</p>";
return $r;
}
/*!\brief This function shows the detail of an action thanks the ag_id
*/
function get()
{
echo_debug('class_action',__LINE__,'Action::Get() ');
$sql="select * from action_gestion left join document using (ag_id) where ag_id=".$this->ag_id;
$r=ExecSql($this->db,$sql);
$row=pg_fetch_all($r);
if ( $row==false) return;
$this->ag_comment=$row[0]['ag_comment'];
$this->ag_timestamp=$row[0]['ag_timestamp'];
$this->f_id=$row[0]['f_id'];
$this->ag_title=$row[0]['ag_title'];
$this->ag_type=$row[0]['ag_type'];
$this->ag_ref=$row[0]['ag_ref'];
$this->d_id=$row[0]['d_id'];
echo_debug('class_action',__LINE__,' Document id = '.$this->d_id);
// if there is no document set 0 to d_id
if ( $this->d_id == "" )
$this->d_id=0;
// if there is a document fill the object
if ($this->d_id != 0 )
{
$this->d_state=$row[0]['d_state'];
}
echo_debug('class_action',__LINE__,' After test Document id = '.$this->d_id);
$this->dt_id=$this->ag_type;
$a=new fiche($this->db,$this->f_id);
$this->qcode=$a->strAttribut(ATTR_DEF_QUICKCODE);
}
/*! Confirm
* \brief Display the encoded data and ask a confirmation
* this correspond to the stage 1, before the generation
@ -150,17 +198,18 @@ class action
*/
function Confirm()
{
if ( isDate($this->ag_date) == NULL )
/*! \todo add the hour */
if ( isDate($this->ag_timestamp) == NULL )
{
// if the date is invalid, default date is today
$this->ag_date=date("d.m.Y");
$this->ag_timestamp=date("d.m.Y");
}
// Compute the widget
// Date
$date=new widget("text");
$date->readonly=true;
$date->name="ag_date";
$date->value=$this->ag_date;
$date->name="ag_timestamp";
$date->value=$this->ag_timestamp;
// Doc Type
$doc_type=new widget("hidden");
$doc_type->name="dt_id";
@ -180,13 +229,13 @@ class action
}
// state
// Retrieve the value
$a=ExecSql($this->db,"select s_value from document_state where s_id=".$this->d_state);
$v=pg_fetch_array($a,0);
$str_state=$v[0];
$state=new widget("hidden");
$state->name="d_state";
$state->value=$this->d_state;
// title
$title=new widget("text");
$title->readonly=true;
@ -195,9 +244,9 @@ class action
// Description
$desc=new widget('textarea');
$desc->name="ag_desc";
$desc->name="ag_comment";
$desc->readonly=" disabled ";
$desc->value=$this->ag_desc;
$desc->value=$this->ag_comment;
// Propose to generate a document
$gen=new widget ("checkbox");
$gen->name="p_gen";
@ -216,6 +265,7 @@ class action
$r.="<p> Tiers : ".$this->qcode." ".$tiers->strAttribut(1).'</p>';
$r.="<p> Titre : ".$title->IOValue();
$r.="<p>Description :".$desc->IOValue()."</p>";
// if no document exist for this type then do not display the question
if ( sizeof($doc_gen->value) != 0)
$r.="<p> G&eacute;n&eacute;rer un document ".$gen->IOValue()." ".$doc_gen->IOValue()."</p>";
@ -254,12 +304,22 @@ class action
$this->ag_title=$doc_mod->dt_value;
}
echo_debug('class_action',__LINE__," tiers->id ".$tiers->id);
$sql=sprintf("insert into action_gestion(ag_type,ag_title,f_id,ag_comment) values ('%s','%s',%d,'%s')", $this->dt_id,
$this->ag_id=NextSequence($this->db,'action_gestion_ag_id_seq');
// Create the reference
$ref=$this->dt_id.'/'.$this->ag_id;
$this->ag_ref=$ref;
$sql=sprintf("insert into action_gestion(ag_id,ag_type,ag_title,f_id,ag_comment,ag_ref) values (%d,'%s','%s',%d,'%s','%s')",
$this->ag_id,
$this->dt_id,
FormatString($this->ag_title),
$tiers->id,
FormatString(urlencode($this->ag_desc)));
FormatString(urlencode($this->ag_comment)),
$ref
);
ExecSql($this->db,$sql);
$this->ag_id=GetSequence($this->db,'action_gestion_ag_id_seq');
// the lob filename and the mimetype needed if we want to generate a doc.
if ( $this->gen == 'on' )
@ -268,7 +328,9 @@ class action
$doc->f_id=$tiers->id;
$doc->md_id=$this->md_id;
$doc->ag_id=$this->ag_id;
$doc->d_state=$this->d_state;
$str_file=$doc->Generate();
$d='<input type="hidden" name="d_id" value="'.$doc->d_id.'">';
}
$r=$this->Display();
@ -278,6 +340,8 @@ class action
$r.='<input type="hidden" name="sa" value="save_action_st3">';
$r.='<input type="hidden" name="p_action" value="suivi_courrier">';
$r.='<input type="hidden" name="ag_id" value="'.$this->ag_id.'">';
// add the d_id
$r.=$d;
// Value for the generated document
if ( $this->gen == 'on' )
@ -329,7 +393,7 @@ class action
function myList($p_filter="",$p_search="")
{
$sql="
select ag_id,to_char(ag_timestamp,'DD-MM-YYYY HH:MI') as my_date,f_id,ag_title,d_id,md_type,dt_value
select ag_id,to_char(ag_timestamp,'DD-MM-YYYY HH:MI') as my_date,f_id,ag_title,d_id,md_type,dt_value,ag_ref
from action_gestion
left outer join document using (ag_id)
left outer join document_modele on (ag_type=md_type)
@ -352,6 +416,7 @@ class action
$r.="<th>Société</th>";
$r.="<th>Titre</th>";
$r.="<th>type</th>";
$r.="<th>Référence</th>";
$r.="<th>Document</th>";
$r.="</tr>";
@ -364,15 +429,21 @@ class action
return $r;
}
echo JS_SEARCH_CARD;
foreach ($a_row as $row )
{
$r.="<tr>";
$r.="<td>".$row['my_date']."</td>";
$f=new fiche($this->db);
$f->id=$row['f_id'];
$r.="<td>".$f->getName()."</td>";
$r.="<td>".$row['ag_title']."</td>";
$q=$f->strAttribut(ATTR_DEF_QUICKCODE);
$js=sprintf("javascript:showfiche('%s','%s')",
$_REQUEST['PHPSESSID'],$q);
$r.="<td>".'<A HREF="'.$js.'">'.$q." : ".$f->getName().'</A></td>';
$r.='<td><A HREF="commercial.php?p_action=suivi_courrier&sa=detail&ag_id='.$row['ag_id'].'">'.
$row['ag_title']."</A></td>";
$r.="<td>".$row['dt_value']."</td>";
$r.="<td>".$row['ag_ref']."</td>";
$doc=new Document($this->db,$row['d_id']);
$r.="<td>".$doc->a_ref()."</td>";

View file

@ -80,13 +80,13 @@ attr_value using (jft_id) where av_text='".$this->company."' and ad_id=".ATTR_DE
$step_contact=$this->GetAll($offset,$search.$extra_sql);
if ( $all_contact == 0 ) return "";
$r=$bar;
$r.='<table>
$r.='<table border="0">
<TR style="background-color:lightgrey;">
<th>Nom</th>
<th>Téléphone</th>
<th>email</th>
<th>Fax</th>
<th>Société</th>
<th colspan="2">Société</th>
</TR>';
$base=$_SERVER['SCRIPT_NAME'];
// Compute the url
@ -105,18 +105,28 @@ attr_value using (jft_id) where av_text='".$this->company."' and ad_id=".ATTR_DE
if ( sizeof ($step_contact ) == 0 )
return $r;
echo JS_SEARCH_CARD;
foreach ($step_contact as $contact ) {
$l_company=new fiche($this->cn);
$l_company->GetByQCode($contact->strAttribut(ATTR_DEF_COMPANY),false);
$l_company_name=$l_company->strAttribut(ATTR_DEF_NAME);
if ( $l_company_name == '- ERROR -' ) $l_company_name="";
// add popup for detail
if ( $l_company_name !="")
{
$l_company_name=sprintf("<A HREF=\"javascript:showfiche('%s','%s')\">%s - %s</A>",
$_REQUEST['PHPSESSID'],
$contact->strAttribut(ATTR_DEF_COMPANY),
$contact->strAttribut(ATTR_DEF_COMPANY),
$l_company_name
);
}
$r.="<TR>";
$r.='<TD><A HREF="'.$url."&sa=detail&f_id=".$contact->id."\">".$contact->strAttribut(ATTR_DEF_NAME)."</A></TD>";
$r.="<TD>".$contact->strAttribut(ATTR_DEF_TEL)."</TD>";
$r.="<TD>".$contact->strAttribut(ATTR_DEF_EMAIL)."</TD>".
"<TD> ".$contact->strAttribut(ATTR_DEF_FAX)."</TD>".
"<TD> ".$l_company_name.
"</TD>";
"<TD> ".$l_company_name. "</TD>";
$r.="</TR>";

View file

@ -19,6 +19,7 @@
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
require_once('class_own.php');
require_once('class_poste.php');
/*! \file
* \brief Class Document corresponds to the table document
*/
@ -34,6 +35,7 @@ class Document
var $d_lob; /*! \enum $d_lob the oid of the lob */
var $d_number; /*! \enum $d_number number of the document */
var $md_id; /*! \enum $md_id document's template */
var $d_state; /*! \enum $d_state document.d_state status of the document */
/* Constructor
* \param $p_cn Database connection
*/
@ -221,6 +223,7 @@ class Document
*/
function SaveGenerated($p_file)
{
echo_debug('class_document',__LINE__,'Save generated');
// We save the generated file
$doc=new Document($this->db);
StartSql($this->db);
@ -229,17 +232,18 @@ class Document
Rollback($this->db); echo_debug('class_document',__LINE__,"can't save file $p_file");
return 1; }
$sql=sprintf("insert into document(ag_id,d_lob,d_number,d_filename,d_mimetype)
values (%d,%s,%d,'%s','%s')",
$sql=sprintf("insert into document(ag_id,d_lob,d_number,d_filename,d_mimetype,d_state)
values (%d,%s,%d,'%s','%s',%d)",
$this->ag_id,
$this->d_lob,
$this->d_number,
$this->d_filename,
$this->d_mimetype
$this->d_mimetype,
$this->d_state
);
ExecSql($this->db,$sql);
$this->d_id=GetSequence($this->db,"document_d_id_seq");
echo_debug('class_document',__LINE__,'document sauvé : d_id'.$this->d_id);
Commit($this->db);
return 0;
}
@ -312,9 +316,9 @@ class Document
return $r;
}
/* ! Get
* \brief Retrieve the document
* \brief Send the document
*/
function Get()
function Send()
{
// retrieve the template and generate document
StartSql($this->db);
@ -349,6 +353,24 @@ class Document
Commit($this->db);
}
/*!\brief Get complete all the data member thx info from the database
*/
function get()
{
$sql="select * from document where d_id=".$this->d_id;
$ret=Exec($this->db,$sql);
if ( pg_num_rows($ret) == 0 )
return;
$row=pg_fetch_array($ret,0);
$this->ag_id=$row['ag_id'];
$this->d_mimetype=$row['d_mimetype'];
$this->d_filename=$row['d_filename'];
$this->d_lob=$row['d_lob'];
$this->d_number=$row[''];
$this->d_state=$row['ag_id'];
$this->d_number=$row['d_number'];
}
/*!
* \brief replace the TAG by the real value, this value can be into
@ -442,6 +464,14 @@ class Document
/*\note The CUST_* are retrieved thx the $_REQUEST['tiers']
* which contains the quick_code
*/
case 'SOLDE':
$tiers=new fiche($this->db);
$qcode=isset($_REQUEST['tiers'])?$_REQUEST['tiers']:$_REQUEST['e_client'];
$tiers->Getbyqcode($qcode,false);
$p=$tiers->strAttribut(ATTR_DEF_ACCOUNT);
$poste=new Poste($this->db,$p);
$r=$poste->GetSolde(' true' );
break;
case 'CUST_NAME':
$tiers=new fiche($this->db);
$qcode=isset($_REQUEST['tiers'])?$_REQUEST['tiers']:$_REQUEST['e_client'];
@ -480,6 +510,13 @@ class Document
case 'NUMBER':
$r=$this->d_number;
break;
case 'REFERENCE':
$act=new action($this->db);
$act->ag_id=$this->ag_id;
$act->get();
$r=$act->ag_ref;
break;
/*
* - [VEN_ART_NAME]
* - [VEN_ART_PRICE]

View file

@ -466,39 +466,46 @@ class fiche {
foreach ( $attr as $r)
{
$msg="";
if ( $r->ad_id == ATTR_DEF_ACCOUNT)
{
$ret.=JS_SEARCH_POSTE;
$w=new widget("js_search_poste");
// account created automatically
$sql="select account_auto($this->fiche_def)";
echo_debug("class_fiche",__LINE__,$sql);
$ret_sql=ExecSql($this->cn,$sql);
$a=pg_fetch_array($ret_sql,0);
// if ( $a['account_auto'] == 't' )
// $msg="<TD> <font color=\"red\">si vide le Poste sera créer automatiquement</font></TD> ";
}
elseif ( $r->ad_id == ATTR_DEF_TVA)
{
$ret.=JS_TVA;
$w=new widget("js_tva");
}
elseif ( $r->ad_id == ATTR_DEF_COMPANY )
{
$ret.=JS_SEARCH_CARD;
$w=new widget("js_search");
// filter on frd_id
$w->extra=FICHE_TYPE_CLIENT.','.FICHE_TYPE_FOURNISSEUR.','.FICHE_TYPE_ADM_TAX;
$w->extra2=0; // jrn = 0
$label=new widget("span");
$label->name="av_text".$r->ad_id."_label";
$msg=$label->IOValue();
}
else
if ( $p_readonly)
{
$w=new widget("text");
}
if ($p_readonly==false)
{
if ( $r->ad_id == ATTR_DEF_ACCOUNT)
{
$ret.=JS_SEARCH_POSTE;
$w=new widget("js_search_poste");
// account created automatically
$sql="select account_auto($this->fiche_def)";
echo_debug("class_fiche",__LINE__,$sql);
$ret_sql=ExecSql($this->cn,$sql);
$a=pg_fetch_array($ret_sql,0);
if ( $a['account_auto'] == 't' )
$msg="<TD> <font color=\"red\">si vide le Poste sera créer automatiquement</font></TD> ";
}
elseif ( $r->ad_id == ATTR_DEF_TVA)
{
$ret.=JS_TVA;
$w=new widget("js_tva");
}
elseif ( $r->ad_id == ATTR_DEF_COMPANY )
{
$ret.=JS_SEARCH_CARD;
$w=new widget("js_search");
// filter on frd_id
$w->extra=FICHE_TYPE_CLIENT.','.FICHE_TYPE_FOURNISSEUR.','.FICHE_TYPE_ADM_TAX;
$w->extra2=0; // jrn = 0
$label=new widget("span");
$label->name="av_text".$r->ad_id."_label";
$msg=$label->IOValue();
}
else
{
$w=new widget("text");
}
}
$w->label=$r->ad_text;
$w->value=$r->av_text;
$w->name="av_text".$r->ad_id;

View file

@ -340,5 +340,16 @@ function update_global_pref($p_type,$p_value="") {
ExecSql($cn,$Update);
}//end function
/*!\brief Return the year of current Periode
* it is the parm_periode.p_exercice col
*/
function getExercice()
{
$sql="select p_exercice from parm_periode where p_id=".$this->GetPeriode();
$Ret=ExecSql($this->db,$sql);
$r=pg_fetch_array($Ret,0);
return $r['p_exercice'];
}
}
?>

View file

@ -36,12 +36,18 @@ class widget {
* \enum $readonly if set to false cannot modify
* \enum $size size for the text type
* \enum $selected selected value for the radio or select
* \enum $table if we want to make a HTML table row
* \enum $table if we want to make a HTML table row the value is return with &lt;TD&gt;
* \enum $label text before the input tag
* \enum $disabled to disable the type
* \enum $extra depends of the input type
* \enum $extra2 depends of the input type
* \enum $tabindex the tabindex
* \brief special value
* js_search and js_search_only :you need to add a span widget the name
* of the js_* widget + '_label' , the member extra contains cred,deb to
* filter the search of cred of deb of a jrn or contains a string with
* a list of frd_id
*
*/
var $type;
@ -98,7 +104,7 @@ class widget {
if ($this->table==1) {
if ( $this->label != "") {
$r="<TD>".$this->label."</TD><TD>".$r."</TD>";
$r="<TD style=\"border:solid 1px blue;\">".$this->label."</TD><TD>".$r."</TD>";
}else {
$r="<TD>".$r."</TD>";
}
@ -316,11 +322,69 @@ class widget {
}// poste==js_search
// input type == js_search => button search for card
/*!\brief js_search_only only for searching a card no new button
*/
if ( strtolower($this->type)=="js_search_only") {
$l_sessid=$_REQUEST['PHPSESSID'];
if ( $this->readonly == false ) {
if ( $this->table==1)
{
$r=sprintf('<TD>
<INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="Search">
%s</TD><TD> <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8" TABINDEX="%s">
',
$l_sessid,
$this->extra,
$this->name,
$this->extra2,
$this->label,
$this->name,
$this->value,
$this->tabindex
);
}
else
{
$r=sprintf('
<INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="Search">
%s <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8" TABINDEX="%s"> ',
$l_sessid,
$this->extra,
$this->name,
$this->extra2,
$this->label,
$this->name,
$this->value,
$this->tabindex
);
}
} else {
// readonly == true
$r=sprintf('<TD> %s</TD>
<TD>
<INPUT TYPE="hidden" NAME="%s" VALUE="%s" SIZE="8">
</TD>',
$this->label,
$this->name,
$this->value
);
}
return $r;
}// poste==js_search_only
// type=span
if ( strtolower($this->type)=="span") {
$r=sprintf('<span id="%s" >%s</span>',
$r=sprintf('<span id="%s" >%s </span>',
$this->name,
$this->value);
$this->value
);
return $r;
}// end type = span

View file

@ -24,7 +24,7 @@
*/
define ("phpcompta_password","dany");
define ("domaine","test_");
define ("domaine","");
define ("DEBUG","true");
@ -91,6 +91,7 @@ define ("NO",0);
define ("OPEN",1);
define ("CLOSED",0);
define ("NOTCENTRALIZED",3);
define ("ALL",4);
// Pour les ShowMenuComptaLeft
define ("MENU_FACT",1);
@ -219,6 +220,12 @@ function RefreshMe() {
define ("JS_SEARCH_CARD","
<script language=\"javascript\">
function showfiche(p_sessid,qcode)
{
var a=window.open('show_fiche.php?PHPSESSID='+p_sessid+'&q='+qcode,'','toolbar=no,width=350,height=450,scrollbar=yes');
}
/* type must be cred or deb and name is
* the control's name
*/

View file

@ -130,7 +130,14 @@ if ( $sub_action == "list" )
$w->name="fd_id";
$w->value= make_array($cn,"select fd_id,fd_label from fiche_def where ".
" frd_id=".FICHE_TYPE_CONTACT);
// if array is empty show an warning and stops
if ( sizeof ($w->value) == 0 ) {
echo '<p style="color:red">Aucune fiche de catégories contact</p>';
echo '<p>allez dans comptabilité -> fiche creation et choississez contact comme sorte</p>';
exit();
}
echo $w->IOValue();
?>
<input type="hidden" name="sa" value="blank">
<input type="submit" name="submit_query" value="Ajout Contact">
@ -140,9 +147,20 @@ if ( $sub_action == "list" )
<form>
<?
$qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
printf ('<span>Tiers QuickCode: <input type="text" name="qcode" value="%s"></span>',
$qcode);
$qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
echo JS_SEARCH_CARD;
$w=new widget('js_search_only');
$w->name='qcode';
$w->value=$qcode;
$w->label='qcode';
$w->extra='4,8,9,14';
$sp= new widget("span");
echo $sp->IOValue("qcode_label",$qcode)."</TD></TR>";
echo $w->IOValue();
// printf ('<span>Tiers QuickCode: <input type="text" name="qcode" value="%s"></span>',
// $qcode);
?>
<input type="submit" name="submit_query" value="recherche">
<input type="hidden" name="p_action" value="contact">

View file

@ -710,7 +710,7 @@ function DefModele ($p_cn,$p_js,$p_array=null,$p_ligne=1)
$display.='<TD><INPUT TYPE="INPUT" NAME="class_base"> '.$p_js;
$display.='</TD></TR>';
// Checkbox for the creation of a post
$display.='<TR><TD> <INPUT TYPE="CHECKBOX" NAME="create" CHECKED>Create accounts for each</TD></TR>';
$display.='<TR><TD> <INPUT TYPE="CHECKBOX" NAME="create" CHECKED>Cr&eacute;ation automatique du poste comptable</TD></TR>';
//display the different template
$ref=Get_fiche_def_ref($p_cn);

View file

@ -20,6 +20,9 @@
include_once("class_widget.php");
/*! \file
* \brief form who call the printing of the bilan in RTF
* file included by user_impress
*
* some variable are already defined ($cn, $User ...)
*/
////////////////////////////////////////////////////////////////////////////////
@ -40,11 +43,14 @@ echo '<FORM ACTION="bilan.php" METHOD="POST">';
echo '<TABLE>';
print '<TR>';
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode order by p_id");
// filter on the current year
$filter_year=" where p_exercice='".$User->getExercice()."'";
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year 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");
$periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
print $w->IOValue('to_periode',$periode_end);
print "</TR>";
echo '</TABLE>';

View file

@ -58,11 +58,14 @@ if ( isset ($_REQUEST['fd_id'])) {
//--
if ( $fiche_def->HasAttribute(ATTR_DEF_ACCOUNT) == true ) {
echo '<form method="POST" ACTION="user_impress.php">';
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode order by p_id");
// filter on the current year
$filter_year=" where p_exercice='".$User->getExercice()."'";
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
$w->selected=(isset($_POST['from_periode']))?$_POST['from_periode']:"";
print "Depuis ".$w->IOValue('from_periode',$periode_start);
$periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode order by p_id");
$periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
$w->selected=(isset($_POST['to_periode']))?$_POST['to_periode']:"";
print " Jusque ".$w->IOValue('to_periode',$periode_end);

View file

@ -21,6 +21,10 @@
include_once("class_widget.php");
/*! \file
* \brief Print account (html or pdf)
* file included from user_impress
*
* some variable are already defined $cn, $User ...
*
*/
////////////////////////////////////////////////////////////////////////////////
@ -114,6 +118,8 @@ $ret=make_array($cn,"select distinct j_poste::text ,j_poste::text||' '||pcm_lib
////////////////////////////////////////////////////////////////////////////////
// Form
////////////////////////////////////////////////////////////////////////////////
if ( $ret==null)
exit('Les journaux sont vides');
echo '<div class="u_content">';
echo '<FORM ACTION="?type=poste" METHOD="POST">';
echo '<TABLE><TR>';
@ -123,11 +129,13 @@ $w->label="Choississez le poste";
print $w->IOValue("poste_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");
// filter on the current year
$filter_year=" where p_exercice='".$User->getExercice()."'";
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year 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");
$periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode order $filter_year by p_id");
print $w->IOValue('to_periode',$periode_end);
print "</TR>";
print "<TR><TD>";

View file

@ -20,6 +20,10 @@
include_once("class_widget.php");
/*! \file
* \brief print first the report in html and propose to print it in pdf
* file included by user_impress
*
* some variable are already defined ($cn, $User ...)
*/
////////////////////////////////////////////////////////////////////////////////
@ -134,11 +138,14 @@ $w->label="Choississez le rapport";
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");
// filter on the current year
$filter_year=" where p_exercice='".$User->getExercice()."'";
$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year 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");
$periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
print $w->IOValue('to_periode',$periode_end);
print "</TR>";
$aStep=array(

View file

@ -18,6 +18,9 @@
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*!\brief this file is always included and then executed
* it permits to change the user preferences
*/
echo '<DIV class="u_content">';
@ -90,19 +93,26 @@ $disp_style.="</SELECT>";
if ( isset ($_SESSION['g_dossier']) ) {
include_once("preference.php");
$msg="";
if ( isset ($_POST["sub_periode"] ) ) {
$periode=$_POST["periode"];
$User->SetPeriode($periode);
// SetUserPeriode($cn,$periode,$_SESSION['g_user']);
echo_debug('pref.inc',__LINE__,"Periode returns ".PeriodeClosed($cn,$periode));
// if periode is closed then warns the users
if ( PeriodeClosed($cn,$periode)=='t')
{
$msg= '<h2 class="error">Attention cette période est fermée, vous ne pourrez rien modifier dans le module comptable</h2>';
}
}
$l_user_per=$User->GetPeriode();
$l_form_per=FormPeriode($cn,$l_user_per);
$l_form_per=FormPeriode($cn,$l_user_per,ALL);
?>
<H2 CLASS="info"> Période</H2>
<? echo $msg; ?>
<FORM ACTION="<? echo $url;?>" METHOD="POST">
<TABLE ALIGN="CENTER">
<TR><TD>PERIODE</TD>

View file

@ -60,7 +60,7 @@ function FormPeriodeMult($p_cn)
*
* \param $p_cn connexion
* \param $p_default default periode
* \param $p_type the type of the periode
* \param $p_type the type of the periode OPEN CLOSE NOTCENTRALIZED or ALL
* \param $p_suff the suffix of the name
*
* \return string containing html code for the HTML
@ -72,20 +72,23 @@ function FormPeriode($p_cn,$l_default=0,$p_type=OPEN,$p_suff="")
{
switch ($p_type) {
case CLOSED:
$sql_closed="p_closed=true and p_central = false ";
$sql_closed="where p_closed=true and p_central = false ";
break;
case OPEN:
$sql_closed="p_closed=false";
$sql_closed="where p_closed=false";
break;
case NOTCENTRALIZED:
$sql_closed="p_closed=true and p_central = false ";
$sql_closed="where p_closed=true and p_central = false ";
break;
case ALL:
$sql_closed="";
break;
default:
error("invalide p_type in 'preference.php'#__LINE__");
}
$sql="select p_id,to_char(p_start,'DD.MM.YYYY') as p_start_string,
to_char(p_end,'DD.MM.YYYY') as p_end_string
from parm_periode where
from parm_periode
$sql_closed
order by p_start";
@ -136,7 +139,7 @@ function GetPeriode($p_cn,$p_periode)
* \param $p_cn database connex
* \param periode id
*
* \return true if closed
* \return 't' if closed otherwise 'f'
*
*
*/

View file

@ -402,6 +402,7 @@ function u_ShowMenuRecherche($p_cn,$p_jrn,$p_sessid,$p_array=null)
// $r.= '<div style="border-style:outset;border-width:1pt;">';
$r.=JS_SEARCH_POSTE;
$r.=JS_SEARCH_CARD;
$r.= "<B>Recherche</B>";
$r.= '<FORM ACTION="recherche.php" METHOD="GET">';
$r.="<table><tr><TD>";
@ -431,13 +432,24 @@ function u_ShowMenuRecherche($p_cn,$p_jrn,$p_sessid,$p_array=null)
$r.="<TR>".$W->IOValue();
$r.= "</TR>";
$r.= "<TR>";
$A=new widget("TEXT");
$A->label="Quick Code";
$A->name="qcode";
$A->value=$p_qcode;
$r.="<TD> Quick Code</TD><TD>".$A->IOValue()."</TD>";
$r.= "</TR>";
$A=new widget('js_search_only');
$A->name='qcode';
$A->value=$p_qcode;
$A->extra="";
$A->table=1;
// $r.=$sp->IOValue("p_qcode_label")."</TD></TR>";
// $A=new widget("TEXT");
$A->label="Quick Code";
$A->extra='all';
//$A->name="qcode";
// $A->value=$p_qcode;
$sp= new widget("span");
$sp->table=0;
$r.=$A->IOValue().'</TD>'.$sp->IOValue("qcode_label");
$r.= "</TR>";
echo_debug('user_menu.php',__LINE__,"<TD>".$A->IOValue().'</TD><TD>'.$sp->IOValue("p_qcode_label")."</TD>");
$r.= '<TD colspan="3"> Le commentaire contient </TD>';
$r.= "</TR><TR>";