From d8be9bcbd2b58be0335f66ae76ebf93f37ec7fa9 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 25 Jun 2006 21:01:41 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20=09*=20vue=20filtrant=20:=20on=20ne=20p?= =?UTF-8?q?ropose=20les=20p=C3=A9riodes=20que=20pour=20l'ann=C3=A9e=20en?= =?UTF-8?q?=20cours=20=09*=20Possibilit=C3=A9=20de=20chercher=20une=20fich?= =?UTF-8?q?e=20dans=20un=20popup=20=09*=20Detail=20des=20tiers=20dans=20le?= =?UTF-8?q?s=20suivi=20courrier=20=09*=20G=C3=A9n=C3=A9ration=20de=20docum?= =?UTF-8?q?ent=20ODS=20(OpenOffice.org)=20sur=20base=20de=20mod=C3=A8le=20?= =?UTF-8?q?que=20l'on=20=09=20=20peut=20charger=20dans=20la=20base=20de=20?= =?UTF-8?q?donn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/admin/setup.php | 3 +- html/admin/sql/patch/upgrade13.sql | 6 ++ html/fiche_search.php | 19 ++-- html/show_document.php | 2 +- html/show_fiche.php | 60 +++++++++++++ include/ac_common.php | 1 + include/action.inc.php | 55 ++++++++---- include/balance.php | 9 +- include/class_action.php | 135 ++++++++++++++++++++++------- include/class_contact.php | 18 +++- include/class_document.php | 49 +++++++++-- include/class_fiche.php | 67 +++++++------- include/class_user.php | 11 +++ include/class_widget.php | 72 ++++++++++++++- include/constant.php | 9 +- include/contact.inc.php | 24 ++++- include/fiche_inc.php | 2 +- include/impress_bilan.php | 10 ++- include/impress_fiche.php | 7 +- include/impress_poste.php | 12 ++- include/impress_rapport.php | 11 ++- include/pref.inc.php | 16 +++- include/preference.php | 15 ++-- include/user_menu.php | 24 +++-- 24 files changed, 509 insertions(+), 128 deletions(-) create mode 100644 html/show_fiche.php diff --git a/html/admin/setup.php b/html/admin/setup.php index 47f32683c..f0f84ab14 100644 --- a/html/admin/setup.php +++ b/html/admin/setup.php @@ -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; } diff --git a/html/admin/sql/patch/upgrade13.sql b/html/admin/sql/patch/upgrade13.sql index 5bb82f57b..5dc3122df 100644 --- a/html/admin/sql/patch/upgrade13.sql +++ b/html/admin/sql/patch/upgrade13.sql @@ -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; diff --git a/html/fiche_search.php b/html/fiche_search.php index cbb92458a..5ebefeed6 100644 --- a/html/fiche_search.php +++ b/html/fiche_search.php @@ -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 diff --git a/html/show_document.php b/html/show_document.php index 2d7fc87e6..e77ed7681 100644 --- a/html/show_document.php +++ b/html/show_document.php @@ -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(); diff --git a/html/show_fiche.php b/html/show_fiche.php new file mode 100644 index 000000000..3527adf0a --- /dev/null +++ b/html/show_fiche.php @@ -0,0 +1,60 @@ +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 '

Vous n\' avez pas accès

'; + return; +} + +// Create a object fiche + +$f=new fiche($cn); +$f->GetByQCode($_REQUEST['q'],false); +echo $f->Display(true); +?> \ No newline at end of file diff --git a/include/ac_common.php b/include/ac_common.php index 25149955a..2e9dff44c 100644 --- a/include/ac_common.php +++ b/include/ac_common.php @@ -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; } diff --git a/include/action.inc.php b/include/action.inc.php index 320d331f4..0157523f3 100644 --- a/include/action.inc.php +++ b/include/action.inc.php @@ -43,11 +43,22 @@ function ShowActionList($cn,$retour,$h_url)
Titre : ', + printf ('Titre ou référence: ', $a); $qcode=(isset($_GET['qcode']))?$_GET['qcode']:""; - printf ('Tiers QuickCode: ', - $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 ('Tiers QuickCode: ', + // $qcode); ?> @@ -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=''; $h_url=""; if ( isset ($_REQUEST['url'])) @@ -116,7 +129,17 @@ if ( isset ($_REQUEST['url'])) $retour=sprintf('',urldecode($_REQUEST['url'])); $h_url=sprintf('',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 ''; 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 "

Date : "; echo $date->IOValue()."

"; // 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/", "", ""); @@ -228,8 +251,8 @@ writeRichText('ag_desc', , 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'; diff --git a/include/balance.php b/include/balance.php index ee1eb02a2..293ab68e1 100644 --- a/include/balance.php +++ b/include/balance.php @@ -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 ''; $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']; diff --git a/include/class_action.php b/include/class_action.php index 8a3266701..1378cc74b 100644 --- a/include/class_action.php +++ b/include/class_action.php @@ -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="

Document ".$doc->a_ref().'

