merge with rel310C

This commit is contained in:
sparkyx 2008-02-11 18:53:44 +00:00
parent 2bddf09d9c
commit aefc4b1eb8
77 changed files with 1189 additions and 1205 deletions

View file

@ -0,0 +1,133 @@
--
-- PostgreSQL database dump
-- Version 2008/02/10 09:19
--
--
-- Name: TABLE tmp_pcmn; Type: COMMENT; Schema: public; Owner: phpcompta
--
COMMENT ON TABLE tmp_pcmn IS 'Plan comptable - Syndicat des copropriétaires : strict';
--
-- Data for Name: tmp_pcmn; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
COPY tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) FROM stdin;
1 Classe 1 - Provisions, avances, subventions et emprunts 0
10 Provisions et avances : 1
102 Provisions pour travaux décidés 10
103 Avances 10
1031 Avances de trésorerie 103
1032 Avances travaux au titre de l'article 18, 6e alinéa de la loi susvisée 103
1033 Autres avances 103
12 Solde en attente sur travaux et opérations exceptionnelles 1
13 Subventions : 1
131 Subventions accordées en instance de versement 13
4 Classe 4 - Copropriétaires et tiers 0
40 Fournisseurs : 4
401 Factures parvenues 40
408 Factures non parvenues 40
409 Fournisseurs débiteurs 40
42 Personnel : 4
421 Rémunérations dues 42
43 Sécurité sociale et autres organismes sociaux : 4
431 Sécurité sociale 43
432 Autres organismes sociaux 43
44 Etat et collectivités territoriales : 4
441 Etat et autres organismes - subventions à recevoir 44
442 Etat - impôts et versements assimilés 44
443 Collectivités territoriales - aides 44
45 Collectivité des copropriétaires : 4
450 Copropriétaire individualisé 45
4501 Sur décision AG : Copropriétaire - budget prévisionnel 450
4502 Sur décision AG : Copropriétaire - travaux de l'article 14-2 de la loi susvisée et opérations exceptionnelles 450
4503 Sur décision AG : Copropriétaire - avances 450
4504 Sur décision AG : Copropriétaire - emprunts 450
459 Copropriétaire - créances douteuses 45
46 Débiteurs et créditeurs divers : 4
461 Débiteurs divers 46
462 Créditeurs divers 46
47 Compte d'attente : 4
471 Compte en attente d'imputation débiteur 47
472 Compte en attente d'imputation créditeur 47
48 Compte de régularisation : 4
486 Charges payées d'avance 48
487 Produits encaissés d'avance 48
49 Dépréciation des comptes de tiers : 4
491 Copropriétaires 49
492 Personnes autres que les copropriétaires 49
5 Classe 5 - Comptes financiers 0
50 Fonds placés : 5
501 Compte à terme 50
502 Autre compte 50
51 Banques, ou fonds disponibles en banque pour le syndicat : 5
512 Banques 51
514 Chèques postaux 51
53 Caisse. 5
6 Classe 6 - Comptes de charges 0
60 Achats de matières et fournitures : 6
601 Eau 60
602 Electricié 60
603 Chauffage, énergie et combustibles 60
604 Achats produits d'entretien et petits équipements 60
605 Matériel 60
606 Fournitures 60
61 Services extérieurs : 6
611 Nettoyage des locaux 5
612 Locations immobiliéres 61
613 Locations mobiliéres 61
614 Contrats de maintenance 61
615 Entretien et petites réparations 61
616 Primes d'assurances 61
62 Frais d'administration et honoraires : 6
621 Rémunérations du syndic sur gestion copropriété 62
6211 Rémunération du syndic 621
6212 Débours 621
6213 Frais postaux 621
622 Autres honoraires du syndic 62
6221 Honoraires travaux 622
6222 Prestations particulières 622
6223 Autres honoraires 622
623 Rémunérations de tiers intervenants 62
624 Frais du conseil syndical 62
63 Impôts - taxes et versements assimilés : 6
632 Taxe de balayage 63
633 Taxe foncière 63
634 Autres impôts et taxes 63
64 Frais de personnel : 6
641 Salaires 64
642 Charges sociales et organismes sociaux 64
643 Taxe sur les salaires 64
644 Autres (médecine du travail, mutuelles, etc.) 64
66 Charges financières des emprunts, agios ou autres : 6
661 Remboursement d'annuités d'emprunt 66
662 Autres charges financières et agios 66
67 Charges pour travaux et opérations exceptionnelles : 6
671 Travaux décidés par l'assemblée générale 67
672 Travaux urgents 67
673 Etudes techniques, diagnostic, consultation 67
677 Pertes sur créances irrécouvrables 67
678 Charges exceptionnelles 67
68 Dotations aux dépréciations sur créances douteuses. 6
7 Classe 7 - Comptes de produits 0
70 Appels de fonds : 7
701 Provisions sur opérations courantes 70
702 Provisions sur travaux de l'article 14-2 et opérations exceptionnelles 70
703 Avances 70
704 Remboursements d'annuités d'emprunts 70
71 Autres produits : 7
711 Subventions 71
712 Emprunts 71
713 Indemnités d'assurances 71
714 Produits divers (dont intérêts légaux dus par les copropriétaires) 71
716 Produits financiers 71
718 Produits exceptionnels 71
78 Reprises de dépréciations sur créances douteuses. 7
8 Comptes spéciaux 0
9 Comptes analytique 0
\.
--
-- PostgreSQL database dump complete
--

Binary file not shown.

View file

@ -147,7 +147,7 @@ function ExecuteScript($p_cn,$script) {
echo_debug('setup.php',__LINE__,"Execute sql $sql");
if ( ExecSql($p_cn,$sql,false) == false ) {
Rollback($p_cn);
if ( DEBUG=='false' ) ob_clean();
if ( DEBUG=='false' ) ob_end_clean();
print "ERROR : $sql";
exit();
}
@ -156,7 +156,7 @@ echo_debug('setup.php',__LINE__,"Execute sql $sql");
print "<hr>";
} // while (feof)
fclose($hf);
if ( DEBUG=='false' ) ob_clean();
if ( DEBUG=='false' ) ob_end_clean();
}
/*! \brief loop to apply all the path to a folder or
* a template
@ -166,7 +166,7 @@ echo_debug('setup.php',__LINE__,"Execute sql $sql");
*/
function apply_patch($p_cn,$p_name)
{
$MaxVersion=36;
$MaxVersion=40;
echo '<ul>';
for ( $i = 4;$i <= $MaxVersion;$i++)
{
@ -238,7 +238,7 @@ function apply_patch($p_cn,$p_name)
ExecuteScript($p_cn,"sql/patch/upgrade36.".$country.".sql");
ExecSql($p_cn,'update tmp_pcmn set pcm_type=find_pcm_type(pcm_val)');
}
if ( DEBUG == 'false') ob_clean();
if ( DEBUG == 'false') ob_end_clean();
}
}
echo '</ul>';
@ -415,7 +415,7 @@ if ($account == 0 ) {
ExecuteScript($cn,"sql/account_repository/constraint.sql");
Commit($cn);
if ( DEBUG=='false') ob_clean();
if ( DEBUG=='false') ob_end_clean();
echo "Creation of Modele1";
if ( DEBUG=='false') ob_start();
@ -426,7 +426,7 @@ if ($account == 0 ) {
ExecuteScript($cn,'sql/mod1/data.sql');
ExecuteScript($cn,'sql/mod1/constraint.sql');
Commit($cn);
if ( DEBUG=='false') ob_clean();
if ( DEBUG=='false') ob_end_clean();
echo "Creation of Modele2";
ExecSql($cn,"create database ".domaine."mod2 encoding='latin1'");
@ -438,7 +438,7 @@ if ($account == 0 ) {
ExecuteScript($cn,'sql/mod1/constraint.sql');
Commit($cn);
if ( DEBUG=='false') ob_clean();
if ( DEBUG=='false') ob_end_clean();
}// end if
// Add a french accountancy model
@ -507,6 +507,6 @@ echo '<hr>';
}
}
if (DEBUG=='false') ob_clean();
if (DEBUG=='false') ob_end_clean();
echo "<h2 class=\"info\">Voil&agrave; tout est install&eacute; ;-)</h2>";
?>

View file

@ -12,6 +12,7 @@ INSERT INTO parm_poste (p_value, p_type) VALUES (492, 'PAS');
INSERT INTO parm_poste (p_value, p_type) VALUES (493, 'PAS');
INSERT INTO parm_poste (p_value, p_type) VALUES (2409, 'ACTINV');
INSERT INTO parm_poste (p_value, p_type) VALUES (2, 'ACT');
INSERT INTO parm_poste (p_value, p_type) VALUES (2409, 'ACTINV');
INSERT INTO parm_poste (p_value, p_type) VALUES (3, 'ACT');
INSERT INTO parm_poste (p_value, p_type) VALUES (5, 'ACT');
INSERT INTO parm_poste (p_value, p_type) VALUES (491, 'ACT');

View file

@ -223,13 +223,6 @@ CREATE SEQUENCE bud_card_bc_id_seq
ALTER TABLE public.bud_card_bc_id_seq OWNER TO phpcompta;
--
-- Name: bud_card_bc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: phpcompta
--
ALTER SEQUENCE bud_card_bc_id_seq OWNED BY bud_card.bc_id;
--
-- Name: bc_id; Type: DEFAULT; Schema: public; Owner: phpcompta
--
@ -322,12 +315,6 @@ CREATE SEQUENCE bud_detail_bd_id_seq
ALTER TABLE public.bud_detail_bd_id_seq OWNER TO phpcompta;
--
-- Name: bud_detail_bd_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: phpcompta
--
ALTER SEQUENCE bud_detail_bd_id_seq OWNED BY bud_detail.bd_id;
--
-- Name: bd_id; Type: DEFAULT; Schema: public; Owner: phpcompta
@ -424,13 +411,6 @@ CREATE SEQUENCE bud_detail_periode_bdp_id_seq
ALTER TABLE public.bud_detail_periode_bdp_id_seq OWNER TO phpcompta;
--
-- Name: bud_detail_periode_bdp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: phpcompta
--
ALTER SEQUENCE bud_detail_periode_bdp_id_seq OWNED BY bud_detail_periode.bdp_id;
--
-- Name: bdp_id; Type: DEFAULT; Schema: public; Owner: phpcompta
--
@ -682,7 +662,7 @@ begin
nLength:=length(str_value);
while nLength > 0 loop
n_value:=to_number(str_value,'99999999999999999999999999999');
select into str_type p_type from parm_poste where p_value=n_value;
select p_type into str_type from parm_poste where p_value=n_value;
if FOUND then
return str_type;
end if;

View file

@ -0,0 +1,43 @@
begin;
CREATE OR REPLACE FUNCTION jrn_check_periode()
RETURNS "trigger" AS
$BODY$
declare
bClosed bool;
str_status text;
ljr_tech_per jrn.jr_tech_per%TYPE;
ljr_def_id jrn.jr_def_id%TYPE;
lreturn jrn%ROWTYPE;
begin
if TG_OP='INSERT' then
ljr_tech_per :=NEW.jr_tech_per;
ljr_def_id :=NEW.jr_def_id;
lreturn :=NEW;
end if;
if TG_OP='DELETE' then
ljr_tech_per :=OLD.jr_tech_per;
ljr_def_id :=OLD.jr_def_id;
lreturn :=OLD;
end if;
select p_closed into bClosed from parm_periode
where p_id=ljr_tech_per;
if bClosed = true then
raise exception 'Periode fermee';
end if;
select status into str_status from jrn_periode
where p_id =ljr_tech_per and jrn_def_id=ljr_def_id;
if str_status <> 'OP' then
raise exception 'Periode fermee';
end if;
return lreturn;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
update version set val=38;
commit;

View file

@ -0,0 +1,28 @@
begin;
CREATE OR REPLACE FUNCTION find_pcm_type(pp_value "numeric")
RETURNS text AS
$BODY$
declare
str_type text;
str_value text;
n_value numeric;
nLength integer;
begin
str_value:=trim(to_char(pp_value,'99999999999999999999999999999'));
nLength:=length(str_value);
while nLength > 0 loop
n_value:=to_number(str_value,'99999999999999999999999999999');
select p_type into str_type from parm_poste where p_value=n_value;
if FOUND then
return str_type;
end if;
nLength:=nLength-1;
str_value:=substring(str_value from 1 for nLength);
end loop;
return 'CON';
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
update version set val=39;
commit;

View file

@ -0,0 +1,40 @@
begin;
create table info_def (
id_type text primary key,
id_description text null
);
comment on table info_def is 'Contains the types of additionnal info we can add to a operation';
create or replace function info_def_ins_upd() returns trigger
AS
$$
declare
row_info_def info_def%ROWTYPE;
str_type text;
begin
row_info_def:=NEW;
str_type:=upper(trim(NEW.id_type));
str_type:=replace(str_type,' ','');
str_type:=replace(str_type,',','');
str_type:=replace(str_type,';','');
if length(str_type) =0 then
raise exception 'id_type cannot be null';
end if;
row_info_def.id_type:=str_type;
return row_info_def;
end;
$$ language plpgsql;
create trigger info_def_ins_upd_t before insert or update on info_def for each row execute procedure info_def_ins_upd();
create table jrn_info (
ji_id serial primary key,
jr_id integer not null,
id_type text not null,
ji_value text
);
alter table jrn_info add constraint fk_jrn foreign key (jr_id) references jrn(jr_id) on delete cascade on update cascade;
alter table jrn_info add constraint fk_info_def foreign key (id_type) references info_def(id_type) on delete cascade on update cascade;
insert into info_def values ('BON_COMMANDE','Numero de bon de commande') ,('OTHER','Info diverses');
insert into attr_def values(30,'Numero de client');
update version set val=40;
commit;

View file

@ -0,0 +1,49 @@
begin;
insert into parm_code values ('DEP_PRIV',4890,'Depense a charge du gerant');
insert into attr_def values (31,'Depense à charge du gérant (partie privée)');
alter table quant_purchase add qp_dep_priv numeric(20,4) default 0.0;
CREATE FUNCTION insert_quant_purchase(p_internal text, p_j_id numeric, p_fiche character varying, p_quant numeric, p_price numeric, p_vat numeric, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric, p_nd_tva_recup numeric,p_dep_priv numeric , p_client character varying) RETURNS void
AS $$
declare
fid_client integer;
fid_good integer;
begin
select f_id into fid_client from
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_client);
select f_id into fid_good from
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_fiche);
insert into quant_purchase
(qp_internal,
j_id,
qp_fiche,
qp_quantite,
qp_price,
qp_vat,
qp_vat_code,
qp_nd_amount,
qp_nd_tva,
qp_nd_tva_recup,
qp_supplier,
qp_dep_priv)
values
(p_internal,
p_j_id,
fid_good,
p_quant,
p_price,
p_vat,
p_vat_code,
p_nd_amount,
p_nd_tva,
p_nd_tva_recup,
fid_client,
p_dep_priv);
return;
end;
$$
LANGUAGE plpgsql;
update version set val=41;
commit;

View file

@ -136,13 +136,15 @@ if ($p_id != -1 ) { // A
if ( $p_id != -1 ) { //B
// Test whether date of the operation is in a closed periode
// get the period_id
$period_id=getPeriodeFromDate($cn,$e_op_date);
$p=ExecSql($cn,"select jr_tech_per from jrn where jr_grpt_id=".$_REQUEST['jrn_op']);
$period_id=pg_fetch_result($p,0,0);
// thanks jrn_op (jrn.jr_id) we find out the concerned ledger
$sql="select jr_def_id from jrn where jr_id=".$_REQUEST['jrn_op'];
$sql="select jr_def_id from jrn where jr_grpt_id=".$_REQUEST['jrn_op'];
$r=ExecSql($cn,$sql);
$nJrn=pg_fetch_result($r,0,0);
$per=new Periode($cn);
$per->set_jrn(nJrn);
$per->set_jrn($nJrn);
$per->set_periode($period_id);
// Check the period_id

View file

@ -72,7 +72,7 @@ if ( isset ($_REQUEST['p_action']))
echo '<div style="float:left">';
echo ShowItem(array(
array('?p_action=ca_pa&'.$str_dossier,'Plan Analytique',"Plan Analytique",0),
array('?p_action=ca_od&'.$str_dossier,'Op&eacute;rations Diverses',"Permet d'enregistrer des opérations sur la compta analytique",1),
array('?p_action=ca_od&'.$str_dossier,'Op&eacute;rations Diverses',"Permet d'enregistrer des operations sur la compta analytique",1),
array('?p_action=ca_groupe&'.$str_dossier,'Groupe','Regroupe les postes analytiques',3),
array('?p_action=ca_imp&'.$str_dossier,'Impression',"impression de rapport",2)
),

View file

@ -56,8 +56,8 @@ $ret=get_array($cn,"select distinct j_poste::text
from jrnx inner join tmp_pcmn on (pcm_val=j_poste)
where
j_tech_per >= ".$sql_from[0]['min']." and
j_tech_per <= ".$sql_to[0]['max']." and j_poste not like '7%'
and j_poste not like '6%'
j_tech_per <= ".$sql_to[0]['max']." and j_poste::text not like '7%'
and j_poste::text not like '6%'
order by j_poste::text");
if ( $ret == null ) {echo 'Rien à exporter'; exit();}
printf ("OUVERTURE\n");

View file

@ -222,7 +222,7 @@ if ( isset ( $_GET["action"]) ) {
$sql="select distinct f_id,fd_id,av_text from fiche join jnt_fic_att_value using (f_id)
join attr_value using (jft_id) where
upper(av_text) like upper('%".FormatString($_GET["search_text"])."%') order by av_text,f_id";
$all=getArray($cn,$sql);
$all=get_array($cn,$sql);
// test on the size
//
if ( sizeof($all) != 0 )

View file

@ -24,7 +24,6 @@
* \brief Fid for the ajax request for cards
*/
header("Content-type: text/xml charset=\"ISO8859-1\"",true);
require_once ("constant.php");
require_once ("postgres.php");
@ -77,23 +76,17 @@ if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1)
$tva_id=$array[0]['tva_id'];
// Check null
$name=($name==null)?" ":$name;
$sell=($sell==null)?" ":$sell;
$buy=($buy==null)?" ":$buy;
$tva_id=($tva_id==null)?" ":$tva_id;
$name=($name==null)?" ":str_replace('"','',$name);
$sell=($sell==null)?" ":str_replace('"','',$sell);
$buy=($buy==null)?" ":str_replace('"','',$buy);
$tva_id=($tva_id==null)?" ":str_replace('"','',$tva_id);
$a='<?xml version="1.0" encoding="iso8859-1" standalone="yes"?>';
$a.="<data>";
$a.="<name>".$name."</name>";
$a.="<sell>".$sell."</sell>";
$a.="<buy>".$buy."</buy>";
$a.="<tva_id>".$tva_id."</tva_id>";
$a.="</data>";
$a='{"answer":"ok","name":"'.$name.'","sell":"'.$sell.'","buy":"'.$buy.'","tva_id":"'.$tva_id.'","ctl":"'.$_GET['ctl'].'"}';
}
else
$a="not connected";
$a='{"answer":"nok"}';
echo_debug("fid.php",__LINE__,"Answer is \n $a");
header("Content-type: text/html; charset: ISO8859-1",true);
print $a;
?>

View file

@ -76,22 +76,18 @@ BODY {
<script src="js/scripts.js" type="text/javascript"></script>
</head>
<BODY onLoad="SetFocus(\'login\',0)">
Version 3.1.0
<div class="remark">
<p class="gras">Il est conseill&eacute; de ne PAS utiliser Internet Explorer.
</p><p>
Vous pouvez utiliser un autre browser: firefox, mozilla, netscape, Konqueror, opera...
</p>
<p>
<a href="https://savannah.nongnu.org/projects/phpcompta">
Si vous avez envie de nous rejoindre, vous êtes les bienvenus
</a> .
</p>
</div>
<span style="background-color:#879ed4;color:white;padding-left:4px;padding-right:4px;">
version 3.1.0
</span>
<BR>
<BR>
<BR>
<BR>
<center>
<IMG SRC="image/logo7.jpg" alt="Logo">
<BR>
<BR>
<BR>
<form action="login.php" method="post" name="loginform">
<TABLE><TR><TD>
@ -105,7 +101,9 @@ Version 3.1.0
<TD><INPUT TYPE="PASSWORD" NAME="p_pass" tabindex="2"></TD>
</TR>
<TR>
<TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT NAME="login" value="Log in"></TD>
<TD COLSPAN=2 ALIGN=CENTER>
<INPUT TYPE="SUBMIT" NAME="login" value="Se connecter">
</TD>
</TR>
</table>
</TD></TR></TABLE>

View file

@ -99,6 +99,15 @@ if ( $_GET['p_simple'] == 0 )
'"internal";'.
'"montant";'.
"\r\n");
// set a filter for the FIN
$a_parm_code=get_array($cn,"select p_value from parm_code where p_code in ('BANQUE','COMPTE_COURANT','CAISSE')");
$sql_fin="(";
$or="";
foreach ($a_parm_code as $code) {
$sql_fin.="$or j_poste::text like '".$code['p_value']."%'";
$or=" or ";
}
$sql_fin.=")";
foreach ($Row as $line)
{
@ -113,7 +122,7 @@ if ( $_GET['p_simple'] == 0 )
// Get the jrn type
if ( $line['jrn_def_type'] == 'FIN' ) {
$positive = CountSql($cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ".
" where jr_id=".$line['jr_id']." and (j_poste like '55%' or j_poste like '57%' )".
" where jr_id=".$line['jr_id']." and $sql_fin ".
" and j_debit='f'");

View file

@ -41,107 +41,79 @@ function clean_Fid(p_ctl)
nSell=p_ctl+"_sell";
nBuy=p_ctl+"_buy";
nTva_id=p_ctl+"_tva_id";
if ( document.getElementById(nSell) != null ) {
document.getElementById(nSell).value="";
}
if ( document.getElementById(nBuy) != null ) {
document.getElementById(nBuy).value="";
}
if ( document.getElementById(nTva_id) != null ) {
document.getElementById(nTva_id).value="";
}
if ( $(nSell) ) { $(nSell).value=""; }
if ( $(nBuy) ) { $(nBuy).value="";}
if ( $(nTva_id) ) { $(nTva_id).value="-1"; }
}
function errorFid(request,json) {
alert('erreur : ajax fiche');
}
/*!\brief this function fills the data from fid.php,
* \param p_ctl the ctrl to fill
* \param p_deb if debit of credit
* \param p_jrn the ledger
*/
function ajaxFid(p_ctl,p_deb,p_jrn){
var ajaxRequest; // The variable that makes Ajax possible!
;
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
if ( ajaxRequest.status == 200 ) {
xmldoc = ajaxRequest.responseXML.documentElement;
data = xmldoc.getElementsByTagName('name');
label = data[0].firstChild.nodeValue;
sell = xmldoc.getElementsByTagName('sell')[0].firstChild.nodeValue;
buy = xmldoc.getElementsByTagName('buy')[0].firstChild.nodeValue;
tva_id = xmldoc.getElementsByTagName('tva_id')[0].firstChild.nodeValue;
toSet=p_ctl+"_label";
if ( trim(label) == "" )
{
var ctl_toSet=document.getElementById(toSet);
ctl_toSet.innerHTML="Fiche inconnue";
ctl_toSet.style.color='red';
clean_Fid(p_ctl);
}
else {
var ctl_toSet=document.getElementById(toSet);
ctl_toSet.style.color='black';
ctl_toSet.innerHTML=label;
nSell=p_ctl+"_sell";
nBuy=p_ctl+"_buy";
nTva_id=p_ctl+"_tva_id";
if ( document.getElementById(nSell) != null ) {
document.getElementById(nSell).value=sell;
}
if ( document.getElementById(nBuy) != null ) {
document.getElementById(nBuy).value=buy;
}
if ( document.getElementById(nTva_id) != null ) {
document.getElementById(nTva_id).value=tva_id;
}
}
}
}
}
if (document.getElementById(p_ctl).value.length == 0 ) {
var toSet=p_ctl+"_label";
var ctl_toSet=document.getElementById(toSet);
ctl_toSet.innerHTML="";
// clean other fields
clean_Fid(p_ctl);
} else {
var gDossier=document.getElementById('gDossier').value;
queryString="?FID="+document.getElementById(p_ctl).value;
queryString=queryString+"&d="+p_deb+"&j="+p_jrn+'&gDossier='+gDossier;
ajaxRequest.open("GET", "fid.php"+queryString, true);
ajaxRequest.send(null);
}
function ajaxFid(p_ctl,p_deb,p_jrn)
{
var gDossier=$('gDossier').value;
var ctl_value=$(p_ctl).value;
if ( trim(ctl_value)==0 ) {
nLabel=p_ctl+"_label";
$(nLabel).value="";
$(nLabel).innerHTML="";
clean_Fid(p_ctl);
return;
}
queryString="?FID="+ctl_value;
queryString=queryString+"&d="+p_deb+"&j="+p_jrn+'&gDossier='+gDossier;
queryString=queryString+'&ctl='+p_ctl;
/* alert(queryString); */
var action=new Ajax.Request (
"fid.php",
{
method:'get',
parameters:queryString,
onFailure:errorFid,
onSuccess:successFid
}
);
}
/*!\brief callback function for ajax
* \param request : object request
* \param json : json answer */
function successFid(request,json) {
var answer=request.responseText.evalJSON(true);
//-->
var data=answer.name;
var sell=answer.sell;
var buy=answer.buy;
var tva_id=answer.tva_id;
var ctl=answer.ctl;
/* alert('data:'+data+' sell:'+sell+' Tva id:'+tva_id); */
var toSet=ctl+'_label';
if (trim(data) == "" ) {
$(toSet).innerHTML="Fiche Inconnue";
$(toSet).style.color="red";
clean_Fid(ctl);
} else {
var nSell=ctl+"_sell";
var nBuy=ctl+"_buy";
var nTva_id=ctl+"_tva_id";
$(toSet).innerHTML=data;
$(toSet).style.color="black";
if ( $(nTva_id) ) {
$(nTva_id).value=tva_id;
}
if ( $(nSell ) ) {
$(nSell).value=sell;
}
$(nBuy).value=buy;
}
}
//-->

View file

@ -30,7 +30,6 @@
// Set the focus to the specified field,
// and select it if requested by SelectIt
function GetID(ID) {
if (document.all) {
return document.all[ID];
@ -92,14 +91,6 @@ function HandleSubmit(e) {
return true;
}
}
/*
* Open the search screen
*/
function openRecherche(p_sessid,p_dossier,p_style) {
if ( p_style == 'E' ) { p_style="expert";}
var w=window.open("recherche.php?gDossier="+p_dossier+"&PHPSESSID="+p_sessid+'&'+p_style,'','statusbar=no,scrollbars=yes,toolbar=no');
w.focus();
}
/*!\brief add a row for the CA
* \param p_table_id

View file

@ -66,18 +66,18 @@ if ( ! isset ( $action )) {
echo JS_VIEW_JRN_MODIFY;
?>
<script language="javascript">
function show (p_div) {
function show_div (p_div) {
// show the div
// hide the div
if ( document.getElementById(p_div) ) {
var a=document.getElementById(p_div);
if ( $(p_div) ) {
var a=$(p_div);
a.style.display="block";
}
}
function hide (p_div) {
function hide_div (p_div) {
// hide the div
if ( document.getElementById(p_div) ) {
var a=document.getElementById(p_div);
if ( $(p_div) ) {
var a=$(p_div);
a.style.display="none";
}
}
@ -115,7 +115,7 @@ if ( $action == 'update' ) {
$readonly=($p_view=='E')?0:1;
$view.=ShowOperationUser($cn,$p_id,$readonly);
$view.='<hr>';
$view.='<input type="button" onclick="hide(\'simple\');show(\'expert\');" value="Vue expert">';
$view.='<input type="button" onclick="hide_div(\'simple\');show_div(\'expert\');" value="Vue expert">';
$view.='<INPUT TYPE="Hidden" name="action" value="update_record">';
$view.="<br>";
$view.="<br>";
@ -137,7 +137,7 @@ if ( $action == 'update' ) {
$readonly=($p_view=='S')?0:1;
$view.=ShowOperationExpert($cn,$p_id,$readonly);
$view.='<hr>';
$view.='<input type="button" onclick="hide(\'expert\');show(\'simple\')" value="Vue simple">';
$view.='<input type="button" onclick="hide_div(\'expert\');show_div(\'simple\')" value="Vue simple">';
$view.='<INPUT TYPE="Hidden" name="action" value="update_record">';
$view.="<br>";
$view.="<br>";
@ -163,7 +163,7 @@ if ( $action=="view_ca") {
$view.='<h2 class="info">Vue simple</h2>';
$view.=ShowOperationUser($cn,$p_id,0);
$view.='<hr>';
$view.='<input type="button" onclick="hide(\'simple\');show(\'expert\');" value="Vue Expert">';
$view.='<input type="button" onclick="hide_div(\'simple\');show_div(\'expert\');" value="Vue Expert">';
$view.='<input type="button" value="Fermer" onClick="window.close(); ">';
$view.='</div>';
@ -175,7 +175,7 @@ if ( $action=="view_ca") {
$view.=ShowOperationExpert($cn,$p_id,0);
$view.='<hr>';
$view.='<input type="button" onclick="hide(\'expert\');show(\'simple\')" value="Vue Simple">';
$view.='<input type="button" onclick="hide_div(\'expert\');show_div(\'simple\')" value="Vue Simple">';
$view.='<input type="button" value="Fermer" onClick="window.close(); ">';
$view.='</div>';
echo $view;

View file

@ -210,8 +210,6 @@ text-align:center;
width:120px;
height :30px;
font-size:10px;
// border: 1px solid;
// padding:3px;
background-color:#DDE6FF;
border: 5px;
}
@ -254,10 +252,8 @@ border:0px;
font-size:10px;
}
td.cell{
// border:1px solid blue;
height:32px;
padding: 1px;
// width:120px;
}
td.selectedcell{
border-style:none;

View file

@ -36,7 +36,7 @@ include_once("ac_common.php");
include_once("postgres.php");
require_once ('class_dossier.php');
if ( ! file_exists('authorized_debug') ) {
echo "Pour pouvoir utiliser ce fichier vous devez créer un fichier nomme authorized_debug
echo "Pour pouvoir utiliser ce fichier vous devez creer un fichier nomme authorized_debug
dans le repertoire html du server";
exit();
@ -45,6 +45,7 @@ exit();
echo __FILE__.":".__LINE__;
if ( ! isset($_REQUEST['gDossier'])) {
echo "Vous avez oublie de specifier le gDossier ;)";
echo "L'url aurait du etre test.php?gDossier=xx";
exit();
}
@ -96,5 +97,7 @@ Bud_Synthese_Hypo::test_me();
require_once ('class_periode.php');
Periode::test_me();
*/
require_once ('verif.inc.php');
*/
require_once('class_acc_jrn_info.php');
Acc_Jrn_Info::test_me();

View file

@ -41,7 +41,7 @@ $User=new User($cn);
$User->Check();
html_page_start($User->theme,
"OnLoad=\"SetFocus('e_date',0);checkTotal();\" ",
"onLoad=\"SetFocus('e_date',0);checkTotal();\" ",
"js/compute.js");

View file

@ -171,11 +171,13 @@ function html_page_start($p_theme="",$p_script="",$p_script2="")
<LINK REL=\"stylesheet\" type=\"text/css\" href=\"$style\" media=\"screen\">
<link rel=\"stylesheet\" type=\"text/css\" href=\"style-print.css\" media=\"print\">".
$p_script2. "
</HEAD><script src=\"js/scripts.js\" type=\"text/javascript\"></script>";
<script src=\"js/scripts.js\" type=\"text/javascript\"></script>";
echo '<script language="javascript" src="js/calendar.js"></script>
<script type="text/javascript" src="js/lang/calendar-en.js"></script>
<script language="javascript" src="js/calendar-setup.js"></script>
<script language="javascript" src="js/prototype.js"></script>
<LINK REL="stylesheet" type="text/css" href="calendar-blue.css" media="screen">
</HEAD>
';
echo "<BODY $p_script>";

View file

@ -1,3 +1,4 @@
<?php
/*
* This file is part of PhpCompta.
@ -143,14 +144,12 @@ if (isset($_POST['corr'] ))
}
// if this page is called from another menu (customer, supplier,...)
// a button back is added
// TODO add function for generating url, hidden tags...
//$retour='<A class="mtitle" HREF="commercial.php?p_action=suivi_courrier"><input type="button" value="Retour"></A>';
$retour="";
$h_url="";
if ( isset ($_REQUEST['url']))
{
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
$retour=widget::button_href('Retour',urldecode($_REQUEST['url']));
$h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
}
//----------------------------------------------------------------------

View file

@ -21,6 +21,7 @@
require_once('class_acc_ledger.php');
require_once('user_form_fin.php');
require_once('jrn.php');
require_once('class_widget.php');
require_once("class_document.php");
require_once("class_fiche.php");
require_once("class_parm_code.php");
@ -56,7 +57,7 @@ $h_url="";
if ( isset ($_REQUEST['url']))
{
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
$retour=widget::button_href('Retour',urldecode($_REQUEST['url']));
$h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
}
@ -85,8 +86,8 @@ if ( $sub_action == "solde" )
$vir_interne=new parm_code($cn,'VIREMENT_INTERNE');
$accountSql="select distinct pcm_val::text,pcm_lib from
tmp_pcmn
where pcm_val like '".$banque->p_value."%' or pcm_val like '".$vir_interne->p_value."%'
or pcm_val like '".$caisse->p_value."%'
where pcm_val::text like '".$banque->p_value."%' or pcm_val::text like '".$vir_interne->p_value."%'
or pcm_val::text like '".$caisse->p_value."%'
order by pcm_val::text";
$ResAccount=ExecSql($cn,$accountSql);
echo '<div class="u_content">';

View file

@ -28,7 +28,7 @@ require_once ('class_bud_hypo.php');
require_once ('class_anc_account.php');
echo '<div class="u_content">';
/*!\todo Check if there is Hypothesis */
/* 1st possibility is not defined */

View file

@ -55,12 +55,24 @@ echo ShowItem(array(
//
echo '</div>';
if ( $do=='po')
if ( $do=='po') {
if ($obj->size_analytic() == 0 ) {
echo '<h2 class="info">Desole pas d\'hypothese definie avec un plan analytique</h2>';
exit();
}
require_once ('bud_spo.inc.php');
}
if ( $do=='ga') {
if ($obj->size_analytic() == 0 ) {
echo '<h2 class="info">Desole pas d\'hypothese definie avec un plan analytique</h2>';
exit();
}
if ( $do=='ga')
require_once ('bud_sga.inc.php');
}
if ( $do=='vglobal')
require_once ('bud_svglobal.inc.php');

View file

@ -135,6 +135,7 @@ if ( isset($_REQUEST['sa']))
$ret.=$po->form();
$ret.=$wSa->IOValue();
$ret.=widget::submit("add","Ajout");
$ret.="</form>";
$ret.="</div>";
}
// record the poste
@ -231,10 +232,7 @@ if ( isset($_REQUEST['sa']))
}
$ret.="</table>";
$ret.=sprintf('<A class="mtitle" HREF="?p_action=ca_pa&sa=po_add&pa_id=%s&'.$str_dossier.'">'.
'<input type="button" value="Ajout"></A>',
$_GET['pa_id']
);
$ret.=widget::button_href('Ajout',"?p_action=ca_pa&sa=po_add&pa_id=".$_GET['pa_id']."&".$str_dossier);
$ret.='</div>';
}

View file

@ -133,7 +133,7 @@ function get_solde($p_cond=" true ") {
case when j_debit='f' then j_montant else 0 end as cred
from jrnx join tmp_pcmn on j_poste=pcm_val
where
j_poste like ('$this->id'::text) and
j_poste::text like ('$this->id'::text) and
$p_cond
) as m ");
$Max=pg_NumRows($Res);
@ -157,7 +157,7 @@ function get_solde_detail($p_cond="") {
case when j_debit='f' then j_montant else 0 end as cred
from jrnx join tmp_pcmn on j_poste=pcm_val
where
j_poste like ('$this->id'::text)
j_poste::text like ('$this->id'::text)
$p_cond
) as m ";
@ -327,7 +327,7 @@ function get_solde_detail($p_cond="") {
if ( strlen (trim($item_cred))) {
if ( strstr($item_cred,"*") == true ) {
$item_cred=strtr($item_cred,"*","%");
$SqlItem="$or pcm_val like '$item_cred'";
$SqlItem="$or pcm_val::text like '$item_cred'";
$or=" or ";
} else {
$SqlItem="$or pcm_val = '$item_cred' ";

View file

@ -229,7 +229,7 @@ class Acc_Bilan {
function load(){
try {
if ( $this->id=="")
throw new Exception("le formulaire id n'est pas donnée");
throw new Exception("le formulaire id n'est pas donnee");
$sql="select b_name,b_file_template,b_file_form,lower(b_type) as b_type from bilan where".
" b_id = ".$this->id;

View file

@ -0,0 +1,158 @@
<?php
/*
* This file is part of PhpCompta.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
require_once ('class_dossier.php');
require_once ('postgres.php');
/*!\file
* \brief Manage the additionnal info for operation (from jrn)
*/
class Acc_Jrn_Info {
var $cn; /*!< connection */
var $ji_id; /*!< primary key */
var $id_type; /*!< type id */
var $jr_id; /*!< primary key of the table jrn */
var $ji_value; /*!< value for this */
function __construct($p_cn,$p_ji_id=0) {
$this->cn=$p_cn;
$this->ji_id=$p_ji_id;
}
function insert() {
if ( ! isset ($this->jr_id) ||
! isset ($this->ji_value) ||
! isset ($this->id_type ) )
{
echo 'Appel incorrecte '.__FILE__.__LINE__;
var_dump($this);
exit();
}
try {
$sql=ExecSqlParam(
$this->cn,
'insert into jrn_info(jr_id,id_type,ji_value) values ($1,$2,$3)'.
' returning ji_id ',
array ($this->jr_id,$this->id_type,$this->ji_value)
);
$this->ji_id=pg_fetch_result($sql,0,0);
} catch (Exception $e) {
echo "Echec sauvegarde info additionnelles";
throw $e;
}
}
function update() {
if ( ! isset ($this->jr_id) ||
! isset ($this->ji_value) ||
! isset ($this->jr_id ) )
{
echo 'Appel incorrecte '.__FILE__.__LINE__;
var_dump($this);
exit();
}
try {
$sql=ExecSqlParam(
$this->cn,
'update jrn_info set jr_id=$1 ,id_type=$2,ji_value=$3 where ji_id=$4)'.
array ($this->jr_id,$this->id_type,$this->ji_value,$this->ji_id)
);
} catch (Exception $e) {
Rollback($this->cn);
echo "Echec sauvegarde info additionnelles";
throw $e;
}
}
function load() {
$sql="select jr_id,id_type,ji_value from jrn_info where ji_id=".$this->ji_id;
$r=ExecSql($this->cn,$sql);
if (pg_NumRows ($r) > 0 ) {
$this->from_array(pg_fetch_array($r,0));
return 0;
}else {
return 1;
}
}
function from_array($p_array) {
foreach ($p_array as $col=>$value) {
$this->$col=$value;
}
}
function set_id($p_ji_id) {
$this->$ji_id=$p_ji_id;
}
function set_jrn_id($p_id) {
$this->jr_id=$p_id;
}
function set_type($p_id) {
$this->id_type=$p_id;
}
function set_value($p_id) {
$this->ji_value=$p_id;
}
/*!\brief load all the jrn_info thanks the jr_id
* \return an array of object
*/
function load_all() {
if ( ! isset ($this->jr_id) ) { echo "jr_id is not set ".__FILE__.__LINE__;exit();}
$sql="select ji_id from jrn_info where jr_id=".$this->jr_id;
$r=ExecSql($this->cn,$sql);
if (pg_NumRows($r) == 0 )
return array();
$array=pg_fetch_all($r);
$ret=array();
foreach ($array as $row) {
$o=new Acc_Jrn_Info($this->cn,$row['ji_id']);
$o->load();
$ret[]=clone $o;
}
return $ret;
}
function count() {
$sql="select ji_id from jrn_info where jr_id=".$this->jr_id;
return CountSql($this->cn,$sql);
}
function search_id_internal($p_internal) {
$sql="select jr_id from jrn where jr_internal='$p_internal'";
$r=ExecSql($this->cn,$sql);
if (pg_NumRows($r) > 0 ) {
$this->jr_id=pg_fetch_result($r,0,0);
return $this->jr_id;
} else {
$this->jr_id=-1;
return $this->jr_id;
}
}
static function test_me() {
echo "Dossier = ".Dossier::id();
$cn=DbConnect(Dossier::id());
$a=new Acc_Jrn_Info($cn);
$a->jr_id=3;
$a->id_type='BON_COMMANDE';
$a->ji_value='BON';
var_dump($a);
$a->insert();
$a->set_jrn_id(7);
$a->set_type('OTHER');
$a->set_value('Autre test');
$a->insert();
}
}

View file

@ -123,8 +123,8 @@ class Acc_Ledger {
if ( $this->id != 0 ) {
if ( $cent=='off' ) {
echo_debug('class_acc_ledger.php',__LINE__,"journaux non centralisé");
// Journaux non centralisés
echo_debug('class_acc_ledger.php',__LINE__,"journaux non centralise");
// Journaux non centralises
$Res=ExecSql($this->db,"select j_id,j_id as int_j_id,to_char(j_date,'DD.MM.YYYY') as j_date,
jr_internal,
case j_debit when 't' then j_montant::text else ' ' end as deb_montant,
@ -141,8 +141,8 @@ class Acc_Ledger {
" and ".$periode." order by j_date::date asc,jr_internal,j_debit desc ".
$cond_limite);
}else {
// Journaux centralisés
// echo'class_acc_ledger.php',__LINE__,"journaux centralisé";
// Journaux centralises
// echo'class_acc_ledger.php',__LINE__,"journaux centralise";
$Sql="select jr_opid as j_id,
c_order as int_j_id,
to_char (c_date,'DD.MM.YYYY') as j_date ,
@ -173,8 +173,8 @@ class Acc_Ledger {
} else {
// Grand Livre
if ( $cent == 'off') {
echo_debug('class_acc_ledger.php',__LINE__,"Grand livre non centralisé");
// Non centralisé
echo_debug('class_acc_ledger.php',__LINE__,"Grand livre non centralise");
// Non centralise
$Res=ExecSql($this->db,"select j_id,j_id as int_j_id,to_char(j_date,'DD.MM.YYYY') as j_date,
jr_internal,
case j_debit when 't' then j_montant::text else ' ' end as deb_montant,
@ -190,8 +190,8 @@ class Acc_Ledger {
$cond_limite);
} else {
echo_debug('class_acc_ledger.php',__LINE__,"Grand livre centralisé");
// Centralisé
echo_debug('class_acc_ledger.php',__LINE__,"Grand livre centralise");
// Centralise
$Sql="select jr_c_opid as j_id,
c_order as int_j_id,
c_j_id,
@ -334,7 +334,7 @@ class Acc_Ledger {
// Non Centralise si cent=off
//--
if ($cent=='off')
{// Non centralisé
{// Non centralise
$periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per');
@ -361,7 +361,7 @@ class Acc_Ledger {
$periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per');
$cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:"";
//Centralisé
//Centralise
//---
$id=($this->id == 0 ) ?"jr_c_opid as num":"jr_opid as num";
@ -1254,7 +1254,7 @@ class Acc_Ledger {
$op->p_jrn=$id;
$op->od_direct='t';
if ($op->count() != 0 )
echo widget::submit('use_opd','Utilisez une op.prédéfinie');
echo widget::submit('use_opd','Utilisez une op.pr&eacute;d&eacute;finie');
echo $op->show_button();
echo '</form>';
exit();

View file

@ -398,8 +398,8 @@ class action
$str_type=$v[0];
if ( isset ($_REQUEST['url']))
{
$retour=sprintf('<A class="one" HREF="%s"><input type="button" value="Retour"></A>',
urldecode($_REQUEST['url']));
$retour=widget::button_href('Retour',urldecode($_REQUEST['url']));
$h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
}
else

View file

@ -101,7 +101,7 @@ class Admin extends fiche{
return $r;
foreach ($step_admin as $admin ) {
$r.="<TR>";
$e=sprintf('<A HREF="%s?p_action=admin&sa=detail&f_id=%d&%s&url=%s" title="Détail"> ',
$e=sprintf('<A HREF="%s?p_action=admin&sa=detail&f_id=%d&%s&url=%s" title="Detail"> ',
$script,$admin->id,$str_dossier,$url);
$r.="<TD> $e".$admin->strAttribut(ATTR_DEF_QUICKCODE)."</A></TD>";

View file

@ -226,10 +226,15 @@ class Anc_Account
$wPa_id=new widget("hidden","pa_id","pa_id",$this->pa_id);
$wAmount=new widget("text","Montant","po_amount",$this->amount);
$wDescription=new widget("text","Description","po_description",$this->description);
$wGa_id=new widget("select","Groupe","ga_id");
$wGa_id->value=make_array($this->db,"select ga_id,ga_id from groupe_analytique",1);
$wGa_id->selected=$this->ga_id;
$wGa_id->table=1;
$aGroup_analytic=make_array($this->db,"select ga_id,ga_id from groupe_analytique where pa_id=".$this->pa_id,1);
if ( count($aGroup_analytic) > 1 ) {
$wGa_id=new widget("select","Groupe","ga_id");
$wGa_id->value=$aGroup_analytic;
$wGa_id->selected=$this->ga_id;
$wGa_id->table=1;
} else {
$wGa_id=new widget('span');
}
$pa=new Anc_Plan($this->db,$this->pa_id);
$pa->get();
$wPaName=new widget("text","Plan A.","",$pa->name);

View file

@ -204,7 +204,7 @@ class Anc_Balance_Double extends Anc_Print
'solde'=>'Solde',
'dc'=>'D/C'),
'Totaux',
array('shaded'=>1,'showHeadings'=>1,cols=>array
array('shaded'=>1,'showHeadings'=>1,'cols'=>array
('debit'=>array('justification'=>'right'),
'credit'=>array('justification'=>'right'),
'solde'=>array('justification'=>'right'), )
@ -274,7 +274,7 @@ class Anc_Balance_Double extends Anc_Print
$choose=new widget("button");
$choose->name="Choix Poste";
$choose->label="Recherche";
$choose->javascript="onClick=search_ca('".$_REQUEST['PHPSESSID']."',".dossier::id().",'from_poste2','pa_id')";
$choose->javascript="onClick=search_ca('".$_REQUEST['PHPSESSID']."',".dossier::id().",'from_poste2','pa_id2')";
$r.=$choose->IOValue();
$r.=" et le poste ".$poste->IOValue("to_poste2",$this->to_poste2);
@ -370,7 +370,7 @@ class Anc_Balance_Double extends Anc_Print
$and=" and ";
}
if ( $filter_poste != "")
$filter_poste.=" where ".$filter_poste;
$filter_poste=" where ".$filter_poste;
$sql="
select a_po_id ,
@ -386,7 +386,7 @@ b.po_id as b_po_id,
case when a.oa_debit='t' then a.oa_amount else 0 end as a_oa_amount_d,
case when a.oa_debit='f' then a.oa_amount else 0 end as a_oa_amount_c
from
operation_analytique as a join operation_analytique as b using (oa_group)
operation_analytique as a join operation_analytique as b using (j_id)
where a.pa_id=".
$this->pa_id."
and b.pa_id=".$this->pa_id2." ".$this->set_sql_filter()."

View file

@ -174,12 +174,12 @@ class Anc_Group_Operation
$p->oa_amount=$p_array["pamount$i"];
$p->oa_description=$p_array["pdesc"];
$p->oa_date=$_POST['pdate'];
$p->oa_date=$p_array['pdate'];
$p->j_id=0;
$p->oa_debit=(isset ($p_array["pdeb$i"]))?'t':'f';
$p->oa_group=0;
$p->po_id=$_POST["pop$i"."plan".$idx];
$p->po_id=$p_array["pop$i"."plan".$idx];
$p->pa_id=$idx;
$this->a_operation[]=clone $p;
}

View file

@ -209,7 +209,7 @@ class Anc_Plan
var_dump($p);
echo "<h2>Update</h2> ";
$p->name="Update ";
$p->description="c'est changé";
$p->description="c'est change";
$p->update();
$p->get();
var_dump($p);

View file

@ -77,7 +77,7 @@ class Bud_Hypo {
function add() {
$bh_saldo=(isNumber($this->bh_saldo) == 1 ) ?$this->bh_saldo:0;
$pa_id=($this->pa_id <= 0 )?null:$this->pa_id;
if ( strlen(trim ($this->bh_name)) == 0 ) return;
$sql="insert into bud_hypothese( bh_name,bh_saldo,bh_description,pa_id) ".
" values ($1,$2,$3,$4) returning bh_id";
$array=array(
@ -90,6 +90,7 @@ class Bud_Hypo {
$this->bh_id=pg_fetch_result($a,0,0);
}
function update() {
if ( strlen(trim ($this->bh_name)) == "" ) return;
$bh_name=pg_escape_string($this->bh_name);
$bh_saldo=(isNumber($this->bh_saldo) == 1 ) ?$this->bh_saldo:0;
$bh_description=pg_escape_string($this->bh_description);
@ -174,6 +175,11 @@ class Bud_Hypo {
$count=getDbValue($this->db,"select count(*) from bud_hypothese");
return $count;
}
function size_analytic() {
$count=getDbValue($this->db,"select count(*) from bud_hypothese where pa_id is not null");
return $count;
}
static function test_me() {
$cn=DbConnect (dossier::id());
ExecSql($cn,"delete from bud_hypothese");

View file

@ -59,7 +59,7 @@ class Bud_Synthese_Acc extends Bud_Synthese {
/* 2nd Step
*/
if ( $this->bh_id == 0 )
throw new Exception ("bh_id n'est pas sélectionné");
throw new Exception ("bh_id n'est pas selectionne");
$hypo=new Bud_Hypo($this->cn);
$hypo->bh_id=$this->bh_id;
$hypo->load();
@ -163,6 +163,8 @@ class Bud_Synthese_Acc extends Bud_Synthese {
" join parm_periode using (p_id) ".
" where bc_id=$1 and $per and pcm_val=$2 group by p_id,p_start order by p_start");
if ( empty ($aBudCard))
return;
// foreach card get the detail per pcm_val and periode
foreach ($aBudCard as $rBudCard) {
$line=array();
@ -232,10 +234,10 @@ class Bud_Synthese_Acc extends Bud_Synthese {
function display_html($p_array) {
$r="";
if (empty($p_array)) return;
$persql=sql_filter_per($this->cn,$this->from,$this->to,'p_id','p_id');
$per=get_array($this->cn,"select to_char(p_start,'MM.YYYY') as d".
" from parm_periode ".
" where p_id between ".$this->from.' and '.
$this->to." order by p_start" );
" where $persql");
$heading="<tr><th> CE </th>";
foreach( $per as $c) { $heading.='<th>'.$c['d'].'</th>';}

View file

@ -57,7 +57,7 @@ class Bud_Synthese_Anc extends Bud_Synthese {
/* 2nd Step
*/
if ( $this->bh_id == 0 )
throw new Exception ("bh_id n'est pas sélectionné");
throw new Exception ("bh_id n'est pas selectionne");
$hypo=new Bud_Hypo($this->cn);
$hypo->bh_id=$this->bh_id;
$hypo->load();
@ -112,7 +112,7 @@ class Bud_Synthese_Anc extends Bud_Synthese {
[80] => 14.0000
)
[acc_name] => Electricité
[acc_name] => Electricite
[acc_amount] => 0
)
@ -225,10 +225,11 @@ class Bud_Synthese_Anc extends Bud_Synthese {
function display_html($p_array) {
$r="";
if (empty($p_array)) return;
$persql=sql_filter_per($this->cn,$this->from,$this->to,'p_id','p_id');
$per=get_array($this->cn,"select to_char(p_start,'MM.YYYY') as d".
" from parm_periode ".
" where p_id between ".$this->from.' and '.
$this->to." order by p_start" );
" where $persql");
$heading="<tr><th> CE </th>";
foreach( $per as $c) { $heading.='<th>'.$c['d'].'</th>';}
$heading.="<th>Total Unite</th>";

View file

@ -1,4 +1,3 @@
<?php
/*
* This file is part of PhpCompta.
@ -56,7 +55,7 @@ class Bud_Synthese_Group extends Bud_Synthese {
*/
if ( $this->bh_id == 0 )
throw new Exception ("bh_id n'est pas sélectionné");
throw new Exception ("bh_id n'est pas selectionne");
$hypo=new Bud_Hypo($this->cn);
$hypo->bh_id=$this->bh_id;
$hypo->load();
@ -192,6 +191,9 @@ class Bud_Synthese_Group extends Bud_Synthese {
$pcm_val="";
$old="XX";
$sub=array();
if ( empty($res) )
return;
foreach ($res as $row) {
$pcm_val=$row['pcm_val'];
@ -375,11 +377,11 @@ Array
function display_html($p_array) {
$r="";
$persql=sql_filter_per($this->cn,$this->from,$this->to,'p_id','p_id');
list ($head,$foot)=$this->head_foot($p_array);
$per=get_array($this->cn,"select p_id,to_char(p_start,'MM.YYYY') as d".
" from parm_periode ".
" where p_id between ".$this->from.' and '.
$this->to." order by p_start" );
" where $persql");
$r.='<table>';
$heading="<tr><th> CE </th>";
foreach( $per as $c) {
@ -401,7 +403,8 @@ Array
$r.='<td></td>';
$r.='</tr>';
// content
if ( empty($p_array))
return;
foreach ($p_array as $key => $value ){
$r.='<tr>';
$r.='<td>'.$key.'</td>';

View file

@ -87,7 +87,7 @@ Array
[GROUPE1] => 81.7
[GROUPE3] => 28
[total_row] => 109.7
[acc_name] => Electricité
[acc_name] => Electricite
[acc_amount] => 0
)

View file

@ -105,8 +105,8 @@ class Customer extends fiche{
jrnx as A
join jrnx as B using (j_grpt)
where
A.j_poste like '".$CUSTOMER."%' and
B.j_poste like '".$SOLD."%'
A.j_poste::text like '".$CUSTOMER."%' and
B.j_poste::text like '".$SOLD."%'
$cond_sql
";

View file

@ -464,6 +464,9 @@ class Document
* - [MY_TVA]
* - [MY_STREET]
* - [MY_NUMBER]
* - BON_COMMANDE
* - OTHER_INFO
* - CUST_NUM
*
* \param TAG
* \return String which must replace the tag
@ -554,8 +557,7 @@ class Document
case 'CUST_CP':
$tiers=new fiche($this->db);
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[
'e_client'];
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_CP);
@ -563,8 +565,7 @@ $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[
case 'CUST_CITY':
$tiers=new fiche($this->db);
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[
'e_client'];
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_CITY);
@ -573,8 +574,7 @@ $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[
case 'CUST_CO':
$tiers=new fiche($this->db);
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[
'e_client'];
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_PAYS);
@ -584,11 +584,17 @@ $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[
case 'CUST_VAT':
$tiers=new fiche($this->db);
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[
'e_client'];
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_NUMTVA);
break;
case 'CUST_NUM':
$tiers=new fiche($this->db);
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_NUMBER_CUSTOMER);
break;
// Marchandise in $_POST['e_march*']
// \see user_form_achat.php or user_form_ven.php
case 'NUMBER':
@ -811,6 +817,19 @@ $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[
$r=$sum;
break;
case 'BON_COMMANDE':
if ( isset($_REQUEST['bon_comm']))
return $_REQUEST['bon_comm'];
else
return "";
break;
case 'OTHER_INFO':
if ( isset($_REQUEST['other_info']))
return $_REQUEST['other_info'];
else
return "";
break;
}
return $r;

View file

@ -37,6 +37,7 @@ require_once('ac_common.php');
class dossier {
/*!\brief return the $_REQUEST['gDossier'] after a check */
static function id() {
echo_debug(__FILE__,__LINE__,"id");

View file

@ -431,9 +431,13 @@ class fiche {
* \brief insert a new record
*
* \param p_fiche_def fiche_def.fd_id
* \param p_array is the array containing the data
*/
function insert($p_fiche_def)
function insert($p_fiche_def,$p_array=null)
{
if ( $p_array == null)
$p_array=$_POST;
$fiche_id=NextSequence($this->cn,'s_fiche');
$this->id=$fiche_id;
// first we create the card
@ -444,8 +448,8 @@ class fiche {
" values (%d,%d)",
$fiche_id,$p_fiche_def);
$Ret=ExecSql($this->cn,$sql);
// parse the $_POST array
foreach ($_POST as $name=>$value )
// parse the $p_array array
foreach ($p_array as $name=>$value )
{
echo_debug ("class_fiche",__LINE__,"Name = $name value $value") ;
list ($id) = sscanf ($name,"av_text%d");
@ -471,8 +475,8 @@ class fiche {
$exercice=$user->get_exercice();
if ( $exercice == 0 ) throw Exception ('Annee invalide erreur');
$str_stock=sprintf('insert into stock_goods(f_id,sg_initial,sg_code,sg_type,sg_exercice) '.
' values (%d,upper(\'%s\'),\'c\',\'%s\')',
$str_stock=sprintf('insert into stock_goods(f_id,sg_quantity,sg_comment,sg_code,sg_type,sg_exercice) '.
' values (%d,0,\'%s\',upper(\'%s\'),\'d\',\'%s\')',
$fiche_id,
'initial',
FormatString($value),
@ -565,12 +569,15 @@ class fiche {
/*!\brief update a card
* \todo add a check to return an error and rollback operation
*/
function update()
function update($p_array=null)
{
if ( $p_array == null)
$p_array=$_POST;
try {
StartSql($this->cn);
// parse the $_POST array
foreach ($_POST as $name=>$value )
// parse the $p_array array
foreach ($p_array as $name=>$value )
{
echo_debug ("class_fiche",__LINE__,"Name = $name value $value") ;
list ($id) = sscanf ($name,"av_text%d");
@ -619,19 +626,24 @@ class fiche {
}
if ( $id == ATTR_DEF_STOCK ) {
$st=CountSql($this->cn,'select * from stock_goods where '.
" upper(sg_code)=upper('$value')");
" f_id=".$this->id);
if ( $st == 0 ) {
$user=new User($this->cn);
$exercice=$user->get_exercice();
if ( $exercice == 0 ) throw Exception ('Annee invalide erreur');
$str_stock=sprintf('insert into stock_goods(f_id,sg_comment,sg_code,sg_type,sg_exercice) '.
' values (%d,upper(\'%s\'),upper(\'%s\'),\'d\',%s)',
$this->id,
'initial',
FormatString($value),
$exercice);
$str_stock=sprintf('insert into stock_goods(f_id,sg_quantity,sg_comment,sg_code,sg_type,sg_exercice) '.
' values (%d,0,\'%s\',upper(\'%s\'),\'d\',\'%s\')',
$this->id,
'initial',
FormatString($value),
$exercice);
ExecSql($this->cn,$str_stock);
}else {
$str_stock=sprintf("update stock_goods set sg_code=upper('%s') where f_id=%d",
FormatString($value),
$this->id);
ExecSql($this->cn,$str_stock);
}
}
@ -876,12 +888,15 @@ class fiche {
*
* \return none
*/
function HtmlTable()
function HtmlTable($p_array=null)
{
if ( $p_array == null)
$p_array=$_POST;
$name=$this->getName();
list($array,$tot_deb,$tot_cred)=$this->get_row( $_POST['from_periode'],
$_POST['to_periode']
list($array,$tot_deb,$tot_cred)=$this->get_row( $p_array['from_periode'],
$p_array['to_periode']
);
if ( count($this->row ) == 0 )
@ -928,8 +943,11 @@ class fiche {
*
* \return none
*/
function HtmlTableHeader()
function HtmlTableHeader($p_array=null)
{
if ( $p_array == null)
$p_array=$_POST;
$submit=new widget();
$hid=new widget("hidden");
echo '<div class="noprint">';
@ -948,8 +966,8 @@ class fiche {
$hid->IOValue('p_action','impress').
$hid->IOValue("f_id",$this->id).
dossier::hidden().
$hid->IOValue("from_periode",$_POST['from_periode']).
$hid->IOValue("to_periode",$_POST['to_periode']);
$hid->IOValue("from_periode",$p_array['from_periode']).
$hid->IOValue("to_periode",$p_array['to_periode']);
echo "</form></TD>";
echo '<TD><form method="POST" ACTION="quick_code_csv.php">'.
@ -958,8 +976,8 @@ class fiche {
$hid->IOValue("type","poste").
$hid->IOValue('p_action','impress').
$hid->IOValue("f_id",$this->id).
$hid->IOValue("from_periode",$_POST['from_periode']).
$hid->IOValue("to_periode",$_POST['to_periode']);
$hid->IOValue("from_periode",$p_array['from_periode']).
$hid->IOValue("to_periode",$p_array['to_periode']);
echo "</form></TD>";
echo "</table>";

View file

@ -43,7 +43,9 @@ class gestion_purchase extends gestion_table
var $qp_nd_tva_recup; /*!< tva ded via taxe */
var $qp_supplier; /*!< supplier code (f_id) */
var $qp_valid;
var $j_id; /*!< jrnx.j_id */
var $j_id; /*!< jrnx.j_id
*/
var $qp_dep_priv; /*!< private purchase */
/*!\brief return an array of gestion_table, the object are
* retrieved thanks the qs_internal
*/
@ -63,7 +65,8 @@ class gestion_purchase extends gestion_table
qp_nd_tva,
qp_nd_tva_recup,
qp_supplier,
j_id
j_id,
qp_dep_priv
from quant_purchase left join tva_rate on (qp_vat_code=tva_id)
where qp_internal='".$this->qp_internal."'";
$ret=ExecSql($this->db,$sql);

View file

@ -217,7 +217,7 @@ class Periode {
echo '<TD ALIGN="CENTER"> '.$l_line['p_exercice'].'</TD>';
if ( $l_line['status'] != 'OP' ) {
$closed=($l_line['status']=='CE')?'<TD>Centralisée</TD>':'<TD>Ferm&eacute;e</TD>';
$closed=($l_line['status']=='CE')?'<TD>Centralisee</TD>':'<TD>Ferm&eacute;e</TD>';
} else {
$closed='<TD class="mtitle">';
$closed.='<A class="mtitle" HREF="?p_action=periode&action=closed&p_per='.$l_line['p_id'].'&'.$str_dossier.'&jrn_def_id='.$this->jrn_def_id.'"> Cloturer</A>';

View file

@ -324,7 +324,7 @@ function load_global_pref()
$line[$type]=$row['parameter_value'];;
}
// save array into g_ variable
$array_pref=array ('g_theme'=>'THEME','g_pagesize'=>'PAGESIZE');
$array_pref=array ('g_theme'=>'THEME','g_pagesize'=>'PAGESIZE','g_topmenu'=>'TOPMENU');
foreach ($array_pref as $name=>$parameter ) {
if ( ! isset ($line[$parameter]) ) {
echo_debug("Missing pref : ".$parameter);
@ -349,7 +349,7 @@ function insert_default_global_pref($p_type="",$p_value="") {
echo_debug('class_user.php',__LINE__,"parameter p_type $p_type p_value $p_value");
$default_parameter= array("THEME"=>"Light",
"PAGESIZE"=>"50");
"PAGESIZE"=>"50",'TOPMENU'=>'SELECT');
$cn=Dbconnect();
$Sql="insert into user_global_pref(user_id,parameter_type,parameter_value)
values ('%s','%s','%s')";
@ -378,7 +378,7 @@ function insert_default_global_pref($p_type="",$p_value="") {
*/
function update_global_pref($p_type,$p_value="") {
$default_parameter= array("THEME"=>"Light",
"PAGESIZE"=>"50");
"PAGESIZE"=>"50",'TOPMENU'=>'SELECT');
$cn=Dbconnect();
$Sql="update user_global_pref set parameter_value='%s'
where parameter_type='%s' and

View file

@ -129,7 +129,7 @@ class widget {
$r='<INPUT '.$style.' TYPE="TEXT" id="'.
$this->name.'"'.
'NAME="'.$this->name.'" VALUE="'.$this->value.'" '.
'SIZE="'.$this->size.'" "'.$this->javascript." ".$disabled." $readonly $this->extra >";
'SIZE="'.$this->size.'" '.$this->javascript." ".$disabled." $readonly $this->extra >";
if ($this->table==1) {
if ( $this->label != "") {
@ -657,9 +657,19 @@ class widget {
return '<INPUT TYPE="hidden" id="'.$p_name.'" NAME="'.$p_name.'" VALUE="'.$p_value.'">';
}
static function button_href($p_name,$p_value) {
return sprintf('<A class="mtitle" HREF="%s"><input type="button" value="%s"></A>',
$p_value,
$p_name);
$agent=$_SERVER['HTTP_USER_AGENT'];
if ( strpos($agent,'MSIE') == 0 &&
strpos ($agent,'Konqueror') ==0)
return sprintf('<A class="mtitle" HREF="%s"><input type="button" value="%s"></A>',
$p_value,
$p_name);
return sprintf('<span style="border:1px solid blue;padding:5px;background-color:lightblue;"> '.
' <A class="mtitle" HREF="%s">%s</A></span>',
$p_value,
$p_name);
}
}

View file

@ -46,8 +46,7 @@ if ( isset ($_POST['delete']) )
if ( $sub_action=="insert" )
{
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',
urldecode($_REQUEST['url']));
$retour=widget::button_href("Retour", urldecode($_REQUEST['url']));
$customer=new Customer($cn);
$customer->Save($_REQUEST['fd_id']);
@ -77,8 +76,8 @@ if ( $sub_action == "" )
if ( $sub_action=="blank")
{
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',
"commercial.php?p_action=client&$str_dossier");
$retour=widget::button_href('Retour','commercial.php?p_action=fournisseur&'.dossier::get());
echo '<div class="u_content">';
echo $retour;
@ -116,7 +115,6 @@ if ( $sub_action == "list" )
<span style="position:float;float:left">
<form method="get" action="commercial.php">
<?php echo dossier::hidden(); ?>
<input type="hidden" name="url" <?php $url=urlencode($_SERVER['REQUEST_URI']);echo 'value="'.$url.'"'; ?>
<input type="hidden" name="p_action" value="client">
<?php
@ -128,6 +126,7 @@ if ( $sub_action == "list" )
?>
<input type="hidden" name="sa" value="blank">
<input type="submit" name="submit_query" value="Ajout Client">
<input type="hidden" name="url" <?php $url=urlencode($_SERVER['REQUEST_URI']);echo 'value="'.$url.'"'; ?>
</form>
</span>
@ -148,8 +147,8 @@ if ( $sub_action == 'detail' )
$f_id=$_REQUEST['f_id'];
echo '<div class="u_content">';
$client=new Customer($cn,$f_id);
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',
urldecode($_REQUEST['url']));
$retour=widget::button_href("Retour", urldecode($_REQUEST['url']));
echo $retour;
echo '<form action="'.$_REQUEST['url'].'" method="post">';
echo dossier::hidden();

View file

@ -136,7 +136,8 @@ define ("ATTR_DEF_EMAIL",18);
define ("ATTR_DEF_CITY",24);
define ("ATTR_DEF_COMPANY",25);
define ("ATTR_DEF_FAX",26);
define ("ATTR_DEF_NUMBER_CUSTOMER",30);
define ("ATTR_DEF_DEP_PRIV",31);
define ("FICHE_TYPE_CLIENT",9);
define ("FICHE_TYPE_VENTE",1);

View file

@ -36,7 +36,8 @@ $sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
// TODO add function for generating url, hidden tags...
if ( isset ($_REQUEST['url']))
{
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
$retour=widget::button_href('Retour',urldecode($_REQUEST['url']));
$h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
}
else
@ -87,8 +88,8 @@ if ( $sub_action == "" )
//Display a blank card
if ( $sub_action=="blank")
{
$retour_action=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',
"commercial.php?p_action=contact&$str_dossier");
$retour_action=widget::button_href('Retour', "commercial.php?p_action=contact&$str_dossier");
echo '<div class="u_redcontent">';
echo $retour_action;

View file

@ -52,7 +52,8 @@ $h_url="";
if ( isset ($_REQUEST['url']))
{
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
$retour=widget::button_href('Retour',urldecode($_REQUEST['url']));
$h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
}

View file

@ -24,6 +24,8 @@ require_once('jrn.php');
require_once("class_document.php");
require_once("class_fiche.php");
require_once("check_priv.php");
require_once('class_acc_jrn_info.php');
$tag_list='<td class="mtitle"><A class="mtitle" HREF="commercial.php?liste&p_action=facture&sa=list&'.$str_dossier.'">Liste</A>';
$tag_list_sel='<td class="selectedcell">Liste</td>';
$tag_unpaid='</td><td class="mtitle"><A class="mtitle" href="commercial.php?liste&p_action=facture&sa=unpaid&'.$str_dossier.'">Non paye</A></TD>';
@ -52,7 +54,8 @@ $h_url="";
if ( isset ($_REQUEST['url']))
{
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
$retour=widget::button_href('Retour',urldecode($_REQUEST['url']));
$h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
}
@ -357,6 +360,19 @@ if ( isset($_POST['record_and_print_invoice']))
// Update the comment with invoice number
$sql="update jrn set jr_comment='Facture ".$doc->d_number."' where jr_internal='$internal'";
ExecSql($cn,$sql);
/* Save the additional information into jrn_info */
$obj=new Acc_Jrn_Info($cn);
$jr_id=$obj->search_id_internal($internal);
if (strlen(trim($_POST['bon_comm'] )) != 0 ) {
$obj->set_type('BON_COMMANDE');
$obj->set_value($_POST['bon_comm']);
$obj->insert();
}
if (strlen(trim($_POST['other_info'] )) != 0 ) {
$obj->set_type('OTHER');
$obj->set_value($_POST['other_info']);
$obj->insert();
}
echo $str_file;
}
} else {

View file

@ -255,7 +255,7 @@ if ( isset ( $_GET["action"]) ) {
$sql="select distinct f_id,fd_id,av_text from fiche join jnt_fic_att_value using (f_id)
join attr_value using (jft_id) where
upper(av_text) like upper('%".FormatString($_GET["search_text"])."%') order by av_text,f_id";
$all=getArray($cn,$sql);
$all=get_array($cn,$sql);
// test on the size
//
if ( sizeof($all) != 0 )

View file

@ -56,7 +56,7 @@ echo "</table>";
if ( isset ($_POST['mod']) )
{
extract ($_POST);
echo '<div style="position:float;padding:2%">';
echo '<div style="float:left;padding:2%">';
echo "Voulez-vous modifier ?<br><font color=\"red\"> Attention, ne changer pas la signification de ";
echo " ce poste, <i>par exemple ne pas changer Client par fournisseur</i>, <br>sinon le programme fonctionnera mal, utiliser uniquement des chiffres pour la classe de base ou rien</font>";
$idx=$_POST['idx'];

View file

@ -27,7 +27,7 @@ require_once('class_user.php');
require_once('class_widget.php');
require_once('class_fiche.php');
require_once('class_acc_ledger.php');
require_once('class_parm_code.php');
/*!
**************************************************
* \brief Parse the file and insert the record
@ -389,7 +389,8 @@ $w=new widget("select");
$w->label='Journal';
echo $w->label." :".$w->IOValue('import_jrn',$jrn)."<br>";
// choose the bank account
$bq=make_array($p_cn,"select pcm_val,pcm_lib from tmp_pcmn where pcm_val like '550%'");
$banque=new parm_code($p_cn,'BANQUE');
$bq=make_array($p_cn,"select pcm_val,pcm_lib from tmp_pcmn where pcm_val::text like '".$banque->p_value."%'");
$w->label='Banque';
echo "Compte en banque :".$w->IOValue('import_bq',$bq)."<br>";
$format_csv=make_array($p_cn,"select include_file,name from format_csv_banque;");

View file

@ -584,7 +584,7 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true,$p_
"select p_exercice from parm_periode where p_id=$user_periode");
$sql_per="select to_char(p_start,'MM.YYYY') as start from parm_periode where ".
" p_exercice='".$periode."' order by p_start";
$ret=getArray($p_cn,$sql_per);
$ret=get_array($p_cn,$sql_per);
$from=$ret[0]['start'];
}
@ -650,7 +650,7 @@ function GetFormulaValue($p_cn,$p_label,$p_formula,$p_cond)
$l_credit=0;
// somme debit
$Res=ExecSql($p_cn,"select sum (j_montant) as montant from
jrnx where $p_cond and j_debit='t' and j_poste like '$p_formula'");
jrnx where $p_cond and j_debit='t' and j_poste::text like '$p_formula'");
if (pg_NumRows($Res)==0){
$l_debit=0;
} else {
@ -659,7 +659,7 @@ function GetFormulaValue($p_cn,$p_label,$p_formula,$p_cond)
}
// somme credit
$Res=ExecSql($p_cn,"select sum (j_montant) as montant from
jrnx where $p_cond and j_debit='f' and j_poste like '$p_formula'");
jrnx where $p_cond and j_debit='f' and j_poste::text like '$p_formula'");
if (pg_NumRows($Res)==0) {
$l_credit=0;
} else {

View file

@ -126,6 +126,15 @@ require_once("class_acc_ledger.php");
/* "<th>Pièce justificative</th>". */
"<th> montant</th>".
"</TR>";
// set a filter for the FIN
$a_parm_code=get_array($cn,"select p_value from parm_code where p_code in ('BANQUE','COMPTE_COURANT','CAISSE')");
$sql_fin="(";
$or="";
foreach ($a_parm_code as $code) {
$sql_fin.="$or j_poste::text like '".$code['p_value']."%'";
$or=" or ";
}
$sql_fin.=")";
foreach ($Row as $line)
{
@ -140,7 +149,7 @@ require_once("class_acc_ledger.php");
// Get the jrn type
if ( $line['jrn_def_type'] == 'FIN' ) {
$positive = CountSql($cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ".
" where jr_id=".$line['jr_id']." and (j_poste like '55%' or j_poste like '57%' )".
" where jr_id=".$line['jr_id']." and $sql_fin ".
" and j_debit='f'");
echo "<TD align=\"right\">";

View file

@ -94,7 +94,7 @@ if ( isset( $_POST['bt_html'] ) ) {
if ( isset ($_POST['poste_fille']) )
{
$parent=$_POST['poste_id'];
$a_poste=get_array($cn,"select pcm_val from tmp_pcmn where pcm_val like '$parent%' order by pcm_val::text");
$a_poste=get_array($cn,"select pcm_val from tmp_pcmn where pcm_val::text like '$parent%' order by pcm_val::text");
$go=3;
}
// Check if the post is numeric and exists

View file

@ -30,6 +30,8 @@ require_once ('class_anc_plan.php');
require_once ('class_anc_operation.php');
require_once ('class_acc_ledger.php');
require_once ('class_acc_operation.php');
require_once ('class_acc_jrn_info.php');
/*!
* \brief Display the form to UPDATE account operation in the expert view
*
@ -143,11 +145,14 @@ function ShowOperationExpert($p_cn,$p_jr_id,$p_mode=1)
if ( $content['jr_pj_name'] != "")
$r.='<TD>Effacer PJ <INPUT TYPE="CHECKBOX" name="to_remove" ></TD>';
}
$r.="<TD>".sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s&%s">%s</A>',
$content['jr_id'],
$content['jr_grpt_id'],
$str_dossier,
$content['jr_pj_name'])."</TD>";
$r.="<TD>".sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s&%s&PHPSESSID=%s">%s</A>',
$content['jr_id'],
$content['jr_grpt_id'],
$str_dossier,
$_REQUEST['PHPSESSID'],
$content['jr_pj_name']
)."</TD>";
$r.="</TR></TABLE>";
if ( $p_mode == 1 ) {
@ -287,12 +292,14 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1)
$r.='<th>Nom</th>';
$r.='<th>PU</th>';
$r.='<th>Quantit&eacute;</th>';
$r.='<th> Dep. priv. </th>';
$r.='<th>tva</th>';
$r.='<th>code tva</th>';
$r.='<th>Non Ded.</th>';
$r.='<th>tva</th>';
$r.='<th>non ded.</th>';
$r.='<th>tva nd</th>';
$r.='<th>tva d impot</th>';
$r.='<th>prix</th>';
$r.='<th>total htva</th>';
$r.='<th>total tvac</th>';
$r.='</tr>';
$object=new gestion_purchase($p_cn);
@ -303,6 +310,7 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1)
$tot_nd=0.0;
$tot_tva_nd=0.0;
$tot_tva_nd_recup=0.0;
$tot_dep_priv=0.0;
$i=0;
$i_march=0;
foreach ($array as $row) {
@ -314,20 +322,24 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1)
$tot_tva_nd+=$row->qp_nd_tva;
$tot_tva_nd_recup+=$row->qp_nd_tva_recup;
$tot_amount+=$row->qp_price;
$tot_dep_priv+=$row->qp_dep_priv;
// $hid_jid=new widget("hidden","","p_jid_".$row->j_id,$row->j_id);
$r.=($i%2==0)?"<tr class=\"odd\">":'<tr>'; $i++;
$pu=0.0;
if ( $row->qp_price != 0.0 && $row->qp_price != 0 ) $pu=round($row->qp_price/$row->qp_quantite,2);
if ( $row->qp_price != 0.0 && $row->qp_price != 0 )
$pu=round(($row->qp_nd_amount+$row->qp_price)/$row->qp_quantite,2);
$r.='<td> '.$fiche->strAttribut(ATTR_DEF_NAME).'</td>';
$r.='<tD>'.$pu.'</td>';
$r.='<td align="right">'.$row->qp_quantite.'</td>';
$r.='<td align="right">'.$row->qp_dep_priv.'</td>';
$r.='<td align="right">'.$row->qp_vat.'</td>';
$r.='<td>'.$row->qp_vat_code.'</td>';
$r.='<td>'.$row->qp_nd_amount.'</td>';
$r.='<td>'.$row->tva_label.'</td>';
$r.='<td>'.$row->qp_nd_amount.'</td>';
$r.='<td>'.$row->qp_nd_tva.'</td>';
$r.='<td>'.$row->qp_nd_tva_recup.'</td>';
$r.='<td align="right">'.$row->qp_price.'</td>';
$r.='<td align="right">'.sprintf("% 12.2f",$row->qp_price).'</td>';
$r.='<td align="right">'.sprintf("% 12.2f",$row->qp_vat+$row->qp_nd_amount+$row->qp_nd_tva+$row->qp_nd_tva_recup+$row->qp_price).'</td>';
//-- add ca
//
@ -347,26 +359,36 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1)
'<td colspan="7">Total HTVA</td>'.
'<td>'.sprintf('% 12.2f',$tot_amount)."</td>".
"</tr>";
if ( $tot_tva != 0 )
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total TVA</td>'.
'<td>'.sprintf('%12.2f',$tot_tva)
."</td>".
"</tr>";
if ( $tot_nd !=0 )
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total nd </td>'.
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_nd)."</td>".
"</tr>";
if ( $tot_tva_nd !=0 )
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total tva nd</td>'.
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_tva_nd)."</td>".
"</tr>";
if ( $tot_tva_nd_recup !=0 )
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total tva nd recup. par impot</td>'.
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_tva_nd_recup)."</td>".
"</tr>";
if ( $tot_dep_priv !=0 )
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total tva nd recup. par impot</td>'.
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_dep_priv)."</td>".
"</tr>";
$r.='<tr style="font-size:13px;color:green;">'.
'<td colspan="7">Total </td>'.
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_amount+$tot_tva)."</td>".
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_dep_priv+$tot_amount+$tot_tva+$tot_tva_nd_recup+$tot_nd+$tot_tva_nd)."</td>".
"</tr>";
$r.= '</table></td></tr>';
@ -464,11 +486,31 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1)
//doc
if ( $p_mode ==1 && $content['jr_pj_name'] != "")
$r.='<tr><TD>Effacer Pj <INPUT TYPE="CHECKBOX" name="to_remove" ></TD>';
$r.="<TD>".sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s&'.$str_dossier.'">%s</A>',
$r.="<TD>".sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s&'.$str_dossier.'&PHPSESSID=%s">%s</A>',
$content['jr_id'],
$content['jr_grpt_id'],
$_REQUEST['PHPSESSID'],
$content['jr_pj_name'])."</TD>";
$r.="</TR></TABLE>";
if ( $content['jrn_def_type'] == 'VEN' ) {
/* count the number of additionnal info */
$acc_jrn_info=new Acc_Jrn_Info($p_cn);
$acc_jrn_info->set_jrn_id($p_jr_id);
/* if additional info > 0 show them */
if ( $acc_jrn_info->count() > 0 ) {
$array=$acc_jrn_info->load_all();
foreach ($array as $row) {
if ( strpos($row->id_type,'BON_COMMANDE') ===0) {
$r.="Num bon de commande : ".$row->ji_value.'<br>';
}
if ( strpos($row->id_type,'OTHER') ===0) {
$r.="Autre info : ".$row->ji_value.'<br>';
}
}
}
}
$r.="<hr>";
if ( $p_mode == 1 ) {
$r.= "<table>";

View file

@ -37,7 +37,7 @@ if ( isset( $_POST['confirm_mod'] ) )
$object=new parm_code($cn);
$all=$object->LoadAll();
echo '<div style="position:float;align:right; ">';
echo '<div style="float:left; ">';
echo '<table align="left">';
for ($i=0;$i<sizeof($all);$i++) {
echo '<TR>';
@ -58,7 +58,7 @@ echo "</div>";
// modifie
if ( isset ($_POST['mod'] ))
{
echo '<div style="position:float;align:right;">';
echo '<div style="float:left;">';
echo "Voulez-vous vraiment modifier ?";
echo '<FORM METHOD="POST">';
@ -75,4 +75,4 @@ if ( isset ($_POST['mod'] ))
echo "</FORM>";
echo "</div>";
}
}

View file

@ -98,7 +98,7 @@ function DbConnect($p_db=-1,$p_type='dossier') {
$phpcompta_user=phpcompta_user;
$password=phpcompta_password;
$port=phpcompta_psql_port;
ob_start();
ob_start();
$a=pg_connect("dbname=$l_dossier host=127.0.0.1 user='$phpcompta_user'
password='$password' port=$port");

View file

@ -21,6 +21,8 @@
/*!\brief this file is always included and then executed
* it permits to change the user preferences
*/
require_once('class_widget.php');
require_once('class_user.php');
echo '<DIV class="u_content">';
@ -92,14 +94,30 @@ $disp_style.="</SELECT>";
</FORM>
<?php
/* propose to use menu or icon for the top menu */
if ( isset($_POST['sub_topmenu']) ){
$_SESSION['g_topmenu']=$_POST['topmenu'];
$User->update_global_pref('TOPMENU',$_POST['topmenu']);
}
$topmenu=new widget('select');
$topmenu->name='topmenu';
$topmenu->selected=$_SESSION['g_topmenu'];
$array=array(
array('value'=>'TEXT','label'=>'Texte'),
array('value'=>'SELECT','label'=>'Menu deroulant')
);
$topmenu->value=$array;
echo '<h3 class="info">Style de menu</h3>';
echo '<span style="text-align:center;width:100%">';
echo '<form method="post" action="'.$url.'">';
echo $topmenu->IOValue();
echo widget::submit('sub_topmenu','Sauver');
echo '</form>';
echo '</span>';
// Si utilise un dossier alors propose de changer
// la periode par defaut
if ( ! isset ($_REQUEST['gDossier']) )
{
echo '<A href="user_login.php"><input type="button" value="Retour"></a>';
}
else
if ( isset ($_REQUEST['gDossier']) )
{
include_once("preference.php");
@ -132,7 +150,10 @@ else
<TR><TD><input type="submit" name="sub_periode" value="Sauve"></TD></TR>
</TABLE>
</FORM>
<?php
}
?>
<H3 CLASS="info"> Taille des pages</H3>
<FORM ACTION="<?php echo $url;?>" METHOD="POST">
<TABLE ALIGN="CENTER">
@ -156,9 +177,13 @@ else
</TABLE>
</FORM>
<?php
if ( ! isset ($_REQUEST['gDossier']) )
{
echo '<A class="mtitle" href="user_login.php"><input type="button" value="Retour"></a>';
}
<?php
}
echo "</DIV>";
?>

View file

@ -21,7 +21,7 @@
/*! \file
* \brief Function for managing the stock
*/
require_once('class_fiche.php');
/*!
**************************************************
@ -123,7 +123,7 @@ $sql="select distinct f_id,av_text
join jnt_fic_att_value using (f_id )
join attr_value using (jft_id)
where
ad_id=".ATTR_DEF_NAME."
ad_id=".ATTR_DEF_STOCK."
and sg_code='$p_sg_code'
";
// Execute
@ -134,7 +134,8 @@ $sql="select distinct f_id,av_text
for ( $i=0; $i<$M;$i++) {
$r=pg_fetch_array($Res,$i);
$a['f_id']=$r['f_id'];
$a['av_text']=$r['av_text'];
$fiche=new Fiche($p_cn,$r['f_id']);
$a['av_text']=$fiche->getName();
$result[$i]=$a;
}

View file

@ -46,8 +46,7 @@ if ( isset ($_POST['delete']) )
// Add card
if ( $sub_action=="insert" )
{
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',
urldecode($_REQUEST['url']));
$retour=widget::button_href("Retour", urldecode($_REQUEST['url']));
$supplier=new Supplier($cn);
$supplier->Save($_REQUEST['fd_id']);
@ -75,8 +74,7 @@ if ( $sub_action == "" )
//Display a blank card
if ( $sub_action=="blank")
{
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',
"commercial.php?p_action=fournisseur&".dossier::get());
$retour=widget::button_href('Retour','commercial.php?p_action=fournisseur&'.dossier::get());
echo '<div class="u_content">';
echo $retour;
@ -85,10 +83,11 @@ if ( $sub_action=="blank")
echo '<input type="hidden" name="p_action" value="fournisseur">';
echo '<input type="hidden" name="sa" value="insert">';
echo '<input type="hidden" name="fd_id" value="'.$_GET['fd_id'].'">';
echo '<input type="hidden" name="url" value="'.$_GET['url'].'">';
echo dossier::hidden();
echo $c->blank($_GET['fd_id']);
echo '<input type="Submit" value="Sauve">';
echo '<input type="hidden" name="url" value="'.$_GET['url'].'">';
echo '</form>';
echo $retour;
echo '</div>';
@ -114,7 +113,6 @@ if ( $sub_action == "list" )
</span>
<span style="position:float;float:left">
<form method="get" action="commercial.php">
<input type="hidden" name="url" <?php $url=urlencode($_SERVER['REQUEST_URI']);echo 'value="'.$url.'"'; ?>
<input type="hidden" name="p_action" value="fournisseur">
<?php
@ -128,6 +126,7 @@ if ( $sub_action == "list" )
?>
<input type="hidden" name="sa" value="blank">
<input type="submit" name="submit_query" value="Ajout Sup">
<input type="hidden" name="url" <?php $url=urlencode($_SERVER['REQUEST_URI']);echo 'value="'.$url.'"'; ?>
</form>
</span>
@ -148,8 +147,8 @@ if ( $sub_action == 'detail' )
$f_id=$_REQUEST['f_id'];
echo '<div class="u_content">';
$sup=new Supplier($cn,$f_id);
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',
urldecode($_REQUEST['url']));
$retour=widget::button_href("Retour", urldecode($_REQUEST['url']));
echo $retour;
echo '<form action="'.$_REQUEST['url'].'" method="post">';
echo $sup->Display(false);

View file

@ -255,6 +255,7 @@ if ( ! isset ($_POST['add'])
<input type="submit" value="Cancel" name="no">
</FORM>
<?php
echo '</div>'; }
}
echo '</div>';
?>

View file

@ -69,7 +69,7 @@ if ( $action=="use_opd" ) {
echo $hid->IOValue("jrn_type","ACH");
if ($op->count() != 0 )
echo widget::submit('use_opd','Utilisez une op.prédéfinie');
echo widget::submit('use_opd','Utilisez une op.pr&eacute;d&eacute;finie');
echo $op->show_button();
echo '</form>';
@ -118,7 +118,7 @@ if ( $action == 'new' ) {
echo $hid->IOValue("jrn_type","ACH");
if ($op->count() != 0 )
echo widget::submit('use_opd','Utilisez une op.prédéfinie');
echo widget::submit('use_opd','Utilisez une op.pr&eacute;d&eacute;finie');
echo $op->show_button();
echo '</form>';
@ -202,7 +202,7 @@ if ( $action == 'new' ) {
list($internal,$comment)=RecordSell($cn,$_POST,$User,$_GET['p_jrn']);
// submit button in the form
$submit='<h2 class="info">Opération '.$internal.' </h2>';
$submit='<h2 class="info">Op&eacute;ration '.$internal.' </h2>';
$r=FormAchView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,"",$nb_number,false);
echo '<div class="u_redcontent">';
echo $submit;

View file

@ -273,8 +273,8 @@ if ( $action == 'solde' ) {
$vir_interne=new parm_code($cn,'VIREMENT_INTERNE');
$accountSql="select distinct pcm_val::text,pcm_lib from
tmp_pcmn
where pcm_val like '".$banque->p_value."%' or pcm_val like '".$vir_interne->p_value."%'
or pcm_val like '".$caisse->p_value."%'
where pcm_val::text like '".$banque->p_value."%' or pcm_val::text like '".$vir_interne->p_value."%'
or pcm_val::text like '".$caisse->p_value."%'
order by pcm_val::text";
$ResAccount=ExecSql($cn,$accountSql);
echo '<div class="u_redcontent">';

View file

@ -129,6 +129,30 @@ echo_debug('user_common.php',__LINE__,"ComputeTotalVat $a_fiche $a_quant $a_pric
//variable containing the nd part
// used when a card has both special rule for vat
$nd1=0;
$base=$a_price[$idx]*$a_vat['tva_rate']*$a_quant[$idx];
$nd_amount3=0;
// if a part is not deductible then reduce vat_amount
$nd3=GetFicheAttribut($p_cn,$a_fiche[$idx],ATTR_DEF_DEP_PRIV);
if ( $nd3 != null && strlen(trim($nd3)) != 0 && $nd3 != 0 )
{
// if tva amount is given we do not compute it
if ( $a_vat_amount != null &&
$a_vat_amount[$idx] != 0 ) {
$nd_amount3=round($a_vat_amount[$idx]*$nd3,2);
$a_vat_amount[$idx]-=$nd_amount3;
}
else
$nd_amount3=round($a_price[$idx]*$a_vat['tva_rate']*$a_quant[$idx]*$nd3,2);
$vat_amount=$vat_amount-$nd_amount3;
$base=$base*$nd3;
// when using both vat, their sum cannot exceed 1, if = 1 then vat = 0
$flag=false;
}
// if a part is not deductible then reduce vat_amount
$nd=GetFicheAttribut($p_cn,$a_fiche[$idx],ATTR_DEF_TVA_NON_DEDUCTIBLE);
if ( $nd != null && strlen(trim($nd)) != 0 && $nd != 0 )
@ -136,9 +160,9 @@ echo_debug('user_common.php',__LINE__,"ComputeTotalVat $a_fiche $a_quant $a_pric
// if tva amount is given we do not compute it
if ( $a_vat_amount != null &&
$a_vat_amount[$idx] != 0 )
$nd_amount=round($vat_amount*$nd,2);
$nd_amount=round($a_vat_amount[$idx]*$nd,2);
else
$nd_amount=round($a_price[$idx]*$a_vat['tva_rate']*$a_quant[$idx]*$nd,2);
$nd_amount=round($base*$nd,2);
// problem with round
@ -159,7 +183,7 @@ echo_debug('user_common.php',__LINE__,"ComputeTotalVat $a_fiche $a_quant $a_pric
$a_vat_amount[$idx] != 0 )
$nd_amount2=round($a_vat_amount[$idx]*$nd,2);
else
$nd_amount2=round($a_price[$idx]*$a_vat['tva_rate']*$a_quant[$idx]*$nd,2);
$nd_amount2=round($base*$nd,2);
$vat_amount=$vat_amount-$nd_amount2;
// when using both vat, their sum cannot exceed 1, if = 1 then vat = 0
@ -438,7 +462,7 @@ $sort_echeance="<th> <A class=\"mtitle\" HREF=\"?$url&o=ea\">$image_asc</A>Ech
$sql_fin="(";
$or="";
foreach ($a_parm_code as $code) {
$sql_fin.="$or j_poste like '".$code['p_value']."%'";
$sql_fin.="$or j_poste::text like '".$code['p_value']."%'";
$or=" or ";
}
$sql_fin.=")";
@ -545,7 +569,7 @@ $sort_echeance="<th> <A class=\"mtitle\" HREF=\"?$url&o=ea\">$image_asc</A>Ech
$l_poste=FormatString($l_poste);
if ( $l_poste != null ) {
$sql.=$l_and." jr_grpt_id in (select j_grpt
from jrnx where j_poste like '$l_poste' ) ";
from jrnx where j_poste::text like '$l_poste' ) ";
$l_and=" and ";
}
// Quick Code
@ -729,10 +753,11 @@ $sort_echeance="<th> <A class=\"mtitle\" HREF=\"?$url&o=ea\">$image_asc</A>Ech
if ( $row['jr_pj_name'] != "")
{
$image='<IMG SRC="image/insert_table.gif" title="'.$row['jr_pj_name'].'" border="0">';
$r.="<TD>".sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s&%s">%s</A>',
$r.="<TD>".sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s&%s&PHPSESSID=%s">%s</A>',
$p_jrn,
$row['jr_grpt_id'],
$str_dossier,
$str_dossier,
$_REQUEST['PHPSESSID'],
$image)
."</TD>";
}

View file

@ -492,7 +492,7 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number)
$per->set_jrn($p_jrn);
$per->set_periode($p_periode);
// Periode fermé
// Periode ferme
if ( $per->is_open() == 0)
{
$msg="Cette periode est fermee pour ce journal";
@ -833,6 +833,8 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
$aNd_amount[$i]=0.0;
$aTva_ded_impot[$i]=0.0;
$aTva_ded_impot_recup[$i]=0.0;
$aDep_priv[$i]=0.0;
$poste=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_ACCOUNT);
@ -840,26 +842,51 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
if ( $a_price[$i]*$a_quant[$i] == 0 ) continue;
$amount=$a_price[$i]*$a_quant[$i];
//We don't compute vat if it's given
$lvat=($a_vat_amount[$i]==0)?ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i], $a_vat_good[$i],$a_vat_amount[$i] ):$a_vat_amount[$i];
//We don't compute vat if it's given
$lvat=($a_vat_amount[$i]==0)?ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i], $a_vat_good[$i],$a_vat_amount[$i] ):$a_vat_amount[$i];
//----------------------------------------------------------------------
// Put the non deductible part into a special account
$non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_DEPENSE_NON_DEDUCTIBLE);
echo_debug('user_form_ach.php',__LINE__,"value non ded : $non_dedu");
if ( $non_dedu != null && strlen(trim($non_dedu)) != 0)
{
// if vat if given we use it to compute ND
$nd_amount=($a_vat_amount[$i]==0)?round($a_quant[$i]*$a_price[$i]*$non_dedu,2):round($a_vat_amount*$non_dedu,2);
// save it
echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6740',$e_date,round($nd_amount,2),$seq,$periode);");
$dna=new parm_code($p_cn,'DNA');
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode);
$amount=$amount-$nd_amount;
// save the ND in an array (for the easy view)
$aNd_amount[$i]=$nd_amount;
}
{
// this doens't concern the vat
$nd_amount=round($a_quant[$i]*$a_price[$i]*$non_dedu,2);
// save it
echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6740',$e_date,round($nd_amount,2),$seq,$periode);");
$dna=new parm_code($p_cn,'DNA');
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode);
$amount=$amount-$nd_amount;
// save the ND in an array (for the easy view)
$aNd_amount[$i]=$nd_amount;
}
//----------------------------------------------------------------------
// Put the non deductible part into a special account
$non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_DEP_PRIV);
echo_debug('user_form_ach.php',__LINE__,"value non ded : $non_dedu");
if ( $non_dedu != null && strlen(trim($non_dedu)) != 0)
{
// Remove also the vat
$nd_amount=round($a_quant[$i]*$a_price[$i]*$non_dedu,2);
$tva_nd=round($lvat*$non_dedu,2);
$nd_amount+=$tva_nd;
// save it
$dna=new parm_code($p_cn,'DEP_PRIV');
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode);
// modify sum
$amount=$amount-$nd_amount+$tva_nd;
$lvat-=$tva_nd;
$sum_tva_nd+=$tva_nd;
// save the ND in an array (for the easy view)
$aDep_priv[$i]=$nd_amount;
}
//----------------------------------------------------------------------
// Put the non deductible part into a special account
$non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_TVA_NON_DEDUCTIBLE);
echo_debug('user_form_ach.php',__LINE__,"TVA value non ded : $non_dedu");
@ -877,27 +904,27 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_dna->p_value,$e_date,round($ded_vat,2),$seq,$periode);
}
//----------------------------------------------------------------------
// Put the non deductible part into a special account
$non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP);
echo_debug('user_form_ach.php',__LINE__,"TVA value non ded : $non_dedu");
if ( $non_dedu != null && strlen(trim($non_dedu)) != 0 )
{
$ded_vat=($lvat != null )?$lvat*$non_dedu:0;
$sum_tva_nd+=round($ded_vat,2);
$aTva_ded_impot_recup[$i]=round($ded_vat,2);
// Save it
$tva_ded_impot=new parm_code($p_cn,'TVA_DED_IMPOT');
echo_debug('user_form_ach.php',__LINE__,
"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,".$tva_ded_impot->p_value.",$e_date,round($ded_vat,2),$seq,$periode);");
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_ded_impot->p_value,$e_date,round($ded_vat,2),$seq,$periode);
}
{
$ded_vat=($lvat != null )?$lvat*$non_dedu:0;
$sum_tva_nd+=round($ded_vat,2);
$aTva_ded_impot_recup[$i]=round($ded_vat,2);
// Save it
$tva_ded_impot=new parm_code($p_cn,'TVA_DED_IMPOT');
echo_debug('user_form_ach.php',__LINE__,
"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,".$tva_ded_impot->p_value.",$e_date,round($ded_vat,2),$seq,$periode);");
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_ded_impot->p_value,$e_date,round($ded_vat,2),$seq,$periode);
}
//----------------------------------------------------------------------
@ -905,7 +932,7 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2),$seq,$periode);");
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2),$seq,$periode,$a_good[$i]);
/* \brief if the quantity is < 0 then the stock increase (return of
/*! \brief if the quantity is < 0 then the stock increase (return of
* material)
*/
$nNeg=($a_quant[$i]<0)?-1:1;
@ -924,53 +951,56 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
$op->oa_description=$comm;
$op->save_form_plan($_POST,$i);
}
//---------------------------------------------------------
// insert into quant_purchase
//---------------------------------------------------------
echo_debug(__FILE__.":".__LINE__,"a_vat = ",$a_vat);
// echo_debug(__FILE__.":".__LINE__."a_vat[$i] =",$a_vat[$i]);
//!\note
// $a_vat_good[$i] contains the tva_id
// $a_vat_amount[$i] contains the amount of vat
$vat_code=$a_vat_good[$i];
$computed_vat=$lvat-$aNd_amount[$i]-$aTva_ded_impot[$i]-$aTva_ded_impot_recup[$i];
$qp_vat=($vat_code==-1)?0:$computed_vat;
echo_debug('form_ach',__LINE__,"Insert into insert_quant_purchase");
$r=ExecSql($p_cn,"select insert_quant_purchase ".
"('".$internal."'".
",".$j_id.
",'".$a_good[$i]."'".
",".$a_quant[$i].",".
round($amount,2).
",".$qp_vat.
",".$vat_code.
",".$aNd_amount[$i].
",".$aTva_ded_impot[$i].
",".$aTva_ded_impot_recup[$i].
",'".$e_client."')");
//---------------------------------------------------------
// insert into quant_purchase
//---------------------------------------------------------
echo_debug(__FILE__.":".__LINE__,"a_vat = ",$a_vat);
// echo_debug(__FILE__.":".__LINE__."a_vat[$i] =",$a_vat[$i]);
//!\note
// $a_vat_good[$i] contains the tva_id
// $a_vat_amount[$i] contains the amount of vat
$vat_code=$a_vat_good[$i];
// $computed_vat=$lvat-$aNd_amount[$i]-$aTva_ded_impot[$i]-$aTva_ded_impot_recup[$i];
$computed_vat=$lvat-$aTva_ded_impot[$i]-$aTva_ded_impot_recup[$i];
$qp_vat=($vat_code==-1)?0:$computed_vat;
echo_debug('form_ach',__LINE__,"Insert into insert_quant_purchase");
$r=ExecSql($p_cn,"select insert_quant_purchase ".
"('".$internal."'".
",".$j_id.
",'".$a_good[$i]."'".
",".$a_quant[$i].",".
round($amount,2).
",".$qp_vat.
",".$vat_code.
",".$aNd_amount[$i].
",".$aTva_ded_impot[$i].
",".$aTva_ded_impot_recup[$i].
",".$aDep_priv[$i].
",'".$e_client."')");
} // end loop
// set up internal code for quant_purchase
// set up internal code for quant_purchase
// Insert Vat
$sum_tva=0.0;
if ( $a_vat != null ) // no vat
{
echo_debug('user_form_ach',__LINE__,'a_vat = '.var_export($a_vat,true));
foreach ($a_vat as $tva_id => $e_tva_amount )
{
echo_debug('user_form_ach',__LINE__," tva_amount = $e_tva_amount tva_id=$tva_id");
$poste=GetTvaPoste($p_cn,$tva_id,'d');
if ($e_tva_amount == 0 ) continue;
echo_debug('user_form_ach',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($e_tva_amount,2),$seq,$periode);");
$r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($e_tva_amount,2),$seq,$periode);
$sum_tva+=round($e_tva_amount,2);
}
echo_debug('user_form_ach',__LINE__,'a_vat = '.var_export($a_vat,true));
foreach ($a_vat as $tva_id => $e_tva_amount )
{
echo_debug('user_form_ach',__LINE__," tva_amount = $e_tva_amount tva_id=$tva_id");
if ($e_tva_amount == 0 ) continue;
$poste=GetTvaPoste($p_cn,$tva_id,'d');
$r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($e_tva_amount,2),$seq,$periode);
$sum_tva+=round($e_tva_amount,2);
}
}
echo_debug('user_form_ach.php',__LINE__,"echeance = $e_ech");
echo_debug('user_form_ach.php',__LINE__,"sum_tva = $sum_tva");
@ -984,14 +1014,14 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
$r=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($amount_jrn+$sum_tva+$sum_tva_nd,2),$seq,
$periode,$e_client);
$r=InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"--",$seq,$periode);
// Set Internal code and Comment
$Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ".
$Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ".
" jr_grpt_id = ".$seq);
$comment=(FormatString($e_comm) == null )?$internal." Fournisseur : ".GetFicheName($p_cn,$e_client):FormatString($e_comm);
// Update and set the invoice's comment
@ -999,14 +1029,14 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
if ( isset ($_FILES))
save_upload_document($p_cn,$seq);
// Save the operation
if ( isset($_POST['opd_save']) && $_POST['opd_save']=='on' ){
echo_debug(__FILE__.':'.__LINE__.'- ','save opd');
$opd=new Pre_op_ach($p_cn);
$opd->get_post();
$opd->save();
// Save the operation
if ( isset($_POST['opd_save']) && $_POST['opd_save']=='on' ){
echo_debug(__FILE__.':'.__LINE__.'- ','save opd');
$opd=new Pre_op_ach($p_cn);
$opd->get_post();
$opd->save();
echo_debug(__FILE__.':'.__LINE__.'- ',"opd = ",$opd);
}
}
} catch (Exception $e) {
echo '<span class="error">'.
'Erreur dans l\'enregistrement '.

View file

@ -235,7 +235,7 @@ function FormVenInput($p_cn,$p_jrn,$p_periode,$p_array=null,$pview_only=true,$p_
$Quantity->size=9;
//$r.=InputType("","TEXT","e_quant".$i,$quant,$pview_only);
$r.=$Quantity->IOValue("e_quant".$i,$quant);
$r.="</tr>";
}
@ -336,8 +336,8 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number)
// compare hidden value and computed
if ( round($ca_amount-$hidden_amount,2) != 0 ) {
$msg="Montant CA est différent total marchandise";
$msg.="montant encodé $ca_amount marchandise $hidden_amount";
$msg="Montant CA est different total marchandise";
$msg.="montant encode $ca_amount marchandise $hidden_amount";
echo "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
@ -644,15 +644,19 @@ function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form'
if ( CountSql($p_cn,
"select md_id,md_name from document_modele where md_type=4") > 0 )
{
$r.='G&eacute;n&eacute;rer une facture <input type="checkbox" name="gen_invoice" CHECKED>';
// We propose to generate the invoice and some template
$doc_gen=new widget("select");
$doc_gen->name="gen_doc";
$doc_gen->value=make_array($p_cn,
"select md_id,md_name from document_modele where md_type=4");
$r.=$doc_gen->IOValue();
$r.="<hr>";
$r.='<fieldset> <legend> G&eacute;n&eacute;ration de facture</legend>';
$obj=new widget('TEXT');
$r.='Numero de bon de commande : '.$obj->IOValue('bon_comm').'<br>';
$r.='Autre information : '.$obj->IOValue('other_info').'<br>';
$r.='G&eacute;n&eacute;rer une facture <input type="checkbox" name="gen_invoice" CHECKED>';
// We propose to generate the invoice and some template
$doc_gen=new widget("select");
$doc_gen->name="gen_doc";
$doc_gen->value=make_array($p_cn,
"select md_id,md_name from document_modele where md_type=4");
$r.=$doc_gen->IOValue().'<br>';
$r.="</fieldset>";
}
}
@ -756,7 +760,7 @@ function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
// Compute the j_grpt
$seq=NextSequence($p_cn,'s_grpt');
$oJrn=new Acc_Ledger($p_cn,$p_jrn);
$oJrn=new Acc_Ledger($p_cn,$p_jrn);
$internal=$oJrn->compute_internal_code($seq);
echo_debug(__FILE__,__LINE__,"Dossier is ".dossier::id());

View file

@ -192,26 +192,7 @@ function ShowMenuCompta($p_high="")
$result=ShowItem($p_array,'H',"mtitle","mtitle",$default,' width="100%"');
$str_dossier=dossier::get();
$r="";
/*
$r.='<div style="float:left;background-color:#879ED4;">';
$r.="<H2 class=\"info\">Comptabilit&eacute; ".dossier::name()."</h2>";
$r.='</div>';
$r.='<div style="text-align:right;">';
$r.='<input type="IMAGE" src="image/search.png" width="36" onclick="openRecherche(\''.$_REQUEST['PHPSESSID'].'\','.dossier::id().',\'E\');">
<A HREF="user_pref.php?'.$str_dossier.'" title="Pr&eacute;f&eacute;rence"><IMG SRC="image/preference.png" width="36" border="0" ></A>
<A HREF="comptanalytic.php?'.$str_dossier.'" title="CA"><IMG SRC="image/comptaanal.png" width="36" border="0" ></A>
<A HREF="parametre.php?'.$str_dossier.'" title="Paramètre"><IMG SRC="image/param.png" width="36" border="0" ></A>
<A HREF="login.php" title="Accueil"><IMG SRC="image/home.png" width="36" border="0" ></A>
<A HREF="logout.php" title="Sortie"><IMG SRC="image/logout.png" title="Logout" width="36" border="0"></A>
</div> ';
*/
// $r.='<div class="u_tmenu">';
$r.=menu_tool("");
$r.=menu_tool("compta");
$r.='<div style="float:left">';
$r.=$result;
$r.='</div>';
@ -822,15 +803,32 @@ function ShowMenuImport(){
echo "</TABLE>";
}
/*!\brief show the top menu to access the different modules in top
* \param $p_from from which module this function is called
* \return string
*/
function menu_tool($p_from) {
if ( ! isset ($_REQUEST['gDossier']))
return "" ;
$r="";
$r.='<script language="javascript">
function openRecherche(p_sessid,p_dossier,p_style) {
if ( p_style == \'E\' ) { p_style="expert";}
var w=window.open("recherche.php?gDossier="+p_dossier+"&PHPSESSID="+p_sessid+\'&\'+p_style,\'\',\'statusbar=no,scrollbars=yes,toolbar=no\');
w.focus();
}
</script>';
$r.= '<div class="u_tool">';
$r.= '<div class="name">';
$r.= "<H2 class=\"info\">Commercial ".dossier::name()."</h2> ";
$r.= '</div>';
$r.= '<div class="acces_direct">';
if ( $from == 'compta') $view='E';
else $view='S';
$agent=$_SERVER['HTTP_USER_AGENT'];
$amodule=array(
array('value'=>'pref','label'=>'Preference'),
@ -842,20 +840,47 @@ function menu_tool($p_from) {
array('value'=>'home','label'=>'Accueil'),
array('value'=>'logout','label'=>'Sortir')
);
if ( $_SESSION['g_topmenu'] == 'SELECT' ) {
$gDossier=dossier::id();
$r.= '<form method="GET" action="control.php">';
$w=new widget('select');
$w->name='m';
$w->value=$amodule;
$r.= '<table><tr><td class="mtitle">';
$gDossier=dossier::id();
$r.= '<form method="GET" action="control.php">';
$w=new widget('select');
$w->name='m';
$w->value=$amodule;
$r.= '<table><tr><td class="mtitle">';
$r.= '<A class="mtitle" HREF="javascript:openRecherche(\''.$_REQUEST['PHPSESSID'].'\','.$gDossier.')">'.
'Recheche</a></td>';
$r.= '<td>'.$w->IOValue().'</td>';
$r.= dossier::hidden();
$r.= '<td>'.widget::submit('','Acces Direct').'</td>';
$r.= '</table>';
$r.= '</form>';
$r.= '</div>';
$search="openRecherche('".$_REQUEST['PHPSESSID']."','".$gDossier."','".$view."');";
$r.='<input type="BUTTON" onClick="'.$search.'" value="Recherche">';
$r.='</td>';
$r.= '<td>'.$w->IOValue().'</td>';
$r.= dossier::hidden();
$r.= '<td>'.widget::submit('','Acces Direct').'</td>';
$r.= '</table>';
$r.= '</form>';
$r.= '</div>';
}
if ( $_SESSION['g_topmenu'] == 'TEXT' ) {
$gDossier=dossier::id();
$r.= '<table><tr><td class="mtitle2">';
$r.= '<A class="cell" HREF="javascript:openRecherche(\''.$_REQUEST['PHPSESSID'].'\','.$gDossier.')">'.
'Recheche</a></td>';
foreach($amodule as $col ) {
$url="control.php?".dossier::get()."&m=".$col['value'];
if ( $p_from==$col['value']) {
$r.= '<td style="background-color:red">'.
'<a class="mtitle" href="'.$url.'" >'.$col['label'].'</a>'.
'</td>';
} else {
$r.= '<td>'.
'<a class="cell" href="'.$url.'" >'.$col['label'].'</a>'.
'</td>';
}
}
$r.='</tr>';
$r.= '</table>';
$r.= '</div>';
}
$r.= '</div>';
return $r;
}

View file

@ -1,6 +1,6 @@
#!/bin/bash
# clean all phpcompta related DB.
DOMAIN="f31"
DOMAIN="beta_"
export PGPASSWORD="dany"
export PGUSER="phpcompta"
export PGHOST=localhost

View file

@ -1,720 +1,48 @@
begin;
alter table import_tmp add n_montant numeric(20,4);
update import_tmp set n_montant=to_number(montant,'999999999.99');
alter table import_tmp drop montant;
alter table import_tmp rename n_montant to montant;
-- alter table import_tmp alter montant type numeric(20,4);
alter table import_tmp alter montant set default 0;
alter table import_tmp alter montant set not null;
alter table import_tmp alter code set not null;
alter table import_tmp alter date_exec set not null;
alter table import_tmp alter date_valeur set not null;
COMMENT ON TABLE import_tmp IS 'Table temporaire pour l''importation des banques en format CSV';
COMMENT ON COLUMN import_tmp.status IS 'Status w waiting, d delete t transfert';
-- insert into parm_code values ('DEP_PRIV',4890,'Depense à charge du gérant');
-- insert into attr_def values (31,'Depense à charge du gérant (partie privée)');
-- alter table quant_purchase add qp_dep_priv numeric(20,4) default 0.0;
alter table poste_analytique add ga_id varchar (10);
CREATE or replace FUNCTION t_document_validate() RETURNS "trigger"
CREATE FUNCTION insert_quant_purchase(p_internal text, p_j_id numeric, p_fiche character varying, p_quant numeric, p_price numeric, p_vat numeric, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric, p_nd_tva_recup numeric,p_dep_priv numeric , p_client character varying) RETURNS void
AS $$
declare
lText text;
modified document%ROWTYPE;
fid_client integer;
fid_good integer;
begin
modified:=NEW;
modified.d_filename:=replace(NEW.d_filename,' ','_');
return modified;
select f_id into fid_client from
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_client);
select f_id into fid_good from
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_fiche);
insert into quant_purchase
(qp_internal,
j_id,
qp_fiche,
qp_quantite,
qp_price,
qp_vat,
qp_vat_code,
qp_nd_amount,
qp_nd_tva,
qp_nd_tva_recup,
qp_supplier,
qp_dep_priv)
values
(p_internal,
p_j_id,
fid_good,
p_quant,
p_price,
p_vat,
p_vat_code,
p_nd_amount,
p_nd_tva,
p_nd_tva_recup,
fid_client,
p_dep_priv);
return;
end;
$$
$$
LANGUAGE plpgsql;
CREATE or replace FUNCTION t_document_type_insert() RETURNS "trigger"
AS $$
declare
nCounter integer;
BEGIN
select count(*) into nCounter from pg_class where relname='seq_doc_type_'||NEW.dt_id;
if nCounter = 0 then
execute 'create sequence seq_doc_type_'||NEW.dt_id;
end if;
RETURN NEW;
END;
$$
LANGUAGE plpgsql;
CREATE or replace FUNCTION t_document_modele_validate() RETURNS "trigger"
AS $$
declare
lText text;
modified document_modele%ROWTYPE;
begin
modified:=NEW;
modified.md_filename:=replace(NEW.md_filename,' ','_');
return modified;
end;
$$
LANGUAGE plpgsql;
CREATE TABLE groupe_analytique
(
ga_id varchar(10) NOT NULL,
pa_id int,
ga_description text,
CONSTRAINT pk_ga_id PRIMARY KEY (ga_id)
) ;
CREATE OR REPLACE FUNCTION group_analytic_ins_upd()
RETURNS "trigger" AS
$BODY$
declare
name text;
begin
name:=upper(NEW.ga_id);
name:=trim(name);
name:=replace(name,' ','');
NEW.ga_id:=name;
return NEW;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE OR REPLACE FUNCTION group_analytique_del()
RETURNS "trigger" AS
$BODY$
begin
update poste_analytique set ga_id=null
where ga_id=OLD.ga_id;
return OLD;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE OR REPLACE FUNCTION poste_analytique_ins_upd()
RETURNS "trigger" AS
$BODY$declare
name text;
rCount record;
begin
name:=upper(NEW.po_name);
name:=trim(name);
name:=replace(name,' ','');
NEW.po_name:=name;
if NEW.ga_id is NULL then
return NEW;
end if;
if length(trim(NEW.ga_id)) = 0 then
NEW.ga_id:=NULL;
return NEW;
end if;
perform 'select ga_id from groupe_analytique where ga_id='||NEW.ga_id;
if NOT FOUND then
raise exception' Inexistent Group Analytic %',NEW.ga_id;
end if;
return NEW;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE OR REPLACE FUNCTION plan_analytic_ins_upd()
RETURNS "trigger" AS
$BODY$
declare
name text;
begin
name:=upper(NEW.pa_name);
name:=trim(name);
name:=replace(name,' ','');
NEW.pa_name:=name;
return NEW;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER t_poste_analytique_ins_upd
BEFORE INSERT OR UPDATE
ON poste_analytique
FOR EACH ROW
EXECUTE PROCEDURE poste_analytique_ins_upd();
CREATE TRIGGER t_plan_analytique_ins_upd
BEFORE INSERT OR UPDATE
ON plan_analytique
FOR EACH ROW
EXECUTE PROCEDURE plan_analytic_ins_upd();
CREATE TRIGGER t_group_analytic_del
before DELETE
ON groupe_analytique
FOR EACH ROW
EXECUTE PROCEDURE group_analytique_del();
CREATE TRIGGER t_group_analytic_ins_upd
BEFORE INSERT OR UPDATE
ON groupe_analytique
FOR EACH ROW
EXECUTE PROCEDURE group_analytic_ins_upd();
drop TRIGGER t_upper_pa_name on plan_analytique;
drop TRIGGER t_upper_po_name on poste_analytique;
drop function upper_pa_name();
drop function upper_po_name();
CREATE TABLE bud_hypothese
(
bh_id int4 NOT NULL,
bh_name text NOT NULL,
bh_saldo numeric(20,4) DEFAULT 0,
bh_description text,
pa_id int4,
CONSTRAINT pk_bud_hypo PRIMARY KEY (bh_id),
CONSTRAINT fk_bud_hypo_pa_id FOREIGN KEY (pa_id)
REFERENCES plan_analytique (pa_id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
)
WITHOUT OIDS;
create sequence seq_bud_hypothese_bh_id;
alter table bud_hypothese alter bh_id set default nextval('seq_bud_hypothese_bh_id');
--
-- Name: bud_card; Type: TABLE; Schema: public; Owner: phpcompta; Tablespace:
--
CREATE TABLE bud_card (
bc_id integer NOT NULL,
bc_code character varying(10) NOT NULL,
bc_description text,
bc_price_unit numeric(20,4) DEFAULT 0.0 NOT NULL,
bc_unit character varying(20),
bh_id integer
);
--
-- Name: TABLE bud_card; Type: COMMENT; Schema: public; Owner: phpcompta
--
COMMENT ON TABLE bud_card IS 'card for budget module';
--
-- Name: COLUMN bud_card.bh_id; Type: COMMENT; Schema: public; Owner: phpcompta
--
COMMENT ON COLUMN bud_card.bh_id IS 'fk to bud_hypothese';
--
-- Name: bud_card_bc_id_seq; Type: SEQUENCE; Schema: public; Owner: phpcompta
--
CREATE SEQUENCE bud_card_bc_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.bud_card_bc_id_seq OWNER TO phpcompta;
--
-- Name: bud_card_bc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: phpcompta
--
ALTER SEQUENCE bud_card_bc_id_seq OWNED BY bud_card.bc_id;
--
-- Name: bc_id; Type: DEFAULT; Schema: public; Owner: phpcompta
--
ALTER TABLE bud_card ALTER COLUMN bc_id SET DEFAULT nextval('bud_card_bc_id_seq'::regclass);
--
-- Name: pk_bud_card_bc_id; Type: CONSTRAINT; Schema: public; Owner: phpcompta; Tablespace:
--
ALTER TABLE ONLY bud_card
ADD CONSTRAINT pk_bud_card_bc_id PRIMARY KEY (bc_id);
--
-- Name: uq_bud_card_bc_code; Type: CONSTRAINT; Schema: public; Owner: phpcompta; Tablespace:
--
ALTER TABLE ONLY bud_card
ADD CONSTRAINT uq_bud_card_bc_code_bh_id UNIQUE (bc_code,bh_id);
ALTER TABLE bud_card ADD CONSTRAINT fk_bud_hypo_bh_id FOREIGN KEY (bh_id) REFERENCES bud_hypothese (bh_id)
ON UPDATE CASCADE ON DELETE CASCADE;
CREATE INDEX fki_bud_hypo_bh_id ON bud_card(bh_id);
ALTER TABLE bud_card ALTER COLUMN bh_id SET NOT NULL;
--
-- Name: bud_detail; Type: TABLE; Schema: public; Owner: phpcompta; Tablespace:
--
CREATE TABLE bud_detail (
bd_id integer NOT NULL,
po_id integer,
bc_id integer,
bh_id integer,
pcm_val poste_comptable
);
ALTER TABLE public.bud_detail OWNER TO phpcompta;
--
-- Name: TABLE bud_detail; Type: COMMENT; Schema: public; Owner: phpcompta
--
COMMENT ON TABLE bud_detail IS 'Detail for card ';
--
-- Name: COLUMN bud_detail.bd_id; Type: COMMENT; Schema: public; Owner: phpcompta
--
COMMENT ON COLUMN bud_detail.bd_id IS 'primary key';
--
-- Name: COLUMN bud_detail.po_id; Type: COMMENT; Schema: public; Owner: phpcompta
--
COMMENT ON COLUMN bud_detail.po_id IS 'FK to poste_analytique';
--
-- Name: COLUMN bud_detail.bc_id; Type: COMMENT; Schema: public; Owner: phpcompta
--
COMMENT ON COLUMN bud_detail.bc_id IS 'fk to bud_card';
--
-- Name: COLUMN bud_detail.pcm_val; Type: COMMENT; Schema: public; Owner: phpcompta
--
COMMENT ON COLUMN bud_detail.pcm_val IS 'fk to tmp_pcmn';
--
-- Name: bud_detail_bd_id_seq; Type: SEQUENCE; Schema: public; Owner: phpcompta
--
CREATE SEQUENCE bud_detail_bd_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.bud_detail_bd_id_seq OWNER TO phpcompta;
--
-- Name: bud_detail_bd_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: phpcompta
--
ALTER SEQUENCE bud_detail_bd_id_seq OWNED BY bud_detail.bd_id;
--
-- Name: bd_id; Type: DEFAULT; Schema: public; Owner: phpcompta
--
ALTER TABLE bud_detail ALTER COLUMN bd_id SET DEFAULT nextval('bud_detail_bd_id_seq'::regclass);
--
-- Name: pk_bud_detail; Type: CONSTRAINT; Schema: public; Owner: phpcompta; Tablespace:
--
ALTER TABLE ONLY bud_detail
ADD CONSTRAINT pk_bud_detail PRIMARY KEY (bd_id);
--
-- Name: fki_bud_card; Type: INDEX; Schema: public; Owner: phpcompta; Tablespace:
--
CREATE INDEX fki_bud_card ON bud_detail USING btree (bc_id);
--
-- Name: fki_tmp_pcmn; Type: INDEX; Schema: public; Owner: phpcompta; Tablespace:
--
CREATE INDEX fki_tmp_pcmn ON bud_detail USING btree (pcm_val);
--
-- Name: fk_bud_card; Type: FK CONSTRAINT; Schema: public; Owner: phpcompta
--
ALTER TABLE ONLY bud_detail
ADD CONSTRAINT fk_bud_card FOREIGN KEY (bc_id) REFERENCES bud_card(bc_id) ON UPDATE CASCADE ON DELETE CASCADE;;
ALTER TABLE ONLY bud_detail
add constraint fk_bud_hypothese_not_null FOREIGN KEY (bh_id) REFERENCES bud_hypothese(bh_id) ON UPDATE CASCADE ON DELETE CASCADE;;
--
-- Name: fk_tmp_pcmn; Type: FK CONSTRAINT; Schema: public; Owner: phpcompta
--
ALTER TABLE ONLY bud_detail
ADD CONSTRAINT fk_tmp_pcmn FOREIGN KEY (pcm_val) REFERENCES tmp_pcmn(pcm_val) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- Name: bud_detail_periode; Type: TABLE; Schema: public; Owner: phpcompta; Tablespace:
--
CREATE TABLE bud_detail_periode (
bdp_id integer NOT NULL,
bdp_amount numeric(20,4) DEFAULT 0.0,
p_id integer NOT NULL,
bd_id integer
);
ALTER TABLE public.bud_detail_periode OWNER TO phpcompta;
--
-- Name: TABLE bud_detail_periode; Type: COMMENT; Schema: public; Owner: phpcompta
--
COMMENT ON TABLE bud_detail_periode IS 'Module budget detail by periode';
--
-- Name: COLUMN bud_detail_periode.p_id; Type: COMMENT; Schema: public; Owner: phpcompta
--
COMMENT ON COLUMN bud_detail_periode.p_id IS 'fk to parm_periode';
--
-- Name: COLUMN bud_detail_periode.bd_id; Type: COMMENT; Schema: public; Owner: phpcompta
--
COMMENT ON COLUMN bud_detail_periode.bd_id IS 'fk to bud_detail';
--
-- Name: bud_detail_periode_bdp_id_seq; Type: SEQUENCE; Schema: public; Owner: phpcompta
--
CREATE SEQUENCE bud_detail_periode_bdp_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.bud_detail_periode_bdp_id_seq OWNER TO phpcompta;
--
-- Name: bud_detail_periode_bdp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: phpcompta
--
ALTER SEQUENCE bud_detail_periode_bdp_id_seq OWNED BY bud_detail_periode.bdp_id;
--
-- Name: bdp_id; Type: DEFAULT; Schema: public; Owner: phpcompta
--
ALTER TABLE bud_detail_periode ALTER COLUMN bdp_id SET DEFAULT nextval('bud_detail_periode_bdp_id_seq'::regclass);
--
-- Name: pk_budget_detail_period; Type: CONSTRAINT; Schema: public; Owner: phpcompta; Tablespace:
--
ALTER TABLE ONLY bud_detail_periode
ADD CONSTRAINT pk_budget_detail_period PRIMARY KEY (bdp_id);
--
-- Name: fk_bud_detail_bd_id; Type: FK CONSTRAINT; Schema: public; Owner: phpcompta
--
ALTER TABLE ONLY bud_detail_periode
ADD CONSTRAINT fk_bud_detail_bd_id FOREIGN KEY (bd_id) REFERENCES bud_detail(bd_id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- Name: fk_parm_periode; Type: FK CONSTRAINT; Schema: public; Owner: phpcompta
--
ALTER TABLE ONLY bud_detail_periode
ADD CONSTRAINT fk_parm_periode FOREIGN KEY (p_id) REFERENCES parm_periode(p_id) ON UPDATE CASCADE ON DELETE CASCADE;
CREATE OR REPLACE FUNCTION bud_detail_ins_upd()
RETURNS "trigger" AS
$BODY$declare
mline bud_detail%ROWTYPE;
begin
mline:=NEW;
if mline.po_id = -1 then
mline.po_id:=NULL;
end if;
return mline;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE OR REPLACE FUNCTION bud_card_ins_upd()
RETURNS "trigger" AS
$BODY$declare
sCode text;
begin
sCode:=trim(upper(NEW.bc_code));
sCode:=replace(sCode,' ','_');
sCode:=substr(sCode,1,10);
NEW.bc_code:=sCode;
return NEW;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION bud_card_ins_upd() OWNER TO phpcompta;
--
-- Name: t_bud_card_ins_up; Type: TRIGGER; Schema: public; Owner: phpcompta
--
CREATE TRIGGER t_bud_card_ins_up
BEFORE INSERT OR UPDATE ON bud_card
FOR EACH ROW
EXECUTE PROCEDURE bud_card_ins_upd();
--
-- Name: bud_hypothese_bh_id; Type: FK CONSTRAINT; Schema: public; Owner: phpcompta
--
ALTER TABLE ONLY bud_card
ADD CONSTRAINT bud_hypothese_bh_id FOREIGN KEY (bh_id) REFERENCES bud_hypothese(bh_id) ON UPDATE CASCADE ON DELETE CASCADE;
CREATE TRIGGER t_bud_detail_ins_upd
BEFORE INSERT OR UPDATE
ON bud_detail
FOR EACH ROW
EXECUTE PROCEDURE bud_detail_ins_upd();
CREATE TABLE jrn_periode
(
jrn_def_id int4 NOT NULL,
p_id int4 NOT NULL,
status text,
CONSTRAINT jrn_periode_pk PRIMARY KEY (jrn_def_id, p_id),
CONSTRAINT jrn_per_jrn_def_id FOREIGN KEY (jrn_def_id)
REFERENCES jrn_def (jrn_def_id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT jrn_periode_p_id FOREIGN KEY (p_id)
REFERENCES parm_periode (p_id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
);
insert into jrn_periode(p_id,jrn_def_id,status) select p_id,jrn_def_id,
case when p_central='t' then 'CE'
when p_closed='t' then 'CL'
else 'OP'
end
from
parm_periode cross join jrn_def;
CREATE OR REPLACE FUNCTION jrn_def_add()
RETURNS "trigger" AS
$BODY$begin
execute 'insert into jrn_periode(p_id,jrn_def_id,status) select p_id,'||NEW.jrn_def_id||',
case when p_central=true then ''CE''
when p_closed=true then ''CL''
else ''OP''
end
from
parm_periode ';
return NEW;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER t_jrn_def_add_periode
AFTER INSERT
ON jrn_def
FOR EACH ROW
EXECUTE PROCEDURE jrn_def_add();
CREATE OR REPLACE FUNCTION jrn_check_periode()
RETURNS "trigger" AS
$BODY$
declare
bClosed bool;
str_status text;
begin
select p_closed into bClosed from parm_periode
where p_id=NEW.jr_tech_per;
if bClosed = true then
raise exception 'Periode fermee';
end if;
select status into str_status from jrn_periode
where p_id =NEW.jr_tech_per and jrn_def_id=NEW.jr_def_id;
if str_status <> 'OP' then
raise exception 'Periode fermee';
end if;
return NEW;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER t_check_jrn
BEFORE INSERT OR DELETE
ON jrn
FOR EACH ROW
EXECUTE PROCEDURE jrn_check_periode();
drop TRIGGER tr_jrn_check_balance on jrn;
CREATE OR REPLACE FUNCTION jrn_def_delete()
RETURNS "trigger" AS
$BODY$
declare
nb numeric;
begin
select count(*) into nb from jrn where jr_def_id=OLD.jrn_def_id;
if nb <> 0 then
raise exception 'EFFACEMENT INTERDIT: JOURNAL UTILISE';
end if;
return OLD;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER t_jrn_def_delete
BEFORE DELETE
ON jrn_def
FOR EACH ROW
EXECUTE PROCEDURE jrn_def_delete();
CREATE OR REPLACE FUNCTION proc_check_balance()
RETURNS "trigger" AS
$BODY$
declare
diff numeric;
tt integer;
begin
if TG_OP = 'INSERT' or TG_OP='UPDATE' then
tt=NEW.jr_grpt_id;
diff:=check_balance(tt);
if diff != 0 then
raise exception 'balance error %',diff ;
end if;
return NEW;
end if;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER t_check_balance
AFTER INSERT OR UPDATE
ON jrn
FOR EACH ROW
EXECUTE PROCEDURE proc_check_balance();
INSERT INTO "action" (ac_id, ac_description) VALUES (60, 'Module Budget');
alter table tmp_pcmn add column pcm_type text;
ALTER TABLE tmp_pcmn ALTER COLUMN pcm_type set default NULL;
CREATE TABLE parm_poste (
p_value poste_comptable NOT NULL,
p_type text NOT NULL
);
--
-- Name: TABLE parm_poste; Type: COMMENT; Schema: public; Owner: postgres
--
COMMENT ON TABLE parm_poste IS 'Contains data for finding is the type of the account (asset)';
--
-- Name: parm_poste_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY parm_poste
ADD CONSTRAINT parm_poste_pkey PRIMARY KEY (p_value);
CREATE OR REPLACE FUNCTION find_pcm_type(pp_value "numeric")
RETURNS text AS
$BODY$
declare
str_type text;
str_value text;
n_value numeric;
nLength integer;
begin
str_value:=trim(to_char(pp_value,'99999999999999999999999999999'));
nLength:=length(str_value);
while nLength > 0 loop
n_value:=to_number(str_value,'99999999999999999999999999999');
select into str_type p_type from parm_poste where p_value=n_value;
if FOUND then
return str_type;
end if;
nLength:=nLength-1;
str_value:=substring(str_value from 1 for nLength);
end loop;
return 'CON';
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE OR REPLACE FUNCTION tmp_pcmn_ins()
RETURNS "trigger" AS
$BODY$
declare
r_record tmp_pcmn%ROWTYPE;
begin
r_record=NEW;
if length(trim(r_record.pcm_type))=0 or r_record.pcm_type is NULL then
r_record.pcm_type:=find_pcm_type(NEW.pcm_val);
return r_record;
end if;
return NEW;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER t_tmp_pcmn_ins
BEFORE INSERT
ON tmp_pcmn
FOR EACH ROW
EXECUTE PROCEDURE tmp_pcmn_ins();
update tmp_pcmn set pcm_type=find_pcm_type(pcm_val);
commit;
commit;