Merged revisions 2905-2938 via svnmerge from

svn+ssh://danydb@svn/svn/phpcompta/branches/rel500

........
  r2906 | danydb | 2010-01-27 15:16:08 +0100 (Wed, 27 Jan 2010) | 2 lines
  
  Cosmetic for html popup
........
  r2907 | danydb | 2010-01-27 15:28:03 +0100 (Wed, 27 Jan 2010) | 5 lines
  
  Fix typo translation
  
  Fix Bug  : cannot save extension in IE, probably because the same scripts are included several times
........
  r2908 | danydb | 2010-01-28 13:56:37 +0100 (Thu, 28 Jan 2010) | 5 lines
  
  Fix Bug In getNodeText when retrieving data for Internet Explorer, 
  it fails if the xmlNode.firstChild.nodeValue does not contains data. 
  It is directly set to undefined
........
  r2909 | danydb | 2010-01-29 12:20:24 +0100 (Fri, 29 Jan 2010) | 2 lines
  
  Generate invoice : update the comment of the entry only if there were no comment
........
  r2910 | danydb | 2010-01-29 19:39:11 +0100 (Fri, 29 Jan 2010) | 6 lines
  
  Improve User
  ============
  Status only plugin means that the user can use only the plugin and can't access to 
  anything else.
........
  r2911 | danydb | 2010-01-29 19:42:38 +0100 (Fri, 29 Jan 2010) | 1 line
  
  Bug import Dexia
........
  r2912 | danydb | 2010-01-31 16:24:22 +0100 (Sun, 31 Jan 2010) | 3 lines
  
  For insert_jrnx, the desc is now in the function, we don't need anymore to update after inserting
........
  r2913 | danydb | 2010-01-31 16:33:55 +0100 (Sun, 31 Jan 2010) | 4 lines
  
  Fix bug : cannot see operation in quick_writing 
     cause : the p_action must be set to ALL, it wasn't for quick_writing
........
  r2914 | danydb | 2010-02-02 14:52:37 +0100 (Tue, 02 Feb 2010) | 4 lines
  
  Code cleaning
  Bug : in ledger of sale, we have twice the possibility to add~ or generate document, and only for invoice (type 4)
  Solution : fix the function Acc_Ledger_Purchase::extra_info (type of document = 10), remove extra code
........
  r2915 | danydb | 2010-02-05 01:01:11 +0100 (Fri, 05 Feb 2010) | 4 lines
  
  Improve : search_card you can also find a card thanks is tva_num
  Documentation doxygen improved
........
  r2916 | danydb | 2010-02-05 11:18:36 +0100 (Fri, 05 Feb 2010) | 2 lines
  
  when inserting into ledger_sold the test to check the attach was wrong
........
  r2917 | danydb | 2010-02-05 14:45:33 +0100 (Fri, 05 Feb 2010) | 2 lines
  
  Extension : add the possibility to use ajax
........
  r2918 | danydb | 2010-02-06 14:25:22 +0100 (Sat, 06 Feb 2010) | 1 line
  
  rewrite the function encodeJSON, hide and show for doxygen
........
  r2919 | danydb | 2010-02-06 14:26:07 +0100 (Sat, 06 Feb 2010) | 1 line
  
  remove error where _SESSION is expired
........
  r2920 | danydb | 2010-02-06 14:26:49 +0100 (Sat, 06 Feb 2010) | 1 line
  
  In ITva_Select add the display
........
  r2921 | danydb | 2010-02-06 14:27:47 +0100 (Sat, 06 Feb 2010) | 1 line
  
  Cosmetic
........
  r2922 | danydb | 2010-02-06 14:27:49 +0100 (Sat, 06 Feb 2010) | 1 line
  
  IPopup add a new property drag to make the ipopup dragguable or not
........
  r2923 | danydb | 2010-02-06 14:35:28 +0100 (Sat, 06 Feb 2010) | 5 lines
  
  Middle of payment
  =================
  Feature : add or remove middle of payment
........
  r2924 | danydb | 2010-02-06 18:17:15 +0100 (Sat, 06 Feb 2010) | 7 lines
  
  Card
  ----
  A same card can now have 2 different sides (debit or credit)
  usefull to have only one card for a customer and a supplier
........
  r2925 | danydb | 2010-02-06 18:23:03 +0100 (Sat, 06 Feb 2010) | 1 line
  
  Add the sql script for the double accounting
........
  r2926 | danydb | 2010-02-06 19:29:29 +0100 (Sat, 06 Feb 2010) | 2 lines
  
  Update documentation
........
  r2927 | danydb | 2010-02-06 20:37:12 +0100 (Sat, 06 Feb 2010) | 4 lines
  
  Fiche_def
  ========
  Permit to have 2 accouting as class_base
........
  r2928 | danydb | 2010-02-06 20:56:00 +0100 (Sat, 06 Feb 2010) | 1 line
  
  Bug : FK from stock prevent the removal of a card
........
  r2929 | danydb | 2010-02-06 21:14:10 +0100 (Sat, 06 Feb 2010) | 1 line
  
  removeless useless test
........
  r2930 | danydb | 2010-02-07 00:55:03 +0100 (Sun, 07 Feb 2010) | 1 line
  
  Improve appearance extension
........
  r2931 | danydb | 2010-02-07 00:56:28 +0100 (Sun, 07 Feb 2010) | 2 lines
  
  remove debug
........
  r2932 | danydb | 2010-02-07 01:16:51 +0100 (Sun, 07 Feb 2010) | 1 line
  
  Improve appearance extension
........
  r2933 | danydb | 2010-02-07 01:19:08 +0100 (Sun, 07 Feb 2010) | 1 line
  
  Improve appearance extension
........
  r2934 | danydb | 2010-02-07 01:30:31 +0100 (Sun, 07 Feb 2010) | 1 line
  
  Improve appearance extension
........
  r2935 | danydb | 2010-02-07 02:36:25 +0100 (Sun, 07 Feb 2010) | 1 line
  
  Version PHP5.3 : split is obsolete and replace by explode
........
  r2936 | danydb | 2010-02-07 04:56:17 +0100 (Sun, 07 Feb 2010) | 1 line
  
  remove owner
........
  r2937 | danydb | 2010-02-08 22:34:07 +0100 (Mon, 08 Feb 2010) | 1 line
  
  typo
........
  r2938 | danydb | 2010-02-08 22:34:28 +0100 (Mon, 08 Feb 2010) | 1 line
  
  Start translation for Dutch
........
This commit is contained in:
Dany De Bontridder 2010-02-10 18:38:16 +00:00
parent 6017727263
commit b43f4c87b4
67 changed files with 4220 additions and 898 deletions

View file

@ -12,6 +12,7 @@
Adresse <<CUST_ADDR_1>><br>
<<CUST_CP>> <<CUST_CITY>><br>
</P>
<h2>FACTURE </h2>
<div style="float:left;clear:both;width:75%">
<h2>Détail</h2>
<table border="0" align="left" cellspacing="1" cellpadding="1" width="75%">

View file

@ -8,3 +8,4 @@
echo "Extract"
cd ..
xgettext -L PHP -j --from-code=UTF-8 -p html/lang/en_US/LC_MESSAGES/ html/*.php include/*.php include/template/*.php
xgettext -L PHP -j --from-code=UTF-8 -p html/lang/nl_NL/LC_MESSAGES/ html/*.php include/*.php include/template/*.php

Binary file not shown.

View file

@ -20,7 +20,7 @@
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*!\file
/*!\file
* \brief first page
*/
require_once("class_idate.php");
@ -40,7 +40,9 @@ require_once('class_acc_ledger.php');
$cn=new Database(dossier::id());
$user=new User($cn);
$user->Check();
$user->check_dossier(dossier::id());
if ( $user->check_dossier(dossier::id()) == 'P') {
redirect("extension.php?".dossier::get(),0);
}
html_page_start($_SESSION['g_theme']);
/* Check Browser version if < IE6 then unsupported */
@ -80,7 +82,7 @@ echo '<div class="u_tmenu">';
echo menu_tool('access.php');
echo '</div>';
echo '<div class="content">';
/*
/*
* Mini Report
*/
$report=$user->get_mini_report();
@ -101,7 +103,7 @@ if ( $report != 0 ) {
} else {
$periode=new Periode($cn);
$limit=$periode->limit_year($exercice);
$result=$rapport->get_row($limit['start'],$limit['end'],'periode');
$ix=0;
echo '<table border="0" width="100%">';
@ -125,7 +127,7 @@ if ( $report != 0 ) {
echo '</fieldset>';
echo '</div>';
}
/*
/*
* Todo list
*/
echo JS_TODO;

View file

@ -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;

View file

@ -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;

View file

@ -0,0 +1,4 @@
begin;
SELECT setval('public.mod_payment_mp_id_seq', 10, true);
update version set val=66;
commit;

View file

@ -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;

View file

@ -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;

38
html/ajax.php Normal file
View file

@ -0,0 +1,38 @@
<?php
/**
* @brief this file is used for the ajax from the extension, it will the ajax.php file from the plugin directory
* all the variable are in $_REQUEST
* The code (of the plugin) is required
* Required variable in $_REQUEST
* - gDossier
* - code
* - PHPSESSID
*/
require_once('class_database.php');
require_once('class_user.php');
require_once('class_extension.php');
if ( !isset ($_REQUEST['gDossier'])) exit();
$cn=new Database(dossier::id());
$user=new User($cn);
$user->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();
}
}
?>

View file

@ -85,7 +85,7 @@ switch($action) {
$enable->selected=$ext->get_parameter('enable');
$str_enable=$enable->input();
$r.='<div style="overflow:auto;">';
$r.='<form id="extde" onsubmit="extension_save(this)">';
$r.='<form id="formext" onsubmit="extension_save(this);return false">';
$r.=dossier::hidden().HtmlInput::phpsessid();
/* property of the extension */
ob_start();
@ -142,7 +142,7 @@ switch($action) {
$enable->selected='Y';
$str_enable=$enable->input();
$r.='<div style="overflow:auto">';
$r.='<form id="extde" onsubmit="extension_save(this);">';
$r.='<form id="formext" onsubmit="extension_save(this);return false;">';
$r.=dossier::hidden().HtmlInput::phpsessid();
ob_start();
require_once('template/extension-detail.php');

View file

@ -22,7 +22,7 @@
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*! \file
* \brief Base of the module "Gestion", the p_action indicates what
* file must included and this file will manage the request
* file must included and this file will manage the request
* (customer, supplier, contact,...)
*/
include_once ("ac_common.php");
@ -41,7 +41,7 @@ $rep=new Database($gDossier);
require_once ("class_user.php");
$User=new User($rep);
$User->Check();
$User->check_dossier($gDossier);
if ($User->check_dossier($gDossier)=='P')exit();
//-----------------------------------------------------
// update preference
@ -132,14 +132,14 @@ echo JS_AJAX_FICHE;
//-----------------------------------------------------
// p_action == pref
//-----------------------------------------------------
if ( $p_action == "pref" )
if ( $p_action == "pref" )
{
require_once("pref.inc.php");
}
//-----------------------------------------------------
// p_action == impression
//-----------------------------------------------------
if ( $p_action == "impress" )
if ( $p_action == "impress" )
{
require_once("impress.inc.php");
}
@ -148,7 +148,7 @@ if ( $p_action == "impress" )
//-----------------------------------------------------
// p_action == adm
//-----------------------------------------------------
if ( $p_action == "adm" )
if ( $p_action == "adm" )
{
$User->can_request(GEADM,1);
require_once("adm.inc.php");
@ -156,7 +156,7 @@ if ( $p_action == "adm" )
//-----------------------------------------------------
// p_action == client
//-----------------------------------------------------
if ( $p_action == "client" )
if ( $p_action == "client" )
{
$User->can_request(GECUST,1);
require_once("client.inc.php");
@ -164,7 +164,7 @@ if ( $p_action == "client" )
// $p_action == fournisseur
//-----------------------------------------------------
// Fournisseur
if ( $p_action == 'supplier')
if ( $p_action == 'supplier')
{
$User->can_request(GESUPPL,1);
require_once("supplier.inc.php");
@ -172,20 +172,20 @@ if ( $p_action == 'supplier')
//-----------------------------------------------------
// action
if ( $p_action == 'suivi_courrier')
if ( $p_action == 'suivi_courrier')
{
$User->can_request(GECOUR,1);
require_once("action.inc.php");
}
//-----------------------------------------------------
// Contact
if ( $p_action == 'fiche')
if ( $p_action == 'fiche')
{
require_once("fiche.inc.php");
}
//-----------------------------------------------------
// Impression
if ( $p_action == 'impress')
if ( $p_action == 'impress')
{
if ( $User->check_action(IMPRAP)==1 ||
$User->check_action(IMPJRN)==1 ||
@ -215,7 +215,7 @@ if ( $p_action=='central') {
}
//-----------------------------------------------------
// Expense
if ( $p_action == 'defreport')
if ( $p_action == 'defreport')
{
$User->can_request(PARPREDE,1);
require_once("report.inc.php");

View file

@ -45,7 +45,7 @@ $cn=new Database($gDossier);
require_once ('class_user.php');
$User=new User($cn);
$User->Check();
$User->check_dossier($gDossier);
if ($User->check_dossier($gDossier)=='P') exit();
html_page_start($_SESSION['g_theme']);

View file

@ -38,7 +38,7 @@ require_once ("class_user.php");
require_once ('user_menu.php');
$User=new User($cn);
$User->Check();
$User->check_dossier($gDossier);
if ($User->check_dossier($gDossier) == 'P') exit();
html_page_start($_SESSION['g_theme']);

View file

@ -35,11 +35,11 @@ require_once('class_iselect.php');
require_once ('constant.security.php');
require_once ('class_user.php');
html_page_start($_SESSION['g_theme']);
@html_page_start($_SESSION['g_theme']);
$cn=new Database(dossier::id());
$user=new User($cn);
$user->check();
$user->check_dossier(dossier::id());
$only_plugin=$user->check_dossier(dossier::id());
/* javascript file */
@ -58,16 +58,20 @@ echo JS_INFOBULLE;
/* show button to return to access */
echo "<h2 class=\"info\">".dossier::name()."</h2>";
if ( $only_plugin != 'P' ) {
// user with only plugin cannot go back to the dashboard
/* return button */
$msg=_('Retour au tableau de bord');
$hidden=dossier::hidden().HtmlInput::phpsessid();
echo <<<EOF
<form method="get" action="access.php">
<div style="position:absolute;top:3px;left:3px">
<form method="get" action="access.php" style="display:inline">
$hidden
<input type="SUBMIT" value="$msg">
</form>
</div>
EOF;
}
/* show all the extension we can access */
$a=new ISelect('code');
$a->value=Extension::make_array($cn);

View file

@ -90,25 +90,32 @@ function extDetail(req){
/**
*@brief save the extension (add or update)
*/
function extension_save(p_obj){
function extension_save(p_obj_form){
try{
var dossier=$("gDossier").value;
var phpsessid=$('phpsessid').value;
var queryString='?gDossier='+dossier;
queryString+='&PHPSESSID='+phpsessid;
queryString+='&action=se'; // se save extension
// Data must be taken here
var data=p_obj.serialize(false);
// Data must be taken here
try{
var data=$(p_obj_form).serialize(false);
} catch(f){
var sType=p_obj_form.tagName;
var sName=p_obj_form.id;
var nbElement=p_obj_form.elements.length;
alert("Message"+sName+" "+sType+" Nb Element"+nbElement+" "+f.message+"\n");
throw (f);
}
queryString+='&'+data;
$(content).innerHTML='<image src="image/loading.gif" alt="chargement"></image>';
var action=new Ajax.Request ( 'ajax_extension.php',
{
method:'POST',
parameters:queryString,
onFailure:errorExtension,
onSuccess:successSave
}
);
hideIPopup('dtext');
$("dtext_content").innerHTML='<image src="image/loading.gif" alt="chargement"></image>';
var action=new Ajax.Request ( 'ajax_extension.php', { method:'POST', parameters:queryString,onFailure:errorExtension,
onSuccess:successSave } );
hideIPopup('dtext');
} catch(e) {
alert("Probleme extension_save "+e._message+"\n"+e.description);
}
}
function errorExtension(){
alert('Ajax extension failed');

View file

@ -74,10 +74,11 @@ function refresh_window() {
}
/**
*@fn encodeJSON(obj)
*@brief we receive a json object as parameter and the function returns the string
* with the format variable=value&var2=val2...
*/
var encodeJSON=function(obj) {
function encodeJSON(obj) {
if (typeof obj != 'object') {alert('encodeParameter obj n\'est pas un objet');}
try{
var str='';var e=0;
@ -89,10 +90,10 @@ var encodeJSON=function(obj) {
return str;
} catch(e){alert('encodeParameter '+e.message);}
}
var hide=function(p_param){
function hide(p_param){
g(p_param).style.display='none';
}
var show=function(p_param){
function show(p_param){
g(p_param).style.display='block';
}
@ -215,8 +216,9 @@ function unescape_xml(code_html) {
function getNodeText(xmlNode)
{
if(!xmlNode) return '';
if(typeof(xmlNode.textContent) != "undefined") return xmlNode.textContent;
return xmlNode.firstChild.nodeValue;
if(typeof(xmlNode.textContent) != "undefined") { return xmlNode.textContent; }
if ( xmlNode.firstChild && xmlNode.firstChild.nodeValue ) return xmlNode.firstChild.nodeValue;
return "";
}
/**
*@brief change the periode in the calendar of the dashboard
@ -248,7 +250,8 @@ function change_month_success(req) {
}
function loading() { return '<image src="image/loading.gif" alt="chargement"></image>';}
function ajax_misc_failure() {
alert('Ajax Misc failed');
}
}

View file

@ -28,7 +28,7 @@
function todo_list_show(p_id) {
var gDossier=$('gDossier').value;
var phpsessid=$('phpsessid').value;
try {
var action=new Ajax.Request(
'todo_list.php',
{
@ -38,6 +38,9 @@ function todo_list_show(p_id) {
onSuccess:todo_list_show_success
}
);
} catch (e) {
alert(" Envoi ajax non possible" + e.message);
}
return false;
}
function todo_list_show_success(req) {

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -215,7 +215,7 @@ if ( isset($_POST['update_record']) ) {
if ( strpos($_POST['rapt'],',') != 0 )
{
$aRapt=split(',',$_POST['rapt']);
$aRapt=explode(',',$_POST['rapt']);
/* reconcialition */
foreach ($aRapt as $rRapt) {

View file

@ -18,7 +18,7 @@
*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*! \file
* \brief Users Security
* \brief Users Security
*/
include_once("ac_common.php");
require_once('class_database.php');
@ -57,7 +57,7 @@ echo '<DIV>';
echo '<h2>Gestion Utilisateurs</h2>';
// User is valid and you're an admin
// User is valid and you're an admin
?>
@ -76,23 +76,23 @@ if ( isset ( $_GET['reset_passwd']) ){
if ( isset ($_POST['SAVE']) ){
$uid = $_POST['UID'];
// Update User
// Update User
$cn=new Database();
$last_name=$_POST['fname'];
$first_name=$_POST['lname'];
$UserChange=new User($cn,$uid);
if ( $UserChange->load()==-1) {
alert("Cet utilisateur n'existe pas");}
if ( $UserChange->load()==-1) {
alert("Cet utilisateur n'existe pas");}
else {
$UserChange->first_name=$first_name;
$UserChange->last_name=$last_name;
$UserChange->active=$_POST['Actif'];
$UserChange->admin=$_POST['Admin'];
$UserChange->save();
// Update Priv on Folder
foreach ($_POST as $name=>$elem)
{
{
echo_debug('priv_user.php',__LINE__,"_POST $name $elem");
if ( substr_count($name,'PRIV')!=0 )
{
@ -100,7 +100,7 @@ if ( isset ($_POST['SAVE']) ){
$db_id=substr($name,4);
$cn=new Database();
$UserChange->set_folder_access($db_id,$elem);
}
}
@ -132,7 +132,7 @@ $UserChange->load();
<TR><TD>
<?php printf('Nom de famille </TD><td><INPUT type="text" NAME="fname" value="%s"> ',$UserChange->name); ?>
</TD></TR>
<?php printf('<td>prénom</td><td>
<?php printf('<td>prénom</td><td>
<INPUT type="text" NAME="lname" value="%s"> ',$UserChange->first_name); ?>
</TD>
</TR>
@ -146,9 +146,9 @@ if ( $UserChange->active == 1 ) {
$ACT="UNCHECKED";$NACT="CHECKED";
}
echo "<TR><TD>";
printf('<INPUT type="RADIO" NAME="Actif" VALUE="1" %s> Actif',$ACT);
printf('<INPUT type="RADIO" NAME="Actif" VALUE="1" %s> Actif',$ACT);
echo "</TD><TD>";
printf('<INPUT type="RADIO" NAME="Actif" VALUE="0" %s> Non Actif',$NACT);
printf('<INPUT type="RADIO" NAME="Actif" VALUE="0" %s> Non Actif',$NACT);
echo "</TD></TR>";
?>
</TABLE>
@ -162,9 +162,9 @@ if ( $UserChange->admin == 1 ) {
$ACT="UNCHECKED";$NACT="CHECKED";
}
echo "<TR><TD>";
printf('<INPUT type="RADIO" NAME="Admin" VALUE="1" %s> Administrateur global',$ACT);
printf('<INPUT type="RADIO" NAME="Admin" VALUE="1" %s> Administrateur global',$ACT);
echo "</TD><TD>";
printf('<INPUT type="RADIO" NAME="Admin" VALUE="0" %s> Pas administrateur global ',$NACT);
printf('<INPUT type="RADIO" NAME="Admin" VALUE="0" %s> Pas administrateur global ',$NACT);
echo "</TD></TR>";
?>
</TABLE>
@ -178,10 +178,11 @@ echo "</TD></TR>";
Les autres droits doivent être réglés dans les dossiers (paramètre->sécurité)
</p>
<TABLE>
<?php
<?php
$array=array(
array('value'=>'X','label'=>'Aucun Accès'),
array('value'=>'R','label'=>'Utilisateur normal'),
array('value'=>'P','label'=>'Utilisateur uniquement extension'),
array('value'=>'L','label'=>'Administrateur local(Tous les droits)')
);
$repo=new Dossier(0);
@ -198,7 +199,7 @@ foreach ( $Dossier as $rDossier) {
$priv=$mod_user->get_folder_access($rDossier['dos_id']);
printf("<TR><TD> Dossier : %s </TD>",h($rDossier['dos_name']));
$select=new ISelect();
$select->table=1;
$select->name=sprintf('PRIV%s',$rDossier['dos_id']);
@ -212,7 +213,7 @@ foreach ( $Dossier as $rDossier) {
</TABLE>
<?php echo HtmlInput::button_anchor('Reinitialiser le mot de passe',
sprintf('priv_user.php?reset_passwd&UID=%s',$uid));
sprintf('priv_user.php?reset_passwd&UID=%s',$uid));
?>

View file

@ -616,12 +616,12 @@ div.popup_border_notitle {
div.popup_content {
position:absolute;
top:10%;
top:5%;
bottom:0;
left:0;
right:0;
width:100%;
height:90%;
height:95%;
overflow: auto;
background-color:lightblue;
font-size:10px ;

View file

@ -4,6 +4,8 @@ BODY {
background-color:#EDF3FF;
font-size:12px;
font-family:arial,sans-serif;
padding:0;
margin:0;
}
.notice {
color:red;
@ -616,12 +618,12 @@ div.popup_border_notitle {
div.popup_content {
position:absolute;
top:10%;
top:5%;
bottom:0;
left:0;
right:0;
width:100%;
height:90%;
height:95%;
overflow: auto;
background-color:lightblue;
font-size:10px ;

View file

@ -4,6 +4,8 @@ BODY {
background-color:#C2D4D7;
font-size:0.7em;
font-family:Arial, Helvetica, sans-serif;
padding:0;
margin:0;
}
.notice {
color:red;
@ -600,12 +602,12 @@ div.popup_border_notitle {
div.popup_content {
position:absolute;
top:10%;
top:5%;
bottom:0;
left:0;
right:0;
width:100%;
height:90%;
height:95%;
overflow: auto;
background-color:lightblue;
font-size:12px ;

View file

@ -39,9 +39,9 @@ echo_debug('user_compta.php',__LINE__,"user is ".$_SESSION['g_user']);
// Get The priv on the selected folder
if ( $User->admin == 0 && $User->is_local_admin(dossier::id()) == 0 ) {
$r=$User->get_folder_access($gDossier);
if ($r == 'X' ){
if ($r == 'X' ||$r=='P'){
/* Cannot Access */
NoAccess(1);
}

View file

@ -77,7 +77,6 @@ $result.='<TR>';
if ( $User->Admin() == 1 ) {
$result.="<TD class=\"cell\" ><A class=\"cell\" HREF=\"admin_repo.php\"> Administration </A></TD>";
}
$result.='<TD class="cell" ><A class="cell" HREF="manuel-fr.pdf" >'._('Aide').' </a></TD>';
$result.='<TD class="cell"><A class="cell" HREF="user_pref.php">'._('Préférence').'</a></TD>';
$result.='<TD class="cell" ><A class="cell" HREF="logout.php" >'._('Deconnexion').'</a></TD>';
$result.="</TR>";

View file

@ -1,4 +1,4 @@
<?php
<?php
/*
* This file is part of PhpCompta.
*
@ -35,7 +35,7 @@ function hi($p_string) { return '<i>'.htmlspecialchars($p_string).'</i>';}
function hb($p_string) { return '<b>'.htmlspecialchars($p_string).'</b>';}
function th($p_string) { return '<th>'.htmlspecialchars($p_string).'</th>';}
/*!\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 '<th>'.htmlspecialchars($p_string).'</th>';}
function td($p_string,$p_class=''){ return '<td class="'.$p_class.'" >'.$p_string.'</td>';}
/*!\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='<script src="'.$p_script2.'" type="text/javascript"></script>';
echo "<HEAD>
echo "<HEAD>
<TITLE>PhpCompta</TITLE>
<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF8\">
<LINK REL=\"stylesheet\" type=\"text/css\" href=\"$style\" media=\"screen\">
@ -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='<script src="'.$p_script2.'" type="text/javascript"></script>';
echo "<HEAD>
echo "<HEAD>
<TITLE>PhpCompta</TITLE>
<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF8\">
<LINK REL=\"stylesheet\" type=\"text/css\" href=\"$style\" media=\"screen\">
@ -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 "</BODY>";
echo "</HTML>";
}
/*!
* \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 "<script>";
echo "alert ('"._('Cette action ne vous est pas autorisée Contactez votre responsable')."');";
echo "</script>";
}
else
else
{
echo '<div class="u_redcontent">';
echo '<h2 class="error">'._(' Cette action ne vous est pas autorisée Contactez votre responsable').'</h2>';
@ -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.="</TABLE>";
return $ret;
}
/*!
/*!
* \brief warns
*
*
* \param p_string error message
* gen :
* - none
* \return:
* - none
*/
function echo_warning($p_string)
function echo_warning($p_string)
{
echo '<H2 class="info">'.$p_string."</H2>";
}
/*!
/*!
* \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 '<span class="notice">'.$_SESSION['g_lang'].'domaine non supporté</h2>';

View file

@ -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));

View file

@ -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 )

View file

@ -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

View file

@ -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 '<h2 class="info">'.$str_file.'</h2>';
}
@ -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));
}
}
}

View file

@ -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
//

View file

@ -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').' <input type="checkbox" name="gen_invoice" UNCHECKED>';
// 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().'<br>';
}
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.='<hr>';
$r.=_('ou générer un document').' <input type="checkbox" name="gen_invoice" CHECKED>';
// 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().'<br>';
}
$r.='<br>';

View file

@ -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;

View file

@ -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.='</td>';
$r.='<td>';
$a=$l['j_poste'];
$r_notable.=$a;
@ -268,14 +277,14 @@ function get_internal() {
$r.=h($a);
$csv.='"'.$a.'";';
$r.='</td>';
$r.='<td>';
$a=$l['j_montant'];
$r_notable.=$a;
$r.=$a;
$csv.=$a.';';
$r.='</td>';
$r.='<td>';
$a=$l['debit'];
$r_notable.=$a;
@ -284,7 +293,7 @@ function get_internal() {
$csv.="\r\n";
$r.='</td>';
$r.='</tr>';
}
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' ) {

View file

@ -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() {

View file

@ -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 )
{

View file

@ -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;

File diff suppressed because it is too large Load diff

View file

@ -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);

View file

@ -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

View file

@ -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
});
</script>
';
';
return $r;
}
/*!\brief print in html the readonly value of the widget*/
public function display()
{
$r="<span> Date : ".$this->value;
$r="<span> : ".$this->value;
$r.='<input type="hidden" name="'.$this->name.'"'.
'id="'.$this->name.'"'.
' value = "'.$this->value.'"></span>';

View file

@ -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;

View file

@ -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()
{
}
}

View file

@ -1,4 +1,4 @@
<?php
<?php
/*
* This file is part of PhpCompta.
*
@ -19,11 +19,11 @@
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*! \file
* \brief
* \brief
* Data & function about connected users
*/
/*!
* \brief
* \brief
* Data & function about connected users
*/
@ -41,7 +41,7 @@ class User {
function User ($p_cn,$p_id=-1){
// if p_id is not set then check the connected user
if ( $p_id == -1 ) {
if ( ! isset ($_SESSION['g_user'])){
if ( ! isset ($_SESSION['g_user'])){
echo '<h2 class="error">'._('Session expirée<br>Utilisateur déconnecté').'</h2>';
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 "<H2 class=\"error\"> Action Invalide !!! $Count select * from user_sec_act where ua_login='$p_login' and ua_act_id=$p_action_id </H2>";
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 "<script>";
echo "alert ('Cette action ne vous est pas autorisée. Contactez votre responsable');";
echo "</script>";
}
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;
}
}
?>

View file

@ -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);

View file

@ -1,4 +1,4 @@
<?php
<?php
/*
* This file is part of PhpCompta.
*
@ -37,27 +37,27 @@ $sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
// if this page is called from another menu (customer, supplier,...)
// a button back is added
// TODO add function for generating url, hidden tags...
if ( isset ($_REQUEST['url']))
if ( isset ($_REQUEST['url']))
{
$retour=HtmlInput::button_anchor('Retour',urldecode($_REQUEST['url']));
$h_url=sprintf('<input type="hidden" name="url" value="%s">',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" )
<span>
<form method="get" action="commercial.php">
<?php
echo dossier::hidden();
echo dossier::hidden();
$a=(isset($_GET['query']))?$_GET['query']:"";
printf ('<input type="text" name="query" value="%s">',
$a);
@ -130,7 +130,7 @@ if ( $sub_action == "list" )
<form>
<?php
echo dossier::hidden();
echo dossier::hidden();
$qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
echo JS_LEDGER;
$w=new ICard();
@ -156,10 +156,10 @@ if ( $sub_action == "list" )
<span>
<form method="get" action="commercial.php">
<? echo dossier::hidden(); ?>
<input type="hidden" name="url" <?php $url=urlencode($_SERVER['REQUEST_URI']);echo 'value="'.$url.'"'; ?>
<input type="hidden" name="url" <?php $url=urlencode($_SERVER['REQUEST_URI']);echo 'value="'.$url.'"'; ?>>
<input type="hidden" name="p_action" value="contact">
<?php
<?php
$w=new ISelect();
$w->name="fd_id";
$w->value= $cn->make_array("select fd_id,fd_label from fiche_def where ".
@ -178,7 +178,7 @@ if ( $sub_action == "list" )
</form>
</span>
<?php
<?php
$contact=new Contact($cn);
$search=(isset($_GET['query']))?$_GET['query']:"";
// check if a company is asked if yes, add a condition
@ -202,7 +202,7 @@ if ( $sub_action == 'detail' )
echo '<div class="u_redcontent">';
$contact=new contact($cn,$f_id);
echo $retour;
echo '<form action="'.$_SERVER['REQUEST_URI'].'" method="post">';
echo '<form action="'.$_SERVER['REQUEST_URI'].'" method="post">';
echo dossier::hidden();
echo $contact->Display(false);
$w=new IHidden();

View file

@ -45,7 +45,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE)
echo_debug('dexia_be',__LINE__,'$row = '.var_export($row,true));
echo_debug('dexia_be',__LINE__,'sizeof($row)'.sizeof($row));
$row=split(';',$data[0]);
$row=explode(';',$data[0]);
//to avoid a level of if
if (!(isset($row[2]))) $row[2]='';

View file

@ -1,4 +1,4 @@
<?php
<?php
/*
* This file is part of PhpCompta.
*
@ -26,7 +26,7 @@
//-----------------------------------------------------
// Bank DEXIA
// Bank DEXIA
//-----------------------------------------------------
$LinesSkipped=0;
$LinesImported=0;
@ -44,7 +44,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) {
echo_debug('dexia_be',__LINE__,'$row = '.var_export($row,true));
echo_debug('dexia_be',__LINE__,'sizeof($row)'.sizeof($row));
$row=split(';',$data[0]);
$row=explode(';',$data[0]);
//to avoid a level of if
if (!(isset($row[2]))) $row[2]='';
@ -53,9 +53,9 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) {
if ( $row[2] == '' || !(ereg('[0-9]{3}-[0-9]{7}-[0-9]{2}',$row[0],$r)))
{
$LinesSkipped++;
continue;
continue;
}
// Alternative filter : import all the operations even without a reference
// Alternative filter : import all the operations even without a reference
// !! Disable check of doubles as all the unreferenced operations have hte smae 'NULL' reference
// Just use the following test : if ( !(ereg('[0-9]{3}-[0-9]{7}-[0-9]{2}',$row[0],$r)))
@ -67,24 +67,24 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) {
$ref_extrait=$row[2]; // Operation reference
$devise=$row[10]; // Curency used
$compte_ordre=$row[0]; // Your own bank account
$detail=trim($row[4]).' '.trim($row[5]).' '.trim($row[6]).' '.trim($row[7]);
$detail=trim($row[4]).' '.trim($row[5]).' '.trim($row[6]).' '.trim($row[7]);
//Details-Communicaion
//----------------------------------------------------
// Skip dubbel
//----------------------------------------------------
$Sql="select * from import_tmp where code='$ref_extrait' and compte_ordre='$compte_ordre' limit 2";
$Sql="select * from import_tmp where code='$ref_extrait' and compte_ordre='$compte_ordre' limit 2";
if ( $p_cn->count_sql(utf8_encode($Sql)) > 0)
{
/* Skip it it already encoded */
echo "Double skipped : $ref_extrait $detail <BR>";
$LinesDup++;
continue;
}
}
//--------------------------------------------------------------------
// SQL request to insert into import_tmp
// SQL request to insert into import_tmp
// Adapt the format of the import's date in the ** to_date ** function
//--------------------------------------------------------------------
$Sql="insert into import_tmp (code,
@ -99,11 +99,11 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) {
jrn,
status)
values ( '$ref_extrait',
to_date('$date_exec','DD/MM/YYYY'),
to_date('$date_val' ,'DD/MM/YYYY'),
to_date('$date_exec','DD/MM/YYYY'),
to_date('$date_val' ,'DD/MM/YYYY'),
$montant,
'$devise',
'" . addslashes($compte_ordre). "',
'" . addslashes($compte_ordre). "',
'".addslashes($detail)."','" .$num_compte." ',
'$p_bq_account',
$p_jrn,
@ -123,14 +123,12 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) {
//-----------------------------------------------------
// The import is OK
//-----------------------------------------------------
$LinesImported++;
$row++;
echo "Record imported: $ref_extrait $detail <BR>";
else {
$LinesImported++;
$row++;
echo "Record imported: $ref_extrait $detail <BR>";
}
}
}
//-----------------------------------------------------
// Close and summary
//-----------------------------------------------------

View file

@ -1,4 +1,4 @@
<?php
<?php
/*
* This file is part of PhpCompta.
*
@ -20,7 +20,7 @@
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*!\file
/*!\file
* \brief Management of the folder
*
*/
@ -70,13 +70,13 @@ if ( isset ($_POST["DATABASE"]) ) {
' deux fois le même nom de dossier');
alert($msg);;
echo_debug(__FILE__.':'.__LINE__.'- echec ','Echec creation ',$e);
$l_id=0;
$l_id=0;
$cn->rollback();
}
// If the id is not null, name successfully inserted
// Database created
if ( $l_id != 0) {
//--
// setting the year
@ -87,7 +87,7 @@ if ( isset ($_POST["DATABASE"]) ) {
echo "$year"._(" est une année invalide");
$Res=$cn->exec_sql("delete from ac_dossier where dos_id=$l_id");
}
else
else
{
$Sql=sprintf("CREATE DATABASE %sDOSSIER%d encoding='UTF8' TEMPLATE %sMOD%d",
domaine,
@ -111,7 +111,7 @@ if ( isset ($_POST["DATABASE"]) ) {
$cn=new Database($l_id);
//--year --
$Res=$cn->exec_sql("delete from parm_periode");
if ( ($year % 4 == 0 && $year % 100 != 0) || $year % 400 == 0 )
if ( ($year % 4 == 0 && $year % 100 != 0) || $year % 400 == 0 )
$fev=29;
else
$fev=28;
@ -119,7 +119,7 @@ if ( isset ($_POST["DATABASE"]) ) {
$Res=$cn->exec_sql("delete from user_local_pref where parameter_type='PERIODE'");
$nb_day=array(31,$fev,31,30,31,30,31,31,30,31,30,30);
$m=1;
foreach ($nb_day as $day)
foreach ($nb_day as $day)
{
$p_start=sprintf("01-%d-%s",$m,$year);
$p_end=sprintf("%d-%d-%s",$day,$m,$year);
@ -137,7 +137,7 @@ if ( isset ($_POST["DATABASE"]) ) {
"select p_id,jrn_def_id, 'OP'".
" from parm_periode cross join jrn_def";
$Res=$cn->exec_sql($sql);
}
} // if $l_id != 0
@ -145,7 +145,7 @@ if ( isset ($_POST["DATABASE"]) ) {
?>
<h2> Dossier Management</h2>
<?php
<?php
$cn=new Database();
//---------------------------------------------------------------------------
// List of folder
@ -156,9 +156,9 @@ if ( $sa == 'list' ) {
$offset=(isset($_REQUEST['offset']))?$_REQUEST['offset']:0;
$page=(isset($_REQUEST['page']))?$_REQUEST['page']:1;
$count=$cn->get_value("select count(*) from ac_dossier");
$size=10;
$size=10;
echo jrn_navigation_bar($offset,$count,$size,$page);
echo jrn_navigation_bar($offset,$count,$size,$page);
$repo=new Dossier(0);
$Res=$repo->show_dossier('all',$offset,$size);
$compteur=1;
@ -169,8 +169,8 @@ if ( $sa == 'list' ) {
// show all dossiers
if ( $Res != null ) {
foreach ( $Res as $Dossier) {
if ( $compteur%2 == 0 )
if ( $compteur%2 == 0 )
$cl='class="odd"';
else
$cl='class="even"';
@ -188,18 +188,18 @@ if ( $sa == 'list' ) {
echo '<td>'.HtmlInput::button_anchor(_('Backup'),'backup.php?action=backup&sa=b&t=d&d='
.$Dossier['dos_id']).
'</td>';
echo '<tr>';
$compteur++;
$compteur++;
}
echo "</TR>";
}
echo '</table>';
echo jrn_navigation_bar($offset,$count,$size,$page);
echo jrn_navigation_bar($offset,$count,$size,$page);
}
@ -207,10 +207,10 @@ if ( $sa == 'list' ) {
// Add a new folder
if ( $sa == 'add' ) {
// Load the available Templates
$Res=$cn->exec_sql("select mod_id,mod_name,mod_desc from
$Res=$cn->exec_sql("select mod_id,mod_name,mod_desc from
modeledef order by mod_name");
$count=Database::num_row($Res);
if ( $count == 0 ) {
echo _("pas de modèle disponible");
} else {
@ -222,7 +222,7 @@ if ( $sa == 'list' ) {
$template.="</SELECT>";
}// if count = 0
$m_date=date('Y');
?>
</TABLE>
@ -237,7 +237,7 @@ if ( $sa == 'list' ) {
<TR> <TD><?php echo _('Modèle'); ?></td><td> <?php echo $template; ?> </TD></TR>
<TR><TD>Année </TD><TD><input type="text" size=4 name="YEAR" value=<?php echo '"'.$m_date.'"'; ?>></TD></TR>
<TR>
<TD> <INPUT TYPE=SUBMIT VALUE="<?php echo _('Creation Dossier'); ?>" </TD>
<TD> <INPUT TYPE=SUBMIT VALUE="<?php echo _('Creation Dossier'); ?>"> </TD>
<td>
<?php echo HtmlInput::button_anchor(_('Retour'),'admin_repo.php?action=dossier_mgt'); ?>
</td>
@ -304,7 +304,7 @@ if ( $sa == 'remove' ) {
ob_start();
if ( $cn->exec_sql($sql)==false) {
ob_end_clean();
echo "<h2 class=\"error\"> ";
echo _('Base de donnée ').domaine."dossier".$_REQUEST['d'].
_("est accèdée, déconnectez-vous d'abord")."</h2>";

View file

@ -35,7 +35,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) {
// first line is skipped
if ( $row > 1) {
$code=""; $date_exec=""; $detail=""; $montant="";
list($code, $date_exec, $detail, $montant) = split(";", $data[$c]);
list($code, $date_exec, $detail, $montant) = explode(";", $data[$c]);
$date_exec = str_replace("\t", "", $date_exec);
$date_exec = str_replace(" ", "", $date_exec);

View file

@ -12,7 +12,9 @@ if (isset($_REQUEST['code']) ) {
exit();
}
/* show name of extension */
echo "<h2>".$ext->get_parameter('name').'</h2>';
echo '<div style="position:absolute;right:3px;top:3px;margin:0;z-index:10">';
echo '<h2 class="error" style="padding:0px;margin:0px">'.$ext->get_parameter('name').'</h2>';
echo '</div>';
require_once('ext'.DIRECTORY_SEPARATOR.trim($ext->get_parameter('filepath')));
} else {
alert(j(_("Cette extension n'existe pas ")));

View file

@ -38,11 +38,6 @@ require_once('class_extension.php');
require_once('class_html_input.php');
require_once('class_ibutton.php');
require_once('class_ipopup.php');
echo js_include('scriptaculous.js');
echo js_include('prototype.js');
echo js_include('effects.js');
echo js_include('controls.js');
echo js_include('dragdrop.js');
echo js_include('extension.js');
$ipopup=new IPopup('dtext');

View file

@ -48,8 +48,6 @@ if ( !isset($sessid))
{
$sessid=$_REQUEST["PHPSESSID"];
}
$search='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchPoste(\''.$sessid."',".dossier::id().",'class_base','')\">";
$cn=new Database($gDossier);
@ -304,7 +302,7 @@ if ( isset ( $_GET["action"]) ) {
$oFiche_Def=new fiche_def($cn);
echo HtmlInput::hidden("p_action","fiche");
echo dossier::hidden().HtmlInput::phpsessid();
echo $oFiche_Def->input($search); // CreateCategory($cn,$search);
echo $oFiche_Def->input(); // CreateCategory($cn,$search);
echo HtmlInput::submit("add_modele" ,"Sauve");
echo '</form>';

View file

@ -41,7 +41,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) {
list($code, $date_exec, $date_valeur, $montant, $devise, $compte_ordre, $detail, $num_compte) = split(";", $data[$c]);
list($code, $date_exec, $date_valeur, $montant, $devise, $compte_ordre, $detail, $num_compte) = explode(";", $data[$c]);
echo "line : $row > ".$data[$c]."<hr>";
//corrige un bug de date

View file

@ -59,7 +59,7 @@ function get_rappel_simple ($p_cn,$p_jrn_id,$p_jrn_type,$p_from,&$arap)
// Compute VAT
foreach ($a_Tva as $line_tva)
{
list ($deb,$cred)=split(',',$line_tva['tva_poste']);
list ($deb,$cred)=explode(',',$line_tva['tva_poste']);
if ( $p_jrn_type == 'ACH' )
$ctva=$deb;
else

View file

@ -36,7 +36,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) {
if ( $row > 1 ) {
$code=""; $date_exec=""; $date_valeur=""; $montant=""; $devise=""; $compte_ordre=""; $detail=""; $num_compte=""; $iduser="";
list($num_compte, $code, $date_exec, $date_valeur, $montant, $devise, $montant2, $devise2, $rubriques, $detail, $zzz, $zzz, $date_comptable) = split(";", $data[$c]);
list($num_compte, $code, $date_exec, $date_valeur, $montant, $devise, $montant2, $devise2, $rubriques, $detail, $zzz, $zzz, $date_comptable) = explode(";", $data[$c]);
# Bug CSV ING : "424 au lieu de 424
#"

View file

@ -39,7 +39,7 @@ while (($data = fgetcsv($handle, 2000,"!")) !== FALSE) {
//-----------------------------------------------------
// Parsing CSV comes here
//-----------------------------------------------------
$row=split(';',$data[$c]);
$row=explode(';',$data[$c]);
echo_debug('keytrade',__LINE__,'$row = '.var_export($row,true));
echo_debug('keytrade',__LINE__,'sizeof($row)'.sizeof($row));
if ( sizeof ($row) < 7 )

View file

@ -186,8 +186,8 @@ $hidden.=HtmlInput::phpsessid();
/* Load the card */
$card=$Ledger->get_fiche_def();
$rdeb=split(',',$card['deb']);
$rcred=split(',',$card['cred']);
$rdeb=explode(',',$card['deb']);
$rcred=explode(',',$card['cred']);
echo '<div class="u_redcontent">';

View file

@ -44,7 +44,8 @@ if ( $sb=='change') {
if ( !isset($_GET['id'])) exit;
$row=new Acc_Payment($cn,$_GET['id']);
$row->load();
echo '<form method="post" action="parametre.php">';
$javascript="return confirm('"._('Vous confirmez')."')";
echo '<form method="post" action="parametre.php" onsubmit="'.$javascript.'">';
echo dossier::hidden();
echo HtmlInput::hidden('p_jrn',0);
echo HtmlInput::hidden('p_action','divers');
@ -55,6 +56,7 @@ if ( $sb=='change') {
echo $row->form();
echo HtmlInput::submit('save',_('Sauve'));
echo HtmlInput::submit('delete',_('Efface'));
echo HtmlInput::button_anchor(_('Retour sans sauvez'),
'?p_action=divers&sa=mp&'.dossier::get()
);
@ -70,7 +72,40 @@ if ( $sb=='save'){
$row->update();
}
//---------------------------------------------------------------------------
// Delete a card
//---------------------------------------------------------------------------
if (isset($_POST['delete'])) {
$row=new Acc_Payment($cn,$_POST['id']);
$row->from_array($_POST);
$row->delete();
}
//---------------------------------------------------------------------------
// Show form to enter a new one
//---------------------------------------------------------------------------
if ($sb=='ins') {
$mp=new Acc_Payment($cn);
$r=$mp->blank();
echo '<form method="POST">';
echo dossier::hidden().HtmlInput::hidden('sa',$_REQUEST['sa']).
HtmlInput::hidden('p_action',$_REQUEST['p_action']).HtmlInput::hidden('sb','insert');
echo $r;
echo HtmlInput::submit('insert',_('Enregistre'));
echo '</form>';
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 '</table>';
}
echo '</fieldset>';
// Button to insert new one
echo HtmlInput::button_anchor(_('Ajout'),'?p_action=divers&sa=mp&sb=ins&'.dossier::get());
echo '</div>';
?>

View file

@ -36,7 +36,7 @@
</tr>
<tr>
<td style="text-align:right">
<?=_('Actif')?>
<?=_('Acti')?>
</td>
<td>
<?=$str_enable?>
@ -44,4 +44,4 @@
</tr>
</table>
</fieldset>
</div>
</div>

View file

@ -5,11 +5,11 @@
</TR>
<TR>
<TD> <?=_('Classe de base')?> </TD>
<TD><INPUT TYPE="INPUT" id="class_base" NAME="class_base"> <INPUT TYPE="BUTTON" VALUE="<?=_('Cherche')?>" OnClick="<?php echo $p_js;?>"></TD>
<TD><?=$f_class_base?> </TD>
<td><span id="class_base_label"></span></td>
</TR>
<TR>
<TD> <INPUT TYPE="CHECKBOX" NAME="create" CHECKED><?=_('Création automatique du poste comptable')?></TD>
<TD colspan='2'> <INPUT TYPE="CHECKBOX" NAME="create" CHECKED><?=_('Création automatique du poste comptable uniquement s\'il n\y a qu\'un seul poste')?></TD>
</TR>
<?php
if ( sizeof($ref) ) {

View file

@ -0,0 +1,51 @@
<fieldset>
<legend><?=_('Nouveau moyen de paiement')?>
</legend>
<table>
<tr>
<td>
<?=_('Libellé')?>
</td>
<td>
<?=$f_lib?>
</td>
</tr>
<tr>
<td>
<?=_('Type de fiche')?>
</td>
<td>
<?=$f_type_fiche?>
</td>
</tr>
<tr>
<td>
<?=_('Pour le type de journal')?>
</td>
<td>
<?=$f_type?>
</td>
</tr>
<tr>
<td>
<?=_('Paiement enregistré dans ')?>
</td>
<td>
<?=$f_ledger_record?>
</td>
</tr>
<tr>
<td>
<?=_('Avec la fiche')?>
</td>
<td>
<?=$f_qcode?>
</td>
</tr>
</table>
</fieldset>

View file

@ -1,4 +1,4 @@
<?php
<?php
/*
* This file is part of PhpCompta.
*
@ -30,17 +30,17 @@ require_once("class_ihidden.php");
require_once("class_document.php");
require_once("class_acc_operation.php");
/*! \file
* \brief Common functions
* \brief Common functions
*/
/*!
/*!
*\brief Insert data into stock_goods,
*
* \param $p_cn Database object
*
* \param $p_cn Database object
* \param $p_j_id the j_id
* \param $p_good the goods
* \param $p_quant quantity
@ -51,7 +51,7 @@ require_once("class_acc_operation.php");
*/
function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type)
{
// Retrieve the good account for stock
$code=new fiche($p_cn);
$code->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.="</A>&nbsp;&nbsp;";
}
//----------------------------------------------------------------------
// 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 '<HTML><head><META HTTP-EQUIV="REFRESH" content="'.$p_time.';url='.$p_string.'"></head><body> Connecting... </body></html>';
}
/*!\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;

View file

@ -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.="<TABLE style=\"width:75%;border-width:0px;border-collapse:collapse;\">";
for ($i=0;$i<sizeof($p_array);$i++) {
$id=$p_array[$i]['dos_id'];
$name= $p_array[$i]['dos_name'];
$desc=$p_array[$i]['dos_description'];
if ( $i%2 == 0)
$tr="odd";
else $tr="even";
if ( $user->check_dossier($id)!='P') {
$target="access.php?gDossier=$id";
} else {
$target="extension.php?gDossier=$id";
}
$result.="<TR class=\"$tr\">";
$result.="<TD class=\"$tr\">";
$result.="<A class=\"dossier\" HREF=\"access.php?gDossier=$id\">";
$result.="<A class=\"dossier\" HREF=\"$target\">";
$result.=$id." <B>".h($name)."</B>";
$result.="</A>";
$result.="</TD>";
$desc=($desc=="")?"<i>Aucune description</i>":h($desc);
$desc="<A class=\"dossier\" HREF=\"access.php?gDossier=$id\">".$desc."</a>";
$desc="<A class=\"dossier\" HREF=\"$target\">$desc</A>";
$result.="<TD class=\"$tr\">".$desc;
$result.="</TD>";
$result.="</TR>";

View file

@ -1,112 +1 @@
begin;
insert into parameter(pr_id,pr_value) values ('MY_CHECK_PERIODE','Y');
alter table jrn add jr_mt text ;
update jrn set jr_mt= extract (microseconds from jr_tech_date);
create index x_mt on jrn(jr_mt);
DROP FUNCTION insert_quant_purchase(text, numeric, character varying, numeric, numeric,numeric, integer, numeric, numeric, numeric, character varying);
DROP FUNCTION insert_quant_sold(text, character varying, numeric, numeric, numeric, integer, character varying);
alter table groupe_analytique add constraint fk_pa_id foreign key(pa_id) references plan_analytique(pa_id) on delete cascade;
alter table stock_goods add constraint fk_stock_good_f_id foreign key(f_id) references fiche(f_id) ;
-- for belgium
insert into parm_code values ('SUPPLIER',440,'Poste par défaut pour les fournisseurs');
-- for french
-- insert into parm_code values ('SUPPLIER',400,'Poste par défaut pour les fournisseurs');
drop table invoice;
-- Function: account_parent(poste_comptable)
DROP FUNCTION account_parent(poste_comptable);
CREATE FUNCTION account_parent(p_account poste_comptable)
RETURNS poste_comptable AS
$BODY$
declare
nParent tmp_pcmn.pcm_val_parent%type;
sParent varchar;
nCount integer;
begin
sParent:=to_char(p_account,'9999999999999999');
sParent:=trim(sParent::text);
nParent:=0;
while nParent = 0 loop
select count(*) into nCount
from tmp_pcmn
where
pcm_val = to_number(sParent,'9999999999999999');
if nCount != 0 then
nParent:=to_number(sParent,'9999999999999999');
exit;
end if;
sParent:= substr(sParent,1,length(sParent)-1);
if length(sParent) <= 0 then
raise exception 'Impossible de trouver le compte parent pour %',p_account;
end if;
end loop;
raise notice 'account_parent : Parent is %',nParent;
return nParent;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
alter table document drop column d_state;
alter table action_gestion drop column f_id_exp;
alter table action_gestion set ag_title type text;
ALTER TABLE action_gestion ADD COLUMN ag_hour time with time zone;
ALTER TABLE action_gestion ADD COLUMN ag_priority integer;
ALTER TABLE action_gestion ALTER COLUMN ag_priority SET DEFAULT 2;
ALTER TABLE action_gestion ADD COLUMN ag_dest text;
ALTER TABLE action_gestion ADD COLUMN ag_owner text;
ALTER TABLE action_gestion ADD COLUMN ag_contact int8;
CREATE OR REPLACE FUNCTION action_gestion_ins_upd()
RETURNS trigger AS
$BODY$
begin
NEW.ag_title := substr(NEW.ag_title,1,70);
NEW.ag_hour := substr(NEW.ag_hour,1,10);
return NEW;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER action_gestion_t_insert_update
BEFORE INSERT OR UPDATE
ON action_gestion
FOR EACH ROW
EXECUTE PROCEDURE action_gestion_ins_upd();
COMMENT ON TRIGGER action_gestion_t_insert_update ON action_gestion IS 'Truncate the column ag_title to 70 char';
ALTER TABLE action_gestion ADD COLUMN ag_state integer;
update action_gestion set f_id_dest = f_id_exp where f_id_exp != 0;
alter table action drop column f_id_dest;
UPDATE document_state SET s_value= 'Clôturé' WHERE s_id=1;
UPDATE document_state SET s_value= 'A suivre' WHERE s_id=2;
UPDATE document_state SET s_value= 'A faire' WHERE s_id=3;
UPDATE document_state SET s_value= 'Abandonné' WHERE s_id=4;
CREATE TABLE action_detail
(
ad_id serial,
f_id int8,
ad_text text,
ad_pu numeric(20,4) DEFAULT 0,
ad_quant numeric(20,4) DEFAULT 0,
ad_tva_id integer DEFAULT 0,
ad_tva_amount numeric(20,4) DEFAULT 0,
ad_total_amount numeric(20,4) DEFAULT 0,
ag_id integer NOT NULL DEFAULT 0,
CONSTRAINT action_detail_pkey PRIMARY KEY (ad_id),
CONSTRAINT action_detail_ag_id_fkey FOREIGN KEY (ag_id)
REFERENCES action_gestion (ag_id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
);
COMMENT ON TABLE action_detail IS 'Detail of action_gestion, see class Action_Detail';
commit;