diff --git a/doc/developper/account_repository.html b/doc/developper/account_repository.html index c7a740514..5cf9da960 100644 --- a/doc/developper/account_repository.html +++ b/doc/developper/account_repository.html @@ -111,7 +111,7 @@
-
Dumped on 2006-07-05
Dumped on 2006-07-06
Tables referencing this one via Foreign Key Constraints:
+
Dumped on 2006-07-05
Dumped on 2006-07-06
- Index - - Schema public -
- -Action for Managing
- - - -| F-Key | -Name | -Type | -Description | -
|---|---|---|---|
| - - - - | -ag_id | -serial | -- - PRIMARY KEY - - - - - - - - - - | -
| - - | -ag_type | -integer | -- - - - - - - | -
| - - | -f_id_dest | -integer | -- - - NOT NULL - - - - | -
| - - | -f_id_exp | -integer | -- - - NOT NULL - - - - | -
| - - | -ag_title | -character varying(70) | -- - - - - - - | -
| - - | -ag_timestamp | -timestamp without time zone | -- - - - DEFAULT now() - - - | -
| - - | -ag_cal | -character(1) | -- - - - DEFAULT 'C'::bpchar - - - | -
| - - | -ag_ref_ag_id | -integer | -- - - - - - - | -
| - - | -ag_comment | -text | -- - - - - - - | -
| - - | -ag_ref | -text | -- - - - - - - | -
- Index - - Schema public -
- -This table contains all the documents : summary and lob files
- - - -| F-Key | -Name | -Type | -Description | -
|---|---|---|---|
| - - - - | -d_id | -serial | -- - PRIMARY KEY - - - - - - - - - - | -
| - - | -ag_id | -integer | -- - - NOT NULL - - - - | -
| - - | -d_lob | -oid | -- - - - - - - | -
| - - | -d_number | -bigint | -- - - NOT NULL - - - - | -
| - - | -d_filename | -text | -- - - - - - - | -
| - - | -d_mimetype | -text | -- - - - - - - | -
| - - | -d_state | -integer | -- - - - - - - | -
- Index - - Schema public -
- -contains all the template for the documents
- - - -| F-Key | -Name | -Type | -Description | -
|---|---|---|---|
| - - - - | -md_id | -serial | -- - PRIMARY KEY - - - - - - - - - - | -
| - - | -md_name | -text | -- - - NOT NULL - - - - | -
| - - | -md_lob | -oid | -- - - - - - - | -
| - - - document_type.dt_id - - - | -md_type | -integer | -- - - - - - - NOT NULL - - - - | -
| - - | -md_filename | -text | -- - - - - - - | -
| - - | -md_mimetype | -text | -- - - - - - - | -
- Index - - Schema public -
- -State of the document
- - - -| F-Key | -Name | -Type | -Description | -
|---|---|---|---|
| - - - - | -s_id | -serial | -- - PRIMARY KEY - - - - - - - - - - | -
| - - | -s_value | -character varying(50) | -- - - NOT NULL - - - - | -
- Index - - Schema public -
- -Type of document : meeting, invoice,...
- - - -| F-Key | -Name | -Type | -Description | -
|---|---|---|---|
| - - - - | -dt_id | -serial | -- - PRIMARY KEY - - - - - - - - - - | -
| - - | -dt_value | -character varying(80) | -- - - - - - - | -
Tables referencing this one via Foreign Key Constraints:
- -- Index - - Schema public -
- -| F-Key | -Name | -Type | -Description | -
|---|---|---|---|
| - - - - | -name | -text | -- - PRIMARY KEY - - - - - - - - - - | -
| - - | -include_file | -text | -- - - NOT NULL - - - - | -
- Index - - Schema public -
- -| F-Key | -Name | -Type | -Description | -
|---|---|---|---|
| - - | -code | -text | -- - - - - - - | -
| - - | -date_exec | -date | -- - - - - - - | -
| - - | -date_valeur | -date | -- - - - - - - | -
| - - | -montant | -text | -- - - - - - - | -
| - - | -devise | -text | -- - - - - - - | -
| - - | -compte_ordre | -text | -- - - - - - - | -
| - - | -detail | -text | -- - - - - - - | -
| - - | -num_compte | -text | -- - - - - - - | -
| - - | -poste_comptable | -text | -- - - - - - - | -
| - - | -ok | -boolean | -- - - - DEFAULT false - - - | -
| - - | -bq_account | -integer | -- - - NOT NULL - - - - | -
| - - | -jrn | -integer | -- - - NOT NULL - - - - | -
- Index - - Schema public -
- -| F-Key | -Name | -Type | -Description | -
|---|---|---|---|
| - - - - | -iv_id | -integer | -- - PRIMARY KEY - - - - - - - DEFAULT nextval('s_invoice'::text) - - - | -
| - - | -iv_name | -text | -- - - NOT NULL - - - - | -
| - - | -iv_file | -oid | -- - - - - - - | -
- Index - - Schema public -
- -| F-Key | -Name | -Type | -Description | -
|---|---|---|---|
| - - - - | -p_code | -text | -- - PRIMARY KEY - - - - - - - - - - | -
| - - | -p_value | -text | -- - - - - - - | -
| - - | -p_comment | -text | -- - - - - - - | -
- Index - - Schema public -
- -Contains about invoice for customer
- - - -| F-Key | -Name | -Type | -Description | -
|---|---|---|---|
| - - - - | -qs_id | -integer | -- - PRIMARY KEY - - - - - - - DEFAULT nextval('s_quantity'::text) - - - | -
| - - | -qs_internal | -text | -- - - NOT NULL - - - - | -
| - - | -qs_fiche | -integer | -- - - NOT NULL - - - - | -
| - - | -qs_quantite | -integer | -- - - NOT NULL - - - - | -
| - - | -qs_price | -numeric(20,4) | -- - - - - - - | -
| - - | -qs_vat | -numeric(20,4) | -- - - - - - - | -
| - - | -qs_vat_code | -integer | -- - - - - - - | -
| - - | -qs_client | -integer | -- - - NOT NULL - - - - | -
Index - Schema public @@ -4761,7 +3385,7 @@
+ Index - + Schema public +
+ +| F-Key | +Name | +Type | +Description | +
|---|---|---|---|
| + + + + | +pref_user | +text | ++ + PRIMARY KEY + + + + + + + + + + | +
| + + | +pref_periode | +integer | ++ + + NOT NULL + + + + | +
minimum attribut for the customer (frd_id=9)
+| - | -quick_code | -text | -- - - - - - - | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - | tva_num | text | @@ -5438,7 +4126,7 @@|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -5454,7 +4142,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -5470,7 +4158,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -5486,7 +4174,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -5502,7 +4190,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -5518,7 +4206,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -5549,7 +4237,6 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - | -quick_code | -text | -- - - - - - - | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - | frd_id | integer | @@ -6110,7 +4748,6 @@ SELECT a.f_id , tva_rate.tva_label , e.av_text AS vw_addr , f.av_text AS vw_cp -, j.av_text AS quick_code , fiche_def.frd_id FROM ( ( @@ -6120,45 +4757,23 @@ FROM ( ( ( ( - ( - SELECT fiche.f_id - , fiche.fd_id - , attr_value.av_text - FROM ( - ( - (fiche - JOIN jnt_fic_att_value - USING (f_id) - ) - JOIN attr_value - USING (jft_id) + SELECT fiche.f_id + , fiche.fd_id + , attr_value.av_text + FROM ( + ( + (fiche + JOIN jnt_fic_att_value + USING (f_id) ) - JOIN attr_def - USING (ad_id) + JOIN attr_value + USING (jft_id) ) - WHERE (jnt_fic_att_value.ad_id = 1) - ) a - LEFT JOIN ( - SELECT fiche.f_id - , attr_value.av_text - FROM ( - ( - (fiche - JOIN jnt_fic_att_value - USING (f_id) - ) - JOIN attr_value - USING (jft_id) - ) - JOIN attr_def - USING (ad_id) - ) - WHERE (jnt_fic_att_value.ad_id = 6) - ) b - ON ( - (a.f_id = b.f_id) + JOIN attr_def + USING (ad_id) ) - ) + WHERE (jnt_fic_att_value.ad_id = 1) + ) a LEFT JOIN ( SELECT fiche.f_id , attr_value.av_text @@ -6174,10 +4789,10 @@ FROM ( JOIN attr_def USING (ad_id) ) - WHERE (jnt_fic_att_value.ad_id = 7) - ) c + WHERE (jnt_fic_att_value.ad_id = 6) + ) b ON ( - (a.f_id = c.f_id) + (a.f_id = b.f_id) ) ) LEFT JOIN ( @@ -6195,10 +4810,10 @@ FROM ( JOIN attr_def USING (ad_id) ) - WHERE (jnt_fic_att_value.ad_id = 2) - ) d + WHERE (jnt_fic_att_value.ad_id = 7) + ) c ON ( - (a.f_id = d.f_id) + (a.f_id = c.f_id) ) ) LEFT JOIN ( @@ -6216,10 +4831,10 @@ FROM ( JOIN attr_def USING (ad_id) ) - WHERE (jnt_fic_att_value.ad_id = 14) - ) e + WHERE (jnt_fic_att_value.ad_id = 2) + ) d ON ( - (a.f_id = e.f_id) + (a.f_id = d.f_id) ) ) LEFT JOIN ( @@ -6237,10 +4852,10 @@ FROM ( JOIN attr_def USING (ad_id) ) - WHERE (jnt_fic_att_value.ad_id = 15) - ) f + WHERE (jnt_fic_att_value.ad_id = 14) + ) e ON ( - (a.f_id = f.f_id) + (a.f_id = e.f_id) ) ) LEFT JOIN ( @@ -6258,10 +4873,10 @@ FROM ( JOIN attr_def USING (ad_id) ) - WHERE (jnt_fic_att_value.ad_id = 23) - ) j + WHERE (jnt_fic_att_value.ad_id = 15) + ) f ON ( - (a.f_id = j.f_id) + (a.f_id = f.f_id) ) ) LEFT JOIN tva_rate @@ -6354,8 +4969,8 @@ FROM (- | av_text | -text | +fd_class_base | +integer |
@@ -6369,22 +4984,6 @@ FROM (
|
- |
- fd_class_base |
- poste_comptable |
-
-
-
-
-
-
-
- |
-
-
|
fd_label |
text |
@@ -6398,7 +4997,7 @@ FROM (
|
@@ -6414,7 +5013,7 @@ FROM (
|
@@ -6446,29 +5045,14 @@ FROM (
SELECT jnt_fic_attr.fd_id
, jnt_fic_attr.ad_id
, attr_def.ad_text
-, attr_value.av_text
, fiche_def.fd_class_base
, fiche_def.fd_label
, fiche_def.fd_create_account
, fiche_def.frd_id
FROM (
- (
- (
- (
- (jnt_fic_att_value
- JOIN attr_value
- USING (jft_id)
- )
- JOIN fiche
- USING (f_id)
- )
- JOIN jnt_fic_attr
- USING (fd_id)
- )
+ (jnt_fic_attr
JOIN attr_def
- ON (
- (attr_def.ad_id = jnt_fic_attr.ad_id)
- )
+ USING (ad_id)
)
JOIN fiche_def
USING (fd_id)
@@ -6612,621 +5196,6 @@ FROM (
- - Index - - Schema public - - -- View: - vw_poste_qcode -- - - -
-SELECT a.f_id -, a.av_text AS j_poste -, b.av_text AS j_qcode -FROM ( - ( - SELECT jnt_fic_att_value.f_id - , attr_value.av_text - FROM (attr_value - JOIN jnt_fic_att_value - USING (jft_id) - ) - WHERE (jnt_fic_att_value.ad_id = 5) - ) a - JOIN ( - SELECT jnt_fic_att_value.f_id - , attr_value.av_text - FROM (attr_value - JOIN jnt_fic_att_value - USING (jft_id) - ) - WHERE (jnt_fic_att_value.ad_id = 23) - ) b - USING (f_id) -);- - - - - - - Index - - Schema public - - -- View: - vw_supplier -- - - -
-SELECT a.f_id -, a.av_text AS name -, a1.av_text AS quick_code -, b.av_text AS tva_num -, c.av_text AS poste_comptable -, d.av_text AS rue -, e.av_text AS code_postal -, f.av_text AS pays -, g.av_text AS telephone -, h.av_text AS email -FROM ( - ( - ( - ( - ( - ( - ( - ( - ( - SELECT jnt_fic_att_value.jft_id - , fiche.f_id - , fiche_def.frd_id - , fiche.fd_id - , fiche_def.fd_class_base - , fiche_def.fd_label - , fiche_def.fd_create_account - , fiche_def_ref.frd_text - , fiche_def_ref.frd_class_base - , jnt_fic_att_value.ad_id - , attr_value.av_text - FROM ( - ( - ( - (fiche - JOIN fiche_def - USING (fd_id) - ) - JOIN fiche_def_ref - USING (frd_id) - ) - JOIN jnt_fic_att_value - USING (f_id) - ) - JOIN attr_value - USING (jft_id) - ) - WHERE (jnt_fic_att_value.ad_id = 1) - ) a - JOIN ( - SELECT jnt_fic_att_value.jft_id - , fiche.f_id - , fiche_def.frd_id - , fiche.fd_id - , fiche_def.fd_class_base - , fiche_def.fd_label - , fiche_def.fd_create_account - , fiche_def_ref.frd_text - , fiche_def_ref.frd_class_base - , jnt_fic_att_value.ad_id - , attr_value.av_text - FROM ( - ( - ( - (fiche - JOIN fiche_def - USING (fd_id) - ) - JOIN fiche_def_ref - USING (frd_id) - ) - JOIN jnt_fic_att_value - USING (f_id) - ) - JOIN attr_value - USING (jft_id) - ) - WHERE (jnt_fic_att_value.ad_id = 13) - ) b - USING (f_id) - ) - JOIN ( - SELECT jnt_fic_att_value.jft_id - , fiche.f_id - , fiche_def.frd_id - , fiche.fd_id - , fiche_def.fd_class_base - , fiche_def.fd_label - , fiche_def.fd_create_account - , fiche_def_ref.frd_text - , fiche_def_ref.frd_class_base - , jnt_fic_att_value.ad_id - , attr_value.av_text - FROM ( - ( - ( - (fiche - JOIN fiche_def - USING (fd_id) - ) - JOIN fiche_def_ref - USING (frd_id) - ) - JOIN jnt_fic_att_value - USING (f_id) - ) - JOIN attr_value - USING (jft_id) - ) - WHERE (jnt_fic_att_value.ad_id = 23) - ) a1 - USING (f_id) - ) - JOIN ( - SELECT jnt_fic_att_value.jft_id - , fiche.f_id - , fiche_def.frd_id - , fiche.fd_id - , fiche_def.fd_class_base - , fiche_def.fd_label - , fiche_def.fd_create_account - , fiche_def_ref.frd_text - , fiche_def_ref.frd_class_base - , jnt_fic_att_value.ad_id - , attr_value.av_text - FROM ( - ( - ( - (fiche - JOIN fiche_def - USING (fd_id) - ) - JOIN fiche_def_ref - USING (frd_id) - ) - JOIN jnt_fic_att_value - USING (f_id) - ) - JOIN attr_value - USING (jft_id) - ) - WHERE (jnt_fic_att_value.ad_id = 5) - ) c - USING (f_id) - ) - JOIN ( - SELECT jnt_fic_att_value.jft_id - , fiche.f_id - , fiche_def.frd_id - , fiche.fd_id - , fiche_def.fd_class_base - , fiche_def.fd_label - , fiche_def.fd_create_account - , fiche_def_ref.frd_text - , fiche_def_ref.frd_class_base - , jnt_fic_att_value.ad_id - , attr_value.av_text - FROM ( - ( - ( - (fiche - JOIN fiche_def - USING (fd_id) - ) - JOIN fiche_def_ref - USING (frd_id) - ) - JOIN jnt_fic_att_value - USING (f_id) - ) - JOIN attr_value - USING (jft_id) - ) - WHERE (jnt_fic_att_value.ad_id = 14) - ) d - USING (f_id) - ) - JOIN ( - SELECT jnt_fic_att_value.jft_id - , fiche.f_id - , fiche_def.frd_id - , fiche.fd_id - , fiche_def.fd_class_base - , fiche_def.fd_label - , fiche_def.fd_create_account - , fiche_def_ref.frd_text - , fiche_def_ref.frd_class_base - , jnt_fic_att_value.ad_id - , attr_value.av_text - FROM ( - ( - ( - (fiche - JOIN fiche_def - USING (fd_id) - ) - JOIN fiche_def_ref - USING (frd_id) - ) - JOIN jnt_fic_att_value - USING (f_id) - ) - JOIN attr_value - USING (jft_id) - ) - WHERE (jnt_fic_att_value.ad_id = 15) - ) e - USING (f_id) - ) - JOIN ( - SELECT jnt_fic_att_value.jft_id - , fiche.f_id - , fiche_def.frd_id - , fiche.fd_id - , fiche_def.fd_class_base - , fiche_def.fd_label - , fiche_def.fd_create_account - , fiche_def_ref.frd_text - , fiche_def_ref.frd_class_base - , jnt_fic_att_value.ad_id - , attr_value.av_text - FROM ( - ( - ( - (fiche - JOIN fiche_def - USING (fd_id) - ) - JOIN fiche_def_ref - USING (frd_id) - ) - JOIN jnt_fic_att_value - USING (f_id) - ) - JOIN attr_value - USING (jft_id) - ) - WHERE (jnt_fic_att_value.ad_id = 16) - ) f - USING (f_id) - ) - JOIN ( - SELECT jnt_fic_att_value.jft_id - , fiche.f_id - , fiche_def.frd_id - , fiche.fd_id - , fiche_def.fd_class_base - , fiche_def.fd_label - , fiche_def.fd_create_account - , fiche_def_ref.frd_text - , fiche_def_ref.frd_class_base - , jnt_fic_att_value.ad_id - , attr_value.av_text - FROM ( - ( - ( - (fiche - JOIN fiche_def - USING (fd_id) - ) - JOIN fiche_def_ref - USING (frd_id) - ) - JOIN jnt_fic_att_value - USING (f_id) - ) - JOIN attr_value - USING (jft_id) - ) - WHERE (jnt_fic_att_value.ad_id = 17) - ) g - USING (f_id) - ) -LEFT JOIN ( - SELECT jnt_fic_att_value.jft_id - , fiche.f_id - , fiche_def.frd_id - , fiche.fd_id - , fiche_def.fd_class_base - , fiche_def.fd_label - , fiche_def.fd_create_account - , fiche_def_ref.frd_text - , fiche_def_ref.frd_class_base - , jnt_fic_att_value.ad_id - , attr_value.av_text - FROM ( - ( - ( - (fiche - JOIN fiche_def - USING (fd_id) - ) - JOIN fiche_def_ref - USING (frd_id) - ) - JOIN jnt_fic_att_value - USING (f_id) - ) - JOIN attr_value - USING (jft_id) - ) - WHERE (jnt_fic_att_value.ad_id = 18) - ) h - USING (f_id) -) -WHERE (a.frd_id = 8);- - - - - Index - Schema public @@ -7237,233 +5206,7 @@ WHERE (a.frd_id = 8); Function: - account_add( p_id public.poste_comptable, p_name character varying ) --Returns: void-Language: PLPGSQL- --declare - nParent tmp_pcmn.pcm_val_parent%type; - nCount integer; -begin - select count(*) into nCount from tmp_pcmn where pcm_val=p_id; - if nCount = 0 then - nParent=account_parent(p_id); - insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent) - values (p_id, p_name,nParent); - end if; -return; -end ; -- - - Function: - account_auto( p_fd_id integer ) --Returns: boolean-Language: PLPGSQL- --declare - l_auto bool; -begin - select fd_create_account into l_auto from fiche_def where fd_id=p_fd_id; - if l_auto is null then - l_auto:=false; - end if; - return l_auto; -end; -- - - Function: - account_compute( p_f_id integer ) --Returns: poste_comptable-Language: PLPGSQL- --declare - class_base poste_comptable; - maxcode int8; -begin - select fd_class_base into class_base - from - fiche_def join fiche using (fd_id) - where - f_id=p_f_id; - raise notice 'class base %',class_base; - select max(pcm_val) into maxcode from tmp_pcmn where pcm_val = class_base; - if maxcode = class_base then - maxcode=class_base*1000+1; - end if; - raise notice 'Max code %',maxcode; -return maxcode+1; -end; -- - - Function: - account_insert( p_f_id integer, p_account public.poste_comptable ) --Returns: integer-Language: PLPGSQL- --declare -nParent tmp_pcmn.pcm_val_parent%type; -sName varchar; -nNew tmp_pcmn.pcm_val%type; -bAuto bool; -nFd_id integer; -nCount integer; -begin - - if length(trim(p_account)) != 0 then - select * into nCount from tmp_pcmn where pcm_val=p_account; - if nCount !=0 then - select av_text into sName from - attr_value join jnt_fic_att_value using (jft_id) - where - ad_id=1 and f_id=p_f_id; - nParent:=account_parent(p_account); - insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) - values (p_account,sName,nParent); - attribut_insert(p_f_id,5,to_char(nNew,'999999999999')); - - end if; - else - select fd_id into nFd_id from fiche where f_id=p_f_id; - bAuto:= account_auto(nFd_id); - if bAuto = true then - nNew:=account_compute(p_f_id); -raise debug 'nNew %', nNew; - select av_text into sName from - attr_value join jnt_fic_att_value using (jft_id) - where - ad_id=1 and f_id=p_f_id; - nParent:=account_parent(nNew); - perform account_add (nNew,sName); - perform attribut_insert(p_f_id,5,to_char(nNew,'999999999999')); - - else - perform attribut_insert(p_f_id,5,null); - end if; - end if; - -return 0; -end; -- - - Function: - account_parent( p_account public.poste_comptable ) --Returns: poste_comptable-Language: PLPGSQL- --declare - nParent tmp_pcmn.pcm_val_parent%type; - sParent varchar; - nCount integer; -begin - sParent:=to_char(p_account,'9999999999999999'); - sParent:=trim(sParent); - nParent:=0; - while nParent = 0 loop - select count(*) into nCount - from tmp_pcmn - where - pcm_val = to_number(sParent,'9999999999999999'); - if nCount != 0 then - nParent:=to_number(sParent,'9999999999999999'); - end if; - sParent:= substr(sParent,1,length(sParent)-1); - if length(sParent) <= 0 then - raise exception 'Impossible de trouver le compte parent pour %',p_account; - end if; - end loop; - return nParent; -end; -- - - Function: - account_update( p_f_id integer, p_account public.poste_comptable ) --Returns: integer-Language: PLPGSQL- --declare -nMax fiche.f_id%type; -nCount integer; -nParent tmp_pcmn.pcm_val_parent%type; -sName varchar; -nJft_id attr_value.jft_id%type; -begin - - if length(trim(p_account)) != 0 then - select count(*) into nCount from tmp_pcmn where pcm_val=p_account; - if nCount = 0 then - select av_text into sName from - attr_value join jnt_fic_att_value using (jft_id) - where - ad_id=1 and f_id=p_f_id; - nParent:=fiche_account_parent(p_f_id); - insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_account,sName,nParent); - end if; - end if; - select jft_id into njft_id from jnt_fic_att_value where f_id=p_f_id and ad_id=5; - update attr_value set av_text=p_account where jft_id=njft_id; - -return njft_id; -end; -- - - Function: - attribut_insert( p_f_id integer, p_ad_id integer, p_value character varying ) --Returns: void-Language: PLPGSQL- -
-declare
- n_jft_id integer;
-begin
- select nextval('s_jnt_fic_att_value') into n_jft_id;
- insert into jnt_fic_att_value (jft_id,f_id,ad_id) values (n_jft_id,p_f_id,p_ad_id);
- insert into attr_value (jft_id,av_text) values (n_jft_id,p_value);
-return;
-end;
-
-
- - Function: - card_class_base( p_f_id integer ) --Returns: poste_comptable-Language: PLPGSQL- --declare - n_poste fiche_def.fd_class_base%type; -begin - select fd_class_base into n_poste from fiche_def join fiche using (fd_id) - where f_id=p_f_id; - if not FOUND then - raise exception 'Invalid fiche card_class_base(%)',p_f_id; - end if; -return; -end; -- - - Function: - check_balance( p_grpt integer ) + check_balance( p_internal text )Returns: numericLanguage: PLPGSQL@@ -7475,19 +5218,22 @@ declare amount_jrn numeric; begin select sum (j_montant) into amount_jrnx_credit - from jrnx + from jrnx join jrn on (j_grpt=jr_grpt_id) where - j_grpt=p_grpt + jr_internal=p_internal and j_debit=false; + select sum (j_montant) into amount_jrnx_debit - from jrnx + from jrnx join jrn on (j_grpt=jr_grpt_id) where - j_grpt=p_grpt + jr_internal=p_internal and j_debit=true; + select jr_montant into amount_jrn from jrn where - jr_grpt_id=p_grpt; + jr_internal=p_internal; + if ( amount_jrnx_debit != amount_jrnx_credit ) then return abs(amount_jrnx_debit-amount_jrnx_credit); @@ -7500,139 +5246,6 @@ begin end; -- Function: - fiche_account_parent( p_f_id integer ) --Returns: poste_comptable-Language: PLPGSQL- --declare -ret poste_comptable; -begin - select fd_class_base into ret from fiche_def join fiche using (fd_id) where f_id=p_f_id; - if not FOUND then - raise exception '% N''existe pas',p_f_id; - end if; - return ret; -end; -- - - Function: - insert_jrnx( p_date character varying, p_montant numeric, p_poste integer, p_grpt integer, p_jrn_def integer, p_debit boolean, p_tech_user text, p_tech_per integer, p_qcode text ) --Returns: void-Language: PLPGSQL- --declare - sCode varchar; - nCount_qcode integer; -begin - sCode=trim(p_qcode); - if length(sCode) = 0 or p_qcode is null then - select count(*) into nCount_qcode - from vw_poste_qcode where j_poste=p_poste; - if nCount_qcode = 1 then - select j_qcode into sCode - from vw_poste_qcode where j_poste=p_poste; - else - sCode=NULL; - end if; - - end if; - if p_montant = 0.0 then - return; - end if; - insert into jrnx - ( - j_date, - j_montant, - j_poste, - j_grpt, - j_jrn_def, - j_debit, - j_tech_user, - j_tech_per, - j_qcode - ) values - ( - to_date(p_date,'DD.MM.YYYY'), - p_montant, - p_poste, - p_grpt, - p_jrn_def, - p_debit, - p_tech_user, - p_tech_per, - sCode - ); -return; -end; -- - - Function: - insert_quant_sold( p_internal text, p_fiche character varying, p_quant integer, p_price numeric, p_vat numeric, p_vat_code integer, p_client character varying ) --Returns: void-Language: PLPGSQL- --declare - fid_client integer; - fid_good integer; -begin - select f_id into fid_client from - attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=p_client; - select f_id into fid_good from - attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=p_fiche; - insert into quant_sold - (qs_internal,qs_fiche,qs_quantite,qs_price,qs_vat,qs_vat_code,qs_client) - values - (p_internal,fid_good,p_quant,p_price,p_vat,p_vat_code,fid_client); - return; -end; -- - - Function: - insert_quick_code( nf_id integer, tav_text text ) --Returns: integer-Language: PLPGSQL- -
- declare
- ns integer;
- nExist integer;
- tText text;
- begin
- tText := upper(trim(tav_text));
- tText := replace(tText,' ','');
-
- loop
- select nextval('s_jnt_fic_att_value') into ns;
- if length (tText) = 0 or tText is null then
- tText := 'FID'||ns;
- end if;
- select count(*) into nExist
- from jnt_fic_att_value join attr_value using (jft_id)
- where
- ad_id=23 and av_text=upper(tText);
- if nExist = 0 then
- exit;
- end if;
- tText:='FID'||ns;
- end loop;
- insert into jnt_fic_att_value values (ns,nf_id,23);
- insert into attr_value values (ns,upper(tText));
- return ns;
- end;
-
-
Function:
plpgsql_validator( oid )
@@ -7652,244 +5265,19 @@ end;
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $act = new action($cn) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $act | ag_id = $_POST['ag_id'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $act | ag_id = $_POST['ag_id'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $act | ag_comment = $_POST['ag_comment'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $act | d_id = (isset($_POST['d_id']))?$_POST['d_id']:0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $act | ag_ref_ag_id = $_POST['ag_id'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $act | ag_ref_ag_id = $_POST['ag_id'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $act | f_id_dest = (isset($_POST['f_id_dest']))?$_POST['f_id_dest']:0 |
@@ -403,7 +403,7 @@ Referenced by action:
| act ag_id = $_POST['ag_id'] | +act ag_id = $_POST['ag_id'] |
Definition at line 159 of file action.inc.php.
-Referenced by Document::blank(), action::Display(), Document::get(), Document::Replace(), action::SaveStage2(), action::SaveStage3(), and action::Update(). +Referenced by Document::blank(), action::Display(), Document::get(), Document::Replace(), action::SaveStage2(), action::SaveStage3(), and action::Update().
@@ -457,7 +457,7 @@ Referenced by action:
| act ag_ref_ag_id = $_POST['ag_id'] | +act ag_ref_ag_id = $_POST['ag_id'] |
Definition at line 167 of file action.inc.php.
-Referenced by Document::blank(), action::Display(), Document::Document(), action::get(), action::myList(), Document::remove(), Document::SaveGenerated(), action::SaveStage3(), and action::Update(). +Referenced by Document::blank(), action::Display(), Document::Document(), action::get(), action::myList(), Document::remove(), Document::SaveGenerated(), action::SaveStage3(), and action::Update().
@@ -608,7 +608,7 @@ Referenced by Docum
Definition at line 162 of file action.inc.php.
-Referenced by action::Confirm(), action::Display(), Document::get(), action::get(), action::SaveStage2(), and action::Update().
+Referenced by action::Confirm(), action::Display(), Document::get(), action::get(), action::SaveStage2(), and action::Update().
@@ -725,7 +725,7 @@ Definition at line 340<
| doc md_id = (isset($_POST['gen_doc']))?$_POST['gen_doc']:0 | +doc md_id = (isset($_POST['gen_doc']))?$_POST['gen_doc']:0 |
-Referenced by ChangeStock(), cl_user::Check(), cl_user::cl_user(), action::Confirm(), EncodeFiche(), EncodeForm(), EncodeModele(), form_verify_input(), FormAchView(), FormFin(), FormODS(), FormVenteView(), Supplier::GetFromPoste(), Customer::GetFromPoste(), cl_user::GetGlobalPref(), rapport::GetName(), poste::GetName(), jrn::GetName(), fiche::insert(), cl_user::insert_default_global_pref(), widget::IOValue(), jrn_navigation_bar(), MakeListingVat(), new_fiche(), Cpdf::o_font(), Cpdf::openFont(), rapport::rapport(), RecordJrn(), Document_modele::Save(), save_upload_document(), action::SaveStage2(), Cpdf::selectFont(), ShowActionList(), ShowFormTransfert(), contact::Summary(), u_ShowMenuRecherche(), fiche::update(), UpdateJrn(), Document::Upload(), Customer::VatListing(), VerifData(), VerifImport(), ViewFiche(), and ViewImp(). +Referenced by ChangeStock(), cl_user::Check(), cl_user::cl_user(), action::Confirm(), EncodeFiche(), EncodeForm(), EncodeModele(), form_verify_input(), FormAchView(), FormFin(), FormODS(), FormVenteView(), Supplier::GetFromPoste(), Customer::GetFromPoste(), cl_user::GetGlobalPref(), rapport::GetName(), poste::GetName(), jrn::GetName(), fiche::insert(), cl_user::insert_default_global_pref(), widget::IOValue(), jrn_navigation_bar(), MakeListingVat(), new_fiche(), Cpdf::o_font(), Cpdf::openFont(), rapport::rapport(), RecordJrn(), Document_modele::Save(), save_upload_document(), action::SaveStage2(), Cpdf::selectFont(), ShowActionList(), ShowFormTransfert(), contact::Summary(), u_ShowMenuRecherche(), fiche::update(), UpdateJrn(), Document::Upload(), Customer::VatListing(), VerifData(), VerifImport(), ViewFiche(), and ViewImp().
@@ -797,7 +797,7 @@ Referenced by ChangeStoc
Definition at line 165 of file action.inc.php.
-Referenced by action::Display(), action::get(), and Document::Replace().
+Referenced by action::Display(), action::get(), and Document::Replace().
@@ -851,7 +851,7 @@ Referenced by action:
Definition at line 241 of file action.inc.php.
-Referenced by ChangeStock(), action::Confirm(), widget::debug(), fiche_def_ref::Display(), DisplayDetailModele(), EncodeFiche(), EncodeForm(), Cezpdf::ezTable(), FormFin(), FormODS(), FormVenteView(), jrn::GetDefLine(), fiche::insert(), cl_user::insert_default_global_pref(), widget::IOValue(), jrn_navigation_bar(), fiche_def_ref::LoadAll(), make_array(), new_fiche(), Cpdf::o_fontDescriptor(), Document::ParseDocument(), RecordJrn(), action::SaveStage2(), ShowActionList(), contact::Summary(), u_ShowMenuRecherche(), fiche::update(), cl_user::update_global_pref(), UpdateJrn(), VerifImport(), ViewFiche(), ViewImp(), and widget::widget().
+Referenced by ChangeStock(), action::Confirm(), widget::debug(), fiche_def_ref::Display(), DisplayDetailModele(), EncodeFiche(), EncodeForm(), Cezpdf::ezTable(), FormFin(), FormODS(), FormVenteView(), jrn::GetDefLine(), fiche::insert(), cl_user::insert_default_global_pref(), widget::IOValue(), jrn_navigation_bar(), fiche_def_ref::LoadAll(), make_array(), new_fiche(), Cpdf::o_fontDescriptor(), Document::ParseDocument(), RecordJrn(), action::SaveStage2(), ShowActionList(), contact::Summary(), u_ShowMenuRecherche(), fiche::update(), cl_user::update_global_pref(), UpdateJrn(), VerifImport(), ViewFiche(), ViewImp(), and widget::widget().
diff --git a/doc/developper/html/balance_8php.html b/doc/developper/html/balance_8php.html
index 5bdf9cb38..c67528d11 100644
--- a/doc/developper/html/balance_8php.html
+++ b/doc/developper/html/balance_8php.html
@@ -73,7 +73,7 @@ Definition in file balance.php
Definition at line 113 of file balance.php.
-Referenced by Cezpdf::alink(), Cpdf::ARC4(), fiche::blank(), Cezpdf::Cezpdf(), ComputeTotalVat(), ComputeVat(), action::Confirm(), fiche::CountByDef(), DbConnect(), fiche::Display(), action::Display(), Cpdf::ellipse(), GetDataJrnPdf(), GetFicheJrn(), getFicheNameCode(), rapport::GetName(), GetParent(), getPeriodeFromDate(), getPeriodeFromMonth(), getPeriodeName(), GetRappel(), jrn::GetRow(), Balance::GetRow(), GetTvaPoste(), GetUserProperty(), GetVersion(), isValid(), ListJrn(), make_array(), MakeListingVat(), Document_modele::myList(), RecordJrn(), ShowActionList(), Supplier::Summary(), Customer::Summary(), Cezpdf::uline(), UpdateFiche(), UpdateJrn(), and withStock().
+Referenced by Cezpdf::alink(), Cpdf::ARC4(), fiche::blank(), Cezpdf::Cezpdf(), ComputeTotalVat(), ComputeVat(), action::Confirm(), fiche::CountByDef(), DbConnect(), fiche::Display(), action::Display(), Cpdf::ellipse(), GetDataJrnPdf(), GetFicheJrn(), getFicheNameCode(), rapport::GetName(), GetParent(), getPeriodeFromDate(), getPeriodeFromMonth(), getPeriodeName(), GetRappel(), jrn::GetRow(), Balance::GetRow(), GetTvaPoste(), GetUserProperty(), GetVersion(), isValid(), ListJrn(), make_array(), MakeListingVat(), Document_modele::myList(), RecordJrn(), ShowActionList(), Supplier::Summary(), Customer::Summary(), Cezpdf::uline(), UpdateFiche(), UpdateJrn(), and withStock().
@@ -356,7 +356,7 @@ Definition at line 70 o
Definition at line 36 of file balance.php.
-Referenced by cl_user::AccessRequest(), AddFiche(), cl_user::Check(), action::Display(), ExecSql(), ExecuteScript(), FormAchInput(), FormAchView(), FormFin(), FormVenInput(), FormVenteView(), GetFicheJrn(), NoAccess(), Document::ParseDocument(), RecordFin(), RecordInvoice(), RecordODS(), RecordSell(), Document_modele::Save(), and TransferCSV().
+Referenced by cl_user::AccessRequest(), AddFiche(), cl_user::Check(), action::Display(), ExecSql(), ExecuteScript(), FormAchInput(), FormAchView(), FormFin(), FormVenInput(), FormVenteView(), GetFicheJrn(), NoAccess(), Document::ParseDocument(), RecordFin(), RecordInvoice(), RecordODS(), RecordSell(), Document_modele::Save(), and TransferCSV().
diff --git a/doc/developper/html/central__inc_8php.html b/doc/developper/html/central__inc_8php.html
index e1bdffa9f..fd2a84661 100644
--- a/doc/developper/html/central__inc_8php.html
+++ b/doc/developper/html/central__inc_8php.html
@@ -74,7 +74,7 @@ Met les donnees centralisees dans la table centralize.
Definition at line 36 of file central_inc.php.
-References $MaxJrn, $MaxLine, $Res, $Res2, $Ret, $row, $sql, Commit(), EndSql(), ExecSql(), and StartSql().
+References $MaxJrn, $MaxLine, $Res, $Res2, $Ret, $row, $sql, Commit(), EndSql(), ExecSql(), and StartSql().
Referenced by ShowMenuAdvanced().
Definition at line 192 of file check_priv.php.
-References $cn, $sql, CheckIsAdmin(), CountSql(), and DbConnect().
Definition at line 167 of file check_priv.php.
-References $cn, $sql, CountSql(), and DbConnect().
+References $cn, $sql, CountSql(), and DbConnect().
Referenced by CheckAction(), CheckDossier(), and CheckJrn().
Definition at line 46 of file check_priv.php.
-References $cn, $Res, $Res2, CheckIsAdmin(), CountSql(), DbConnect(), echo_debug(), and ExecSql().
+References $cn, $Res, $Res2, CheckIsAdmin(), CountSql(), DbConnect(), echo_debug(), and ExecSql().
Referenced by ShowMenuJrnUser().
Definition at line 53 of file class_balance.php.
-References $a, $array, $i, $M, $r, $Res, $sql, ExecSql(), GetPosteLibelle(), and label.
Definition at line 377 of file class.ezpdf.php.
-References $l, $num, $tmp, $w, Cpdf::addText(), Cpdf::closeObject(), ezPRVTpageNumberSearch(), Cpdf::getTextWidth(), Cpdf::reopenObject(), and size.
+References $l, $num, $tmp, $w, Cpdf::addText(), Cpdf::closeObject(), ezPRVTpageNumberSearch(), Cpdf::getTextWidth(), Cpdf::reopenObject(), and size.
Referenced by ezPRVTcleanUp().
Definition at line 1417 of file class.pdf.php.
-References $d, $data, $i, $list, $num, $tmp, extra, name, and width.
Definition at line 57 of file class_customer.php.
-References $Res, $row, $sql, ExecSql(), f_id, and name.
+References $Res, $row, $sql, ExecSql(), f_id, and name.
Referenced by VatListing().
Definition at line 195 of file class_customer.php.
-References $a, $bar, $e, $offset, $page, $r, $search, $url, fiche::CountByDef(), FormatString(), fiche::GetAll(), jrn_navigation_bar(), poste, and table.
Definition at line 84 of file class_customer.php.
-References $a_Res, $c, $customer, $e, $Res, $Res2, $sql, $t, ExecSql(), GetFromPoste(), and name.
References d_id.
-Referenced by SaveGenerated().
-Definition at line 334 of file class_document.php.
+Definition at line 344 of file class_document.php.
-References $r.
@@ -198,7 +198,7 @@ insert a minimal document and set the d_id
Definition at line 49 of file class_document.php.
-References $sql, ag_id, d_id, ExecSql(), and NextSequence().
Definition at line 79 of file class_document.php.
-References $Res, $ret, $row, Commit(), echo_debug(), ExecSql(), md_type, NextSequence(), ParseDocument(), SaveGenerated(), and StartSql().
@@ -345,23 +355,23 @@ Get complete all the data member thx info from the database.
-Definition at line 383 of file class_document.php.
+Definition at line 393 of file class_document.php.
-References $ret, $row, $sql, ag_id, and d_state.
@@ -401,16 +411,16 @@ Move a document from the table document into the concerned row the document is n
-Definition at line 741 of file class_document.php.
+Definition at line 751 of file class_document.php.
-References $sql, and ExecSql().
@@ -471,89 +481,89 @@ ParseDocument
-Definition at line 153 of file class_document.php.
+Definition at line 163 of file class_document.php.
-References $h, echo_debug(), exit, Replace(), and value.
+References $h, echo_debug(), exit, Replace(), and value.
-Referenced by Generate().
@@ -587,12 +597,12 @@ remove a row from the table document, the lob object is not deleted because can
-Definition at line 730 of file class_document.php.
+Definition at line 740 of file class_document.php.
-References $sql, d_id, and ExecSql().
@@ -639,296 +649,296 @@ replace the TAG by the real value, this value can be into the database or in $_P
-Definition at line 431 of file class_document.php.
+Definition at line 441 of file class_document.php.
-References $act, $my, $p, $poste, $qcode, $r, ag_id, break, fiche, GetTvaRate(), MY_COMMUNE, MY_CP, MY_FAX, MY_NAME, MY_NUMBER, MY_PAYS, MY_STREET, MY_TEL, MY_TVA, and qcode_dest.
+References $act, $my, $p, $poste, $qcode, $r, ag_id, break, fiche, GetTvaRate(), MY_COMMUNE, MY_CP, MY_FAX, MY_NAME, MY_NUMBER, MY_PAYS, MY_STREET, MY_TEL, MY_TVA, and qcode_dest.
-Referenced by ParseDocument().
@@ -964,7 +974,7 @@ Save save the state of the document.
Definition at line 63 of file class_document.php.
-References $sql, and ExecSql().
-Definition at line 246 of file class_document.php.
+Definition at line 256 of file class_document.php.
-References $doc, $sql, Commit(), d_id, Document(), echo_debug(), ExecSql(), GetSequence(), Rollback(), and StartSql().
+References $doc, $sql, Commit(), d_id, Document(), echo_debug(), ExecSql(), GetSequence(), Rollback(), and StartSql().
-Referenced by Generate().
@@ -1069,43 +1079,43 @@ Referenced by Gener
-Definition at line 345 of file class_document.php.
+Definition at line 355 of file class_document.php.
-References $file, $ret, $row, $tmp, Commit(), ExecSql(), and StartSql().
@@ -1141,57 +1151,57 @@ Upload
-Definition at line 279 of file class_document.php.
+Definition at line 289 of file class_document.php.
-References $old_oid, $r, $ret, $sql, Commit(), ExecSql(), name, Rollback(), and StartSql().
@@ -1204,7 +1214,7 @@ References $old_oid,
-action_gestion.ag_id (pk)
+action_gestion.ag_id (pk)
Definition at line 32 of file class_document.php.
Definition at line 179 of file class_document_modele.php.
-References $r, $res, $sql, Commit(), ExecSql(), and StartSql().
Definition at line 252 of file class_document_modele.php.
-References $h, $r, $start, $t, $w, dt_id, and make_array().
+References $h, $r, $start, $t, $w, dt_id, and make_array().
Referenced by myList().
Definition at line 49 of file class_document_modele.php.
-References $a, $all, $c, $r, $Res, $row, $sql, ExecSql(), form(), md_id, and md_name.
Definition at line 103 of file class_document_modele.php.
-References $old_oid, $r, $ret, $Ret, $sql, Commit(), echo_debug(), echo_error(), ExecSql(), exit, FormatString(), isNumber(), md_id, name, NextSequence(), Rollback(), start, and StartSql().
Definition at line 43 of file class_document_type.php.
-References $r, $sql, dt_id, and ExecSql().00036 {
00037 $sql="insert into centralized( c_j_id,
diff --git a/doc/developper/html/check__priv_8php.html b/doc/developper/html/check__priv_8php.html
index 996d41e1f..19ef3b44b 100644
--- a/doc/developper/html/check__priv_8php.html
+++ b/doc/developper/html/check__priv_8php.html
@@ -153,7 +153,7 @@ Check if an user has acces to a folder.
00193 {
+References $cn, $sql, CheckIsAdmin(), CountSql(), and DbConnect().
00193 {
00194 if ( CheckIsAdmin ($p_user) ) return 1;
00195 $cn=DbConnect();
00196 $sql="select dos_id from ac_users
@@ -213,7 +213,7 @@ Check if an user is an administrator.
00168 {
00169 if ( $p_user == 'phpcompta') return 1;
@@ -291,7 +291,7 @@ $p_user le login user
00047 {
00048 if ( CheckIsAdmin( $p_user) == 1 ) return 2;
diff --git a/doc/developper/html/classBalance.html b/doc/developper/html/classBalance.html
index 70473b6e3..41a80efd1 100644
--- a/doc/developper/html/classBalance.html
+++ b/doc/developper/html/classBalance.html
@@ -116,7 +116,7 @@ retrieve all the row from the ledger in the range of a periode
00053 {
+References $a, $array, $i, $M, $r, $Res, $sql, ExecSql(), GetPosteLibelle(), and label.
00053 {
00054 // compute periode
00055 if ( $p_from_periode==$p_to_periode ) {
00056 $per_sql=" j_tech_per = $p_from_periode ";
diff --git a/doc/developper/html/classCezpdf.html b/doc/developper/html/classCezpdf.html
index eca46a226..527ed1914 100644
--- a/doc/developper/html/classCezpdf.html
+++ b/doc/developper/html/classCezpdf.html
@@ -950,7 +950,7 @@ Referenced by ezTable(
00377 {
00378 // this will go through the pageNumbering array and add the page numbers are required
diff --git a/doc/developper/html/classCpdf.html b/doc/developper/html/classCpdf.html
index d20267350..e3d259da1 100644
--- a/doc/developper/html/classCpdf.html
+++ b/doc/developper/html/classCpdf.html
@@ -5524,7 +5524,7 @@ if the font is not loaded then load it and make the required object else just ma
01417 {
+References $d, $data, $i, $list, $num, $tmp, extra, name, and width.
01417 {
01418 if (!isset($this->fonts[$fontName])){
01419 // load the file
01420 $this->openFont($fontName);
diff --git a/doc/developper/html/classCustomer.html b/doc/developper/html/classCustomer.html
index ec5377d9b..97b65187a 100644
--- a/doc/developper/html/classCustomer.html
+++ b/doc/developper/html/classCustomer.html
@@ -129,7 +129,7 @@ Get all info contains in the view thanks to the poste elt (account).
00057 {
00058 $this->poste=($p_poste==0)?$this->poste:$p_poste;
@@ -139,7 +139,7 @@ Referenced by VatLi
00062 // There is only _one_ row by customer
00063 $row=pg_fetch_array($Res,0);
00064 $this->name=$row['name'];
-00065 $this->id=$row['f_id'];
+00065 $this->id=$row['f_id'];
00066 $this->street=$row['rue'];
00067 $this->cp=$row['code_postal'];
00068 $this->country=$row['pays'];
@@ -184,7 +184,7 @@ parm :
00196 {
+References $a, $bar, $e, $offset, $page, $r, $search, $url, fiche::CountByDef(), FormatString(), fiche::GetAll(), jrn_navigation_bar(), poste, and table.
00196 {
00197 $p_search=FormatString($p_search);
00198 $url=urlencode($_SERVER['REQUEST_URI']);
00199 $script=$_SERVER['SCRIPT_NAME'];
@@ -298,7 +298,7 @@ Get all the info for making a vat listing for the vat administration.
00084 {
+References $a_Res, $c, $customer, $e, $Res, $Res2, $sql, $t, ExecSql(), GetFromPoste(), and name.
00084 {
00085 $cond_sql=" and A.j_date = B.j_date
00086 and extract(year from A.j_date) ='$p_year'";
00087
diff --git a/doc/developper/html/classDocument.html b/doc/developper/html/classDocument.html
index f10068d8e..f1478a0e2 100644
--- a/doc/developper/html/classDocument.html
+++ b/doc/developper/html/classDocument.html
@@ -114,7 +114,7 @@ Definition at line
00043 {
+Referenced by SaveGenerated().
00043 {
00044 $this->db=$p_cn;
00045 $this->d_id=$p_d_id;
00046 }
@@ -154,15 +154,15 @@ a_ref
00335 {
-00336 if ( $this->d_id == 0 )
-00337 return '';
-00338 $r="";
-00339 $r='<A class="mtitle" HREF="show_document.php?d_id='.$this->d_id.'">Document</A>';
-00340 return $r;
-00341 }
+References $r.
00345 {
+00346 if ( $this->d_id == 0 )
+00347 return '';
+00348 $r="";
+00349 $r='<A class="mtitle" HREF="show_document.php?d_id='.$this->d_id.'">Document</A>';
+00350 return $r;
+00351 }
00050 {
+References $sql, ag_id, d_id, ExecSql(), and NextSequence().
00050 {
00051 $this->d_id=NextSequence($this->db,"document_d_id_seq");
00052 // affect a number
00053 $this->d_number=NextSequence($this->db,"seq_doc_type_".$this->md_type);
@@ -251,67 +251,77 @@ Generate the document, Call $this->Replace to replace tag by value.
00080 {
+References $Res, $ret, $row, Commit(), echo_debug(), ExecSql(), md_type, NextSequence(), ParseDocument(), SaveGenerated(), and StartSql().
00080 {
00081 // create a temp directory in /tmp to unpack file and to parse it
00082 $dirname=tempnam('/tmp','doc_');
-00083 echo $dirname;
-00084 unlink($dirname);
-00085 mkdir ($dirname);
-00086 echo_debug('class_action',__LINE__,"Dirname is $dirname");
-00087 // Retrieve the lob and save it into $dirname
-00088 StartSql($this->db);
-00089 $dm_info="select md_type,md_lob,md_filename,md_mimetype
-00090 from document_modele where md_id=".$this->md_id;
-00091 $Res=ExecSql($this->db,$dm_info);
-00092
-00093 $row=pg_fetch_array($Res,0);
-00094 $this->d_lob=$row['md_lob'];
-00095 $this->d_filename=$row['md_filename'];
-00096 $this->d_mimetype=$row['md_mimetype'];
-00097
-00098 echo_debug('class_document',__LINE__,"OID is ".$row['md_lob']);
-00100 chdir($dirname);
-00101 $filename=$row['md_filename'];
-00102 pg_lo_export($this->db,$row['md_lob'],$filename);
-00103 $type="n";
-00104 echo_debug('class_document',__LINE__,'The document type is '.$row['md_mimetype']);
-00105 // if the doc is a OOo, we need to unzip it first
-00106 // and the name of the file to change is always content.xml
-00107 if ( strpos($row['md_mimetype'],'vnd.oasis') != 0 )
-00108 {
-00109 echo_debug('class_document',__LINE__,'Unzip the OOo');
-00110 system("unzip ".$filename);
-00111 // Remove the file we do not need anymore
-00112 unlink($filename);
-00113 $file_to_parse="content.xml";
-00114 $type="OOo";
-00115 }
-00116 else
-00117 $file_to_parse=$filename;
-00118 // affect a number
-00119 $this->d_number=NextSequence($this->db,"seq_doc_type_".$row['md_type']);
-00120
-00121
-00122 // parse the document - return the doc number ?
-00123 $this->ParseDocument($dirname,$file_to_parse,$type);
-00124
-00125 Commit($this->db);
-00126 // if the doc is a OOo, we need to re-zip it
-00127 if ( strpos($row['md_mimetype'],'vnd.oasis') != 0 )
-00128 {
-00129 system ("zip -r ".$filename." *");
-00130 $file_to_parse=$filename;
-00131 }
-00132 // Create a directory
-00133 mkdir ($_SERVER['DOCUMENT_ROOT'].$dirname);
-00134
-00135 // we need to rename the new generated file
-00136 rename($dirname."/".$file_to_parse,$_SERVER['DOCUMENT_ROOT'].$dirname.'/'.$file_to_parse);
-00137 $ret=sprintf('<A HREF="%s">Document généré</A>',
-00138 $dirname.'/'.$file_to_parse);
-00139 $this->SaveGenerated($_SERVER['DOCUMENT_ROOT'].$dirname."/".$file_to_parse);
-00140 return $ret;
-00141 }
+00083
+00084
+00085 unlink($dirname);
+00086 mkdir ($dirname);
+00087 echo_debug('class_action',__LINE__,"Dirname is $dirname");
+00088 // Retrieve the lob and save it into $dirname
+00089 StartSql($this->db);
+00090 $dm_info="select md_type,md_lob,md_filename,md_mimetype
+00091 from document_modele where md_id=".$this->md_id;
+00092 $Res=ExecSql($this->db,$dm_info);
+00093
+00094 $row=pg_fetch_array($Res,0);
+00095 $this->d_lob=$row['md_lob'];
+00096 $this->d_filename=$row['md_filename'];
+00097 $this->d_mimetype=$row['md_mimetype'];
+00098
+00099 echo_debug('class_document',__LINE__,"OID is ".$row['md_lob']);
+00101 chdir($dirname);
+00102 $filename=$row['md_filename'];
+00103 pg_lo_export($this->db,$row['md_lob'],$filename);
+00104 $type="n";
+00105 echo_debug('class_document',__LINE__,'The document type is '.$row['md_mimetype']);
+00106 // if the doc is a OOo, we need to unzip it first
+00107 // and the name of the file to change is always content.xml
+00108 if ( strpos($row['md_mimetype'],'vnd.oasis') != 0 )
+00109 {
+00110 echo_debug('class_document',__LINE__,'Unzip the OOo');
+00111 echo '<span id="gen_msg">';
+00112 echo '<blink><font color="red">Un moment de patience, le document se prépare...</font></blink>';
+00113 echo '</span>';
+00114 ob_start();
+00115 system("unzip ".$filename);
+00116 // Remove the file we do not need anymore
+00117 unlink($filename);
+00118 ob_end_clean();
+00119 $file_to_parse="content.xml";
+00120 $type="OOo";
+00121 }
+00122 else
+00123 $file_to_parse=$filename;
+00124 // affect a number
+00125 $this->d_number=NextSequence($this->db,"seq_doc_type_".$row['md_type']);
+00126
+00127
+00128 // parse the document - return the doc number ?
+00129 $this->ParseDocument($dirname,$file_to_parse,$type);
+00130
+00131 Commit($this->db);
+00132 // if the doc is a OOo, we need to re-zip it
+00133 if ( strpos($row['md_mimetype'],'vnd.oasis') != 0 )
+00134 {
+00135 ob_start();
+00136 system ("zip -r ".$filename." *");
+00137 ob_end_clean();
+00138 echo "le document est prêt ";
+00139
+00140 $file_to_parse=$filename;
+00141 }
+00142 // Create a directory
+00143 mkdir ($_SERVER['DOCUMENT_ROOT'].$dirname);
+00144
+00145 // we need to rename the new generated file
+00146 rename($dirname."/".$file_to_parse,$_SERVER['DOCUMENT_ROOT'].$dirname.'/'.$file_to_parse);
+00147 $ret=sprintf('<A HREF="%s">Document généré</A>',
+00148 $dirname.'/'.$file_to_parse);
+00149 $this->SaveGenerated($_SERVER['DOCUMENT_ROOT'].$dirname."/".$file_to_parse);
+00150 return $ret;
+00151 }
00384 {
-00385 $sql="select * from document where d_id=".$this->d_id;
-00386 $ret=Exec($this->db,$sql);
-00387 if ( pg_num_rows($ret) == 0 )
-00388 return;
-00389 $row=pg_fetch_array($ret,0);
-00390 $this->ag_id=$row['ag_id'];
-00391 $this->d_mimetype=$row['d_mimetype'];
-00392 $this->d_filename=$row['d_filename'];
-00393 $this->d_lob=$row['d_lob'];
-00394 $this->d_number=$row[''];
-00395 $this->d_state=$row['ag_id'];
-00396 $this->d_number=$row['d_number'];
-00397
-00398 }
+References $ret, $row, $sql, ag_id, and d_state.
00394 {
+00395 $sql="select * from document where d_id=".$this->d_id;
+00396 $ret=Exec($this->db,$sql);
+00397 if ( pg_num_rows($ret) == 0 )
+00398 return;
+00399 $row=pg_fetch_array($ret,0);
+00400 $this->ag_id=$row['ag_id'];
+00401 $this->d_mimetype=$row['d_mimetype'];
+00402 $this->d_filename=$row['d_filename'];
+00403 $this->d_lob=$row['d_lob'];
+00404 $this->d_number=$row[''];
+00405 $this->d_state=$row['ag_id'];
+00406 $this->d_number=$row['d_number'];
+00407
+00408 }
00742 {
-00743
-00744 $sql=sprintf("update jrn set jr_pj=%s,jr_pj_name='%s',jr_pj_type='%s' where jr_internal='%s'",
-00745 $this->d_lob,$this->d_filename,$this->d_mimetype,$p_internal);
-00746 ExecSql($this->db,$sql);
-00747 // clean the table document
-00748 $this->remove();
-00749 }
+References $sql, and ExecSql().
00752 {
+00753
+00754 $sql=sprintf("update jrn set jr_pj=%s,jr_pj_name='%s',jr_pj_type='%s' where jr_internal='%s'",
+00755 $this->d_lob,$this->d_filename,$this->d_mimetype,$p_internal);
+00756 ExecSql($this->db,$sql);
+00757 // clean the table document
+00758 $this->remove();
+00759 }
00154 {
-00155
-00156 echo_debug('class_document',__LINE__,'Begin parsing of '.$p_dir.' '.$p_file.'Type = '.$p_type);
-00157
-00164 // open the document
-00165 $infile_name=$p_dir."/".$p_file;
-00166 echo_debug("class_document.php",__LINE__,"Open the document $p_dir/$p_file");
-00167 $h=fopen($infile_name,"r");
-00168 $output_name=tempnam($_SERVER["DOCUMENT_ROOT"]."/tmp","gen_doc_");
-00169 $output_file=fopen($output_name,"w+");
-00170 // check if the opening is sucessfull
-00171 if ( $h == false )
-00172 {
-00173 echo "cannot open $p_dir $p_file ";
-00174 exit();
-00175 }
-00176 if ( $output_file == false)
-00177 {
-00178 echo "ne peut pas ouvrir le fichier de sortie";
-00179 exit();
-00180 }
-00181 // compute the regex
-00182 if ( $p_type=='OOo')
-00183 {
-00184 $regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
-00185 $lt="<";
-00186 $gt=">";
-00187 }
-00188 else
-00189 {
-00190 $regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
-00191 $lt="<";
-00192 $gt=">";
-00193 }
-00194 //read the file
-00195 while(! feof($h))
-00196 {
-00197 // replace the tag
-00198 $buffer=fgets($h);
-00199 // search in the buffer the magic << and >>
-00200 // while ereg finds something to replace
-00201 while ( ereg ($regex,$buffer,$f) )
-00202 {
-00203
-00204 echo_debug('class_document',__LINE__,'var_export '.var_export( $f,true));
-00205 foreach ( $f as $pattern )
-00206 {
-00207 echo_debug('class_document',__LINE__, "pattern");
-00208 echo_debug('class_document',__LINE__, var_export($pattern,true));
-00209 $to_remove=$pattern;
-00210 // we remove the < and > from the pattern
-00211 $pattern=str_replace($lt,'',$pattern);
-00212 $pattern=str_replace($gt,'',$pattern);
+Referenced by Generate().
00164 {
+00165
+00166 echo_debug('class_document',__LINE__,'Begin parsing of '.$p_dir.' '.$p_file.'Type = '.$p_type);
+00167
+00174 // open the document
+00175 $infile_name=$p_dir."/".$p_file;
+00176 echo_debug("class_document.php",__LINE__,"Open the document $p_dir/$p_file");
+00177 $h=fopen($infile_name,"r");
+00178 $output_name=tempnam($_SERVER["DOCUMENT_ROOT"]."/tmp","gen_doc_");
+00179 $output_file=fopen($output_name,"w+");
+00180 // check if the opening is sucessfull
+00181 if ( $h == false )
+00182 {
+00183 echo "cannot open $p_dir $p_file ";
+00184 exit();
+00185 }
+00186 if ( $output_file == false)
+00187 {
+00188 echo "ne peut pas ouvrir le fichier de sortie";
+00189 exit();
+00190 }
+00191 // compute the regex
+00192 if ( $p_type=='OOo')
+00193 {
+00194 $regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
+00195 $lt="<";
+00196 $gt=">";
+00197 }
+00198 else
+00199 {
+00200 $regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
+00201 $lt="<";
+00202 $gt=">";
+00203 }
+00204 //read the file
+00205 while(! feof($h))
+00206 {
+00207 // replace the tag
+00208 $buffer=fgets($h);
+00209 // search in the buffer the magic << and >>
+00210 // while ereg finds something to replace
+00211 while ( ereg ($regex,$buffer,$f) )
+00212 {
00213
-00214
-00215 // if the pattern if found we replace it
-00216 $value=$this->Replace($pattern);
-00217 // replace into the $buffer
-00218 // take the position in the buffer
-00219 $pos=strpos($buffer,$to_remove);
-00220 // get the length of the string to remove
-00221 $len=strlen($to_remove);
-00222 $buffer=substr_replace($buffer,$value,$pos,$len);
+00214 echo_debug('class_document',__LINE__,'var_export '.var_export( $f,true));
+00215 foreach ( $f as $pattern )
+00216 {
+00217 echo_debug('class_document',__LINE__, "pattern");
+00218 echo_debug('class_document',__LINE__, var_export($pattern,true));
+00219 $to_remove=$pattern;
+00220 // we remove the < and > from the pattern
+00221 $pattern=str_replace($lt,'',$pattern);
+00222 $pattern=str_replace($gt,'',$pattern);
00223
-00224 // echo_debug('class_document',__LINE__, $buffer);
+00224
00225 // if the pattern if found we replace it
-00226 echo_debug('class_document',__LINE__,"Transform $pattern by $value");
-00227 }
-00228 }
-00229 // write into the output_file
-00230 fwrite($output_file,$buffer);
-00231
-00232 }
-00233 fclose($h);
-00234 fclose($output_file);
-00235 rename ($output_name,$infile_name);
-00236 // Save the document into the database
-00237
-00238 }
+00226 $value=$this->Replace($pattern);
+00227 // replace into the $buffer
+00228 // take the position in the buffer
+00229 $pos=strpos($buffer,$to_remove);
+00230 // get the length of the string to remove
+00231 $len=strlen($to_remove);
+00232 $buffer=substr_replace($buffer,$value,$pos,$len);
+00233
+00234 // echo_debug('class_document',__LINE__, $buffer);
+00235 // if the pattern if found we replace it
+00236 echo_debug('class_document',__LINE__,"Transform $pattern by $value");
+00237 }
+00238 }
+00239 // write into the output_file
+00240 fwrite($output_file,$buffer);
+00241
+00242 }
+00243 fclose($h);
+00244 fclose($output_file);
+00245 rename ($output_name,$infile_name);
+00246 // Save the document into the database
+00247
+00248 }
00731 {
-00732 $sql='delete from document where d_id='.$this->d_id;
-00733 ExecSql($this->db,$sql);
-00734 }
+References $sql, d_id, and ExecSql().
00741 {
+00742 $sql='delete from document where d_id='.$this->d_id;
+00743 ExecSql($this->db,$sql);
+00744 }
00432 {
-00433 $r="Tag inconnu";
-00434 static $counter=0;
-00435 switch ($p_tag)
-00436 {
-00437 case 'DATE':
-00438 $r=' Date inconnue ';
-00439 // Date are in $_REQUEST['ag_date']
-00440 // or $_POST['e_date']
-00441 if ( isset ($_REQUEST['ag_date']))
-00442 $r=$_REQUEST['ag_date'];
-00443 if ( isset ($_REQUEST['e_date']))
-00444 $r=$_REQUEST['e_date'];
-00445
-00446 break;
-00447 //
-00448 // the company priv
-00449
-00450 case 'MY_NAME':
-00451 $my=new own($this->db);
-00452 $r=$my->MY_NAME;
-00453 break;
-00454 case 'MY_CP':
-00455 $my=new own($this->db);
-00456 $r=$my->MY_CP;
-00457 break;
-00458 case 'MY_COMMUNE':
-00459 $my=new own($this->db);
-00460 $r=$my->MY_COMMUNE;
-00461 break;
-00462 case 'MY_TVA':
-00463 $my=new own($this->db);
-00464 $r=$my->MY_TVA;
-00465 break;
-00466 case 'MY_STREET':
-00467 $my=new own($this->db);
-00468 $r=$my->MY_STREET;
-00469 break;
-00470 case 'MY_NUMBER':
-00471 $my=new own($this->db);
-00472 $r=$my->MY_NUMBER;
-00473 break;
-00474 case 'MY_TEL':
-00475 $my=new own($this->db);
-00476 $r=$my->MY_TEL;
-00477 break;
-00478 case 'MY_FAX':
-00479 $my=new own($this->db);
-00480 $r=$my->MY_FAX;
-00481 break;
-00482 case 'MY_PAYS':
-00483 $my=new own($this->db);
-00484 $r=$my->MY_PAYS;
-00485 break;
-00486
-00487 // customer
-00488 /*\note The CUST_* are retrieved thx the $_REQUEST['tiers']
-00489 * which contains the quick_code
-00490 */
-00491 case 'SOLDE':
-00492 $tiers=new fiche($this->db);
-00493 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00494 $tiers->Getbyqcode($qcode,false);
-00495 $p=$tiers->strAttribut(ATTR_DEF_ACCOUNT);
-00496 $poste=new Poste($this->db,$p);
-00497 $r=$poste->GetSolde(' true' );
-00498 break;
-00499 case 'CUST_NAME':
-00500 $tiers=new fiche($this->db);
-00501 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00502 $tiers->getByQcode($qcode,false);
-00503 $r=$tiers->strAttribut(ATTR_DEF_NAME);
-00504 break;
-00505 case 'CUST_ADDR_1':
-00506 $tiers=new fiche($this->db);
-00507 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00508 $tiers->getByQcode($qcode,false);
-00509 $r=$tiers->strAttribut(ATTR_DEF_ADRESS);
-00510
-00511 break ;
-00512 case 'CUST_CP':
-00513 $tiers=new fiche($this->db);
-00514 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00515 $tiers->getByQcode($qcode,false);
-00516 $r=$tiers->strAttribut(ATTR_DEF_CP);
-00517
-00518 break;
-00519 case 'CUST_CO':
-00520 $tiers=new fiche($this->db);
-00521 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00522 $tiers->getByQcode($qcode,false);
-00523 $r=$tiers->strAttribut(ATTR_DEF_PAYS);
-00524
-00525 break;
-00526 case 'CUST_VAT':
-00527 $tiers=new fiche($this->db);
-00528 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00529 $tiers->getByQcode($qcode,false);
-00530 $r=$tiers->strAttribut(ATTR_DEF_NUMTVA);
-00531 break;
-00532 // Marchandise in $_POST['e_march*']
-00533 // \see user_form_achat.php or user_form_ven.php
-00534 case 'NUMBER':
-00535 $r=$this->d_number;
-00536 break;
-00537 case 'REFERENCE':
-00538 $act=new action($this->db);
-00539 $act->ag_id=$this->ag_id;
-00540 $act->get();
-00541 $r=$act->ag_ref;
-00542 break;
-00543
-00544 /*
-00545 * - [VEN_ART_NAME]
-00546 * - [VEN_ART_PRICE]
-00547 * - [VEN_ART_QUANT]
-00548 * - [VEN_ART_TVA_CODE]
-00549 * - [VEN_ART_TVA_AMOUNT]
-00550 * - [VEN_ART_STOCK_CODE]
-00551 * - [VEN_HTVA]
-00552 * - [VEN_TVAC]
-00553 * - [VEN_TVA]
-00554 * - [TOTAL_VEN_HTVA]
-00555 */
-00556 case 'MARCH_NEXT':
-00557 $counter++;
-00558 $r='';
-00559 break;
-00560
-00561 case 'VEN_ART_NAME':
-00562 extract ($_POST);
-00563 $id='e_march'.$counter;
-00564 // check if the march exists
-00565 if ( ! isset (${$id})) return "";
-00566 // check that something is sold
-00567 if ( ${'e_march'.$counter.'_sell'} != 0 && ${'e_quant'.$counter} != 0 )
-00568 {
-00569 $f=new fiche($this->db);
-00570 $f->GetByQCode(${$id},false);
-00571 $r=$f->strAttribut(ATTR_DEF_NAME);
-00572 } else $r = "";
-00573 break;
-00574
-00575 case 'VEN_ART_PRICE':
-00576 extract ($_POST);
-00577 $id='e_march'.$counter.'_sell' ;
-00578 if ( !isset (${$id}) ) return "";
-00579 $r=${$id};
-00580 break;
-00581
-00582 case 'TVA_CODE':
-00583 extract ($_POST);
-00584 $id='e_march'.$counter.'_tva_id';
-00585 if ( !isset (${$id}) ) return "";
-00586 if ( ${$id} == -1 ) return "";
-00587 $qt='e_quant'.$counter;
-00588 $price='e_march'.$counter.'_sell' ;
-00589 if ( ${$price} == 0 || ${$qt} == 0
-00590 || strlen(trim( $price )) ==0
-00591 || strlen(trim($qt)) ==0)
-00592 return "";
-00593
-00594 $r=${$id};
-00595 break;
-00596
-00597 case 'TVA_LABEL':
-00598 extract ($_POST);
-00599 $id='e_march'.$counter.'_tva_id';
-00600 if ( !isset (${$id}) ) return "";
-00601 $tva=GetTvaRate($this->db,${$id});
-00602 if ( $tva == null || $tva==0 ) return "";
-00603 $r=$tva['tva_label'];
-00604 break;
-00605
+Referenced by ParseDocument().
00442 {
+00443 $r="Tag inconnu";
+00444 static $counter=0;
+00445 switch ($p_tag)
+00446 {
+00447 case 'DATE':
+00448 $r=' Date inconnue ';
+00449 // Date are in $_REQUEST['ag_date']
+00450 // or $_POST['e_date']
+00451 if ( isset ($_REQUEST['ag_date']))
+00452 $r=$_REQUEST['ag_date'];
+00453 if ( isset ($_REQUEST['e_date']))
+00454 $r=$_REQUEST['e_date'];
+00455
+00456 break;
+00457 //
+00458 // the company priv
+00459
+00460 case 'MY_NAME':
+00461 $my=new own($this->db);
+00462 $r=$my->MY_NAME;
+00463 break;
+00464 case 'MY_CP':
+00465 $my=new own($this->db);
+00466 $r=$my->MY_CP;
+00467 break;
+00468 case 'MY_COMMUNE':
+00469 $my=new own($this->db);
+00470 $r=$my->MY_COMMUNE;
+00471 break;
+00472 case 'MY_TVA':
+00473 $my=new own($this->db);
+00474 $r=$my->MY_TVA;
+00475 break;
+00476 case 'MY_STREET':
+00477 $my=new own($this->db);
+00478 $r=$my->MY_STREET;
+00479 break;
+00480 case 'MY_NUMBER':
+00481 $my=new own($this->db);
+00482 $r=$my->MY_NUMBER;
+00483 break;
+00484 case 'MY_TEL':
+00485 $my=new own($this->db);
+00486 $r=$my->MY_TEL;
+00487 break;
+00488 case 'MY_FAX':
+00489 $my=new own($this->db);
+00490 $r=$my->MY_FAX;
+00491 break;
+00492 case 'MY_PAYS':
+00493 $my=new own($this->db);
+00494 $r=$my->MY_PAYS;
+00495 break;
+00496
+00497 // customer
+00498 /*\note The CUST_* are retrieved thx the $_REQUEST['tiers']
+00499 * which contains the quick_code
+00500 */
+00501 case 'SOLDE':
+00502 $tiers=new fiche($this->db);
+00503 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00504 $tiers->Getbyqcode($qcode,false);
+00505 $p=$tiers->strAttribut(ATTR_DEF_ACCOUNT);
+00506 $poste=new Poste($this->db,$p);
+00507 $r=$poste->GetSolde(' true' );
+00508 break;
+00509 case 'CUST_NAME':
+00510 $tiers=new fiche($this->db);
+00511 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00512 $tiers->getByQcode($qcode,false);
+00513 $r=$tiers->strAttribut(ATTR_DEF_NAME);
+00514 break;
+00515 case 'CUST_ADDR_1':
+00516 $tiers=new fiche($this->db);
+00517 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00518 $tiers->getByQcode($qcode,false);
+00519 $r=$tiers->strAttribut(ATTR_DEF_ADRESS);
+00520
+00521 break ;
+00522 case 'CUST_CP':
+00523 $tiers=new fiche($this->db);
+00524 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00525 $tiers->getByQcode($qcode,false);
+00526 $r=$tiers->strAttribut(ATTR_DEF_CP);
+00527
+00528 break;
+00529 case 'CUST_CO':
+00530 $tiers=new fiche($this->db);
+00531 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00532 $tiers->getByQcode($qcode,false);
+00533 $r=$tiers->strAttribut(ATTR_DEF_PAYS);
+00534
+00535 break;
+00536 case 'CUST_VAT':
+00537 $tiers=new fiche($this->db);
+00538 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00539 $tiers->getByQcode($qcode,false);
+00540 $r=$tiers->strAttribut(ATTR_DEF_NUMTVA);
+00541 break;
+00542 // Marchandise in $_POST['e_march*']
+00543 // \see user_form_achat.php or user_form_ven.php
+00544 case 'NUMBER':
+00545 $r=$this->d_number;
+00546 break;
+00547 case 'REFERENCE':
+00548 $act=new action($this->db);
+00549 $act->ag_id=$this->ag_id;
+00550 $act->get();
+00551 $r=$act->ag_ref;
+00552 break;
+00553
+00554 /*
+00555 * - [VEN_ART_NAME]
+00556 * - [VEN_ART_PRICE]
+00557 * - [VEN_ART_QUANT]
+00558 * - [VEN_ART_TVA_CODE]
+00559 * - [VEN_ART_TVA_AMOUNT]
+00560 * - [VEN_ART_STOCK_CODE]
+00561 * - [VEN_HTVA]
+00562 * - [VEN_TVAC]
+00563 * - [VEN_TVA]
+00564 * - [TOTAL_VEN_HTVA]
+00565 */
+00566 case 'MARCH_NEXT':
+00567 $counter++;
+00568 $r='';
+00569 break;
+00570
+00571 case 'VEN_ART_NAME':
+00572 extract ($_POST);
+00573 $id='e_march'.$counter;
+00574 // check if the march exists
+00575 if ( ! isset (${$id})) return "";
+00576 // check that something is sold
+00577 if ( ${'e_march'.$counter.'_sell'} != 0 && ${'e_quant'.$counter} != 0 )
+00578 {
+00579 $f=new fiche($this->db);
+00580 $f->GetByQCode(${$id},false);
+00581 $r=$f->strAttribut(ATTR_DEF_NAME);
+00582 } else $r = "";
+00583 break;
+00584
+00585 case 'VEN_ART_PRICE':
+00586 extract ($_POST);
+00587 $id='e_march'.$counter.'_sell' ;
+00588 if ( !isset (${$id}) ) return "";
+00589 $r=${$id};
+00590 break;
+00591
+00592 case 'TVA_CODE':
+00593 extract ($_POST);
+00594 $id='e_march'.$counter.'_tva_id';
+00595 if ( !isset (${$id}) ) return "";
+00596 if ( ${$id} == -1 ) return "";
+00597 $qt='e_quant'.$counter;
+00598 $price='e_march'.$counter.'_sell' ;
+00599 if ( ${$price} == 0 || ${$qt} == 0
+00600 || strlen(trim( $price )) ==0
+00601 || strlen(trim($qt)) ==0)
+00602 return "";
+00603
+00604 $r=${$id};
+00605 break;
00606
-00607 case 'TVA_AMOUNT':
+00607 case 'TVA_LABEL':
00608 extract ($_POST);
-00609 $qt='e_quant'.$counter;
-00610 $price='e_march'.$counter.'_sell' ;
-00611 $tva='e_march'.$counter.'_tva_id';
-00612 if ( !isset (${'e_march'.$counter}) ) return "";
-00613 // check that something is sold
-00614 if ( ${$price} == 0 || ${$qt} == 0
-00615 || strlen(trim( $price )) ==0
-00616 || strlen(trim($qt)) ==0)
-00617 return "";
-00618 $a_tva=GetTvaRate($this->db,${$tva});
-00619 echo_debug('class_document',__LINE__,'Tva :'.var_export($a_tva,true));
-00620 // if no vat returns 0
-00621 if ( sizeof($a_tva) == 0 ) return "";
-00622 $r=round(${$price},2)*${$qt}*$a_tva['tva_rate'];
-00623 $r=round($r,2);
-00624 break;
-00625
-00626 case 'VEN_ART_QUANT':
-00627 extract ($_POST);
-00628 $id='e_quant'.$counter;
-00629 if ( !isset (${$id}) ) return "";
-00630 // check that something is sold
-00631 if ( ${'e_march'.$counter.'_sell'} == 0
-00632 || ${'e_quant'.$counter} == 0
-00633 || strlen(trim( ${'e_march'.$counter.'_sell'} )) ==0
-00634 || strlen(trim(${'e_quant'.$counter})) ==0 )
-00635 return "";
-00636 $r=${$id};
-00637 break;
-00638
-00639 case 'VEN_HTVA':
-00640 extract ($_POST);
-00641 $id='e_march'.$counter.'_sell' ;
-00642 $quant='e_quant'.$counter;
-00643 if ( !isset (${$id}) ) return "";
-00644
-00645 // check that something is sold
-00646 if ( ${'e_march'.$counter.'_sell'} == 0 || ${'e_quant'.$counter} == 0
-00647 || strlen(trim( ${'e_march'.$counter.'_sell'} )) ==0
-00648 || strlen(trim(${'e_quant'.$counter})) ==0)
-00649 return "";
-00655 $r=round(${$id}*${$quant},2);
-00656 break;
-00657
-00658 case 'VEN_TVAC':
-00659 extract ($_POST);
-00660 $id='e_march'.$counter.'_sell' ;
-00661 $quant='e_quant'.$counter;
-00662 // if it is exist
-00663 if ( ! isset(${$id}))
-00664 return "";
-00665 // check that something is sold
-00666 if ( ${'e_march'.$counter.'_sell'} == 0 || ${'e_quant'.$counter} == 0 )
-00667 return "";
-00672 $r=${$id}*${$quant};
-00673 $tva=GetTvaRate($this->db,${'e_march'.$counter.'_tva_id'});
-00674 // if there is no vat we return now
-00675 if ( $tva == null || $tva == 0 ) return $r;
-00676 // we compute with the vat included
-00677 $r=$r+$r*$tva['tva_rate'];
-00678 $r=round($r,2);
-00679 break;
-00680 case 'TOTAL_VEN_HTVA':
-00681 extract($_POST);
-00682 echo_debug('class_document',__LINE__,'TOTAL_VEN_TVA item :'.$nb_item);
-00683
-00684 $sum=0.0;
-00685 for ($i=0;$i<$nb_item;$i++)
-00686 {
-00687 $sell='e_march'.$i.'_sell';
-00688 $qt='e_quant'.$i;
-00689 echo_debug('class_document',__LINE__,'sell :'.$sell.' qt = '.$qt);
-00690
-00691 echo_debug('class_document',__LINE__,'counter :'.$i.' sur '.$nb_item);
-00692 if ( ! isset (${$sell}) ) break;
-00693 echo_debug('class_document',__LINE__,'sell :'.${$sell}.' qt = '.${$qt});
-00694
-00695 if ( strlen(trim(${$sell})) == 0 ||
-00696 strlen(trim(${$qt})) == 0 ||
-00697 ${$qt}==0 || ${$sell}==0)
-00698 continue;
-00699 $sum+=${$sell}*${$qt};
-00700 echo_debug('class_document',__LINE__,'sum :'.$sum);
-00701
-00702 }
-00703 $r=round($sum,2);
-00704 break;
-00705 case 'TOTAL_VEN_TVAC':
-00706 extract($_POST);
-00707 $sum=0.0;
-00708 for ($i=0;$i<$nb_item;$i++)
-00709 {
-00710 $tva=GetTvaRate($this->db,${'e_march'.$i.'_tva_id'});
-00711 $tva_rate=( $tva == null || $tva == 0 )?0.0:$tva['tva_rate'];
-00712 echo_debug('class_document',__LINE__,' :'.$i.' sur '.$nb_item);
-00713 $sell=${'e_march'.$i.'_sell'};
-00714 $qt=${'e_quant'.$i};
-00715 echo_debug('class_document',__LINE__,'sell :'.$sell.' qt = '.$qt);
-00716
-00717 $sum+=$sell*$qt*(1+$tva_rate);
-00718 // $sum+=${'e_march'.$i.'_sell'}*${'e_quant'.$i}*(1+$tva_rate);
-00719 }
-00720 $r=round($sum,2);
-00721
-00722 break;
-00723
-00724 }
-00725 return $r;
-00726 }
+00609 $id='e_march'.$counter.'_tva_id';
+00610 if ( !isset (${$id}) ) return "";
+00611 $tva=GetTvaRate($this->db,${$id});
+00612 if ( $tva == null || $tva==0 ) return "";
+00613 $r=$tva['tva_label'];
+00614 break;
+00615
+00616
+00617 case 'TVA_AMOUNT':
+00618 extract ($_POST);
+00619 $qt='e_quant'.$counter;
+00620 $price='e_march'.$counter.'_sell' ;
+00621 $tva='e_march'.$counter.'_tva_id';
+00622 if ( !isset (${'e_march'.$counter}) ) return "";
+00623 // check that something is sold
+00624 if ( ${$price} == 0 || ${$qt} == 0
+00625 || strlen(trim( $price )) ==0
+00626 || strlen(trim($qt)) ==0)
+00627 return "";
+00628 $a_tva=GetTvaRate($this->db,${$tva});
+00629 echo_debug('class_document',__LINE__,'Tva :'.var_export($a_tva,true));
+00630 // if no vat returns 0
+00631 if ( sizeof($a_tva) == 0 ) return "";
+00632 $r=round(${$price},2)*${$qt}*$a_tva['tva_rate'];
+00633 $r=round($r,2);
+00634 break;
+00635
+00636 case 'VEN_ART_QUANT':
+00637 extract ($_POST);
+00638 $id='e_quant'.$counter;
+00639 if ( !isset (${$id}) ) return "";
+00640 // check that something is sold
+00641 if ( ${'e_march'.$counter.'_sell'} == 0
+00642 || ${'e_quant'.$counter} == 0
+00643 || strlen(trim( ${'e_march'.$counter.'_sell'} )) ==0
+00644 || strlen(trim(${'e_quant'.$counter})) ==0 )
+00645 return "";
+00646 $r=${$id};
+00647 break;
+00648
+00649 case 'VEN_HTVA':
+00650 extract ($_POST);
+00651 $id='e_march'.$counter.'_sell' ;
+00652 $quant='e_quant'.$counter;
+00653 if ( !isset (${$id}) ) return "";
+00654
+00655 // check that something is sold
+00656 if ( ${'e_march'.$counter.'_sell'} == 0 || ${'e_quant'.$counter} == 0
+00657 || strlen(trim( ${'e_march'.$counter.'_sell'} )) ==0
+00658 || strlen(trim(${'e_quant'.$counter})) ==0)
+00659 return "";
+00665 $r=round(${$id}*${$quant},2);
+00666 break;
+00667
+00668 case 'VEN_TVAC':
+00669 extract ($_POST);
+00670 $id='e_march'.$counter.'_sell' ;
+00671 $quant='e_quant'.$counter;
+00672 // if it is exist
+00673 if ( ! isset(${$id}))
+00674 return "";
+00675 // check that something is sold
+00676 if ( ${'e_march'.$counter.'_sell'} == 0 || ${'e_quant'.$counter} == 0 )
+00677 return "";
+00682 $r=${$id}*${$quant};
+00683 $tva=GetTvaRate($this->db,${'e_march'.$counter.'_tva_id'});
+00684 // if there is no vat we return now
+00685 if ( $tva == null || $tva == 0 ) return $r;
+00686 // we compute with the vat included
+00687 $r=$r+$r*$tva['tva_rate'];
+00688 $r=round($r,2);
+00689 break;
+00690 case 'TOTAL_VEN_HTVA':
+00691 extract($_POST);
+00692 echo_debug('class_document',__LINE__,'TOTAL_VEN_TVA item :'.$nb_item);
+00693
+00694 $sum=0.0;
+00695 for ($i=0;$i<$nb_item;$i++)
+00696 {
+00697 $sell='e_march'.$i.'_sell';
+00698 $qt='e_quant'.$i;
+00699 echo_debug('class_document',__LINE__,'sell :'.$sell.' qt = '.$qt);
+00700
+00701 echo_debug('class_document',__LINE__,'counter :'.$i.' sur '.$nb_item);
+00702 if ( ! isset (${$sell}) ) break;
+00703 echo_debug('class_document',__LINE__,'sell :'.${$sell}.' qt = '.${$qt});
+00704
+00705 if ( strlen(trim(${$sell})) == 0 ||
+00706 strlen(trim(${$qt})) == 0 ||
+00707 ${$qt}==0 || ${$sell}==0)
+00708 continue;
+00709 $sum+=${$sell}*${$qt};
+00710 echo_debug('class_document',__LINE__,'sum :'.$sum);
+00711
+00712 }
+00713 $r=round($sum,2);
+00714 break;
+00715 case 'TOTAL_VEN_TVAC':
+00716 extract($_POST);
+00717 $sum=0.0;
+00718 for ($i=0;$i<$nb_item;$i++)
+00719 {
+00720 $tva=GetTvaRate($this->db,${'e_march'.$i.'_tva_id'});
+00721 $tva_rate=( $tva == null || $tva == 0 )?0.0:$tva['tva_rate'];
+00722 echo_debug('class_document',__LINE__,' :'.$i.' sur '.$nb_item);
+00723 $sell=${'e_march'.$i.'_sell'};
+00724 $qt=${'e_quant'.$i};
+00725 echo_debug('class_document',__LINE__,'sell :'.$sell.' qt = '.$qt);
+00726
+00727 $sum+=$sell*$qt*(1+$tva_rate);
+00728 // $sum+=${'e_march'.$i.'_sell'}*${'e_quant'.$i}*(1+$tva_rate);
+00729 }
+00730 $r=round($sum,2);
+00731
+00732 break;
+00733
+00734 }
+00735 return $r;
+00736 }
00064 {
+References $sql, and ExecSql().
00064 {
00065 $sql="update document set d_state=".$this->d_state.
00066 " where d_id=".$this->d_id;
00067 ExecSql($this->db,$sql);
@@ -1009,35 +1019,35 @@ SaveGenerated
00247 {
-00248 echo_debug('class_document',__LINE__,'Save generated');
-00249 // We save the generated file
-00250 $doc=new Document($this->db);
-00251 StartSql($this->db);
-00252 $this->d_lob=pg_lo_import($this->db,$p_file);
-00253 if ( $this->d_lob == false ) {
-00254 Rollback($this->db); echo_debug('class_document',__LINE__,"can't save file $p_file");
-00255 return 1; }
-00256
-00257 $sql=sprintf("insert into document(ag_id,d_lob,d_number,d_filename,d_mimetype,d_state)
-00258 values (%d,%s,%d,'%s','%s',%d)",
-00259 $this->ag_id,
-00260 $this->d_lob,
-00261 $this->d_number,
-00262 $this->d_filename,
-00263 $this->d_mimetype,
-00264 $this->d_state
-00265 );
-00266 ExecSql($this->db,$sql);
-00267 $this->d_id=GetSequence($this->db,"document_d_id_seq");
-00268 echo_debug('class_document',__LINE__,'document sauvé : d_id'.$this->d_id);
-00269 Commit($this->db);
-00270 return 0;
-00271 }
+Referenced by Generate().
00257 {
+00258 echo_debug('class_document',__LINE__,'Save generated');
+00259 // We save the generated file
+00260 $doc=new Document($this->db);
+00261 StartSql($this->db);
+00262 $this->d_lob=pg_lo_import($this->db,$p_file);
+00263 if ( $this->d_lob == false ) {
+00264 Rollback($this->db); echo_debug('class_document',__LINE__,"can't save file $p_file");
+00265 return 1; }
+00266
+00267 $sql=sprintf("insert into document(ag_id,d_lob,d_number,d_filename,d_mimetype,d_state)
+00268 values (%d,%s,%d,'%s','%s',%d)",
+00269 $this->ag_id,
+00270 $this->d_lob,
+00271 $this->d_number,
+00272 $this->d_filename,
+00273 $this->d_mimetype,
+00274 $this->d_state
+00275 );
+00276 ExecSql($this->db,$sql);
+00277 $this->d_id=GetSequence($this->db,"document_d_id_seq");
+00278 echo_debug('class_document',__LINE__,'document sauvé : d_id'.$this->d_id);
+00279 Commit($this->db);
+00280 return 0;
+00281 }
00346 {
-00347 // retrieve the template and generate document
-00348 StartSql($this->db);
-00349 $ret=ExecSql($this->db,
-00350 "select d_id,d_lob,d_filename,d_mimetype from document where d_id=".$this->d_id );
-00351 if ( pg_num_rows ($ret) == 0 )
-00352 return;
-00353 $row=pg_fetch_array($ret,0);
-00354 //the document is saved into file $tmp
-00355 $tmp=tempnam('/tmp/','document_');
-00356 pg_lo_export($this->db,$row['d_lob'],$tmp);
-00357 $this->d_mimetype=$row['d_mimetype'];
-00358 $this->d_filename=$row['d_filename'];
-00359
-00360 // send it to stdout
-00361 ini_set('zlib.output_compression','Off');
-00362 header("Pragma: public");
-00363 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-00364 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
-00365 header("Cache-Control: must-revalidate");
-00366 header('Content-type: "'.$this->d_mimetype.'"');
-00367 header('Content-Disposition: attachment;filename="'.$this->d_filename.'"',FALSE);
-00368 header("Accept-Ranges: bytes");
-00369 $file=fopen($tmp,'r');
-00370 while ( !feof ($file) )
-00371 {
-00372 echo fread($file,8192);
-00373 }
-00374 fclose($file);
-00375
-00376 unlink ($tmp);
-00377
-00378 Commit($this->db);
-00379
-00380 }
+References $file, $ret, $row, $tmp, Commit(), ExecSql(), and StartSql().
00356 {
+00357 // retrieve the template and generate document
+00358 StartSql($this->db);
+00359 $ret=ExecSql($this->db,
+00360 "select d_id,d_lob,d_filename,d_mimetype from document where d_id=".$this->d_id );
+00361 if ( pg_num_rows ($ret) == 0 )
+00362 return;
+00363 $row=pg_fetch_array($ret,0);
+00364 //the document is saved into file $tmp
+00365 $tmp=tempnam('/tmp/','document_');
+00366 pg_lo_export($this->db,$row['d_lob'],$tmp);
+00367 $this->d_mimetype=$row['d_mimetype'];
+00368 $this->d_filename=$row['d_filename'];
+00369
+00370 // send it to stdout
+00371 ini_set('zlib.output_compression','Off');
+00372 header("Pragma: public");
+00373 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+00374 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+00375 header("Cache-Control: must-revalidate");
+00376 header('Content-type: "'.$this->d_mimetype.'"');
+00377 header('Content-Disposition: attachment;filename="'.$this->d_filename.'"',FALSE);
+00378 header("Accept-Ranges: bytes");
+00379 $file=fopen($tmp,'r');
+00380 while ( !feof ($file) )
+00381 {
+00382 echo fread($file,8192);
+00383 }
+00384 fclose($file);
+00385
+00386 unlink ($tmp);
+00387
+00388 Commit($this->db);
+00389
+00390 }
00280 {
-00281
-00282 // nothing to save
-00283 if ( sizeof($_FILES) == 0 ) return;
-00284
-00285 // Start Transaction
-00286 StartSql($this->db);
-00287 $new_name=tempnam('/tmp','doc_');
-00288
-00289
-00290 // check if a file is submitted
-00291 if ( strlen($_FILES['file_upload']['tmp_name']) != 0 )
-00292 {
-00293 // upload the file and move it to temp directory
-00294 if ( move_uploaded_file($_FILES['file_upload']['tmp_name'],$new_name))
-00295 {
-00296 $oid=pg_lo_import($this->db,$new_name);
-00297 // check if the lob is in the database
-00298 if ( $oid == false )
-00299 {
-00300 Rollback($this->db);
-00301 return 1;
-00302 }
-00303 }
-00304 // the upload in the database is successfull
-00305 $this->d_lob=$oid;
-00306 $this->d_filename=$_FILES['file_upload']['name'];
-00307 $this->d_mimetype=$_FILES['file_upload']['type'];
-00308 // now we have to update the col.
-00309 // We retrieve the row to remove a possible existing lob (replace)
-00310 $sql="select d_lob from document where d_id=".$this->d_id;
-00311 $ret=ExecSql($this->db,$sql);
-00312
-00313 if (pg_num_rows($ret) != 0)
-00314 {
-00315 // a result is found, the old oid is keept in order to
-00316 // remove it later
-00317 $r=pg_fetch_array($ret,0) ;
-00318 $old_oid=$r['d_lob'] ;
-00319 if (strlen($old_oid) != 0) { pg_lo_unlink ($this->db,$old_oid);}
-00320 }
-00321 // Update the table
-00322 $sql=sprintf("update document set d_lob=%s,d_filename='%s',d_mimetype='%s' where d_id=%d",
-00323 $this->d_lob,$this->d_filename,$this->d_mimetype,$this->d_id);
-00324 ExecSql($this->db,$sql);
-00325 }
-00326 Commit($this->db);
-00327
-00328 }
+References $old_oid, $r, $ret, $sql, Commit(), ExecSql(), name, Rollback(), and StartSql().
00290 {
+00291
+00292 // nothing to save
+00293 if ( sizeof($_FILES) == 0 ) return;
+00294
+00295 // Start Transaction
+00296 StartSql($this->db);
+00297 $new_name=tempnam('/tmp','doc_');
+00298
+00299
+00300 // check if a file is submitted
+00301 if ( strlen($_FILES['file_upload']['tmp_name']) != 0 )
+00302 {
+00303 // upload the file and move it to temp directory
+00304 if ( move_uploaded_file($_FILES['file_upload']['tmp_name'],$new_name))
+00305 {
+00306 $oid=pg_lo_import($this->db,$new_name);
+00307 // check if the lob is in the database
+00308 if ( $oid == false )
+00309 {
+00310 Rollback($this->db);
+00311 return 1;
+00312 }
+00313 }
+00314 // the upload in the database is successfull
+00315 $this->d_lob=$oid;
+00316 $this->d_filename=$_FILES['file_upload']['name'];
+00317 $this->d_mimetype=$_FILES['file_upload']['type'];
+00318 // now we have to update the col.
+00319 // We retrieve the row to remove a possible existing lob (replace)
+00320 $sql="select d_lob from document where d_id=".$this->d_id;
+00321 $ret=ExecSql($this->db,$sql);
+00322
+00323 if (pg_num_rows($ret) != 0)
+00324 {
+00325 // a result is found, the old oid is keept in order to
+00326 // remove it later
+00327 $r=pg_fetch_array($ret,0) ;
+00328 $old_oid=$r['d_lob'] ;
+00329 if (strlen($old_oid) != 0) { pg_lo_unlink ($this->db,$old_oid);}
+00330 }
+00331 // Update the table
+00332 $sql=sprintf("update document set d_lob=%s,d_filename='%s',d_mimetype='%s' where d_id=%d",
+00333 $this->d_lob,$this->d_filename,$this->d_mimetype,$this->d_id);
+00334 ExecSql($this->db,$sql);
+00335 }
+00336 Commit($this->db);
+00337
+00338 }
@@ -1218,7 +1228,7 @@ References $old_oid,
-
Document::$ag_id
+ Document::$ag_id
@@ -1379,7 +1389,7 @@ Definition at line
diff --git a/doc/developper/html/classDocument__modele.html b/doc/developper/html/classDocument__modele.html
index 649617ee9..c7c5f3bdc 100644
--- a/doc/developper/html/classDocument__modele.html
+++ b/doc/developper/html/classDocument__modele.html
@@ -129,7 +129,7 @@ Remove a template.
-
Document::$md_id
+ Document::$md_id
00180 {
+References $r, $res, $sql, Commit(), ExecSql(), and StartSql().
00180 {
00181 StartSql($this->cn);
00182 // first we unlink the document
00183 $sql="select md_lob from document_modele where md_id=".$this->md_id;
@@ -189,7 +189,7 @@ show the form for loading a template
00253 {
00254 $r="<p>";
@@ -345,7 +345,7 @@ References $
00049 {
+References $a, $all, $c, $r, $Res, $row, $sql, ExecSql(), form(), md_id, and md_name.
00049 {
00050 $sql="select md_id,md_name,dt_value from document_modele join document_type on(dt_id=md_type)";
00051 $Res=ExecSql($this->cn,$sql);
00052 $all=pg_fetch_all($Res);
@@ -422,7 +422,7 @@ none
00104 {
+References $old_oid, $r, $ret, $Ret, $sql, Commit(), echo_debug(), echo_error(), ExecSql(), exit, FormatString(), isNumber(), md_id, name, NextSequence(), Rollback(), start, and StartSql().
00104 {
00105 // if name is empty return immediately
00106 if ( trim(strlen($this->md_name))==0)
00107 return;
@@ -530,7 +530,7 @@ Definition at line
diff --git a/doc/developper/html/classDocument__type.html b/doc/developper/html/classDocument__type.html
index b797a98bf..0748c3a84 100644
--- a/doc/developper/html/classDocument__type.html
+++ b/doc/developper/html/classDocument__type.html
@@ -96,7 +96,7 @@ Get all the data for this dt_id.
-
Document_modele::$md_id
+ Document_modele::$md_id
00044 {
+References $r, $sql, dt_id, and ExecSql().
00044 {
00045 $sql="select * from document_type where dt_id=".$this->dt_id;
00046 $R=ExecSql($this->db,$sql);
00047 $r=pg_fetch_array($R,0);
diff --git a/doc/developper/html/class__action_8php-source.html b/doc/developper/html/class__action_8php-source.html
index 1894a916f..585944458 100644
--- a/doc/developper/html/class__action_8php-source.html
+++ b/doc/developper/html/class__action_8php-source.html
@@ -48,7 +48,7 @@
00078 function action ($p_cn)
00079 {
00080 $this->db=$p_cn;
-00081 $this->f_id=0;
+00081 $this->f_id=0;
00082
00083 }
00084 //----------------------------------------------------------------------
@@ -444,7 +444,7 @@
00508
00509 // Get The sequence id,
00510 $seq_name="seq_doc_type_".$this->dt_id;
-00511 $str_file="";
+00511 $str_file="";
00512 $add_file='';
00513 // f_id dest
00514 $tiers=new fiche($this->db);
@@ -495,7 +495,7 @@
00561 $doc->md_id=$this->md_id;
00562 $doc->ag_id=$this->ag_id;
00563 $doc->d_state=$this->d_state;
-00564 $str_file=$doc->Generate();
+00564 $str_file=$doc->Generate();
00565 $d='<input type="hidden" name="d_id" value="'.$doc->d_id.'">';
00566 }
00567 $r="";
@@ -516,7 +516,7 @@
00582 {
00583 $r.='<input type="hidden" name="d_id" value="'.$doc->d_id.'">';
00584 $r.="Sauver le document généré :";
-00585 $r.=$str_file;
+00585 $r.=$str_file;
00586 $checkbox=new widget("checkbox");
00587 $checkbox->name="save_generate";
00588 $r.=$checkbox->IOValue();
diff --git a/doc/developper/html/class__contact_8php-source.html b/doc/developper/html/class__contact_8php-source.html
index 1043e7626..d3072d4a8 100644
--- a/doc/developper/html/class__contact_8php-source.html
+++ b/doc/developper/html/class__contact_8php-source.html
@@ -88,7 +88,7 @@
00096 if ( isset ($get) ) {
00097 foreach ($get as $name=>$value ) {
00098 // we clean the parameter offset, step, page and size
-00099 if ( ! in_array($name,array('f_id','detail'))) {
+00099 if ( ! in_array($name,array('f_id','detail'))) {
00100 $url.=$and.$name."=".$value;
00101 $and="&";
00102 }// if
@@ -114,7 +114,7 @@
00122 );
00123 }
00124 $r.="<TR>";
-00125 $r.='<TD><A HREF="'.$url."&sa=detail&f_id=".$contact->id."\">".$contact->strAttribut(ATTR_DEF_NAME)."</A></TD>";
+00125 $r.='<TD><A HREF="'.$url."&sa=detail&f_id=".$contact->id."\">".$contact->strAttribut(ATTR_DEF_NAME)."</A></TD>";
00126 $r.="<TD>".$contact->strAttribut(ATTR_DEF_TEL)."</TD>";
00127 $r.="<TD>".$contact->strAttribut(ATTR_DEF_EMAIL)."</TD>".
00128 "<TD> ".$contact->strAttribut(ATTR_DEF_FAX)."</TD>".
diff --git a/doc/developper/html/class__customer_8php-source.html b/doc/developper/html/class__customer_8php-source.html
index 77df7d234..c8b4b6193 100644
--- a/doc/developper/html/class__customer_8php-source.html
+++ b/doc/developper/html/class__customer_8php-source.html
@@ -58,7 +58,7 @@
00062 // There is only _one_ row by customer
00063 $row=pg_fetch_array($Res,0);
00064 $this->name=$row['name'];
-00065 $this->id=$row['f_id'];
+00065 $this->id=$row['f_id'];
00066 $this->street=$row['rue'];
00067 $this->cp=$row['code_postal'];
00068 $this->country=$row['pays'];
diff --git a/doc/developper/html/class__document_8php-source.html b/doc/developper/html/class__document_8php-source.html
index 03fed0c2c..edcc84ed7 100644
--- a/doc/developper/html/class__document_8php-source.html
+++ b/doc/developper/html/class__document_8php-source.html
@@ -69,587 +69,597 @@
00080 {
00081 // create a temp directory in /tmp to unpack file and to parse it
00082 $dirname=tempnam('/tmp','doc_');
-00083 echo $dirname;
-00084 unlink($dirname);
-00085 mkdir ($dirname);
-00086 echo_debug('class_action',__LINE__,"Dirname is $dirname");
-00087 // Retrieve the lob and save it into $dirname
-00088 StartSql($this->db);
-00089 $dm_info="select md_type,md_lob,md_filename,md_mimetype
-00090 from document_modele where md_id=".$this->md_id;
-00091 $Res=ExecSql($this->db,$dm_info);
-00092
-00093 $row=pg_fetch_array($Res,0);
-00094 $this->d_lob=$row['md_lob'];
-00095 $this->d_filename=$row['md_filename'];
-00096 $this->d_mimetype=$row['md_mimetype'];
-00097
-00098 echo_debug('class_document',__LINE__,"OID is ".$row['md_lob']);
-00100 chdir($dirname);
-00101 $filename=$row['md_filename'];
-00102 pg_lo_export($this->db,$row['md_lob'],$filename);
-00103 $type="n";
-00104 echo_debug('class_document',__LINE__,'The document type is '.$row['md_mimetype']);
-00105 // if the doc is a OOo, we need to unzip it first
-00106 // and the name of the file to change is always content.xml
-00107 if ( strpos($row['md_mimetype'],'vnd.oasis') != 0 )
-00108 {
-00109 echo_debug('class_document',__LINE__,'Unzip the OOo');
-00110 system("unzip ".$filename);
-00111 // Remove the file we do not need anymore
-00112 unlink($filename);
-00113 $file_to_parse="content.xml";
-00114 $type="OOo";
-00115 }
-00116 else
-00117 $file_to_parse=$filename;
-00118 // affect a number
-00119 $this->d_number=NextSequence($this->db,"seq_doc_type_".$row['md_type']);
-00120
-00121
-00122 // parse the document - return the doc number ?
-00123 $this->ParseDocument($dirname,$file_to_parse,$type);
-00124
-00125 Commit($this->db);
-00126 // if the doc is a OOo, we need to re-zip it
-00127 if ( strpos($row['md_mimetype'],'vnd.oasis') != 0 )
-00128 {
-00129 system ("zip -r ".$filename." *");
-00130 $file_to_parse=$filename;
-00131 }
-00132 // Create a directory
-00133 mkdir ($_SERVER['DOCUMENT_ROOT'].$dirname);
-00134
-00135 // we need to rename the new generated file
-00136 rename($dirname."/".$file_to_parse,$_SERVER['DOCUMENT_ROOT'].$dirname.'/'.$file_to_parse);
-00137 $ret=sprintf('<A HREF="%s">Document généré</A>',
-00138 $dirname.'/'.$file_to_parse);
-00139 $this->SaveGenerated($_SERVER['DOCUMENT_ROOT'].$dirname."/".$file_to_parse);
-00140 return $ret;
-00141 }
-00142
-00153 function ParseDocument($p_dir,$p_file,$p_type)
-00154 {
-00155
-00156 echo_debug('class_document',__LINE__,'Begin parsing of '.$p_dir.' '.$p_file.'Type = '.$p_type);
-00157
-00164 // open the document
-00165 $infile_name=$p_dir."/".$p_file;
-00166 echo_debug("class_document.php",__LINE__,"Open the document $p_dir/$p_file");
-00167 $h=fopen($infile_name,"r");
-00168 $output_name=tempnam($_SERVER["DOCUMENT_ROOT"]."/tmp","gen_doc_");
-00169 $output_file=fopen($output_name,"w+");
-00170 // check if the opening is sucessfull
-00171 if ( $h == false )
-00172 {
-00173 echo "cannot open $p_dir $p_file ";
-00174 exit();
-00175 }
-00176 if ( $output_file == false)
-00177 {
-00178 echo "ne peut pas ouvrir le fichier de sortie";
-00179 exit();
-00180 }
-00181 // compute the regex
-00182 if ( $p_type=='OOo')
-00183 {
-00184 $regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
-00185 $lt="<";
-00186 $gt=">";
-00187 }
-00188 else
-00189 {
-00190 $regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
-00191 $lt="<";
-00192 $gt=">";
-00193 }
-00194 //read the file
-00195 while(! feof($h))
-00196 {
-00197 // replace the tag
-00198 $buffer=fgets($h);
-00199 // search in the buffer the magic << and >>
-00200 // while ereg finds something to replace
-00201 while ( ereg ($regex,$buffer,$f) )
-00202 {
-00203
-00204 echo_debug('class_document',__LINE__,'var_export '.var_export( $f,true));
-00205 foreach ( $f as $pattern )
-00206 {
-00207 echo_debug('class_document',__LINE__, "pattern");
-00208 echo_debug('class_document',__LINE__, var_export($pattern,true));
-00209 $to_remove=$pattern;
-00210 // we remove the < and > from the pattern
-00211 $pattern=str_replace($lt,'',$pattern);
-00212 $pattern=str_replace($gt,'',$pattern);
+00083
+00084
+00085 unlink($dirname);
+00086 mkdir ($dirname);
+00087 echo_debug('class_action',__LINE__,"Dirname is $dirname");
+00088 // Retrieve the lob and save it into $dirname
+00089 StartSql($this->db);
+00090 $dm_info="select md_type,md_lob,md_filename,md_mimetype
+00091 from document_modele where md_id=".$this->md_id;
+00092 $Res=ExecSql($this->db,$dm_info);
+00093
+00094 $row=pg_fetch_array($Res,0);
+00095 $this->d_lob=$row['md_lob'];
+00096 $this->d_filename=$row['md_filename'];
+00097 $this->d_mimetype=$row['md_mimetype'];
+00098
+00099 echo_debug('class_document',__LINE__,"OID is ".$row['md_lob']);
+00101 chdir($dirname);
+00102 $filename=$row['md_filename'];
+00103 pg_lo_export($this->db,$row['md_lob'],$filename);
+00104 $type="n";
+00105 echo_debug('class_document',__LINE__,'The document type is '.$row['md_mimetype']);
+00106 // if the doc is a OOo, we need to unzip it first
+00107 // and the name of the file to change is always content.xml
+00108 if ( strpos($row['md_mimetype'],'vnd.oasis') != 0 )
+00109 {
+00110 echo_debug('class_document',__LINE__,'Unzip the OOo');
+00111 echo '<span id="gen_msg">';
+00112 echo '<blink><font color="red">Un moment de patience, le document se prépare...</font></blink>';
+00113 echo '</span>';
+00114 ob_start();
+00115 system("unzip ".$filename);
+00116 // Remove the file we do not need anymore
+00117 unlink($filename);
+00118 ob_end_clean();
+00119 $file_to_parse="content.xml";
+00120 $type="OOo";
+00121 }
+00122 else
+00123 $file_to_parse=$filename;
+00124 // affect a number
+00125 $this->d_number=NextSequence($this->db,"seq_doc_type_".$row['md_type']);
+00126
+00127
+00128 // parse the document - return the doc number ?
+00129 $this->ParseDocument($dirname,$file_to_parse,$type);
+00130
+00131 Commit($this->db);
+00132 // if the doc is a OOo, we need to re-zip it
+00133 if ( strpos($row['md_mimetype'],'vnd.oasis') != 0 )
+00134 {
+00135 ob_start();
+00136 system ("zip -r ".$filename." *");
+00137 ob_end_clean();
+00138 echo "le document est prêt ";
+00139
+00140 $file_to_parse=$filename;
+00141 }
+00142 // Create a directory
+00143 mkdir ($_SERVER['DOCUMENT_ROOT'].$dirname);
+00144
+00145 // we need to rename the new generated file
+00146 rename($dirname."/".$file_to_parse,$_SERVER['DOCUMENT_ROOT'].$dirname.'/'.$file_to_parse);
+00147 $ret=sprintf('<A HREF="%s">Document généré</A>',
+00148 $dirname.'/'.$file_to_parse);
+00149 $this->SaveGenerated($_SERVER['DOCUMENT_ROOT'].$dirname."/".$file_to_parse);
+00150 return $ret;
+00151 }
+00152
+00163 function ParseDocument($p_dir,$p_file,$p_type)
+00164 {
+00165
+00166 echo_debug('class_document',__LINE__,'Begin parsing of '.$p_dir.' '.$p_file.'Type = '.$p_type);
+00167
+00174 // open the document
+00175 $infile_name=$p_dir."/".$p_file;
+00176 echo_debug("class_document.php",__LINE__,"Open the document $p_dir/$p_file");
+00177 $h=fopen($infile_name,"r");
+00178 $output_name=tempnam($_SERVER["DOCUMENT_ROOT"]."/tmp","gen_doc_");
+00179 $output_file=fopen($output_name,"w+");
+00180 // check if the opening is sucessfull
+00181 if ( $h == false )
+00182 {
+00183 echo "cannot open $p_dir $p_file ";
+00184 exit();
+00185 }
+00186 if ( $output_file == false)
+00187 {
+00188 echo "ne peut pas ouvrir le fichier de sortie";
+00189 exit();
+00190 }
+00191 // compute the regex
+00192 if ( $p_type=='OOo')
+00193 {
+00194 $regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
+00195 $lt="<";
+00196 $gt=">";
+00197 }
+00198 else
+00199 {
+00200 $regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
+00201 $lt="<";
+00202 $gt=">";
+00203 }
+00204 //read the file
+00205 while(! feof($h))
+00206 {
+00207 // replace the tag
+00208 $buffer=fgets($h);
+00209 // search in the buffer the magic << and >>
+00210 // while ereg finds something to replace
+00211 while ( ereg ($regex,$buffer,$f) )
+00212 {
00213
-00214
-00215 // if the pattern if found we replace it
-00216 $value=$this->Replace($pattern);
-00217 // replace into the $buffer
-00218 // take the position in the buffer
-00219 $pos=strpos($buffer,$to_remove);
-00220 // get the length of the string to remove
-00221 $len=strlen($to_remove);
-00222 $buffer=substr_replace($buffer,$value,$pos,$len);
+00214 echo_debug('class_document',__LINE__,'var_export '.var_export( $f,true));
+00215 foreach ( $f as $pattern )
+00216 {
+00217 echo_debug('class_document',__LINE__, "pattern");
+00218 echo_debug('class_document',__LINE__, var_export($pattern,true));
+00219 $to_remove=$pattern;
+00220 // we remove the < and > from the pattern
+00221 $pattern=str_replace($lt,'',$pattern);
+00222 $pattern=str_replace($gt,'',$pattern);
00223
-00224 // echo_debug('class_document',__LINE__, $buffer);
+00224
00225 // if the pattern if found we replace it
-00226 echo_debug('class_document',__LINE__,"Transform $pattern by $value");
-00227 }
-00228 }
-00229 // write into the output_file
-00230 fwrite($output_file,$buffer);
-00231
-00232 }
-00233 fclose($h);
-00234 fclose($output_file);
-00235 rename ($output_name,$infile_name);
-00236 // Save the document into the database
-00237
-00238 }
-00246 function SaveGenerated($p_file)
-00247 {
-00248 echo_debug('class_document',__LINE__,'Save generated');
-00249 // We save the generated file
-00250 $doc=new Document($this->db);
-00251 StartSql($this->db);
-00252 $this->d_lob=pg_lo_import($this->db,$p_file);
-00253 if ( $this->d_lob == false ) {
-00254 Rollback($this->db); echo_debug('class_document',__LINE__,"can't save file $p_file");
-00255 return 1; }
-00256
-00257 $sql=sprintf("insert into document(ag_id,d_lob,d_number,d_filename,d_mimetype,d_state)
-00258 values (%d,%s,%d,'%s','%s',%d)",
-00259 $this->ag_id,
-00260 $this->d_lob,
-00261 $this->d_number,
-00262 $this->d_filename,
-00263 $this->d_mimetype,
-00264 $this->d_state
-00265 );
-00266 ExecSql($this->db,$sql);
-00267 $this->d_id=GetSequence($this->db,"document_d_id_seq");
-00268 echo_debug('class_document',__LINE__,'document sauvé : d_id'.$this->d_id);
-00269 Commit($this->db);
-00270 return 0;
-00271 }
-00279 function Upload()
-00280 {
-00281
-00282 // nothing to save
-00283 if ( sizeof($_FILES) == 0 ) return;
-00284
-00285 // Start Transaction
-00286 StartSql($this->db);
-00287 $new_name=tempnam('/tmp','doc_');
-00288
-00289
-00290 // check if a file is submitted
-00291 if ( strlen($_FILES['file_upload']['tmp_name']) != 0 )
-00292 {
-00293 // upload the file and move it to temp directory
-00294 if ( move_uploaded_file($_FILES['file_upload']['tmp_name'],$new_name))
-00295 {
-00296 $oid=pg_lo_import($this->db,$new_name);
-00297 // check if the lob is in the database
-00298 if ( $oid == false )
-00299 {
-00300 Rollback($this->db);
-00301 return 1;
-00302 }
-00303 }
-00304 // the upload in the database is successfull
-00305 $this->d_lob=$oid;
-00306 $this->d_filename=$_FILES['file_upload']['name'];
-00307 $this->d_mimetype=$_FILES['file_upload']['type'];
-00308 // now we have to update the col.
-00309 // We retrieve the row to remove a possible existing lob (replace)
-00310 $sql="select d_lob from document where d_id=".$this->d_id;
-00311 $ret=ExecSql($this->db,$sql);
-00312
-00313 if (pg_num_rows($ret) != 0)
-00314 {
-00315 // a result is found, the old oid is keept in order to
-00316 // remove it later
-00317 $r=pg_fetch_array($ret,0) ;
-00318 $old_oid=$r['d_lob'] ;
-00319 if (strlen($old_oid) != 0) { pg_lo_unlink ($this->db,$old_oid);}
-00320 }
-00321 // Update the table
-00322 $sql=sprintf("update document set d_lob=%s,d_filename='%s',d_mimetype='%s' where d_id=%d",
-00323 $this->d_lob,$this->d_filename,$this->d_mimetype,$this->d_id);
-00324 ExecSql($this->db,$sql);
-00325 }
-00326 Commit($this->db);
-00327
-00328 }
-00334 function a_ref()
-00335 {
-00336 if ( $this->d_id == 0 )
-00337 return '';
-00338 $r="";
-00339 $r='<A class="mtitle" HREF="show_document.php?d_id='.$this->d_id.'">Document</A>';
-00340 return $r;
-00341 }
-00342 /* ! Get
-00343 * \brief Send the document
-00344 */
-00345 function Send()
-00346 {
-00347 // retrieve the template and generate document
-00348 StartSql($this->db);
-00349 $ret=ExecSql($this->db,
-00350 "select d_id,d_lob,d_filename,d_mimetype from document where d_id=".$this->d_id );
-00351 if ( pg_num_rows ($ret) == 0 )
-00352 return;
-00353 $row=pg_fetch_array($ret,0);
-00354 //the document is saved into file $tmp
-00355 $tmp=tempnam('/tmp/','document_');
-00356 pg_lo_export($this->db,$row['d_lob'],$tmp);
-00357 $this->d_mimetype=$row['d_mimetype'];
-00358 $this->d_filename=$row['d_filename'];
-00359
-00360 // send it to stdout
-00361 ini_set('zlib.output_compression','Off');
-00362 header("Pragma: public");
-00363 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-00364 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
-00365 header("Cache-Control: must-revalidate");
-00366 header('Content-type: "'.$this->d_mimetype.'"');
-00367 header('Content-Disposition: attachment;filename="'.$this->d_filename.'"',FALSE);
-00368 header("Accept-Ranges: bytes");
-00369 $file=fopen($tmp,'r');
-00370 while ( !feof ($file) )
-00371 {
-00372 echo fread($file,8192);
-00373 }
-00374 fclose($file);
-00375
-00376 unlink ($tmp);
-00377
-00378 Commit($this->db);
-00379
-00380 }
-00383 function get()
-00384 {
-00385 $sql="select * from document where d_id=".$this->d_id;
-00386 $ret=Exec($this->db,$sql);
-00387 if ( pg_num_rows($ret) == 0 )
-00388 return;
-00389 $row=pg_fetch_array($ret,0);
-00390 $this->ag_id=$row['ag_id'];
-00391 $this->d_mimetype=$row['d_mimetype'];
-00392 $this->d_filename=$row['d_filename'];
-00393 $this->d_lob=$row['d_lob'];
-00394 $this->d_number=$row[''];
-00395 $this->d_state=$row['ag_id'];
-00396 $this->d_number=$row['d_number'];
-00397
-00398 }
-00431 function Replace($p_tag)
-00432 {
-00433 $r="Tag inconnu";
-00434 static $counter=0;
-00435 switch ($p_tag)
-00436 {
-00437 case 'DATE':
-00438 $r=' Date inconnue ';
-00439 // Date are in $_REQUEST['ag_date']
-00440 // or $_POST['e_date']
-00441 if ( isset ($_REQUEST['ag_date']))
-00442 $r=$_REQUEST['ag_date'];
-00443 if ( isset ($_REQUEST['e_date']))
-00444 $r=$_REQUEST['e_date'];
-00445
-00446 break;
-00447 //
-00448 // the company priv
-00449
-00450 case 'MY_NAME':
-00451 $my=new own($this->db);
-00452 $r=$my->MY_NAME;
-00453 break;
-00454 case 'MY_CP':
-00455 $my=new own($this->db);
-00456 $r=$my->MY_CP;
-00457 break;
-00458 case 'MY_COMMUNE':
-00459 $my=new own($this->db);
-00460 $r=$my->MY_COMMUNE;
-00461 break;
-00462 case 'MY_TVA':
-00463 $my=new own($this->db);
-00464 $r=$my->MY_TVA;
-00465 break;
-00466 case 'MY_STREET':
-00467 $my=new own($this->db);
-00468 $r=$my->MY_STREET;
-00469 break;
-00470 case 'MY_NUMBER':
-00471 $my=new own($this->db);
-00472 $r=$my->MY_NUMBER;
-00473 break;
-00474 case 'MY_TEL':
-00475 $my=new own($this->db);
-00476 $r=$my->MY_TEL;
-00477 break;
-00478 case 'MY_FAX':
-00479 $my=new own($this->db);
-00480 $r=$my->MY_FAX;
-00481 break;
-00482 case 'MY_PAYS':
-00483 $my=new own($this->db);
-00484 $r=$my->MY_PAYS;
-00485 break;
-00486
-00487 // customer
-00488 /*\note The CUST_* are retrieved thx the $_REQUEST['tiers']
-00489 * which contains the quick_code
-00490 */
-00491 case 'SOLDE':
-00492 $tiers=new fiche($this->db);
-00493 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00494 $tiers->Getbyqcode($qcode,false);
-00495 $p=$tiers->strAttribut(ATTR_DEF_ACCOUNT);
-00496 $poste=new Poste($this->db,$p);
-00497 $r=$poste->GetSolde(' true' );
-00498 break;
-00499 case 'CUST_NAME':
-00500 $tiers=new fiche($this->db);
-00501 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00502 $tiers->getByQcode($qcode,false);
-00503 $r=$tiers->strAttribut(ATTR_DEF_NAME);
-00504 break;
-00505 case 'CUST_ADDR_1':
-00506 $tiers=new fiche($this->db);
-00507 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00508 $tiers->getByQcode($qcode,false);
-00509 $r=$tiers->strAttribut(ATTR_DEF_ADRESS);
-00510
-00511 break ;
-00512 case 'CUST_CP':
-00513 $tiers=new fiche($this->db);
-00514 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00515 $tiers->getByQcode($qcode,false);
-00516 $r=$tiers->strAttribut(ATTR_DEF_CP);
-00517
-00518 break;
-00519 case 'CUST_CO':
-00520 $tiers=new fiche($this->db);
-00521 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00522 $tiers->getByQcode($qcode,false);
-00523 $r=$tiers->strAttribut(ATTR_DEF_PAYS);
-00524
-00525 break;
-00526 case 'CUST_VAT':
-00527 $tiers=new fiche($this->db);
-00528 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
-00529 $tiers->getByQcode($qcode,false);
-00530 $r=$tiers->strAttribut(ATTR_DEF_NUMTVA);
-00531 break;
-00532 // Marchandise in $_POST['e_march*']
-00533 // \see user_form_achat.php or user_form_ven.php
-00534 case 'NUMBER':
-00535 $r=$this->d_number;
-00536 break;
-00537 case 'REFERENCE':
-00538 $act=new action($this->db);
-00539 $act->ag_id=$this->ag_id;
-00540 $act->get();
-00541 $r=$act->ag_ref;
-00542 break;
-00543
-00544 /*
-00545 * - [VEN_ART_NAME]
-00546 * - [VEN_ART_PRICE]
-00547 * - [VEN_ART_QUANT]
-00548 * - [VEN_ART_TVA_CODE]
-00549 * - [VEN_ART_TVA_AMOUNT]
-00550 * - [VEN_ART_STOCK_CODE]
-00551 * - [VEN_HTVA]
-00552 * - [VEN_TVAC]
-00553 * - [VEN_TVA]
-00554 * - [TOTAL_VEN_HTVA]
-00555 */
-00556 case 'MARCH_NEXT':
-00557 $counter++;
-00558 $r='';
-00559 break;
-00560
-00561 case 'VEN_ART_NAME':
-00562 extract ($_POST);
-00563 $id='e_march'.$counter;
-00564 // check if the march exists
-00565 if ( ! isset (${$id})) return "";
-00566 // check that something is sold
-00567 if ( ${'e_march'.$counter.'_sell'} != 0 && ${'e_quant'.$counter} != 0 )
-00568 {
-00569 $f=new fiche($this->db);
-00570 $f->GetByQCode(${$id},false);
-00571 $r=$f->strAttribut(ATTR_DEF_NAME);
-00572 } else $r = "";
-00573 break;
-00574
-00575 case 'VEN_ART_PRICE':
-00576 extract ($_POST);
-00577 $id='e_march'.$counter.'_sell' ;
-00578 if ( !isset (${$id}) ) return "";
-00579 $r=${$id};
-00580 break;
-00581
-00582 case 'TVA_CODE':
-00583 extract ($_POST);
-00584 $id='e_march'.$counter.'_tva_id';
-00585 if ( !isset (${$id}) ) return "";
-00586 if ( ${$id} == -1 ) return "";
-00587 $qt='e_quant'.$counter;
-00588 $price='e_march'.$counter.'_sell' ;
-00589 if ( ${$price} == 0 || ${$qt} == 0
-00590 || strlen(trim( $price )) ==0
-00591 || strlen(trim($qt)) ==0)
-00592 return "";
-00593
-00594 $r=${$id};
-00595 break;
-00596
-00597 case 'TVA_LABEL':
-00598 extract ($_POST);
-00599 $id='e_march'.$counter.'_tva_id';
-00600 if ( !isset (${$id}) ) return "";
-00601 $tva=GetTvaRate($this->db,${$id});
-00602 if ( $tva == null || $tva==0 ) return "";
-00603 $r=$tva['tva_label'];
-00604 break;
-00605
+00226 $value=$this->Replace($pattern);
+00227 // replace into the $buffer
+00228 // take the position in the buffer
+00229 $pos=strpos($buffer,$to_remove);
+00230 // get the length of the string to remove
+00231 $len=strlen($to_remove);
+00232 $buffer=substr_replace($buffer,$value,$pos,$len);
+00233
+00234 // echo_debug('class_document',__LINE__, $buffer);
+00235 // if the pattern if found we replace it
+00236 echo_debug('class_document',__LINE__,"Transform $pattern by $value");
+00237 }
+00238 }
+00239 // write into the output_file
+00240 fwrite($output_file,$buffer);
+00241
+00242 }
+00243 fclose($h);
+00244 fclose($output_file);
+00245 rename ($output_name,$infile_name);
+00246 // Save the document into the database
+00247
+00248 }
+00256 function SaveGenerated($p_file)
+00257 {
+00258 echo_debug('class_document',__LINE__,'Save generated');
+00259 // We save the generated file
+00260 $doc=new Document($this->db);
+00261 StartSql($this->db);
+00262 $this->d_lob=pg_lo_import($this->db,$p_file);
+00263 if ( $this->d_lob == false ) {
+00264 Rollback($this->db); echo_debug('class_document',__LINE__,"can't save file $p_file");
+00265 return 1; }
+00266
+00267 $sql=sprintf("insert into document(ag_id,d_lob,d_number,d_filename,d_mimetype,d_state)
+00268 values (%d,%s,%d,'%s','%s',%d)",
+00269 $this->ag_id,
+00270 $this->d_lob,
+00271 $this->d_number,
+00272 $this->d_filename,
+00273 $this->d_mimetype,
+00274 $this->d_state
+00275 );
+00276 ExecSql($this->db,$sql);
+00277 $this->d_id=GetSequence($this->db,"document_d_id_seq");
+00278 echo_debug('class_document',__LINE__,'document sauvé : d_id'.$this->d_id);
+00279 Commit($this->db);
+00280 return 0;
+00281 }
+00289 function Upload()
+00290 {
+00291
+00292 // nothing to save
+00293 if ( sizeof($_FILES) == 0 ) return;
+00294
+00295 // Start Transaction
+00296 StartSql($this->db);
+00297 $new_name=tempnam('/tmp','doc_');
+00298
+00299
+00300 // check if a file is submitted
+00301 if ( strlen($_FILES['file_upload']['tmp_name']) != 0 )
+00302 {
+00303 // upload the file and move it to temp directory
+00304 if ( move_uploaded_file($_FILES['file_upload']['tmp_name'],$new_name))
+00305 {
+00306 $oid=pg_lo_import($this->db,$new_name);
+00307 // check if the lob is in the database
+00308 if ( $oid == false )
+00309 {
+00310 Rollback($this->db);
+00311 return 1;
+00312 }
+00313 }
+00314 // the upload in the database is successfull
+00315 $this->d_lob=$oid;
+00316 $this->d_filename=$_FILES['file_upload']['name'];
+00317 $this->d_mimetype=$_FILES['file_upload']['type'];
+00318 // now we have to update the col.
+00319 // We retrieve the row to remove a possible existing lob (replace)
+00320 $sql="select d_lob from document where d_id=".$this->d_id;
+00321 $ret=ExecSql($this->db,$sql);
+00322
+00323 if (pg_num_rows($ret) != 0)
+00324 {
+00325 // a result is found, the old oid is keept in order to
+00326 // remove it later
+00327 $r=pg_fetch_array($ret,0) ;
+00328 $old_oid=$r['d_lob'] ;
+00329 if (strlen($old_oid) != 0) { pg_lo_unlink ($this->db,$old_oid);}
+00330 }
+00331 // Update the table
+00332 $sql=sprintf("update document set d_lob=%s,d_filename='%s',d_mimetype='%s' where d_id=%d",
+00333 $this->d_lob,$this->d_filename,$this->d_mimetype,$this->d_id);
+00334 ExecSql($this->db,$sql);
+00335 }
+00336 Commit($this->db);
+00337
+00338 }
+00344 function a_ref()
+00345 {
+00346 if ( $this->d_id == 0 )
+00347 return '';
+00348 $r="";
+00349 $r='<A class="mtitle" HREF="show_document.php?d_id='.$this->d_id.'">Document</A>';
+00350 return $r;
+00351 }
+00352 /* ! Get
+00353 * \brief Send the document
+00354 */
+00355 function Send()
+00356 {
+00357 // retrieve the template and generate document
+00358 StartSql($this->db);
+00359 $ret=ExecSql($this->db,
+00360 "select d_id,d_lob,d_filename,d_mimetype from document where d_id=".$this->d_id );
+00361 if ( pg_num_rows ($ret) == 0 )
+00362 return;
+00363 $row=pg_fetch_array($ret,0);
+00364 //the document is saved into file $tmp
+00365 $tmp=tempnam('/tmp/','document_');
+00366 pg_lo_export($this->db,$row['d_lob'],$tmp);
+00367 $this->d_mimetype=$row['d_mimetype'];
+00368 $this->d_filename=$row['d_filename'];
+00369
+00370 // send it to stdout
+00371 ini_set('zlib.output_compression','Off');
+00372 header("Pragma: public");
+00373 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+00374 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+00375 header("Cache-Control: must-revalidate");
+00376 header('Content-type: "'.$this->d_mimetype.'"');
+00377 header('Content-Disposition: attachment;filename="'.$this->d_filename.'"',FALSE);
+00378 header("Accept-Ranges: bytes");
+00379 $file=fopen($tmp,'r');
+00380 while ( !feof ($file) )
+00381 {
+00382 echo fread($file,8192);
+00383 }
+00384 fclose($file);
+00385
+00386 unlink ($tmp);
+00387
+00388 Commit($this->db);
+00389
+00390 }
+00393 function get()
+00394 {
+00395 $sql="select * from document where d_id=".$this->d_id;
+00396 $ret=Exec($this->db,$sql);
+00397 if ( pg_num_rows($ret) == 0 )
+00398 return;
+00399 $row=pg_fetch_array($ret,0);
+00400 $this->ag_id=$row['ag_id'];
+00401 $this->d_mimetype=$row['d_mimetype'];
+00402 $this->d_filename=$row['d_filename'];
+00403 $this->d_lob=$row['d_lob'];
+00404 $this->d_number=$row[''];
+00405 $this->d_state=$row['ag_id'];
+00406 $this->d_number=$row['d_number'];
+00407
+00408 }
+00441 function Replace($p_tag)
+00442 {
+00443 $r="Tag inconnu";
+00444 static $counter=0;
+00445 switch ($p_tag)
+00446 {
+00447 case 'DATE':
+00448 $r=' Date inconnue ';
+00449 // Date are in $_REQUEST['ag_date']
+00450 // or $_POST['e_date']
+00451 if ( isset ($_REQUEST['ag_date']))
+00452 $r=$_REQUEST['ag_date'];
+00453 if ( isset ($_REQUEST['e_date']))
+00454 $r=$_REQUEST['e_date'];
+00455
+00456 break;
+00457 //
+00458 // the company priv
+00459
+00460 case 'MY_NAME':
+00461 $my=new own($this->db);
+00462 $r=$my->MY_NAME;
+00463 break;
+00464 case 'MY_CP':
+00465 $my=new own($this->db);
+00466 $r=$my->MY_CP;
+00467 break;
+00468 case 'MY_COMMUNE':
+00469 $my=new own($this->db);
+00470 $r=$my->MY_COMMUNE;
+00471 break;
+00472 case 'MY_TVA':
+00473 $my=new own($this->db);
+00474 $r=$my->MY_TVA;
+00475 break;
+00476 case 'MY_STREET':
+00477 $my=new own($this->db);
+00478 $r=$my->MY_STREET;
+00479 break;
+00480 case 'MY_NUMBER':
+00481 $my=new own($this->db);
+00482 $r=$my->MY_NUMBER;
+00483 break;
+00484 case 'MY_TEL':
+00485 $my=new own($this->db);
+00486 $r=$my->MY_TEL;
+00487 break;
+00488 case 'MY_FAX':
+00489 $my=new own($this->db);
+00490 $r=$my->MY_FAX;
+00491 break;
+00492 case 'MY_PAYS':
+00493 $my=new own($this->db);
+00494 $r=$my->MY_PAYS;
+00495 break;
+00496
+00497 // customer
+00498 /*\note The CUST_* are retrieved thx the $_REQUEST['tiers']
+00499 * which contains the quick_code
+00500 */
+00501 case 'SOLDE':
+00502 $tiers=new fiche($this->db);
+00503 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00504 $tiers->Getbyqcode($qcode,false);
+00505 $p=$tiers->strAttribut(ATTR_DEF_ACCOUNT);
+00506 $poste=new Poste($this->db,$p);
+00507 $r=$poste->GetSolde(' true' );
+00508 break;
+00509 case 'CUST_NAME':
+00510 $tiers=new fiche($this->db);
+00511 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00512 $tiers->getByQcode($qcode,false);
+00513 $r=$tiers->strAttribut(ATTR_DEF_NAME);
+00514 break;
+00515 case 'CUST_ADDR_1':
+00516 $tiers=new fiche($this->db);
+00517 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00518 $tiers->getByQcode($qcode,false);
+00519 $r=$tiers->strAttribut(ATTR_DEF_ADRESS);
+00520
+00521 break ;
+00522 case 'CUST_CP':
+00523 $tiers=new fiche($this->db);
+00524 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00525 $tiers->getByQcode($qcode,false);
+00526 $r=$tiers->strAttribut(ATTR_DEF_CP);
+00527
+00528 break;
+00529 case 'CUST_CO':
+00530 $tiers=new fiche($this->db);
+00531 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00532 $tiers->getByQcode($qcode,false);
+00533 $r=$tiers->strAttribut(ATTR_DEF_PAYS);
+00534
+00535 break;
+00536 case 'CUST_VAT':
+00537 $tiers=new fiche($this->db);
+00538 $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+00539 $tiers->getByQcode($qcode,false);
+00540 $r=$tiers->strAttribut(ATTR_DEF_NUMTVA);
+00541 break;
+00542 // Marchandise in $_POST['e_march*']
+00543 // \see user_form_achat.php or user_form_ven.php
+00544 case 'NUMBER':
+00545 $r=$this->d_number;
+00546 break;
+00547 case 'REFERENCE':
+00548 $act=new action($this->db);
+00549 $act->ag_id=$this->ag_id;
+00550 $act->get();
+00551 $r=$act->ag_ref;
+00552 break;
+00553
+00554 /*
+00555 * - [VEN_ART_NAME]
+00556 * - [VEN_ART_PRICE]
+00557 * - [VEN_ART_QUANT]
+00558 * - [VEN_ART_TVA_CODE]
+00559 * - [VEN_ART_TVA_AMOUNT]
+00560 * - [VEN_ART_STOCK_CODE]
+00561 * - [VEN_HTVA]
+00562 * - [VEN_TVAC]
+00563 * - [VEN_TVA]
+00564 * - [TOTAL_VEN_HTVA]
+00565 */
+00566 case 'MARCH_NEXT':
+00567 $counter++;
+00568 $r='';
+00569 break;
+00570
+00571 case 'VEN_ART_NAME':
+00572 extract ($_POST);
+00573 $id='e_march'.$counter;
+00574 // check if the march exists
+00575 if ( ! isset (${$id})) return "";
+00576 // check that something is sold
+00577 if ( ${'e_march'.$counter.'_sell'} != 0 && ${'e_quant'.$counter} != 0 )
+00578 {
+00579 $f=new fiche($this->db);
+00580 $f->GetByQCode(${$id},false);
+00581 $r=$f->strAttribut(ATTR_DEF_NAME);
+00582 } else $r = "";
+00583 break;
+00584
+00585 case 'VEN_ART_PRICE':
+00586 extract ($_POST);
+00587 $id='e_march'.$counter.'_sell' ;
+00588 if ( !isset (${$id}) ) return "";
+00589 $r=${$id};
+00590 break;
+00591
+00592 case 'TVA_CODE':
+00593 extract ($_POST);
+00594 $id='e_march'.$counter.'_tva_id';
+00595 if ( !isset (${$id}) ) return "";
+00596 if ( ${$id} == -1 ) return "";
+00597 $qt='e_quant'.$counter;
+00598 $price='e_march'.$counter.'_sell' ;
+00599 if ( ${$price} == 0 || ${$qt} == 0
+00600 || strlen(trim( $price )) ==0
+00601 || strlen(trim($qt)) ==0)
+00602 return "";
+00603
+00604 $r=${$id};
+00605 break;
00606
-00607 case 'TVA_AMOUNT':
+00607 case 'TVA_LABEL':
00608 extract ($_POST);
-00609 $qt='e_quant'.$counter;
-00610 $price='e_march'.$counter.'_sell' ;
-00611 $tva='e_march'.$counter.'_tva_id';
-00612 if ( !isset (${'e_march'.$counter}) ) return "";
-00613 // check that something is sold
-00614 if ( ${$price} == 0 || ${$qt} == 0
-00615 || strlen(trim( $price )) ==0
-00616 || strlen(trim($qt)) ==0)
-00617 return "";
-00618 $a_tva=GetTvaRate($this->db,${$tva});
-00619 echo_debug('class_document',__LINE__,'Tva :'.var_export($a_tva,true));
-00620 // if no vat returns 0
-00621 if ( sizeof($a_tva) == 0 ) return "";
-00622 $r=round(${$price},2)*${$qt}*$a_tva['tva_rate'];
-00623 $r=round($r,2);
-00624 break;
-00625
-00626 case 'VEN_ART_QUANT':
-00627 extract ($_POST);
-00628 $id='e_quant'.$counter;
-00629 if ( !isset (${$id}) ) return "";
-00630 // check that something is sold
-00631 if ( ${'e_march'.$counter.'_sell'} == 0
-00632 || ${'e_quant'.$counter} == 0
-00633 || strlen(trim( ${'e_march'.$counter.'_sell'} )) ==0
-00634 || strlen(trim(${'e_quant'.$counter})) ==0 )
-00635 return "";
-00636 $r=${$id};
-00637 break;
-00638
-00639 case 'VEN_HTVA':
-00640 extract ($_POST);
-00641 $id='e_march'.$counter.'_sell' ;
-00642 $quant='e_quant'.$counter;
-00643 if ( !isset (${$id}) ) return "";
-00644
-00645 // check that something is sold
-00646 if ( ${'e_march'.$counter.'_sell'} == 0 || ${'e_quant'.$counter} == 0
-00647 || strlen(trim( ${'e_march'.$counter.'_sell'} )) ==0
-00648 || strlen(trim(${'e_quant'.$counter})) ==0)
-00649 return "";
-00655 $r=round(${$id}*${$quant},2);
-00656 break;
-00657
-00658 case 'VEN_TVAC':
-00659 extract ($_POST);
-00660 $id='e_march'.$counter.'_sell' ;
-00661 $quant='e_quant'.$counter;
-00662 // if it is exist
-00663 if ( ! isset(${$id}))
-00664 return "";
-00665 // check that something is sold
-00666 if ( ${'e_march'.$counter.'_sell'} == 0 || ${'e_quant'.$counter} == 0 )
-00667 return "";
-00672 $r=${$id}*${$quant};
-00673 $tva=GetTvaRate($this->db,${'e_march'.$counter.'_tva_id'});
-00674 // if there is no vat we return now
-00675 if ( $tva == null || $tva == 0 ) return $r;
-00676 // we compute with the vat included
-00677 $r=$r+$r*$tva['tva_rate'];
-00678 $r=round($r,2);
-00679 break;
-00680 case 'TOTAL_VEN_HTVA':
-00681 extract($_POST);
-00682 echo_debug('class_document',__LINE__,'TOTAL_VEN_TVA item :'.$nb_item);
-00683
-00684 $sum=0.0;
-00685 for ($i=0;$i<$nb_item;$i++)
-00686 {
-00687 $sell='e_march'.$i.'_sell';
-00688 $qt='e_quant'.$i;
-00689 echo_debug('class_document',__LINE__,'sell :'.$sell.' qt = '.$qt);
-00690
-00691 echo_debug('class_document',__LINE__,'counter :'.$i.' sur '.$nb_item);
-00692 if ( ! isset (${$sell}) ) break;
-00693 echo_debug('class_document',__LINE__,'sell :'.${$sell}.' qt = '.${$qt});
-00694
-00695 if ( strlen(trim(${$sell})) == 0 ||
-00696 strlen(trim(${$qt})) == 0 ||
-00697 ${$qt}==0 || ${$sell}==0)
-00698 continue;
-00699 $sum+=${$sell}*${$qt};
-00700 echo_debug('class_document',__LINE__,'sum :'.$sum);
-00701
-00702 }
-00703 $r=round($sum,2);
-00704 break;
-00705 case 'TOTAL_VEN_TVAC':
-00706 extract($_POST);
-00707 $sum=0.0;
-00708 for ($i=0;$i<$nb_item;$i++)
-00709 {
-00710 $tva=GetTvaRate($this->db,${'e_march'.$i.'_tva_id'});
-00711 $tva_rate=( $tva == null || $tva == 0 )?0.0:$tva['tva_rate'];
-00712 echo_debug('class_document',__LINE__,' :'.$i.' sur '.$nb_item);
-00713 $sell=${'e_march'.$i.'_sell'};
-00714 $qt=${'e_quant'.$i};
-00715 echo_debug('class_document',__LINE__,'sell :'.$sell.' qt = '.$qt);
-00716
-00717 $sum+=$sell*$qt*(1+$tva_rate);
-00718 // $sum+=${'e_march'.$i.'_sell'}*${'e_quant'.$i}*(1+$tva_rate);
-00719 }
-00720 $r=round($sum,2);
-00721
-00722 break;
-00723
-00724 }
-00725 return $r;
-00726 }
-00730 function remove()
-00731 {
-00732 $sql='delete from document where d_id='.$this->d_id;
-00733 ExecSql($this->db,$sql);
-00734 }
-00741 function MoveDocumentPj($p_internal)
-00742 {
-00743
-00744 $sql=sprintf("update jrn set jr_pj=%s,jr_pj_name='%s',jr_pj_type='%s' where jr_internal='%s'",
-00745 $this->d_lob,$this->d_filename,$this->d_mimetype,$p_internal);
-00746 ExecSql($this->db,$sql);
-00747 // clean the table document
-00748 $this->remove();
-00749 }
-00750
-00751
-00752 }
+00609 $id='e_march'.$counter.'_tva_id';
+00610 if ( !isset (${$id}) ) return "";
+00611 $tva=GetTvaRate($this->db,${$id});
+00612 if ( $tva == null || $tva==0 ) return "";
+00613 $r=$tva['tva_label'];
+00614 break;
+00615
+00616
+00617 case 'TVA_AMOUNT':
+00618 extract ($_POST);
+00619 $qt='e_quant'.$counter;
+00620 $price='e_march'.$counter.'_sell' ;
+00621 $tva='e_march'.$counter.'_tva_id';
+00622 if ( !isset (${'e_march'.$counter}) ) return "";
+00623 // check that something is sold
+00624 if ( ${$price} == 0 || ${$qt} == 0
+00625 || strlen(trim( $price )) ==0
+00626 || strlen(trim($qt)) ==0)
+00627 return "";
+00628 $a_tva=GetTvaRate($this->db,${$tva});
+00629 echo_debug('class_document',__LINE__,'Tva :'.var_export($a_tva,true));
+00630 // if no vat returns 0
+00631 if ( sizeof($a_tva) == 0 ) return "";
+00632 $r=round(${$price},2)*${$qt}*$a_tva['tva_rate'];
+00633 $r=round($r,2);
+00634 break;
+00635
+00636 case 'VEN_ART_QUANT':
+00637 extract ($_POST);
+00638 $id='e_quant'.$counter;
+00639 if ( !isset (${$id}) ) return "";
+00640 // check that something is sold
+00641 if ( ${'e_march'.$counter.'_sell'} == 0
+00642 || ${'e_quant'.$counter} == 0
+00643 || strlen(trim( ${'e_march'.$counter.'_sell'} )) ==0
+00644 || strlen(trim(${'e_quant'.$counter})) ==0 )
+00645 return "";
+00646 $r=${$id};
+00647 break;
+00648
+00649 case 'VEN_HTVA':
+00650 extract ($_POST);
+00651 $id='e_march'.$counter.'_sell' ;
+00652 $quant='e_quant'.$counter;
+00653 if ( !isset (${$id}) ) return "";
+00654
+00655 // check that something is sold
+00656 if ( ${'e_march'.$counter.'_sell'} == 0 || ${'e_quant'.$counter} == 0
+00657 || strlen(trim( ${'e_march'.$counter.'_sell'} )) ==0
+00658 || strlen(trim(${'e_quant'.$counter})) ==0)
+00659 return "";
+00665 $r=round(${$id}*${$quant},2);
+00666 break;
+00667
+00668 case 'VEN_TVAC':
+00669 extract ($_POST);
+00670 $id='e_march'.$counter.'_sell' ;
+00671 $quant='e_quant'.$counter;
+00672 // if it is exist
+00673 if ( ! isset(${$id}))
+00674 return "";
+00675 // check that something is sold
+00676 if ( ${'e_march'.$counter.'_sell'} == 0 || ${'e_quant'.$counter} == 0 )
+00677 return "";
+00682 $r=${$id}*${$quant};
+00683 $tva=GetTvaRate($this->db,${'e_march'.$counter.'_tva_id'});
+00684 // if there is no vat we return now
+00685 if ( $tva == null || $tva == 0 ) return $r;
+00686 // we compute with the vat included
+00687 $r=$r+$r*$tva['tva_rate'];
+00688 $r=round($r,2);
+00689 break;
+00690 case 'TOTAL_VEN_HTVA':
+00691 extract($_POST);
+00692 echo_debug('class_document',__LINE__,'TOTAL_VEN_TVA item :'.$nb_item);
+00693
+00694 $sum=0.0;
+00695 for ($i=0;$i<$nb_item;$i++)
+00696 {
+00697 $sell='e_march'.$i.'_sell';
+00698 $qt='e_quant'.$i;
+00699 echo_debug('class_document',__LINE__,'sell :'.$sell.' qt = '.$qt);
+00700
+00701 echo_debug('class_document',__LINE__,'counter :'.$i.' sur '.$nb_item);
+00702 if ( ! isset (${$sell}) ) break;
+00703 echo_debug('class_document',__LINE__,'sell :'.${$sell}.' qt = '.${$qt});
+00704
+00705 if ( strlen(trim(${$sell})) == 0 ||
+00706 strlen(trim(${$qt})) == 0 ||
+00707 ${$qt}==0 || ${$sell}==0)
+00708 continue;
+00709 $sum+=${$sell}*${$qt};
+00710 echo_debug('class_document',__LINE__,'sum :'.$sum);
+00711
+00712 }
+00713 $r=round($sum,2);
+00714 break;
+00715 case 'TOTAL_VEN_TVAC':
+00716 extract($_POST);
+00717 $sum=0.0;
+00718 for ($i=0;$i<$nb_item;$i++)
+00719 {
+00720 $tva=GetTvaRate($this->db,${'e_march'.$i.'_tva_id'});
+00721 $tva_rate=( $tva == null || $tva == 0 )?0.0:$tva['tva_rate'];
+00722 echo_debug('class_document',__LINE__,' :'.$i.' sur '.$nb_item);
+00723 $sell=${'e_march'.$i.'_sell'};
+00724 $qt=${'e_quant'.$i};
+00725 echo_debug('class_document',__LINE__,'sell :'.$sell.' qt = '.$qt);
+00726
+00727 $sum+=$sell*$qt*(1+$tva_rate);
+00728 // $sum+=${'e_march'.$i.'_sell'}*${'e_quant'.$i}*(1+$tva_rate);
+00729 }
+00730 $r=round($sum,2);
+00731
+00732 break;
+00733
+00734 }
+00735 return $r;
+00736 }
+00740 function remove()
+00741 {
+00742 $sql='delete from document where d_id='.$this->d_id;
+00743 ExecSql($this->db,$sql);
+00744 }
+00751 function MoveDocumentPj($p_internal)
+00752 {
+00753
+00754 $sql=sprintf("update jrn set jr_pj=%s,jr_pj_name='%s',jr_pj_type='%s' where jr_internal='%s'",
+00755 $this->d_lob,$this->d_filename,$this->d_mimetype,$p_internal);
+00756 ExecSql($this->db,$sql);
+00757 // clean the table document
+00758 $this->remove();
+00759 }
+00760
+00761
+00762 }