rel 205
This commit is contained in:
parent
e151e59b86
commit
bbbd978f92
5 changed files with 112 additions and 103 deletions
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
w
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {
|
||||
|
|
@ -481,6 +481,9 @@ if ( DEBUG=='false' ) ob_start();
|
|||
if ( GetVersion($db) == 19 ) {
|
||||
ExecuteScript($db,'sql/patch/upgrade19.sql');
|
||||
} // version
|
||||
if ( GetVersion($db) == 20 ) {
|
||||
ExecuteScript($db,'sql/patch/upgrade20.sql');
|
||||
} // version
|
||||
|
||||
if ( DEBUG == 'false') ob_end_clean();
|
||||
}//for
|
||||
|
|
@ -575,6 +578,9 @@ if (DEBUG == 'false' ) ob_start();
|
|||
if ( GetVersion($db) == 19 ) {
|
||||
ExecuteScript($db,'sql/patch/upgrade19.sql');
|
||||
} // version
|
||||
if ( GetVersion($db) == 20 ) {
|
||||
ExecuteScript($db,'sql/patch/upgrade20.sql');
|
||||
} // version
|
||||
|
||||
if ( DEBUG == 'false') ob_end_clean();
|
||||
}
|
||||
|
|
|
|||
103
html/admin/sql/patch/upgrade20.sql
Normal file
103
html/admin/sql/patch/upgrade20.sql
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
begin;
|
||||
CREATE or replace FUNCTION insert_quant_sold
|
||||
(p_internal text,
|
||||
p_fiche character varying,
|
||||
p_quant integer,
|
||||
p_price numeric,
|
||||
p_vat numeric,
|
||||
p_vat_code integer,
|
||||
p_client character varying)
|
||||
RETURNS void
|
||||
AS
|
||||
$body$
|
||||
declare
|
||||
fid_client integer;
|
||||
fid_good integer;
|
||||
begin
|
||||
select f_id into fid_client from
|
||||
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_client);
|
||||
|
||||
select f_id into fid_good from
|
||||
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_fiche);
|
||||
|
||||
|
||||
insert into quant_sold
|
||||
(qs_internal,qs_fiche,qs_quantite,qs_price,qs_vat,qs_vat_code,qs_client)
|
||||
values
|
||||
(p_internal,fid_good,p_quant,p_price,p_vat,p_vat_code,fid_client);
|
||||
return;
|
||||
end;
|
||||
$body$ LANGUAGE plpgsql;
|
||||
|
||||
-- add quick code for contact
|
||||
|
||||
insert into attr_min (frd_id,ad_id)
|
||||
select distinct 16,23
|
||||
from attr_min
|
||||
where not exists (select * from attr_min where ad_id=23 and frd_id=16);
|
||||
|
||||
|
||||
insert into jnt_fic_attr (fd_id,ad_id)
|
||||
select fd_id,23 from fiche_def where frd_id=16
|
||||
and not exists (select *
|
||||
from jnt_fic_attr join fiche_def using (fd_id)
|
||||
where frd_id=16 and ad_id=23);
|
||||
|
||||
|
||||
CREATE or replace FUNCTION update_quick_code(njft_id integer, tav_text text) RETURNS integer
|
||||
AS $body$
|
||||
declare
|
||||
ns integer;
|
||||
nExist integer;
|
||||
tText text;
|
||||
old_qcode varchar;
|
||||
begin
|
||||
-- get current value
|
||||
select av_text into old_qcode from attr_value where jft_id=njft_id;
|
||||
-- av_text didn't change so no update
|
||||
if tav_text = upper( trim(old_qcode)) then
|
||||
return 0;
|
||||
end if;
|
||||
|
||||
tText := trim(upper(tav_text));
|
||||
tText := replace(tText,' ','');
|
||||
if length ( tText) = 0 or tText is null then
|
||||
return 0;
|
||||
end if;
|
||||
|
||||
ns := njft_id;
|
||||
|
||||
loop
|
||||
-- av_text already used ?
|
||||
select count(*) into nExist
|
||||
from jnt_fic_att_value join attr_value using (jft_id)
|
||||
where
|
||||
ad_id=23 and av_text=tText;
|
||||
|
||||
if nExist = 0 then
|
||||
exit;
|
||||
end if;
|
||||
if tText = 'FID'||ns then
|
||||
-- take the next sequence
|
||||
select nextval('s_jnt_fic_att_value') into ns;
|
||||
end if;
|
||||
tText :='FID'||ns;
|
||||
|
||||
end loop;
|
||||
update attr_value set av_text = tText where jft_id=njft_id;
|
||||
|
||||
-- update also the contact
|
||||
update attr_value set av_text = tText
|
||||
where jft_id in
|
||||
( select jft_id
|
||||
from jnt_fic_att_value join attr_value using (jft_id)
|
||||
where ad_id=25 and av_text=old_qcode);
|
||||
|
||||
|
||||
update jrnx set j_qcode=tText where j_qcode = old_qcode;
|
||||
return ns;
|
||||
end;
|
||||
$body$
|
||||
LANGUAGE plpgsql;
|
||||
update version set val=21;
|
||||
commit;
|
||||
|
|
@ -76,7 +76,7 @@ BODY {
|
|||
<script src="scripts.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<BODY onLoad="SetFocus(\'login\',0)">
|
||||
Version 2.0.4
|
||||
Version 2.0.5
|
||||
<div class="remark">
|
||||
<p class="gras">Il est conseillé de ne PAS utiliser Internet Explorer.
|
||||
</p><p>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ dropdb -U phpcompta -h localhost dossier3
|
|||
dropdb -U phpcompta -h localhost dossier4
|
||||
dropdb -U phpcompta -h localhost dossier5
|
||||
dropdb -U phpcompta -h localhost dossier13
|
||||
|
||||
dropdb -U phpcompta -h localhost mod1
|
||||
dropdb -U phpcompta -h localhost mod2
|
||||
dropdb -U phpcompta -h localhost mod3
|
||||
|
|
|
|||
101
sql/upgrade.sql
101
sql/upgrade.sql
|
|
@ -1,101 +0,0 @@
|
|||
CREATE or replace FUNCTION insert_quant_sold
|
||||
(p_internal text,
|
||||
p_fiche character varying,
|
||||
p_quant integer,
|
||||
p_price numeric,
|
||||
p_vat numeric,
|
||||
p_vat_code integer,
|
||||
p_client character varying)
|
||||
RETURNS void
|
||||
AS $$
|
||||
declare
|
||||
fid_client integer;
|
||||
fid_good integer;
|
||||
begin
|
||||
select f_id into fid_client from
|
||||
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_client);
|
||||
|
||||
select f_id into fid_good from
|
||||
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_fiche);
|
||||
|
||||
|
||||
insert into quant_sold
|
||||
(qs_internal,qs_fiche,qs_quantite,qs_price,qs_vat,qs_vat_code,qs_client)
|
||||
values
|
||||
(p_internal,fid_good,p_quant,p_price,p_vat,p_vat_code,fid_client);
|
||||
return;
|
||||
end;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
-- add quick code for contact
|
||||
|
||||
insert into attr_min (frd_id,ad_id)
|
||||
select distinct 16,23
|
||||
from attr_min
|
||||
where not exists (select * from attr_min where ad_id=23 and frd_id=16);
|
||||
|
||||
|
||||
insert into jnt_fic_attr (fd_id,ad_id)
|
||||
select fd_id,23 from fiche_def where frd_id=16
|
||||
and not exists (select *
|
||||
from jnt_fic_attr join fiche_def using (fd_id)
|
||||
where frd_id=16 and ad_id=23);
|
||||
|
||||
|
||||
CREATE or replace FUNCTION update_quick_code(njft_id integer, tav_text text) RETURNS integer
|
||||
AS $$
|
||||
declare
|
||||
ns integer;
|
||||
nExist integer;
|
||||
tText text;
|
||||
old_qcode varchar;
|
||||
begin
|
||||
-- get current value
|
||||
select av_text into old_qcode from attr_value where jft_id=njft_id;
|
||||
-- av_text didn't change so no update
|
||||
if tav_text = upper( trim(old_qcode)) then
|
||||
return 0;
|
||||
end if;
|
||||
|
||||
tText := trim(upper(tav_text));
|
||||
tText := replace(tText,' ','');
|
||||
if length ( tText) = 0 or tText is null then
|
||||
return 0;
|
||||
end if;
|
||||
|
||||
ns := njft_id;
|
||||
|
||||
loop
|
||||
-- av_text already used ?
|
||||
select count(*) into nExist
|
||||
from jnt_fic_att_value join attr_value using (jft_id)
|
||||
where
|
||||
ad_id=23 and av_text=tText;
|
||||
|
||||
if nExist = 0 then
|
||||
exit;
|
||||
end if;
|
||||
if tText = 'FID'||ns then
|
||||
-- take the next sequence
|
||||
select nextval('s_jnt_fic_att_value') into ns;
|
||||
end if;
|
||||
tText :='FID'||ns;
|
||||
|
||||
end loop;
|
||||
update attr_value set av_text = tText where jft_id=njft_id;
|
||||
|
||||
-- update also the contact
|
||||
update attr_value set av_text = tText
|
||||
where jft_id in
|
||||
( select jft_id
|
||||
from jnt_fic_att_value join attr_value using (jft_id)
|
||||
where ad_id=25 and av_text=old_qcode);
|
||||
|
||||
|
||||
update jrnx set j_qcode=tText where j_qcode = old_qcode;
|
||||
return ns;
|
||||
end;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue