';
@@ -125,7 +127,7 @@ if ( $report != 0 ) {
echo '';
echo '';
}
-/*
+/*
* Todo list
*/
echo JS_TODO;
diff --git a/html/admin/sql/patch/upgrade63.sql b/html/admin/sql/patch/upgrade63.sql
new file mode 100644
index 000000000..afaf0b8bd
--- /dev/null
+++ b/html/admin/sql/patch/upgrade63.sql
@@ -0,0 +1,62 @@
+begin;
+
+DROP FUNCTION insert_jrnx(character varying, numeric, poste_comptable, integer, integer, boolean, text, integer, text);
+
+CREATE OR REPLACE FUNCTION insert_jrnx(p_date character varying, p_montant numeric, p_poste poste_comptable, p_grpt integer, p_jrn_def integer, p_debit boolean, p_tech_user text, p_tech_per integer, p_qcode text,p_comment text)
+ RETURNS void AS
+$BODY$
+declare
+ sCode varchar;
+ nCount_qcode integer;
+begin
+ sCode=trim(p_qcode);
+
+ -- if p_qcode is empty try to find one
+ if length(sCode) = 0 or p_qcode is null then
+ select count(*) into nCount_qcode
+ from vw_poste_qcode where j_poste=p_poste::text;
+ -- if we find only one q_code for a accountancy account
+ -- then retrieve it
+ if nCount_qcode = 1 then
+ select j_qcode::text into sCode
+ from vw_poste_qcode where j_poste=p_poste::text;
+ else
+ sCode=NULL;
+ end if;
+
+ end if;
+
+ insert into jrnx
+ (
+ j_date,
+ j_montant,
+ j_poste,
+ j_grpt,
+ j_jrn_def,
+ j_debit,
+ j_text,
+ 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_comment,
+ p_tech_user,
+ p_tech_per,
+ sCode
+ );
+
+return;
+end;
+$BODY$
+LANGUAGE plpgsql;
+
+update version set val=64;
+
+commit;
diff --git a/html/admin/sql/patch/upgrade64.sql b/html/admin/sql/patch/upgrade64.sql
new file mode 100644
index 000000000..a580f8402
--- /dev/null
+++ b/html/admin/sql/patch/upgrade64.sql
@@ -0,0 +1,67 @@
+begin;
+
+DROP VIEW vw_fiche_attr;
+
+CREATE OR REPLACE VIEW vw_fiche_attr AS
+ SELECT a.f_id, a.fd_id, a.av_text AS vw_name, b.av_text AS vw_sell, c.av_text AS vw_buy, d.av_text AS tva_code, tva_rate.tva_id, tva_rate.tva_rate, tva_rate.tva_label, e.av_text AS vw_addr, f.av_text AS vw_cp, j.av_text AS quick_code, h.av_text AS vw_description, i.av_text AS tva_num, fiche_def.frd_id
+ 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)
+ 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
+ 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
+ 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 = 7) c ON a.f_id = c.f_id
+ 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 = 2) d ON a.f_id = d.f_id
+ 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 = 14) e ON a.f_id = e.f_id
+ 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 = 15) f ON a.f_id = f.f_id
+ 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 = 23) j ON a.f_id = j.f_id
+ 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 = 9) h ON a.f_id = h.f_id
+ 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 = 13) i ON a.f_id = i.f_id
+ LEFT JOIN tva_rate ON d.av_text = tva_rate.tva_id::text
+ JOIN fiche_def USING (fd_id);
+
+update version set val=65;
+
+commit;
+
diff --git a/html/admin/sql/patch/upgrade65.sql b/html/admin/sql/patch/upgrade65.sql
new file mode 100644
index 000000000..b1d1ce290
--- /dev/null
+++ b/html/admin/sql/patch/upgrade65.sql
@@ -0,0 +1,4 @@
+begin;
+SELECT setval('public.mod_payment_mp_id_seq', 10, true);
+update version set val=66;
+commit;
\ No newline at end of file
diff --git a/html/admin/sql/patch/upgrade66.sql b/html/admin/sql/patch/upgrade66.sql
new file mode 100644
index 000000000..219a1d7b2
--- /dev/null
+++ b/html/admin/sql/patch/upgrade66.sql
@@ -0,0 +1,134 @@
+begin;
+
+drop function account_insert(p_f_id integer, p_account poste_comptable);
+
+CREATE OR REPLACE FUNCTION account_insert(p_f_id integer, p_account text)
+ RETURNS integer AS
+$BODY$
+declare
+nParent tmp_pcmn.pcm_val_parent%type;
+sName varchar;
+nNew tmp_pcmn.pcm_val%type;
+bAuto bool;
+nFd_id integer;
+nCount integer;
+first text;
+second text;
+begin
+
+ if length(trim(p_account)) != 0 then
+ -- if there is coma in p_account, treat normally
+ if position (',' in p_account) = 0 then
+ raise info 'p_account is not empty';
+ select count(*) into nCount from tmp_pcmn where pcm_val=p_account;
+ raise notice 'found in tmp_pcm %',nCount;
+ if nCount !=0 then
+ raise info 'this account exists in tmp_pcmn ';
+ perform attribut_insert(p_f_id,5,p_account);
+ else
+ -- account doesn't exist, create it
+ 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::poste_comptable);
+ insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_account::poste_comptable,sName,nParent);
+ perform attribut_insert(p_f_id,5,p_account);
+
+ end if;
+ else
+ raise info 'presence of a comma';
+ -- there is 2 accounts separated by a comma
+ first := split_part(p_account,',',1);
+ second := split_part(p_account,',',2);
+ -- check there is no other coma
+ raise info 'first value % second value %', first, second;
+
+ if position (',' in first) != 0 or position (',' in second) != 0 then
+ raise exception 'Too many comas, invalid account';
+ end if;
+ perform attribut_insert(p_f_id,5,p_account);
+ end if;
+ else
+ raise info 'p_account is empty';
+ select fd_id into nFd_id from fiche where f_id=p_f_id;
+ bAuto:= account_auto(nFd_id);
+ if bAuto = true then
+ raise notice 'account generated automatically';
+ nNew:=account_compute(p_f_id);
+ raise notice '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,'999999999999999999999999'));
+
+ else
+ -- if there is an account_base then it is the default
+ select fd_class_base::text into nNew from fiche_def join fiche using (fd_id) where f_id=p_f_id;
+ if nNew is null or length(trim(nNew)) = 0 then
+ raise notice 'count is null';
+ perform attribut_insert(p_f_id,5,null);
+ else
+ perform attribut_insert(p_f_id,5,to_char(nNew,'999999999999999999999999'));
+ end if;
+ end if;
+ end if;
+
+return 0;
+end;
+$BODY$
+LANGUAGE 'plpgsql';
+
+drop function account_update(p_f_id integer, p_account poste_comptable);
+
+CREATE OR REPLACE FUNCTION account_update(p_f_id integer, p_account text)
+ RETURNS integer AS
+$BODY$
+declare
+nMax fiche.f_id%type;
+nCount integer;
+nParent tmp_pcmn.pcm_val_parent%type;
+sName varchar;
+nJft_id attr_value.jft_id%type;
+first text;
+second text;
+begin
+
+ if length(trim(p_account)) != 0 then
+ if position (',' in 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:=account_parent(p_account::poste_comptable);
+ insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_account::poste_comptable,sName,nParent);
+ end if;
+ else
+ raise info 'presence of a comma';
+ -- there is 2 accounts separated by a comma
+ first := split_part(p_account,',',1);
+ second := split_part(p_account,',',2);
+ -- check there is no other coma
+ raise info 'first value % second value %', first, second;
+
+ if position (',' in first) != 0 or position (',' in second) != 0 then
+ raise exception 'Too many comas, invalid account';
+ end if;
+ 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;
+$BODY$
+LANGUAGE 'plpgsql';
+
+update version set val=67;
+commit;
\ No newline at end of file
diff --git a/html/admin/sql/patch/upgrade67.sql b/html/admin/sql/patch/upgrade67.sql
new file mode 100644
index 000000000..203b1b516
--- /dev/null
+++ b/html/admin/sql/patch/upgrade67.sql
@@ -0,0 +1,177 @@
+begin;
+
+DROP VIEW vw_fiche_def;
+DROP VIEW vw_supplier;
+DROP VIEW vw_client;
+
+alter table fiche_def alter fd_class_base type text;
+CREATE OR REPLACE VIEW vw_fiche_def AS
+ SELECT jnt_fic_attr.fd_id, jnt_fic_attr.ad_id, attr_def.ad_text, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def.frd_id
+ FROM fiche_def
+ JOIN jnt_fic_attr USING (fd_id)
+ JOIN attr_def ON attr_def.ad_id = jnt_fic_attr.ad_id;
+
+COMMENT ON VIEW vw_fiche_def IS 'all the attributs for card family';
+
+CREATE OR REPLACE VIEW vw_supplier AS
+ 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;
+CREATE OR REPLACE VIEW vw_client AS
+ 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 = 9;
+
+
+CREATE OR REPLACE FUNCTION fiche_def_ins_upd()
+ RETURNS "trigger" AS
+$BODY$
+begin
+
+if position (',' in NEW.fd_class_base) != 0 then
+ NEW.fd_create_account='f';
+
+end if;
+return NEW;
+end;$BODY$
+LANGUAGE 'plpgsql';
+
+CREATE TRIGGER fiche_def_ins_upd
+ BEFORE INSERT OR UPDATE
+ ON fiche_def
+ FOR EACH ROW
+ EXECUTE PROCEDURE fiche_def_ins_upd();
+
+ALTER TABLE stock_goods DROP CONSTRAINT fk_stock_good_f_id;
+
+ALTER TABLE stock_goods
+ ADD CONSTRAINT fk_stock_good_f_id FOREIGN KEY (f_id)
+ REFERENCES fiche (f_id) MATCH SIMPLE
+ ON UPDATE cascade ON DELETE cascade;
+
+update version set val=68;
+commit;
diff --git a/html/ajax.php b/html/ajax.php
new file mode 100644
index 000000000..4f1702488
--- /dev/null
+++ b/html/ajax.php
@@ -0,0 +1,38 @@
+check(true);
+
+/* if a code has been asked */
+if (isset($_REQUEST['code']) ) {
+
+ $ext=new Extension($cn);
+ $ext->search('code',$_REQUEST['code']);
+ if ( $ext->get_parameter('id') != 0 ) {
+ /* security */
+ if ( !isset ($_SESSION['g_user']) || $ext->can_request($_SESSION['g_user']) == 0 ) {
+ exit();
+ }
+ /* call the ajax script */
+ require_once('ext'.DIRECTORY_SEPARATOR.dirname(trim($ext->get_parameter('filepath'))).DIRECTORY_SEPARATOR.'ajax.php');
+ } else {
+ alert(j(_("Cette extension n'existe pas ")));
+ exit();
+ }
+
+}
+?>
\ No newline at end of file
diff --git a/html/ajax_extension.php b/html/ajax_extension.php
index 4f8f4b699..fdea35465 100644
--- a/html/ajax_extension.php
+++ b/html/ajax_extension.php
@@ -85,7 +85,7 @@ switch($action) {
$enable->selected=$ext->get_parameter('enable');
$str_enable=$enable->input();
$r.='
";
diff --git a/include/ac_common.php b/include/ac_common.php
index 2f6249a9a..e63a56d08 100644
--- a/include/ac_common.php
+++ b/include/ac_common.php
@@ -1,4 +1,4 @@
-'.htmlspecialchars($p_string).'';}
function hb($p_string) { return ''.htmlspecialchars($p_string).'';}
function th($p_string) { return '
'.htmlspecialchars($p_string).'
';}
-/*!\brief surrond the string with td
+/*!\brief surrond the string with td
*\param string
*\param class to use
* \return string surrounded by td
@@ -43,15 +43,15 @@ function th($p_string) { return '
'.htmlspecialchars($p_string).'
';}
function td($p_string,$p_class=''){ return '
'.$p_string.'
';}
/*!\brief escape correctly php string to javascript */
function j($p_string) { $a=preg_replace("/\r?\n/", "\\n", addslashes($p_string)); return $a;}
-/*!
+/*!
* \brief log error into the /tmp/phpcompta_error.log it doesn't work on windows
*
* \param p_log message
* \param p_line line number
* \param p_message is the message
- *
+ *
* \return nothing
- *
+ *
*/
function echo_error ($p_log, $p_line="", $p_message="") {
echo "ERREUR :".$p_log." ".$p_line." ".$p_message;
@@ -62,15 +62,15 @@ function echo_error ($p_log, $p_line="", $p_message="") {
echo_debug($p_log,$p_line,$p_message);
}
}
-
-/*!
+
+/*!
* \brief Compare 2 dates
- * \param p_date
+ * \param p_date
* \param p_date_oth
- *
- * \return
+ *
+ * \return
* - == 0 les dates sont identiques
- * - > 0 date1 > date2
+ * - > 0 date1 > date2
* - < 0 date1 < date2
*/
function cmpDate ($p_date,$p_date_oth) {
@@ -88,12 +88,12 @@ function cmpDate ($p_date,$p_date_oth) {
// si $p_date > $p_date_oth return > 0
return $l_mkdate-$l2_mkdate;
}
-/*!
+/*!
* \brief check if the argument is a number
*
* \param $p_int number to test
*
- * \return
+ * \return
* - 1 it's a number
* - 0 it is not
*/
@@ -107,16 +107,16 @@ function isNumber(&$p_int) {
}
-/*!
+/*!
* \brief Verifie qu'une date est bien formaté
* en d.m.y et est valable
* \param $p_date
- *
+ *
* \return
* - null si la date est invalide ou malformaté
* - $p_date si tout est bon
*
- */
+ */
function isDate ( $p_date) {
if ( strlen (trim($p_date)) == 0 ) return null;
@@ -141,9 +141,9 @@ function isDate ( $p_date) {
}// !ereg
return $p_date;
}
-/*!
+/*!
* \brief Default page header for each page
- *
+ *
* \param p_theme default theme
* \param $p_script
* \param $p_script2 another js script
@@ -151,13 +151,13 @@ function isDate ( $p_date) {
* \return none
*/
function html_page_start($p_theme="",$p_script="",$p_script2="")
-{
+{
$cn=new Database();
if ( $p_theme != "") {
$Res=$cn->exec_sql("select the_filestyle from theme
where the_name='".$p_theme."'");
- if (Database::num_row($Res)==0)
+ if (Database::num_row($Res)==0)
$style="style.css";
else {
$s=Database::fetch_array($Res,0);
@@ -172,7 +172,7 @@ function html_page_start($p_theme="",$p_script="",$p_script2="")
if ( $p_script2 != "" )
$p_script2='';
- echo "
+ echo "
PhpCompta
@@ -198,9 +198,9 @@ function html_page_start($p_theme="",$p_script="",$p_script2="")
}
}
-/*!
+/*!
* \brief Minimal page header for each page, used for small popup window
- *
+ *
* \param p_theme default theme
* \param $p_script
* \param $p_script2 another js script
@@ -208,13 +208,13 @@ function html_page_start($p_theme="",$p_script="",$p_script2="")
* \return none
*/
function html_min_page_start($p_theme="",$p_script="",$p_script2="")
-{
+{
$cn=new Database();
if ( $p_theme != "") {
$Res=$cn->exec_sql("select the_filestyle from theme
where the_name='".$p_theme."'");
- if (Database::num_row($Res)==0)
+ if (Database::num_row($Res)==0)
$style="style.css";
else {
$s=Database::fetch_array($Res,0);
@@ -230,7 +230,7 @@ function html_min_page_start($p_theme="",$p_script="",$p_script2="")
if ( $p_script2 != "" )
$p_script2='';
- echo "
+ echo "
PhpCompta
@@ -248,31 +248,31 @@ function html_min_page_start($p_theme="",$p_script="",$p_script2="")
}
-/*!
- * \brief end tag
- *
+/*!
+ * \brief end tag
+ *
*/
function html_page_stop()
{
echo "";
echo "";
}
-/*!
- * \brief Echo no access and stop
- *
+/*!
+ * \brief Echo no access and stop
+ *
* \return nothing
*/
-function NoAccess($js=1)
+function NoAccess($js=1)
{
- if ( $js == 1 )
+ if ( $js == 1 )
{
echo "";
}
- else
+ else
{
echo '
';
echo '
'._(' Cette action ne vous est pas autorisée Contactez votre responsable').'
';
@@ -280,13 +280,13 @@ function NoAccess($js=1)
}
exit -1;
}
-/*!
+/*!
* \brief Fix the problem with the quote char for the database
- *
- * \param $p_string
+ *
+ * \param $p_string
* \return a string which won't let strange char for the database
*/
-function FormatString($p_string)
+function FormatString($p_string)
{
$p_string=trim($p_string);
if (strlen($p_string) == 0 ) return null;
@@ -296,10 +296,10 @@ function FormatString($p_string)
return $p_string;
}
-/*!
-/* \brief store the string which print
- * the content of p_array in a table
- * used to display the menu
+/*!
+/* \brief store the string which print
+ * the content of p_array in a table
+ * used to display the menu
* \param $p_array array like ( HREF reference, visible item (name),Help(opt),
* selected (opt)
* \param $p_dir direction of the menu (H Horizontal V vertical)
@@ -317,9 +317,9 @@ function ShowItem($p_array,$p_dir='V',$class="mtitle",$class_ref="mtitle",$defau
foreach ($p_array as $all=>$href){
$title="";
$set="XX";
- if ( isset ($href[2] ))
+ if ( isset ($href[2] ))
$title=$href[2];
- if ( isset($href[3] ))
+ if ( isset($href[3] ))
$set=$href[3];
if ( $set == $default )
@@ -336,7 +336,7 @@ function ShowItem($p_array,$p_dir='V',$class="mtitle",$class_ref="mtitle",$defau
$title="";
$set="A";
- if ( isset ($href[2] ))
+ if ( isset ($href[2] ))
$title=$href[2];
if ( isset($href[3]))
@@ -356,31 +356,31 @@ function ShowItem($p_array,$p_dir='V',$class="mtitle",$class_ref="mtitle",$defau
$ret.="";
return $ret;
}
-/*!
+/*!
* \brief warns
- *
+ *
* \param p_string error message
* gen :
* - none
* \return:
* - none
*/
-function echo_warning($p_string)
+function echo_warning($p_string)
{
echo '
'.$p_string."
";
}
-/*!
+/*!
* \brief Show the periode which found thanks its id
- *
- *
- * \param $p_cn database connection
+ *
+ *
+ * \param $p_cn database connection
* \param p_id
* \param pos Start or end
*
* \return: string
*/
function getPeriodeName($p_cn,$p_id,$pos='p_start') {
- if ( $pos != 'p_start' and
+ if ( $pos != 'p_start' and
$pos != 'p_end')
echo_error('ac_common.php'."-".__LINE__.' UNDEFINED PERIODE');
$ret=$p_cn->get_value("select to_char($pos,'Mon YYYY') as t from parm_periode where p_id=$p_id");
@@ -388,10 +388,10 @@ function getPeriodeName($p_cn,$p_id,$pos='p_start') {
}
-/*!
- * \brief Return the period corresponding to the
+/*!
+ * \brief Return the period corresponding to the
* date
- *
+ *
* \param p_cn database connection
* \param p_date the month + year 'MM.YYYY'
*
@@ -401,7 +401,7 @@ function getPeriodeName($p_cn,$p_id,$pos='p_start') {
function getPeriodeFromMonth($p_cn,$p_date) {
$R=$p_cn->get_value("select p_id from parm_periode where
to_char(p_start,'DD.MM.YYYY') = '01.$p_date'");
- if ( $R == "" )
+ if ( $R == "" )
return -1;
return $R;
}
@@ -422,13 +422,13 @@ function Decode($p_html){
* \param $p_from start date (date)
* \param $p_to end date (date)
* \param $p_form if the p_from and p_to are date or p_id
- * \param $p_field column name
+ * \param $p_field column name
* \return a string containg the query
*/
function sql_filter_per($p_cn,$p_from,$p_to,$p_form='p_id',$p_field='jr_tech_per')
{
- if ( $p_form != 'p_id' &&
+ if ( $p_form != 'p_id' &&
$p_form != 'date' )
{
echo_error (__FILE__,__LINE__,'Mauvais parametres ');
@@ -444,22 +444,22 @@ function sql_filter_per($p_cn,$p_from,$p_to,$p_form='p_id',$p_field='jr_tech_per
throw new Exception(__FILE__.__LINE__.'Attention periode '.
' non trouvee periode p_from='.$p_from.
'p_to_periode = '.$p_to);
-
+
$p_from=$a_start['p_start'];
$p_to=$a_end['p_end'];
- }
- if ( $p_from == $p_to )
+ }
+ if ( $p_from == $p_to )
$periode=" $p_field = (select p_id from parm_periode ".
" where ".
- " p_start = to_date('$p_from','DD.MM.YYYY')) ";
+ " p_start = to_date('$p_from','DD.MM.YYYY')) ";
else
$periode = "$p_field in (select p_id from parm_periode ".
" where p_start >= to_date('$p_from','DD.MM.YYYY') and p_end <= to_date('$p_to','DD.MM.YYYY')) ";
return $periode;
}
-/*!\brief alert in javascript
+/*!\brief alert in javascript
*\param $p_msg is the message
*\param $buffer if false, echo directly and execute the javascript, if $buffer is true, the alert javascript
* is in the return string
@@ -482,7 +482,7 @@ function alert($p_msg,$buffer=false)
function set_language() {
$dir="";
$dir=setlocale(LC_MESSAGES,$_SESSION['g_lang']);
-
+
if ( $dir == "") {
$dir=setlocale(LC_MESSAGES,"fr_FR.utf8");
echo ''.$_SESSION['g_lang'].'domaine non supporté';
diff --git a/include/argenta_be.inc.php b/include/argenta_be.inc.php
index a2ff3c4a4..a23fb0320 100644
--- a/include/argenta_be.inc.php
+++ b/include/argenta_be.inc.php
@@ -34,7 +34,7 @@ while (($data = fgetcsv($handle, 2000,"!")) !== FALSE) {
$num = count($data);
for ($c=0; $c < $num; $c++) {
if ( $line==1) {
- $row=split(';',$data[$c]);
+ $row=explode(';',$data[$c]);
$num_compte=$row[1];
}
if ( $line < 2 )
@@ -42,7 +42,7 @@ while (($data = fgetcsv($handle, 2000,"!")) !== FALSE) {
//-----------------------------------------------------
// Parsing CSV comes here
//-----------------------------------------------------
- $row=split(';',$data[$c]);
+ $row=explode(';',$data[$c]);
echo 'ici sizeof $row = '.sizeof($row);
echo_debug('argenta',__LINE__,'$row = '.var_export($row,true));
echo_debug('argenta',__LINE__,'sizeof($row)'.sizeof($row));
diff --git a/include/cbc_be.inc.php b/include/cbc_be.inc.php
index 8594e1b3c..1fa1d052e 100644
--- a/include/cbc_be.inc.php
+++ b/include/cbc_be.inc.php
@@ -36,7 +36,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) {
//-----------------------------------------------------
// Parsing CSV comes here
//-----------------------------------------------------
- $row=split(';',$data[$c]);
+ $row=explode(';',$data[$c]);
echo_debug('cbc_be',__LINE__,'$row = '.var_export($row,true));
echo_debug('cbc_be',__LINE__,'sizeof($row)'.sizeof($row));
if ( sizeof ($row) < 13 )
diff --git a/include/class_acc_account_ledger.php b/include/class_acc_account_ledger.php
index b5b8d5846..1596ad779 100644
--- a/include/class_acc_account_ledger.php
+++ b/include/class_acc_account_ledger.php
@@ -243,7 +243,7 @@ function get_solde_detail($p_cond="") {
{
if ( $line_tva['tva_poste'] == '' )
continue;
- list($tva_deb,$tva_cred)=split(',',$line_tva['tva_poste']);
+ list($tva_deb,$tva_cred)=explode(',',$line_tva['tva_poste']);
if ( $this->id == $tva_deb ||
$this->id == $tva_cred )
{
@@ -368,7 +368,7 @@ function get_solde_detail($p_cond="") {
if ( trim ($filter) == '')
return 0;
- $valid_cred=split(" ",$filter);
+ $valid_cred=explode(" ",$filter);
$sql="select count(*) as poste from tmp_pcmn where ";
// Creation query
$or="";
@@ -403,7 +403,7 @@ function get_solde_detail($p_cond="") {
$l=new Acc_Ledger($this->db,$p_jrn);
$row=$l->get_propertie();
if ( strlen(trim($row['jrn_def_class_deb'])) == 0 ) return array();
- $valid_account=split(" ",$row['jrn_def_class_deb']);
+ $valid_account=explode(" ",$row['jrn_def_class_deb']);
return $valid_account;
}
/*!\brief build a sql statement thanks a array found with get_account_ledger
diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php
index b0d109f4e..8d23e7464 100644
--- a/include/class_acc_ledger.php
+++ b/include/class_acc_ledger.php
@@ -910,7 +910,7 @@ jr_comment||' ('||c_internal||')'||case when jr_pj_number is not null and jr_pj_
{
echo_debug('class_acc_ledger',__LINE__,'ICI');
echo_debug('class_acc_ledger',__LINE__,'Montant TVA = '.$p_array['AMOUNT_TVA']);
- list($tva_deb,$tva_cred)=split(',',$line_tva['tva_poste']);
+ list($tva_deb,$tva_cred)=explode(',',$line_tva['tva_poste']);
if ( $code['j_poste'] == $tva_deb ||
$code['j_poste'] == $tva_cred )
{
@@ -1578,7 +1578,14 @@ jr_comment||' ('||c_internal||')'||case when jr_pj_number is not null and jr_pj_
if ( isset(${'qc_'.$i})) {
$qc=new fiche($this->db);
$qc->get_by_qcode(${'qc_'.$i},false);
- $poste=$qc->strAttribut(ATTR_DEF_ACCOUNT);
+ $sposte=$qc->strAttribut(ATTR_DEF_ACCOUNT);
+ /* if there are 2 accounts take following the deb or cred */
+ if (strpos($sposte,',') != 0 ){
+ $array=explode(",",$sposte);
+ $poste=(isset(${'ck'.$i}))?$array[0]:$array[1];
+ } else {
+ $poste=$sposte;
+ }
$quick_code=${'qc_'.$i};
}
else {
@@ -1588,6 +1595,8 @@ jr_comment||' ('||c_internal||')'||case when jr_pj_number is not null and jr_pj_
// compute the periode is do not check it
if ($check_periode == false ) $acc_op->periode=$oPeriode->p_id;
$acc_op->desc=$desc;
+ if ( strlen(trim(${'ld'.$i})) != 0 )
+ $acc_op->desc=${'ld'.$i};
$acc_op->amount=round(${'amount'.$i},2);
$acc_op->grpt=$seq;
$acc_op->poste=$poste;
@@ -1595,8 +1604,6 @@ jr_comment||' ('||c_internal||')'||case when jr_pj_number is not null and jr_pj_
$acc_op->type=(isset (${'ck'.$i}))?'d':'c';
$acc_op->qcode=$quick_code;
$j_id=$acc_op->insert_jrnx();
- if ( strlen(trim(${'ld'.$i})) != 0 )
- $acc_op->update_comment(${'ld'.$i});
$tot_amount+=round($acc_op->amount,2);
$tot_deb+=($acc_op->type=='d')?$acc_op->amount:0;
$tot_cred+=($acc_op->type=='c')?$acc_op->amount:0;
@@ -1851,9 +1858,11 @@ function get_last_date()
$str_file=$doc->Generate();
// Move the document to the jrn
$doc->MoveDocumentPj($internal);
- // Update the comment with invoice number
- $sql="update jrn set jr_comment=' document ".$doc->d_number."' where jr_internal='$internal'";
- $this->db->exec_sql($sql);
+ // Update the comment with invoice number, if the comment is empty
+ if ( ! isset ($e_comm) || strlen(trim($e_comm))== 0 ) {
+ $sql="update jrn set jr_comment=' document ".$doc->d_number."' where jr_internal='$internal'";
+ $this->db->exec_sql($sql);
+ }
return '
'.$str_file.'
';
}
@@ -1870,7 +1879,16 @@ function get_last_date()
if ( $empl->empty_attribute(ATTR_DEF_ACCOUNT)== true) {
throw new Exception('Celui qui paie n\' a pas de poste comptable',20);
}
- $poste=new Acc_Account_Ledger($this->db,$empl->strAttribut(ATTR_DEF_ACCOUNT));
+ /* get the account and explode if necessary */
+ $sposte=$empl->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts, take only the debit one for customer
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[0];
+ } else {
+ $poste_val=$sposte;
+ }
+ $poste=new Acc_Account_Ledger($this->db,$poste_val);
if ( $poste->load() == false ){
throw new Exception('Pour la fiche'.$empl->quick_code.' le poste comptable ['.$poste->id.'n\'existe pas',9);
@@ -2075,9 +2093,10 @@ function get_last_date()
if ( $p_action == 'client') $p_action='ALL';
if ( $p_action == 'fournisseur') $p_action='ALL';
if ( $p_action == 'adm') $p_action='ALL';
+ if ( $p_action == 'quick_writing') $p_action='ALL';
- $fil_ledger=$user->get_ledger_sql($p_action,2);
+ $fil_ledger=$user->get_ledger_sql($p_action,3);
$and=' and ';
} else if ( $p_jrn != 0 ){
$fil_ledger = ' jrn_def_id = '.$p_jrn;
@@ -2300,10 +2319,10 @@ function get_last_date()
$array=$this->db->get_array($sql);
return $array;
}
- /**
+ /**
*@brief retreive the jr_grpt_id from a ledger
*@param $p_what the column to seek
- * possible values are
+ * possible values are
* - internal
*@param $p_value the value of the col.
*/
@@ -2312,7 +2331,7 @@ function get_last_date()
case 'internal':
return $this->db->get_value('select jr_grpt_id from jrn where jr_internal=$1',
array($p_value));
-
+
}
}
}
diff --git a/include/class_acc_ledger_fin.php b/include/class_acc_ledger_fin.php
index b9899fa28..d27ef810f 100644
--- a/include/class_acc_ledger_fin.php
+++ b/include/class_acc_ledger_fin.php
@@ -95,8 +95,19 @@ class Acc_Ledger_Fin extends Acc_Ledger {
if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
throw new Exception('La fiche '.$e_bank_account.'n\'a pas de poste comptable',8);
+ /* get the account and explode if necessary */
+ $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts, take only the debit one for customer
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[0];
+ } else {
+ $poste_val=$sposte;
+ }
+
+ $acc_pay=new Acc_Operation($this->db);
/* The account exists */
- $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT));
+ $poste=new Acc_Account_Ledger($this->db,$poste_val);
if ( $poste->load() == false ){
throw new Exception('Pour la fiche '.$e_bank_account.' le poste comptable ['.$poste->id.'] n\'existe pas',9);
}
@@ -126,8 +137,17 @@ class Acc_Ledger_Fin extends Acc_Ledger {
$fiche->get_by_qcode(${'e_other'.$i});
if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
throw new Exception('La fiche '.${'e_other'.$i}.'n\'a pas de poste comptable',8);
+
+ $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts, take only the debit one for customer
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[1];
+ } else {
+ $poste_val=$sposte;
+ }
/* The account exists */
- $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT));
+ $poste=new Acc_Account_Ledger($this->db,$poste_val);
if ( $poste->load() == false ){
throw new Exception('Pour la fiche '.${'e_other'.$i}.' le poste comptable ['.$poste->id.'n\'existe pas',9);
}
@@ -554,7 +574,16 @@ class Acc_Ledger_Fin extends Acc_Ledger {
$exercice=$pPeriode->get_exercice();
$filter_year=" j_tech_per in (select p_id from parm_periode where p_exercice='".$exercice."')";
- $acc_account=new Acc_Account_Ledger($this->db,$fBank->strAttribut(ATTR_DEF_ACCOUNT));
+ $sposte=$fBank->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts, take only the debit one for customer
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[0];
+ } else {
+ $poste_val=$sposte;
+ }
+
+ $acc_account=new Acc_Account_Ledger($this->db,$poste_val);
$solde=$acc_account->get_solde($filter_year);
$new_solde=$solde;
@@ -580,7 +609,20 @@ class Acc_Ledger_Fin extends Acc_Ledger {
$acc_operation=new Acc_Operation($this->db);
$acc_operation->date=$e_date;
- $acc_operation->poste=$fPoste->strAttribut(ATTR_DEF_ACCOUNT);
+ $sposte=$fPoste->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ if ( ${"e_other$i"."_amount"} < 0 )
+ $poste_val=$array[0];
+ else
+ $poste_val=$array[1];
+ } else {
+ $poste_val=$sposte;
+ }
+
+
+ $acc_operation->poste=$poste_val;
$acc_operation->amount=${"e_other$i"."_amount"}*(-1);
$acc_operation->grpt=$seq;
$acc_operation->jrn=$p_jrn;
@@ -600,7 +642,20 @@ class Acc_Ledger_Fin extends Acc_Ledger {
$acc_operation=new Acc_Operation($this->db);
$acc_operation->date=$e_date;
- $acc_operation->poste=$fBank->strAttribut(ATTR_DEF_ACCOUNT);
+ $sposte=$fBank->strAttribut(ATTR_DEF_ACCOUNT);
+
+ // if 2 accounts
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ if ( ${"e_other$i"."_amount"} < 0 )
+ $poste_val=$array[1];
+ else
+ $poste_val=$array[0];
+ } else {
+ $poste_val=$sposte;
+ }
+
+ $acc_operation->poste=$poste_val;
$acc_operation->amount=${"e_other$i"."_amount"};
$acc_operation->grpt=$seq;
$acc_operation->jrn=$p_jrn;
@@ -635,7 +690,7 @@ class Acc_Ledger_Fin extends Acc_Ledger {
if ( trim(${"e_concerned".$i}) != "" ) {
if ( strpos(${"e_concerned".$i},',') != 0 )
{
- $aRapt=split(',',${"e_concerned".$i});
+ $aRapt=explode(',',${"e_concerned".$i});
foreach ($aRapt as $rRapt) {
// Add a "concerned operation to bound these op.together
//
diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php
index 52725bafe..dc4358c4a 100644
--- a/include/class_acc_ledger_purchase.php
+++ b/include/class_acc_ledger_purchase.php
@@ -104,8 +104,18 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
throw new Exception(_('La fiche ').$e_client._('n\'a pas de poste comptable'),8);
+ /* get the account and explode if necessary */
+ $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts, take only the credit one for supplier
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[1];
+ } else {
+ $poste_val=$sposte;
+ }
+
/* The account exists */
- $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT));
+ $poste=new Acc_Account_Ledger($this->db,$poste_val);
if ( $poste->load() == false ){
throw new Exception(_('Pour la fiche ').$e_client._(' le poste comptable [').$poste->id.'] '._('n\'existe pas'),9);
}
@@ -139,8 +149,19 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
$fiche->get_by_qcode(${'e_march'.$i});
if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
throw new Exception(_('La fiche ').${'e_march'.$i}._('n\'a pas de poste comptable'),8);
+
+ /* get the account and explode if necessary */
+ $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts, take only the debit
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[0];
+ } else {
+ $poste_val=$sposte;
+ }
+
/* The account exists */
- $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT));
+ $poste=new Acc_Account_Ledger($this->db,$poste_val);
if ( $poste->load() == false ){
throw new Exception(_('Pour la fiche ').${'e_march'.$i}._(' le poste comptable').' ['.$poste->id._('n\'existe pas'),9);
}
@@ -160,8 +181,37 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
}
/*!\brief insert into the database, it calls first the verify function
- * change the value of this->jr_id and this->jr_internal
+ * change the value of this->jr_id and this->jr_internal.
+ * It generates the document and save the middle of payment, if 'gen_invoice is set
+ * and e_mp
*\param $p_array is usually $_POST or a predefined operation
+\verbatim
+ Array
+(
+
+ [e_client] =>BELGACOM
+ [nb_item] =>9
+ [p_jrn] =>3
+ [period] =>117
+ [e_comm] =>Frais de téléphone
+ [e_date] =>01.09.2009
+ [e_ech] =>
+ [jrn_type] =>ACH
+ [e_pj] =>ACH53
+ [e_pj_suggest] =>ACH53
+ [mt] =>1265318941.39
+ [e_mp] =>0
+ [e_march0] =>TEL
+ [e_march0_price] =>63.6700
+ [e_march0_tva_id] =>1
+ [e_march0_tva_amount] =>13.3700
+ [e_quant0] =>1.000
+ ...
+ [bon_comm] =>
+ [other_info] =>
+ [record] =>Enregistrement
+)
+\endverbatim
*\return string
*\note throw an Exception
*/
@@ -179,7 +229,15 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
$cust=new fiche($this->db);
$cust->get_by_qcode($e_client);
- $poste=$cust->strAttribut(ATTR_DEF_ACCOUNT);
+ $sposte=$cust->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts, take only the credit Supplier
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste=$array[1];
+ } else {
+ $poste=$sposte;
+ }
+
$oPeriode=new Periode($this->db);
$check_periode=$this->check_periode();
@@ -276,7 +334,17 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
$acc_amount->correct();
$tot_amount+=$amount;
- $acc_operation->poste=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
+ /* get the account and explode if necessary */
+ $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts, take only the debit one for customer
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[0];
+ } else {
+ $poste_val=$sposte;
+ }
+
+ $acc_operation->poste=$poste_val;
$acc_operation->amount=$acc_amount->amount;
$acc_operation->qcode=${"e_march".$i};
if( $acc_amount->amount > 0 ) $tot_debit=bcadd($tot_debit,$acc_amount->amount);
@@ -504,7 +572,17 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
/* Insert paid by */
$acc_pay=new Acc_Operation($this->db);
$acc_pay->date=$e_date;
- $acc_pay->poste=$acfiche->strAttribut(ATTR_DEF_ACCOUNT);
+
+ /* get the account and explode if necessary */
+ $sposte=$acfiche->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts, take only the debit one for customer
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[1];
+ } else {
+ $poste_val=$sposte;
+ }
+ $acc_pay->poste=$poste_val;
$acc_pay->qcode=$fqcode;
$acc_pay->amount=abs(round($tot_debit,2));
$acc_pay->desc=$e_comm;
@@ -872,7 +950,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
// Set correctly the REQUEST param for jrn_type
$r.= HtmlInput::hidden('jrn_type','ACH');
$r.= HtmlInput::button('add_item',_('Ajout article'), ' onClick="ledger_add_row()"');
-
+
/* if we suggest the pj n# the run the script */
@@ -1119,32 +1197,9 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
}
// check for upload piece
-/**
-*@todo clean dead code
-*/
- /* $file=new IFile();
- $file->table=0;
- $r.=_("Ajoutez une pièce justificative ");
- $r.=$file->input("pj","");
- */
$r.=HtmlInput::warnbulle(12);
$r.=$this->extra_info();
- /* Propose to generate a note of fee */
- if ( $this->db->count_sql("select md_id,md_name from document_modele where md_type=10") > 0 &&
- $e_mp != 0)
- {
-
-
- $r.=_('ou générer une note de frais').' ';
- // We propose to generate the invoice and some template
- $doc_gen=new ISelect();
- $doc_gen->name="gen_doc";
- $doc_gen->value=$this->db->make_array(
- "select md_id,md_name from document_modele where md_type=10");
- $r.=$doc_gen->input().' ';
- }
-
return $r;
}
@@ -1152,7 +1207,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
* - add a attachment
* - generate an invoice
* - insert extra info
- *\return string
+ *\return html string
*/
public function extra_info() {
$r="";
@@ -1164,17 +1219,17 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
$r.=_("Ajoutez une pièce justificative ");
$r.=$file->input("pj","");
- if ( $this->db->count_sql("select md_id,md_name from document_modele where md_type=4") > 0 )
+ if ( $this->db->count_sql("select md_id,md_name from document_modele where md_type=10") > 0 )
{
-
+ $r.='';
$r.=_('ou générer un document').' ';
// We propose to generate the note of fee
$doc_gen=new ISelect();
$doc_gen->name="gen_doc";
$doc_gen->value=$this->db->make_array(
"select md_id,md_name ".
- " from document_modele where md_type=4");
+ " from document_modele where md_type=10");
$r.=$doc_gen->input().' ';
}
$r.=' ';
diff --git a/include/class_acc_ledger_sold.php b/include/class_acc_ledger_sold.php
index f70143387..1e674e4a7 100644
--- a/include/class_acc_ledger_sold.php
+++ b/include/class_acc_ledger_sold.php
@@ -105,8 +105,19 @@ class Acc_Ledger_Sold extends Acc_Ledger {
if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
throw new Exception(_('La fiche ').$e_client._('n\'a pas de poste comptable'),8);
+ /* get the account and explode if necessary */
+ $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts, take only the debit one for customer
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[0];
+ } else {
+ $poste_val=$sposte;
+ }
/* The account exists */
- $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT));
+
+ $poste=new Acc_Account_Ledger($this->db,$poste_val);
+
if ( $poste->load() == false ){
throw new Exception(_('Pour la fiche ').$e_client._(' le poste comptable [').$poste->id._('] n\'existe pas'),9);
}
@@ -136,7 +147,16 @@ class Acc_Ledger_Sold extends Acc_Ledger {
if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
throw new Exception(_('La fiche ').${'e_march'.$i}._('n\'a pas de poste comptable'),8);
/* The account exists */
- $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT));
+ $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
+
+ // if 2 accounts, take only the credit one
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[1];
+ } else {
+ $poste_val=$sposte;
+ }
+ $poste=new Acc_Account_Ledger($this->db,$poste_val);
if ( $poste->load() == false ){
throw new Exception(_('Pour la fiche ').${'e_march'.$i}._(' le poste comptable [').$poste->id._('n\'existe pas'),9);
}
@@ -162,11 +182,14 @@ class Acc_Ledger_Sold extends Acc_Ledger {
/*!\brief insert into the database, it calls first the verify function,
* change the value of this->jr_id and this->jr_internal
+ * * It generates the document if gen_invoice is set and save the middle of payment if any ($e_mp)
+ *
*\param $p_array is usually $_POST or a predefined operation
*\return string
*\note throw an Exception
*/
public function insert($p_array) {
+
extract ($p_array);
$this->verify($p_array) ;
@@ -187,7 +210,17 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$cust=new fiche($this->db);
$cust->get_by_qcode($e_client);
- $poste=$cust->strAttribut(ATTR_DEF_ACCOUNT);
+ $sposte=$cust->strAttribut(ATTR_DEF_ACCOUNT);
+
+ // if 2 accounts, take only the debit one for the customer
+ //
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste=$array[0];
+ } else {
+ $poste=$sposte;
+ }
+
bcscale(4);
try {
$tot_amount=0;
@@ -207,7 +240,17 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$tot_amount+=$amount;
$acc_operation=new Acc_Operation($this->db);
$acc_operation->date=$e_date;
- $acc_operation->poste=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
+ $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
+
+ // if 2 accounts, take only the credit one
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[1];
+ } else {
+ $poste_val=$sposte;
+ }
+
+ $acc_operation->poste=$poste_val;
$acc_operation->amount=$amount;
$acc_operation->grpt=$seq;
$acc_operation->jrn=$p_jrn;
@@ -347,7 +390,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
" jr_grpt_id = ".$seq);
/* Save the attachment or generate doc*/
- if ( isset ($_FILES)) {
+ if ( isset ($_FILES['pj'])) {
if ( strlen(trim($_FILES['pj']['name'])) != 0 )
$this->db->save_upload_document($seq);
else
@@ -379,7 +422,17 @@ class Acc_Ledger_Sold extends Acc_Ledger {
/* Insert paid by */
$acc_pay=new Acc_Operation($this->db);
$acc_pay->date=$e_date;
- $acc_pay->poste=$acfiche->strAttribut(ATTR_DEF_ACCOUNT);
+ /* get the account and explode if necessary */
+ $sposte=$acfiche->strAttribut(ATTR_DEF_ACCOUNT);
+ // if 2 accounts, take only the debit one for customer
+ if ( strpos($sposte,',') != 0 ) {
+ $array=explode(',',$sposte);
+ $poste_val=$array[0];
+ } else {
+ $poste_val=$sposte;
+ }
+
+ $acc_pay->poste=$poste_val;
$acc_pay->qcode=$fqcode;
$acc_pay->amount=abs(round($tot_debit,2));
$acc_pay->desc=$e_comm;
diff --git a/include/class_acc_operation.php b/include/class_acc_operation.php
index d991eb4e0..c495c4ce9 100644
--- a/include/class_acc_operation.php
+++ b/include/class_acc_operation.php
@@ -22,14 +22,14 @@
/*!\file
* \brief this file match the tables jrn & jrnx the purpose is to
- * remove or save accountant writing to these table.
+ * remove or save accountant writing to these table.
*/
require_once ('class_user.php');
/*! \brief this file match the tables jrn & jrnx the purpose is to
- * remove or save accountant writing to these table.
+ * remove or save accountant writing to these table.
*
*/
-class Acc_Operation
+class Acc_Operation
{
var $db; /*!< database connx */
var $jr_id; /*!< pk of jrn */
@@ -42,7 +42,7 @@ var $jr_id; /*!< pk of jrn */
var $periode; /*!< periode to use */
var $amount; /*!< amount of the operatoin */
var $grpt; /*!< the group id */
-/*!
+/*!
* \brief constructor set automatically the attributes user and periode
* \param $p_cn the databse connection
*/
@@ -54,12 +54,21 @@ var $jr_id; /*!< pk of jrn */
$this->periode=$user->get_periode();
$this->jr_id=0;
}
- /* **************************************************
- *\brief Insert into the table Jrn
- *
- *
- * \return nothing
- *
+ /**
+ *@brief Insert into the table Jrn
+ *The needed data are :
+ * - this->date
+ * - this->amount
+ * - this->poste
+ * - this->grpt
+ * - this->jrn
+ * - this->type ( debit or credit)
+ * - this->user
+ * - this->periode
+ * - this->qcode
+ * - this->desc optional
+ *@note if the amount is less than 0 then side changes, for example debit becomes
+ *a credit and vice versa
*/
function insert_jrnx()
@@ -71,23 +80,24 @@ var $jr_id; /*!< pk of jrn */
}
$this->amount=abs($this->amount);
$debit=($this->type=='c')?'false':'true';
-
+ $this->desc=(isset($this->desc))?$this->desc:'';
$Res=$this->db->exec_sql("select insert_jrnx
- ($1::text,abs($2)::numeric,$3::poste_comptable,$4::integer,$5::integer,$6::bool,$7::text,$8::integer,upper($9))",
+ ($1::text,abs($2)::numeric,$3::poste_comptable,$4::integer,$5::integer,$6::bool,$7::text,$8::integer,upper($9),$10::text)",
array(
- $this->date,
- round($this->amount,2),
- $this->poste,
- $this->grpt,
- $this->jrn,
- $debit,
- $this->user,
- $this->periode,
- $this->qcode));
+ $this->date, //$1
+ round($this->amount,2), //$2
+ $this->poste, //$3
+ $this->grpt, //$4
+ $this->jrn, //$5
+ $debit, //$6
+ $this->user, //$7
+ $this->periode, //$8
+ $this->qcode, // $9
+ $this->desc)); //$10
if ( $Res==false) return $Res;
$this->jrnx_id=$this->db->get_current_seq('s_jrn_op');
return $this->jrnx_id;
-
+
}
/*!\brief set the pj of a operation in jrn. the jr_id must be set
*\note if the jr_id it fails
@@ -120,10 +130,10 @@ var $jr_id; /*!< pk of jrn */
/* check if the new pj numb exist */
$c=$this->db->count_sql("select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2",
array($this->pj,$this->jrn)
- );
+ );
if ( $c == 0 ) { $flag=1; break;}
$limit--;
- }
+ }
/* a pj numb is found */
if ( $flag == 1 ) {
$sql="update jrn set jr_pj_number=$1 where jr_id=$2";
@@ -134,12 +144,11 @@ var $jr_id; /*!< pk of jrn */
}
/*!
- **************************************************
- *\brief Insert into the table Jrn, the amount is computed from jrnx thanks the
+ *\brief Insert into the table Jrn, the amount is computed from jrnx thanks the
* group id ($p_grpt)
- *
- * \return sequence
- *
+ *
+ * \return sequence of jr_id
+ *
*/
function insert_jrn()
@@ -148,7 +157,7 @@ var $jr_id; /*!< pk of jrn */
$diff=$this->db->get_value("select check_balance ($1)",array($this->grpt));
if ( $diff != 0 ) {
-
+
echo "Erreur : balance incorrecte :diff = $diff";
return false;
}
@@ -158,7 +167,7 @@ var $jr_id; /*!< pk of jrn */
$this->mt=microtime(true);
}
// if amount == -1then the triggers will throw an error
- //
+ //
$Res=$this->db->exec_sql("insert into jrn (jr_def_id,jr_montant,jr_comment,".
"jr_date,jr_ech,jr_grpt_id,jr_tech_per,jr_mt) values (".
"$1,$2,$3,".
@@ -177,7 +186,7 @@ var $jr_id; /*!< pk of jrn */
*
*/
function get_internal() {
- if ( ! isset($this->jr_id) )
+ if ( ! isset($this->jr_id) )
throw new Exception('jr_id is not set',1);
$Res=$this->db->exec_sql("select jr_internal from jrn where jr_id=".$this->jr_id);
if ( Database::num_row($Res) == 0 ) return null;
@@ -196,7 +205,7 @@ function get_internal() {
$this->jr_id=Database::fetch_result($Res,0,0);
return 0;
}
- /*!\brief retrieve data from jrnx
+ /*!\brief retrieve data from jrnx
* \return an array
*/
function get_jrnx_detail() {
@@ -231,7 +240,7 @@ function get_internal() {
return $row;
}
/*!\brief display_jrnx_detail : get the data from get_jrnx_data and
- return a string with HTML code
+ return a string with HTML code
* \param table(=0 no code for table,1 code for table,2 code for CSV)
*/
@@ -253,7 +262,7 @@ function get_internal() {
$r.=$a;
$csv.='"'.$a.'";';
$r.='';
-
+
$r.='
';
-
+
$r.='';
}
switch ($p_table) {
@@ -299,9 +308,9 @@ function get_internal() {
}
return "ERROR PARAMETRE";
}
-/*!
+/*!
* @brief Get data from jrnx where p_grpt=jrnx(j_grpt)
- *
+ *
* @param connection
* @return array of 3 elements
* - First Element is an array
@@ -312,27 +321,27 @@ Array
[class_cred0] => 7000008
[mont_cred0] => 8880.0000
[op_cred0] => 754
- [text_cred0] =>
+ [text_cred0] =>
[jr_internal] => 23VEN-01-302
- [comment] =>
- [ech] =>
+ [comment] =>
+ [ech] =>
[jr_id] => 302
[jr_def_id] => 2
[class_deb0] => 4000005
[mont_deb0] => 10744.8000
- [text_deb0] =>
+ [text_deb0] =>
[op_deb0] => 755
[class_cred1] => 4511
[mont_cred1] => 1864.8000
[op_cred1] => 756
- [text_cred1] =>
+ [text_cred1] =>
)
@endverbatim
- * - Second : number of line with debit
+ * - Second : number of line with debit
* - Third : number of line with credit
- */
+ */
function get_data ($p_grpt) {
- $Res=$this->db->exec_sql("select
+ $Res=$this->db->exec_sql("select
to_char(j_date,'DD.MM.YYYY') as j_date,
j_text,
j_debit,
@@ -349,7 +358,7 @@ Array
if ( $MaxLine == 0 ) return null;
$deb=0;$cred=0;
for ( $i=0; $i < $MaxLine; $i++) {
-
+
$l_line=Database::fetch_array($Res,$i);
$l_array['op_date']=$l_line['j_date'];
if ( $l_line['j_debit'] == 't' ) {
diff --git a/include/class_acc_payment.php b/include/class_acc_payment.php
index 36a3c28e0..fcf994d5b 100644
--- a/include/class_acc_payment.php
+++ b/include/class_acc_payment.php
@@ -94,6 +94,15 @@ class Acc_Payment
public function insert() {
if ( $this->verify() != 0 ) return;
+ $sql='INSERT INTO mod_payment(
+ mp_lib, mp_jrn_def_id, mp_type, mp_fd_id, mp_qcode)
+ VALUES ($1, $2, $3, $4, upper($5)) returning mp_id';
+ $this->mp_id=$this->cn->exec_sql($sql,array(
+ $this->mp_lib,
+ $this->mp_jrn_def_id,
+ $this->mp_type,
+ $this->mp_fd_id,
+ $this->mp_qcode));
}
public function update() {
@@ -140,8 +149,12 @@ class Acc_Payment
$row=Database::fetch_array($res,0);
foreach ($row as $idx=>$value) { $this->$idx=$value; }
}
+ /**
+ *@brief remove a middle of payment
+ */
public function delete() {
-
+ $sql="delete from mod_payment where mp_id=$1";
+ $this->cn->exec_sql($sql,array($this->mp_id));
}
/*!\brief retrieve all the data for a certain type
*\param non
@@ -314,9 +327,45 @@ class Acc_Payment
*/
public function from_array($p_array) {
$idx=array('mp_id','mp_lib','mp_fd_id','mp_jrn_def_id','mp_qcode','mp_type');
- foreach ($idx as $l)
+ foreach ($idx as $l)
if (isset($p_array[$l])) $this->$l=$p_array[$l];
}
+ /**
+ *@brief return an html with a form to add a new middle of payment
+ */
+ public function blank() {
+ //label
+ $lib=new IText('mp_lib');
+ $f_lib=$lib->input();
+ // Type of ledger
+ $tledger=new ISelect('mp_type');
+ $tledger->value=array(array ('value'=>'ACH','label'=>_('Achat')),
+ array ('value'=>'VEN','label'=>_('Vente')));
+ $f_type=$tledger->input();
+
+ // type of card
+ $tcard=new ISelect('mp_fd_id');
+ $tcard->value=$this->cn->make_array('select fd_id,fd_label from fiche_def join fiche_def_ref '.
+ ' using (frd_id) where frd_id in (25,4) order by fd_label');
+ $f_type_fiche=$tcard->input();
+ $ledger_record=new ISelect('mp_jrn_def_id');
+ $ledger_record->value=$this->cn->make_array("select jrn_def_id,jrn_Def_name from
+ jrn_def where jrn_def_type in ('ODS','FIN')");
+ $f_ledger_record=$ledger_record->input();
+
+ // the card
+ $qcode=new ICard();
+ $qcode->noadd=true;
+ $qcode->name='mp_qcode';
+ $list=$this->cn->make_list('select fd_id from fiche_def where frd_id in (25,4)');
+ $qcode->extra=$list;
+ $f_qcode=$qcode->input();
+ ob_start();
+ require_once('template/new_mod_payment.php');
+ $r=ob_get_contents();
+ ob_end_clean();
+ return $r;
+ }
/*!\brief test function
*/
static function test_me() {
diff --git a/include/class_acc_reconciliation.php b/include/class_acc_reconciliation.php
index 454a28d82..581519cb8 100644
--- a/include/class_acc_reconciliation.php
+++ b/include/class_acc_reconciliation.php
@@ -68,7 +68,7 @@ class Acc_Reconciliation {
return;
if ( strpos($jr_id2,',') !== 0 )
{
- $aRapt=split(',',$jr_id2);
+ $aRapt=explode(',',$jr_id2);
foreach ($aRapt as $rRapt) {
if ( isNumber($rRapt) == 1 )
{
diff --git a/include/class_acc_tva.php b/include/class_acc_tva.php
index 124d099e0..6d8a82821 100644
--- a/include/class_acc_tva.php
+++ b/include/class_acc_tva.php
@@ -131,7 +131,7 @@ class Acc_Tva
*/
public function get_side($p_side) {
if ( strlen($this->tva_poste) == 0 ) $this->load();
- list($deb,$cred)=split(",",$this->tva_poste);
+ list($deb,$cred)=explode(",",$this->tva_poste);
switch ($p_side) {
case 'd':
return $deb;
diff --git a/include/class_fiche.php b/include/class_fiche.php
index d8ce4b893..7e49a788d 100644
--- a/include/class_fiche.php
+++ b/include/class_fiche.php
@@ -1,4 +1,4 @@
-quick_code;
$p_qcode=trim($p_qcode);
- $sql="select f_id from jnt_fic_att_value join attr_value
+ $sql="select f_id from jnt_fic_att_value join attr_value
using (jft_id) where ad_id=23 and av_text=upper($1)";
$this->id=$this->cn->get_value($sql,array($p_qcode));
if ( $this->cn->count()==0) {
@@ -93,9 +93,9 @@ class fiche {
if ( $this->id == 0){
return;
}
- $sql="select *
- from jnt_fic_att_value
- natural join fiche
+ $sql="select *
+ from jnt_fic_att_value
+ natural join fiche
natural join attr_value
join jnt_fic_attr on (jnt_fic_attr.fd_id=fiche.fd_id and jnt_fic_attr.ad_id=jnt_fic_att_value.ad_id)
join attr_def on (attr_def.ad_id=jnt_fic_att_value.ad_id) where f_id=".$this->id.
@@ -122,10 +122,10 @@ class fiche {
foreach ($e->attribut as $f ) {
$flag=0;
foreach ($this->attribut as $g ) {
- if ( $g->ad_id == $f->ad_id )
+ if ( $g->ad_id == $f->ad_id )
$flag=1;
}
- if ( $flag == 0 ) {
+ if ( $flag == 0 ) {
// there's a missing one, we insert it
$t=new Attribut ($f->ad_id);
$t->av_text="";
@@ -135,15 +135,26 @@ class fiche {
$Max++;
} // if flag == 0
- }// foreach
+ }// foreach
$this->attribut=SortAttributeById($this->attribut);
}//missing attribut
}
+ /**
+ * @brief find the card with the p_attribut equal to p_value, it is not case sensitive
+ * @param $p_attribut attribute to find see table attr_def
+ * @param $p_value value in attr_value.av_text
+ * @return return ARRAY OF jft_id,f_id,fd_id,ad_id,av_text
+ */
+ function seek($p_attribut,$p_value){
+ $sql="select jft_id,f_id,fd_id,ad_id,av_text from fiche join jnt_fic_att_value using (f_id) join attr_value
+ using (jft_id) where ad_id=$1 and upper(av_text)=upper($2)";
+ $res=$this->cn->get_array($sql,array($p_attribut,$p_value));
+ return $res;
+ }
-
-/*!
+/*!
* \brief give the size of a card object
*
* \return size
@@ -156,10 +167,10 @@ class fiche {
}
-/*!
+/*!
**************************************************
* \brief Return array of card from the frd family
- *
+ *
* \param $p_frd_id the fiche_def_ref.frd_id
* \param $p_search p_search is a filter on the name
* \param $p_sql extra sql condition
@@ -167,11 +178,11 @@ class fiche {
* \return array of fiche object
*/
function CountByDef($p_frd_id,$p_search="",$p_sql="") {
- $sql="select *
+ $sql="select *
from
fiche join fiche_Def using (fd_id)
where frd_id=".$p_frd_id;
- if ( $p_search != "" )
+ if ( $p_search != "" )
{
$a=FormatString($p_search);
$sql="select * from vw_fiche_attr where frd_id=".$p_frd_id.
@@ -179,14 +190,14 @@ class fiche {
}
$Ret=$this->cn->exec_sql($sql.$p_sql);
-
+
return Database::num_row($Ret) ;
}
-/*!
+/*!
**************************************************
* \brief Return array of card from the frd family
- *
- *
+ *
+ *
* \param $p_frd_id the fiche_def_ref.frd_id
* \param $p_offset
* \param $p_search is an optional filter
@@ -194,17 +205,17 @@ class fiche {
* \return array of fiche object
*/
function GetByDef($p_frd_id,$p_offset=-1,$p_search="") {
- if ( $p_offset == -1 )
+ if ( $p_offset == -1 )
{
- $sql="select *
+ $sql="select *
from
fiche join fiche_Def using (fd_id)
where frd_id=".$p_frd_id." $p_search order by f_id";
- }
- else
+ }
+ else
{
$limit=($_SESSION['g_pagesize']!=-1)?"limit ".$_SESSION['g_pagesize']:"";
- $sql="select *
+ $sql="select *
from
fiche join fiche_Def using (fd_id)
where frd_id=".$p_frd_id." $p_search order by f_id "
@@ -235,17 +246,17 @@ class fiche {
"
".
$this->attribut_def."
";
}
-/*!
+/*!
**************************************************
* \brief return the string of the given attribute
- * (attr_def.ad_id)
+ * (attr_def.ad_id)
* \param $p_ad_id the AD_ID from attr_def.ad_id
* \see constant.php
* \return string
*/
- function strAttribut($p_ad_id)
+ function strAttribut($p_ad_id)
{
- if ( sizeof ($this->attribut) == 0 )
+ if ( sizeof ($this->attribut) == 0 )
{
if ($this->id==0) return '- ERROR -';
@@ -255,15 +266,15 @@ class fiche {
$Res=$this->cn->exec_sql($sql);
$row=Database::fetch_all($Res);
// if not found return error
- if ( $row == false )
+ if ( $row == false )
return ' - ERROR -';
-
+
return $row[0]['av_text'];
}
foreach ($this->attribut as $e)
{
- if ( $e->ad_id == $p_ad_id )
+ if ( $e->ad_id == $p_ad_id )
return $e->av_text;
}
return '- ERROR -';
@@ -276,15 +287,15 @@ Example
Array
(
[av_text1] => Nom
- [av_text12] => Personne de contact
+ [av_text12] => Personne de contact
[av_text5] => Poste Comptable
- [av_text13] => numéro de tva
- [av_text14] => Adresse
+ [av_text13] => numéro de tva
+ [av_text14] => Adresse
[av_text15] => code postal
[av_text24] => Ville
- [av_text16] => pays
- [av_text17] => téléphone
- [av_text18] => email
+ [av_text16] => pays
+ [av_text17] => téléphone
+ [av_text18] => email
[av_text23] => Quick Code
)
@@ -310,15 +321,15 @@ Array
return $array;
}
-/*!
+/*!
* \brief insert a new record
* show a blank card to be filled
- *
+ *
* \param $p_fiche_def is the fiche_def.fd_id
- *
+ *
* \return HTML Code
*/
- function blank($p_fiche_def)
+ function blank($p_fiche_def)
{
// array = array of attribute object sorted on ad_id
$f=new fiche_def($this->cn,$p_fiche_def);
@@ -328,7 +339,7 @@ Array
foreach ($array as $attr)
{
$msg="";
- if ( $attr->ad_id == ATTR_DEF_ACCOUNT)
+ if ( $attr->ad_id == ATTR_DEF_ACCOUNT)
{
$w=new IPoste("av_text".$attr->ad_id);
$w->set_attribute('ipopup','ipop_account');
@@ -340,26 +351,26 @@ Array
$a=Database::fetch_array($ret_sql,0);
$label=new ISpan();
$label->name="av_text".$attr->ad_id."_label";
-
+
if ( $a['account_auto'] == 't' )
$msg.="
".$label->input()." "._("Rappel: Poste créé automatiquement à partir de ").$f->class_base."
";
- else
+ else
{
// if there is a class base in fiche_def_ref, this account will be the
// the default one
- if ( strlen(trim($f->class_base)) != 0 )
+ if ( strlen(trim($f->class_base)) != 0 )
{
$msg.="
".$label->input()." "._("Rappel: Poste par défaut sera ").
$f->class_base.
" !
';
-
+
}
- /*!
+ /*!
* \brief give the balance of an card
* \return
* balance of the card
*
- */
+ */
function get_solde_detail($p_cond="") {
if ( $this->id == 0 ) exit('fiche->id est nul');
$qcode=$this->strAttribut(ATTR_DEF_QUICKCODE);
if ( $p_cond != "") $p_cond=" and ".$p_cond;
- $Res=$this->cn->exec_sql("select sum(deb) as sum_deb, sum(cred) as sum_cred from
- ( select j_poste,
- case when j_debit='t' then j_montant else 0 end as deb,
- case when j_debit='f' then j_montant else 0 end as cred
- from jrnx
- where
+ $Res=$this->cn->exec_sql("select sum(deb) as sum_deb, sum(cred) as sum_cred from
+ ( select j_poste,
+ case when j_debit='t' then j_montant else 0 end as deb,
+ case when j_debit='f' then j_montant else 0 end as cred
+ from jrnx
+ where
j_qcode = ('$qcode'::text)
$p_cond
) as m ");
$Max=Database::num_row($Res);
if ($Max==0) return 0;
$r=Database::fetch_array($Res,0);
-
+
return array('debit'=>$r['sum_deb'],
'credit'=>$r['sum_cred'],
'solde'=>abs($r['sum_deb']-$r['sum_cred']));
@@ -1185,8 +1188,8 @@ function get_solde_detail($p_cond="") {
*/
function empty_attribute($p_attr) {
$sql="select av_text
- from jnt_fic_att_value
- natural join fiche
+ from jnt_fic_att_value
+ natural join fiche
natural join attr_value
left join attr_def using (ad_id) where f_id=".$this->id.
" and ad_id = ".$p_attr.
@@ -1196,24 +1199,24 @@ function empty_attribute($p_attr) {
$text=Database::fetch_result($res,0,0);
return (strlen(trim($text)) > 0)?false:true;
-
+
}
/*! Summary
* \brief show the default screen
- *
- * \param p_search (filter)
+ *
+ * \param p_search (filter)
* \param p_action show the action column
- *
+ *
* \return: string to display
*/
- function Summary($p_search="",$p_action="")
+ function Summary($p_search="",$p_action="")
{
$str_dossier=dossier::get();
$p_search=FormatString($p_search);
$script=$_SERVER['PHP_SELF'];
// Creation of the nav bar
// Get the max numberRow
- $all_tiers=$this->CountByDef($this->fiche_def_ref,$p_search);
+ $all_tiers=$this->CountByDef($this->fiche_def_ref,$p_search);
// Get offset and page variable
$offset=( isset ($_REQUEST['offset'] )) ?$_REQUEST['offset']:0;
$page=(isset($_REQUEST['page']))?$_REQUEST['page']:1;
@@ -1230,8 +1233,8 @@ function empty_attribute($p_attr) {
if ( trim($p_search) != "" )
{
$search=" and f_id in
-(select f_id from jnt_fic_att_value
- join fiche using (f_id)
+(select f_id from jnt_fic_att_value
+ join fiche using (f_id)
join attr_value using (jft_id)
where
ad_id=1 and av_text ~* '$p_search')";
@@ -1275,7 +1278,7 @@ $r.='';
$r.=sprintf('
%15.2f€
',$a['credit']);
$r.=sprintf('
%15.2f€
',$a['solde']);
-
+
$r.="";
}
@@ -1283,10 +1286,10 @@ $r.='';
$r.=$bar;
return $r;
}
-/*!
+/*!
* \brief get the fd_id of the card : fd_id, it set the attribute fd_id
*/
- function get_categorie()
+ function get_categorie()
{
if ( $this->id == 0 ) exit('class_fiche : f_id = 0 ');
$sql='select fd_id from fiche where f_id='.$this->id;
@@ -1296,39 +1299,39 @@ $r.='';
else
$this->fd_id=$R;
}
-/*!
+/*!
***************************************************
* \brief Check if a fiche is used by a jrn
* return 1 if the fiche is in the range otherwise 0, the quick_code
* or the id must be set
- *
- *
+ *
+ *
* \param $p_jrn journal_id
* \param $p_type : deb or cred default empty
- *
+ *
* \return 1 if the fiche is in the range otherwise < 1
* -1 the card doesn't exist
* -2 the ledger has no card to check
- *
+ *
*/
function belong_ledger($p_jrn,$p_type="")
{
// check if we have a quick_code or a f_id
- if (($this->quick_code==null || $this->quick_code == "" )
+ if (($this->quick_code==null || $this->quick_code == "" )
&& $this->id == 0 ) {
echo 'erreur ni quick_code ni f_id ne sont donnes';
exit();
}
//retrieve the quick_code
- if ( $this->quick_code=="")
+ if ( $this->quick_code=="")
$this->quick_code=$this->get_quick_code();
- if ( $this->quick_code==null)
+ if ( $this->quick_code==null)
return -1;
- if ( $this->id == 0 )
+ if ( $this->id == 0 )
if ( $this->get_by_qcode(null,false) == 1)
return -1;
@@ -1343,10 +1346,10 @@ function belong_ledger($p_jrn,$p_type="")
$Res=$this->cn->exec_sql("select $get as fiche from jrn_def where jrn_def_id=$p_jrn");
} else {
// Get all the fiche type (deb and cred)
- $Res=$this->cn->exec_sql(" select jrn_def_fiche_cred as fiche
+ $Res=$this->cn->exec_sql(" select jrn_def_fiche_cred as fiche
from jrn_def where jrn_def_id=$p_jrn
union
- select jrn_def_fiche_deb
+ select jrn_def_fiche_deb
from jrn_def where jrn_def_id=$p_jrn"
);
}
@@ -1372,12 +1375,12 @@ function belong_ledger($p_jrn,$p_type="")
$sql="select *
from fiche
- where
+ where
fd_id in (".$str_list.") and f_id= ".$this->id;
$Res=$this->cn->exec_sql($sql);
$Max=Database::num_row($Res);
- if ($Max==0 )
+ if ($Max==0 )
return 0;
else
return 1;
@@ -1404,22 +1407,22 @@ function is_used() {
$qcode=$this->strAttribut(ATTR_DEF_QUICKCODE);
$sql='select count(*) as c from jrnx where j_qcode=$1';
$count=$this->cn->get_value($sql,array($qcode));
- if ( $count == 0 ) return false;
+ if ( $count == 0 ) return false;
return true;
}
/*\brief remove a card without verification */
function delete() {
// Remove from attr_value
- $Res=$this->cn->exec_sql("delete from attr_value
- where jft_id in (select jft_id
- from jnt_fic_att_value
+ $Res=$this->cn->exec_sql("delete from attr_value
+ where jft_id in (select jft_id
+ from jnt_fic_att_value
natural join fiche where f_id=".$this->id.")");
// Remove from jnt_fic_att_value
$Res=$this->cn->exec_sql("delete from jnt_fic_att_value where f_id=".$this->id);
-
+
// Remove from fiche
$Res=$this->cn->exec_sql("delete from fiche where f_id=".$this->id);
-
+
}
/*!\brief create the sql statement for retrieving all
* the card
@@ -1473,7 +1476,7 @@ function is_used() {
$and=" and ";
if (isset($query)){
$query=FormatString($query);
- $filter_query=$and."(vw_name ilike '%$query%' or quick_code ilike ('%$query%') or vw_description ilike '%$query%')";
+ $filter_query=$and."(vw_name ilike '%$query%' or quick_code ilike ('%$query%') or vw_description ilike '%$query%' or tva_num ilike '%$query%')";
}
$sql="select * from vw_fiche_attr where ".$filter_fd_id.$filter_query;
return $sql;
diff --git a/include/class_fiche_def.php b/include/class_fiche_def.php
index 6f698f820..ab6ebc511 100644
--- a/include/class_fiche_def.php
+++ b/include/class_fiche_def.php
@@ -52,17 +52,20 @@ function input ()
{
$ref=$this->cn->get_array("select * from fiche_def_ref order by frd_text");
$iradio=new IRadio();
- $p_js=" SearchPosteFilter('".$_REQUEST['PHPSESSID']."','".dossier::id()."','class_base','all','','class_base_label')";
+ /* the accounting item */
+ $class_base=new IPoste('class_base');
+ $class_base->set_attribute('ipopup','ipop_account');
+ $class_base->set_attribute('account','class_base');
+ $class_base->set_attribute('label','acc_label');
+ $f_class_base=$class_base->input();
require_once ('template/fiche_def_input.php');
return;
}
/*!
- **************************************************
* \brief Get attribut of a fiche_def
*
* \return string value of the attribute
- * none
*/
function GetAttribut() {
$sql="select * from jnt_fic_attr ".
@@ -84,7 +87,6 @@ function input ()
}
/*!
- **************************************************
* \brief Get attribut of the fiche_def
*
*/
@@ -173,11 +175,6 @@ function input ()
// Format correctly the name of the cat. of card
$p_nom_mod=FormatString($p_nom_mod);
- // Format the p_class_base
- // must be an integer
- if ( isNumber($p_class_base) == 0 && FormatString($p_class_base) != null ) {
- echo_error ('p_class_base is NOT a number');
- }
// Name can't be empty
if ( strlen(trim($p_nom_mod)) == 0 )
return;
@@ -212,25 +209,26 @@ function input ()
$p_create='false';
// Class is valid ?
- if ( FormatString($p_class_base) != null) {
+ if ( FormatString($p_class_base) != null || strpos(',',$p_class_base) != 0 ) {
// p_class is a valid number
- $sql=sprintf("insert into fiche_def(fd_label,fd_class_base,frd_id,fd_create_account)
- values ('%s',%s,%d,'%s')",
- $p_nom_mod,$p_class_base,$p_FICHE_REF,$p_create);
- $Res=$this->cn->exec_sql($sql);
-
- // p_class must be added to tmp_pcmn
- $sql=sprintf("select account_add(%d,'%s')",
- $p_class_base,$p_nom_mod);
-
- $Res=$this->cn->exec_sql($sql);
-
+ $sql="insert into fiche_def(fd_label,fd_class_base,frd_id,fd_create_account)
+ values ($1,$2,$3,$4)";
+
+ $Res=$this->cn->exec_sql($sql,array($p_nom_mod,$p_class_base,$p_FICHE_REF,$p_create));
+
+ // p_class must be added to tmp_pcmn if it is a single accounting
+ if ( strpos(',',$p_class_base) ==0) {
+ $sql=sprintf("select account_add(%d,'%s')",
+ $p_class_base,$p_nom_mod);
+
+ $Res=$this->cn->exec_sql($sql);
+ }
+
// Get the fd_id
$fd_id=$this->cn->get_current_seq('s_fdef');
- // Add the class_base if needed
-
+ // update jnt_fic_attr
$sql=sprintf("insert into jnt_fic_attr(fd_id,ad_id,jnt_order)
values (%d,%d,10)",$fd_id,ATTR_DEF_ACCOUNT);
$Res=$this->cn->exec_sql($sql);
diff --git a/include/class_icard.php b/include/class_icard.php
index 49559c060..71883e8df 100644
--- a/include/class_icard.php
+++ b/include/class_icard.php
@@ -231,6 +231,17 @@ class ICard extends HtmlInput
* - typecard (deb, cred, filter or list of value)
* will be set
* if ICard is in readOnly, the button disappears, so the return string is empty
+\code
+ // search ipopup
+$search_card=new IPopup('ipop_card');
+$search_card->title=_('Recherche de fiche');
+$search_card->value='';
+echo $search_card->input();
+
+$a=new ICard('test');
+$a->search();
+
+\endcode
*\see ajax_card.php
*\note the ipopup id is hard coded : ipop_card
*@return HTML string with the button
diff --git a/include/class_idate.php b/include/class_idate.php
index 9dd93de5f..0049af2a0 100644
--- a/include/class_idate.php
+++ b/include/class_idate.php
@@ -20,8 +20,8 @@
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-/*!\file
- * \brief Html Input
+/*!\file
+ * \brief Html Input
*/
require_once('class_html_input.php');
class IDate extends HtmlInput
@@ -50,14 +50,14 @@ require_once('class_html_input.php');
singleClick : true
});
-';
+';
return $r;
}
/*!\brief print in html the readonly value of the widget*/
public function display()
{
- $r=" Date : ".$this->value;
+ $r=" : ".$this->value;
$r.='name.'"'.
' value = "'.$this->value.'">';
diff --git a/include/class_ipopup.php b/include/class_ipopup.php
index ecf4c9b76..9312c3dec 100644
--- a/include/class_ipopup.php
+++ b/include/class_ipopup.php
@@ -31,23 +31,24 @@ require_once('class_html_input.php');
class IPopup extends HtmlInput
{
var $name; /*!< name name and id of the div */
- function __construct($p_name)
+ function __construct($p_name)
{
$this->name=$p_name;
$this->parameter='';
$this->attribute=array();
+ $this->drag=true;
}
function set_width($p_val) {
$js=sprintf('$("%s'.'_border").style.width="%s";',
$this->name,$p_val);
$this->parameter.=$js;
-
+
}
function set_height($p_val) {
$js=sprintf('$("%s'.'_border").style.height="%s";',
$this->name,$p_val);
$this->parameter.=$js;
-
+
}
function set_zindex($p_val) {
@@ -55,7 +56,10 @@ class IPopup extends HtmlInput
$this->name,$p_val);
$js=sprintf('$("%s'.'_content").style.zIndex=%d;',
$this->name,$p_val);
- $this->parameter.=$js;
+ $this->parameter.=$js;
+ }
+ function set_dragguable($p_value){
+ $this->drag=$p_value;
}
/*!\brief set the attribute thanks javascript as the width, the position ...
*\param $p_name attribute name
@@ -99,10 +103,10 @@ class IPopup extends HtmlInput
$this->name,
$this->name,
$this->value);
-
+
/* Add properties at the widget */
$attr=$this->parameter;
- for ($i=0;$i< count($this->attribute);$i++){
+ for ($i=0;$i< count($this->attribute);$i++){
list($name,$value)=$this->attribute[$i];
$tmp1=sprintf("$('%s').%s='%s';",
$this->name,
@@ -110,12 +114,15 @@ class IPopup extends HtmlInput
$value);
$attr.=$tmp1;
}
-
+ $draggable='';
+ if ($this->drag==true){
/* add draggable possibility */
$draggable=sprintf(" new Draggable('%s_border',{starteffect:function(){
new Effect.Highlight('%s_border',{scroll:window,queue:'end'}); } });"
,$this->name
,$this->name);
+
+ }
$attr=create_script($attr.$draggable);
$r.=$attr;
return $r;
diff --git a/include/class_itva_select.php b/include/class_itva_select.php
index 0ada9acdc..9c9d784d1 100644
--- a/include/class_itva_select.php
+++ b/include/class_itva_select.php
@@ -20,8 +20,8 @@
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-/*!\file
- * \brief Html Input
+/*!\file
+ * \brief Html Input
*/
require_once('class_iselect.php');
class ITva_Select extends ISelect
@@ -39,15 +39,18 @@ require_once('class_iselect.php');
$this->value=$select_tva;
$r=parent::input();
return $r;
-
+
}
/*!\brief print in html the readonly value of the widget*/
public function display()
{
- throw new Exception ("Pas de function display pour la TVA",1);
+ $select_tva=$this->db->make_array("select tva_id,tva_label from tva_rate order by tva_label asc",0);
+ $this->value=$select_tva;
+ $r=parent::display();
+ return $r;
}
static public function test_me()
{
-
+
}
}
diff --git a/include/class_user.php b/include/class_user.php
index 73c6bf5fd..9f0770285 100644
--- a/include/class_user.php
+++ b/include/class_user.php
@@ -1,4 +1,4 @@
-'._('Session expirée Utilisateur déconnecté').'';
redirect('index.php',1);
exit();
@@ -55,21 +55,21 @@ class User {
$this->id=-1;
if ( isset($_SESSION['g_theme']) )
$this->theme=$_SESSION['g_theme'];
-
+
$this->admin=( isset($_SESSION['use_admin']) )?$_SESSION['use_admin']:0;
-
+
if ( isset($_SESSION['use_name']) )
$this->name=$_SESSION['use_name'];
if ( isset($_SESSION['use_first_name']) )
$this->first_name=$_SESSION['use_first_name'];
$this->load();
- }
+ }
else // if p_id is set get data of another user
{
$this->id=$p_id;
$this->db=$p_cn;
$this->load();
- }
+ }
}
/*!\brief load data from database.
* if this->id == -1, it is unknown so we have to retrieve it
@@ -93,7 +93,7 @@ class User {
use_active,
use_admin
from ac_users ";
- $cn=new Database();
+ $cn=new Database();
$Res=$cn->exec_sql($sql.$sql_cond,$sql_array);
if (($Max=Database::num_row($Res)) == 0 ) return -1;
$row=Database::fetch_array($Res,0);
@@ -105,30 +105,30 @@ class User {
$this->admin=$row['use_admin'];
}
function save() {
-
+
$Sql="update ac_users set use_first_name=$1, use_name=$2
,use_active=$3,use_admin=$4 where use_id=$5";
- $cn=new Database();
+ $cn=new Database();
$Res=$cn->exec_sql($Sql,array($this->first_name,$this->last_name,$this->active,$this->admin,$this->id));
}
/*!
* \brief Check if user is active and exists in therepository
* Automatically redirect, it doesn't check if a user can access a folder
*\param $silent false, echo an error message and exit, true : exit without warning
- * default is false
- *
+ * default is false
+ *
++*/
function Check($silent=false)
{
-
+
$res=0;
$pass5=md5($this->pass);
$cn=new Database();
$sql="select ac_users.use_login,ac_users.use_active, ac_users.use_pass,
use_admin,use_first_name,use_name
- from ac_users
- where ac_users.use_id='$this->id'
+ from ac_users
+ where ac_users.use_id='$this->id'
and ac_users.use_active=1
and ac_users.use_pass='$pass5'";
echo_debug('class_user.php',__LINE__,"Sql = $sql");
@@ -141,33 +141,33 @@ class User {
$_SESSION['use_name']=$r['use_name'];
$_SESSION['use_first_name']=$r['use_first_name'];
$_SESSION['isValid']=1;
-
+
$this->admin=$_SESSION['use_admin'];
$this->name=$_SESSION['use_name'];
$this->first_name=$_SESSION['use_first_name'];
$this->load_global_pref();
-
+
}
-
+
if ( $res == 0 ) {
if ( ! $silent) {
alert(_('Utilisateur ou mot de passe incorrect'));
redirect('index.html');
}
session_unset();
- exit -1;
+ exit -1;
} else {
$this->valid=1;
}
-
+
return $ret;
-
+
}
- /*!\brief return the access to a folder,
+ /*!\brief return the access to a folder,
* \param $p_dossier id if it is == 0 then we take the value from $_SESSION
- *\return the priv_priv
+ *\return the priv_priv
* - X no access
* - R has access (normal user)
* - L Local Admin
@@ -186,8 +186,8 @@ where use_id=$1 and dos_id=$2";
if ( $res=='') return 'X';
return $res;
}
- /*\brief save the access of a folder
- *\param $db_id the dossier id
+ /*\brief save the access of a folder
+ *\param $db_id the dossier id
*\param $priv the priv. to set
*/
function set_folder_access($db_id,$priv) {
@@ -197,16 +197,16 @@ where use_id=$1 and dos_id=$2";
if ( $cn->size() == 0 ) {
- $Res=$cn->exec_sql("insert into jnt_use_dos(dos_id,use_id) values($1,$2)",array($db_id,$this->id));
+ $Res=$cn->exec_sql("insert into jnt_use_dos(dos_id,use_id) values($1,$2)",array($db_id,$this->id));
$jnt=$cn->get_value("select jnt_id from jnt_use_dos where dos_id=$1 and use_id=$2",array($db_id,$this->id));
$Res=$cn->exec_sql("insert into priv_user (priv_priv,priv_jnt) values($1,$2)",array($priv,$jnt));
}
$Res=$cn->exec_sql("update priv_user set priv_priv=$1 where priv_jnt=$2",array($priv,$jnt));
-
+
}
/*!\brief check that a user is valid and the access to the folder
* \param $p_ledger the ledger to check
- *\return the priv_priv
+ *\return the priv_priv
* - O only predefined operation
* - W write
* - R read only
@@ -227,7 +227,7 @@ where use_id=$1 and dos_id=$2";
return $res;
}
- /*!
+ /*!
* \brief get all the available ledgers for the current user
* \param $p_type = ALL or the type of the ledger (ACH,VEN,FIN,ODS)
* \param $p_access =3 for Read or WRITE, 2 write, 1 for readonly
@@ -249,13 +249,13 @@ where use_id=$1 and dos_id=$2";
$sql_access=" and uj_priv = 'R'";
break;
- }
+ }
$sql="select jrn_def_id,jrn_def_type,
jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
jrn_deb_max_line,jrn_cred_max_line
from jrn_def join jrn_type on jrn_def_type=jrn_type_id
- join user_sec_jrn on uj_jrn_id=jrn_def_id
+ join user_sec_jrn on uj_jrn_id=jrn_def_id
where
uj_login='".$this->login."'".
$sql_type.$sql_access.
@@ -264,7 +264,7 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
$sql_type=($p_type=='ALL')?'':"where jrn_def_type=upper('".FormatString($p_type)."')";
$sql="select jrn_def_id,jrn_def_type,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line,
jrn_type_id,jrn_desc,'W' as uj_priv
- from jrn_def join jrn_type on jrn_def_type=jrn_type_id
+ from jrn_def join jrn_type on jrn_def_type=jrn_type_id
$sql_type
order by jrn_Def_id";
@@ -291,9 +291,9 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
$sql.='-1)';
return $sql;
}
- /*!
+ /*!
* \brief Check if an user is an admin
- *
+ *
* \return 1 for yes 0 for no
*/
function Admin() {
@@ -301,23 +301,23 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
$pass5=md5($this->pass);
$sql="select use_admin from ac_users where use_login=$1
and use_active=1 ";
-
+
$cn=new Database();
$res=$cn->exec_sql($sql,array($this->login));
if ( Database::num_row($res)==0) exit(__FILE__." ".__LINE__." aucun resultat");
$this->admin=Database::fetch_result($res,0);
- }
+ }
else $this->admin=1;
-
+
return $this->admin;
}
- /*!
+ /*!
* \brief Set the selected periode in the user's preferences
- *
- * \param $p_periode periode
+ *
+ * \param $p_periode periode
* \param - $p_user
*
- */
+ */
function set_periode($p_periode) {
$sql="update user_local_pref set parameter_value='$p_periode' where user_id='$this->id' and parameter_type='PERIODE'";
$Res=$this->db->exec_sql($sql);
@@ -343,24 +343,24 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
$pid=Database::fetch_result($Res2,0,0);
}
- $sql=sprintf("insert into user_local_pref (user_id,parameter_value,parameter_type)
+ $sql=sprintf("insert into user_local_pref (user_id,parameter_value,parameter_type)
values ('%s','%d','PERIODE')",
$this->id,$pid);
$Res=$this->db->exec_sql($sql);
}
- /*!
+ /*!
* \brief Get the default periode from the user's preferences
- *
- * \return the default periode
- *
*
- */
+ * \return the default periode
+ *
+ *
+ */
function get_periode() {
$array=$this->get_preference();
- if ( ! isset ($array['PERIODE'])) {
+ if ( ! isset ($array['PERIODE'])) {
$this->set_default_periode();
$array=$this->get_preference();
}
@@ -373,7 +373,7 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
$array=$this->get_preference();
$fr_id=(isset($array['MINIREPORT']))?$array['MINIREPORT']:0;
return $fr_id;
-
+
}
/*!\brief set the mini rapport to display on the welcome page
@@ -394,10 +394,10 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
}
- /*!
+ /*!
* \brief Get the default user's preferences
* \return array of (parameter_type => parameter_value)
- */
+ */
function get_preference ()
{
$sql="select parameter_type,parameter_value from user_local_pref where user_id='".$this->id."'";
@@ -412,20 +412,20 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
return $l_array;
}
- /*!
+ /*!
* \brief Check if an user is allowed to do an action
- * \param p_action_id
+ * \param p_action_id
* \return
* - 0 no priv
* - 1 priv granted
*
- */
+ */
function check_action ( $p_action_id)
{
if ( $this->Admin()==1 ) return 1;
if ( $this->is_local_admin(dossier::id()) == 1 ) return 1;
-
+
$Res=$this->db->exec_sql(
"select * from user_sec_act where ua_login=$1 and ua_act_id=$2",
array($this->login,$p_action_id));
@@ -435,18 +435,18 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
echo "
Action Invalide !!! $Count select * from user_sec_act where ua_login='$p_login' and ua_act_id=$p_action_id
";
exit();
}
- /*!
+ /*!
* \brief Get the global preferences from user_global_pref
* in the account_repository db
*
* \note set $SESSION[g_variable]
*/
- function load_global_pref()
+ function load_global_pref()
{
echo_debug('class_user.php',__LINE__,"function load_global_pref");
$cn=new Database();
// Load everything in an array
- $Res=$cn->exec_sql ("select parameter_type,parameter_value from
+ $Res=$cn->exec_sql ("select parameter_type,parameter_value from
user_global_pref
where user_id='".$this->login."'");
$Max=Database::num_row($Res);
@@ -459,7 +459,7 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
$line=array();
for ($i=0;$i<$Max;$i++) {
$row=Database::fetch_array($Res,$i);
- $type=$row['parameter_type'];
+ $type=$row['parameter_type'];
$line[$type]=$row['parameter_value'];;
}
// save array into g_ variable
@@ -470,14 +470,14 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
$this->insert_default_global_pref($parameter);
$this->load_global_pref();
return;
- }
+ }
$_SESSION[$name]=$line[$parameter];
}
}
- /*!
+ /*!
* \brief insert default pref
- * if no parameter are given insert all the existing
+ * if no parameter are given insert all the existing
* parameter otherwise only the requested
* \param $p_type parameter's type or nothing
* \param $p_value parameter value
@@ -492,7 +492,7 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
'TOPMENU'=>'TEXT',
'LANG'=>'fr_FR.utf8');
$cn=new Database();
- $Sql="insert into user_global_pref(user_id,parameter_type,parameter_value)
+ $Sql="insert into user_global_pref(user_id,parameter_type,parameter_value)
values ('%s','%s','%s')";
if ( $p_type == "" ) {
foreach ( $default_parameter as $name=>$value) {
@@ -509,11 +509,11 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
}
- /*!
+ /*!
* \brief update default pref
* if value is not given then use the default value
*
- * \param $p_type parameter's type
+ * \param $p_type parameter's type
* \param $p_value parameter's value value of the type
*/
function update_global_pref($p_type,$p_value="") {
@@ -522,8 +522,8 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
"LANG"=>'fr_FR.utf8',
'TOPMENU'=>'SELECT');
$cn=new Database();
- $Sql="update user_global_pref set parameter_value=$1
- where parameter_type=$2 and
+ $Sql="update user_global_pref set parameter_value=$1
+ where parameter_type=$2 and
user_id=$3";
$value=($p_value=="")?$default_parameter[$p_type]:$p_value;
$cn->exec_sql($Sql,array($value,$p_type,$this->login));
@@ -537,17 +537,17 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
{
$sql="select p_exercice from parm_periode where p_id=".$this->get_periode();
$Ret=$this->db->exec_sql($sql);
- if (Database::num_row($Ret) == 1)
+ if (Database::num_row($Ret) == 1)
{
$r=Database::fetch_array($Ret,0);
return $r['p_exercice'];
}
- else
+ else
return 0;
}
- /*!\brief Check if the user can access
+ /*!\brief Check if the user can access
* otherwise warn and exit
* \param $p_action requested action
* \param $p_js = 1 javascript, or 0 just a text
@@ -562,7 +562,7 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
echo "";
-
+
}
else
{
@@ -575,19 +575,19 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
}
}
-
- /*!
+
+ /*!
* \brief Check if an user is an local administrator
- *
- *
+ *
+ *
* \param $p_dossier : dossier_id
- *
+ *
* \return
* - 0 if no
* - 1 if yes
*
- */
- function is_local_admin($p_dossier=-1)
+ */
+ function is_local_admin($p_dossier=-1)
{
if ($p_dossier==-1) {
$p_dossier=dossier::id();
@@ -599,7 +599,7 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
" where priv_priv='L' and use_login='".$this->login."' and dos_id=$p_dossier";
$cn=new Database();
-
+
$isAdmin=$cn->count_sql($sql);
@@ -615,24 +615,24 @@ jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
* array indices
* - use_id (id )
* - use_login (login of the user)
- * - use_name
+ * - use_name
* - use_first_name
*
*\exception throw an exception if nobody can access
*/
static function get_list($p_dossier) {
- $sql="select distinct use_id,use_login,use_first_name,use_name from ac_users
- left outer join jnt_use_dos using (use_id)
-where
+ $sql="select distinct use_id,use_login,use_first_name,use_name from ac_users
+ left outer join jnt_use_dos using (use_id)
+where
(dos_id=$1 or use_admin=1) and use_active=1";
$repo=new Database();
$array=$repo->get_array($sql,array($p_dossier));
if ( $repo->size() == 0 ) throw new Exception ('Error inaccessible folder');
return $array;
}
- /*!
+ /*!
* \brief check the access of an user on a ledger
- *
+ *
* \param $p_jrn the ledger id
* \return
* - O only predefined operation
@@ -640,9 +640,9 @@ where
* - R read only
* - X no access
*
- */
+ */
- function check_jrn($p_jrn)
+ function check_jrn($p_jrn)
{
return $this->get_ledger_access($p_jrn);
}
@@ -650,9 +650,13 @@ where
* and exit
*\param the folder if
*\param $silent false, echo an error message and exit, true : exit without warning
- * default is false
+ * default is false
+ * \return
+ * - L for administrator (local and global)
+ * - P for extension only
+ * - R regular user
*/
- function check_dossier($p_dossier_id,$silent=false)
+ function check_dossier($p_dossier_id,$silent=false)
{
$this->Admin();
if ( $this->admin==1 || $this->is_local_admin($p_dossier_id)==1) return 'L';
@@ -664,7 +668,9 @@ where
if ( ! $silent) alert(_('Dossier non accessible'));
exit();
}
+ return $dossier;
}
-
+
+
}
?>
diff --git a/include/constant.php b/include/constant.php
index 4b3c3519b..bcf1c1760 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -26,7 +26,7 @@
require_once ('config.inc.php');
require_once('constant.security.php');
-define ("DBVERSION",63);
+define ("DBVERSION",68);
define ("MAX_COMPTE",4);
define ('MAX_ARTICLE',9);
diff --git a/include/contact.inc.php b/include/contact.inc.php
index cc4d37ce8..dce8ad9e3 100644
--- a/include/contact.inc.php
+++ b/include/contact.inc.php
@@ -1,4 +1,4 @@
-',urldecode($_REQUEST['url']));
}
-else
-{
+else
+{
$retour="";
$h_url="";
}
// Menu
// Remove a card
-if ( isset ($_POST['delete']) )
+if ( isset ($_POST['delete']) )
{
$f_id=$_REQUEST['f_id'];
$fiche=new contact($cn,$f_id);
$fiche->remove();
- $sub_action="list";
+ $sub_action="list";
}
//-----------------------------------------------------
// Add card
@@ -75,7 +75,7 @@ if ( $sub_action=="insert" )
//-----------------------------------------------------
// Save modification
-if ( isset ($_POST['mod']))
+if ( isset ($_POST['mod']))
{
// modification is asked
$f_id=$_REQUEST['f_id'];
@@ -85,11 +85,11 @@ if ( isset ($_POST['mod']))
$sub_action="list";
}
// by default open liste
-if ( $sub_action == "" )
+if ( $sub_action == "" )
$sub_action="list";
//-----------------------------------------------------
-//Display a blank card
-if ( $sub_action=="blank")
+//Display a blank card
+if ( $sub_action=="blank")
{
$retour_action=HtmlInput::button_anchor('Retour', "commercial.php?p_action=contact&$str_dossier");
@@ -118,7 +118,7 @@ if ( $sub_action == "list" )
';
+ echo HtmlInput::button_anchor(_('Retour sans sauvez'),
+ '?p_action=divers&sa=mp&'.dossier::get()
+ );
+ exit();
+}
+//---------------------------------------------------------------------------
+// Insert a new mod of payment
+//---------------------------------------------------------------------------
+if ( $sb=='insert') {
+ $row=new Acc_Payment($cn);
+ $row->from_array($_POST);
+ $row->insert();
+}
//----------------------------------------------------------------------
// LEDGER PURCHASE
//----------------------------------------------------------------------
@@ -124,7 +159,9 @@ if ( ! empty ($array)) {
}
echo '';
}
-
echo '';
+// Button to insert new one
+echo HtmlInput::button_anchor(_('Ajout'),'?p_action=divers&sa=mp&sb=ins&'.dossier::get());
+
echo '
';
?>
\ No newline at end of file
diff --git a/include/template/extension-detail.php b/include/template/extension-detail.php
index 89a9a4f75..a28ea533e 100644
--- a/include/template/extension-detail.php
+++ b/include/template/extension-detail.php
@@ -36,7 +36,7 @@
=_('Création automatique du poste comptable uniquement s\'il n\y a qu\'un seul poste')?>
+
+
+
+
+ =_('Libellé')?>
+
+
+=$f_lib?>
+
+
+
+
+
+ =_('Type de fiche')?>
+
+
+=$f_type_fiche?>
+
+
+
+
+
+ =_('Pour le type de journal')?>
+
+
+=$f_type?>
+
+
+
+
+
+ =_('Paiement enregistré dans ')?>
+
+
+=$f_ledger_record?>
+
+
+
+
+
+ =_('Avec la fiche')?>
+
+
+=$f_qcode?>
+
+
+
+
+
\ No newline at end of file
diff --git a/include/user_common.php b/include/user_common.php
index 85e6bd153..e33f4c249 100644
--- a/include/user_common.php
+++ b/include/user_common.php
@@ -1,4 +1,4 @@
-get_by_qcode($p_good);
@@ -69,23 +69,22 @@ function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type)
$Res=$p_cn->exec_sql("insert into stock_goods (
j_id,
f_id,
- sg_code,
+ sg_code,
sg_quantity,
sg_type,sg_exercice ) values (
$p_j_id,
$f_id,
'$code_marchandise',
- $p_quant, '$p_type',$exercice)
+ $p_quant, '$p_type',$exercice)
");
return $Res;
}
-/*! isValid ($p_cn, $p_grpt_id
- **************************************************
+/*!
*\brief test if a jrn op is valid
- *
- * \param $p_cn db
+ *
+ * \param $p_cn db
* \param $p_grpt_id
* \return:
* - 1 is valid
@@ -106,17 +105,17 @@ function isValid ($p_cn,$p_grpt_id) {
}
-/*!
+/*!
**************************************************
- *\brief
+ *\brief
* Create a navigation_bar (pagesize)
- *
- * \param $p_offset first record number
+ *
+ * \param $p_offset first record number
* \param $p_line total of returned row
* \param $p_size current g_pagesize user's preference
- * \param $p_page number of the page where the user is
+ * \param $p_page number of the page where the user is
* \param $p_javascript javascript code to add
- * \note example :
+ * \note example :
\verbatim
$step=$_SESSION['g_pagesize'];
$page=(isset($_GET['offset']))?$_GET['page']:1;
@@ -170,8 +169,8 @@ function jrn_navigation_bar($p_offset,$p_line,$p_size=0,$p_page=1,$p_javascript=
$r.=" ";
}
//----------------------------------------------------------------------
- // Create a partial bar
- // if current page < 11 show 1 to 20
+ // Create a partial bar
+ // if current page < 11 show 1 to 20
// otherwise show $p_page -10 to $p_page + 10
//----------------------------------------------------------------------
$start_bar=($p_page < 11 )?1:$p_page-10;
@@ -193,7 +192,7 @@ function jrn_navigation_bar($p_offset,$p_line,$p_size=0,$p_page=1,$p_javascript=
} //else
} //for
// next
-
+
if ($p_page !=$nb_page) {
// If we are not at the last page show the button next
$e=$p_page+1;
@@ -210,7 +209,7 @@ function jrn_navigation_bar($p_offset,$p_line,$p_size=0,$p_page=1,$p_javascript=
return $r;
}
-/*!
+/*!
* \brief Clean the url, remove the $_GET offset,step, page and size
* \param none
*
@@ -238,12 +237,12 @@ function redirect($p_string,$p_time=0) {
echo ' Connecting... ';
}
/*!\brief remove the useless space, change comma by period and try to return
- * a number
+ * a number
*\param $p_num number to format
*\return the formatted number
*/
-function toNumber($p_num) {
- $p_num=trim($p_num);
+function toNumber($p_num) {
+ $p_num=trim($p_num);
if ($p_num=='') return 0;
$p_num=str_replace(',','.',$p_num);
return $p_num;
diff --git a/include/user_menu.php b/include/user_menu.php
index cb41705e1..64417ca9f 100644
--- a/include/user_menu.php
+++ b/include/user_menu.php
@@ -32,7 +32,8 @@ require_once("class_ispan.php");
/*!
* \brief Show all the available folder for the users
- * at the login page
+ * at the login page. For the special case 'E'
+ * go directly to extension and bypasse the dashboard
* \param $p_user user
* \param $p_admin 1 if admin
*
@@ -45,25 +46,34 @@ function u_ShowDossier($p_user,$p_admin,$p_filtre="")
$result="";
if ( $p_array == 0 ) return $result." * Aucun dossier *";
+ $cn=new Database();
+ $user=new User($cn);
+
+
$result.="