'; + } + 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.="

Date : ".$date->IOValue()."

"; - $r.="

Etat $str_state".$state->IOValue()."

"; - $r.="

Type du document $str_type".$doc_type->IOValue()."

"; + if ( $str_type != "" ) + $r.="

Type du document $str_type".$doc_type->IOValue()."

"; $r.="

Tiers : ".$this->qcode." ".$tiers->strAttribut(1).'

'; - $r.="

Titre : ".$title->IOValue(); - $r.="

Description :".urldecode($desc->IOValue())."

"; + $r.="

Titre : ".$title->IOValue().' Ref :'.$ag_ref->IOValue(); + $r.=$doc_ref; + $r.="

Description :".urldecode(urldecode($desc->IOValue()))."

"; + 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.="

Tiers : ".$this->qcode." ".$tiers->strAttribut(1).'

'; $r.="

Titre : ".$title->IOValue(); $r.="

Description :".$desc->IOValue()."

"; + // if no document exist for this type then do not display the question if ( sizeof($doc_gen->value) != 0) $r.="

Générer un document ".$gen->IOValue()." ".$doc_gen->IOValue()."

"; @@ -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=''; } $r=$this->Display(); @@ -278,6 +340,8 @@ class action $r.=''; $r.=''; $r.=''; + // 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.="Société"; $r.="Titre"; $r.="type"; + $r.="Référence"; $r.="Document"; $r.=""; @@ -364,15 +429,21 @@ class action return $r; } + echo JS_SEARCH_CARD; foreach ($a_row as $row ) { $r.=""; $r.="".$row['my_date'].""; $f=new fiche($this->db); $f->id=$row['f_id']; - $r.="".$f->getName().""; - $r.="".$row['ag_title'].""; + $q=$f->strAttribut(ATTR_DEF_QUICKCODE); + $js=sprintf("javascript:showfiche('%s','%s')", + $_REQUEST['PHPSESSID'],$q); + $r.="".''.$q." : ".$f->getName().''; + $r.=''. + $row['ag_title'].""; $r.="".$row['dt_value'].""; + $r.="".$row['ag_ref'].""; $doc=new Document($this->db,$row['d_id']); $r.="".$doc->a_ref().""; diff --git a/include/class_contact.php b/include/class_contact.php index 182a018ca..b982a4e1f 100644 --- a/include/class_contact.php +++ b/include/class_contact.php @@ -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.=' + $r.='
- +'; $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("%s - %s", + $_REQUEST['PHPSESSID'], + $contact->strAttribut(ATTR_DEF_COMPANY), + $contact->strAttribut(ATTR_DEF_COMPANY), + $l_company_name + ); + } $r.=""; $r.='"; $r.=""; $r.="". "". - ""; + ""; $r.=""; diff --git a/include/class_document.php b/include/class_document.php index 59ef51166..1125ae042 100644 --- a/include/class_document.php +++ b/include/class_document.php @@ -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] diff --git a/include/class_fiche.php b/include/class_fiche.php index 8f6bd7231..14241efd5 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -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=" "; - } - 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=" "; + } + 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; diff --git a/include/class_user.php b/include/class_user.php index 31fcc182d..81e5b2f05 100644 --- a/include/class_user.php +++ b/include/class_user.php @@ -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']; +} + } ?> diff --git a/include/class_widget.php b/include/class_widget.php index cbdf64ff9..0ea0a6386 100644 --- a/include/class_widget.php +++ b/include/class_widget.php @@ -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 <TD> * \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=""; + $r=""; }else { $r=""; } @@ -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(' + ', + $this->label, + $this->name, + $this->value + ); + + } + return $r; + }// poste==js_search_only + + + + + // type=span if ( strtolower($this->type)=="span") { - $r=sprintf('%s', + $r=sprintf('%s ', $this->name, - $this->value); + $this->value + ); + return $r; }// end type = span diff --git a/include/constant.php b/include/constant.php index d90df00de..0c53b6ca4 100644 --- a/include/constant.php +++ b/include/constant.php @@ -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","
Nom Téléphone email FaxSociétéSociété
id."\">".$contact->strAttribut(ATTR_DEF_NAME)."".$contact->strAttribut(ATTR_DEF_TEL)."".$contact->strAttribut(ATTR_DEF_EMAIL)." ".$contact->strAttribut(ATTR_DEF_FAX)." ".$l_company_name. - " ".$l_company_name. "
si vide le Poste sera créer automatiquement si vide le Poste sera créer automatiquement".$this->label."".$r."".$this->label."".$r."".$r." + + %s + ', + $l_sessid, + $this->extra, + $this->name, + $this->extra2, + $this->label, + $this->name, + $this->value, + $this->tabindex + ); + } + else + { + $r=sprintf(' + + %s ', + $l_sessid, + $this->extra, + $this->name, + $this->extra2, + $this->label, + $this->name, + $this->value, + $this->tabindex + ); + } + } else { + // readonly == true + $r=sprintf(' %s + +