Fix cosmetic bugs and add support for OOo
This commit is contained in:
parent
8bd4bd94c6
commit
547e392253
33 changed files with 365 additions and 682 deletions
|
|
@ -96,6 +96,10 @@ function GetVersion($p_cn) {
|
|||
*/
|
||||
function ExecuteScript($p_cn,$script) {
|
||||
$hf=fopen($script,'r');
|
||||
if ( $hf == false ) {
|
||||
echo 'Ne peut ouvrir '.$script;
|
||||
exit();
|
||||
}
|
||||
$sql="";
|
||||
$flag_function=false;
|
||||
while (!feof($hf)) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
begin;
|
||||
insert into Theme values ('Colored','style-color.css',null);
|
||||
delete from theme where the_filestyle='style-aqua.css' or the_filestyle='style-elegant.css'
|
||||
delete from theme where the_filestyle='style-aqua.css' or the_filestyle='style-elegant.css';
|
||||
update version set val=8;
|
||||
commit;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ drop table user_pref;
|
|||
-- trim the space
|
||||
update parm_code set p_code=trim(p_code);
|
||||
|
||||
upgrade version set val=13;
|
||||
update version set val=13;
|
||||
|
||||
commit;
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ create table document
|
|||
d_mimetype text
|
||||
);
|
||||
|
||||
alter table document add constraint fk_ag_id foreign key (ag_id) references action_gestion(ag_id);
|
||||
|
||||
|
||||
comment on table document is 'This table contains all the documents : summary and lob files';
|
||||
|
||||
|
|
@ -417,8 +417,8 @@ INSERT INTO document_state VALUES (2, 'Brouillon');
|
|||
INSERT INTO document_state VALUES (3, 'A envoyer');
|
||||
|
||||
ALTER TABLE ONLY document_state ADD CONSTRAINT document_state_pkey PRIMARY KEY (s_id);
|
||||
|
||||
insert into attr_def (ad_id,ad_text) values (24,'Ville');
|
||||
alter sequence s_attr_def restart with 24;
|
||||
insert into attr_def (ad_text) values ('Ville');
|
||||
insert into attr_min values(9,24);
|
||||
insert into attr_min values(8,24);
|
||||
insert into attr_min values(14,24);
|
||||
|
|
@ -442,9 +442,13 @@ create table action_gestion (
|
|||
);
|
||||
|
||||
comment on table action_gestion is 'Action for Managing';
|
||||
|
||||
|
||||
-- add contact
|
||||
insert into fiche_def_ref(frd_text) values ('Contact');
|
||||
insert into attr_def(ad_text) values ('Société');
|
||||
alter sequence s_fiche_def_ref restart 16;
|
||||
insert into fiche_def_ref(frd_text) values ('Contact');
|
||||
|
||||
insert into attr_def(ad_text) values ('Société');
|
||||
insert into attr_def(ad_text) values ('Fax');
|
||||
insert into attr_min values(16,1);
|
||||
insert into attr_min values(16,17);
|
||||
|
|
@ -529,6 +533,9 @@ create view vw_supplier as SELECT a.f_id, a.av_text AS name, a1.av_text AS quick
|
|||
WHERE jnt_fic_att_value.ad_id = 18) h USING (f_id)
|
||||
WHERE a.frd_id = 8;
|
||||
|
||||
insert into parameter (pr_id) values ('MY_TEL');
|
||||
insert into parameter (pr_id) values ('MY_PAYS');
|
||||
insert into parameter (pr_id) values ('MY_FAX');
|
||||
|
||||
update version set val=14;
|
||||
|
||||
|
|
|
|||
|
|
@ -158,6 +158,9 @@ if ( $p_action=='company') {
|
|||
$m->MY_NUMBER=$p_no;
|
||||
$m->MY_CP=$p_cp;
|
||||
$m->MY_COMMUNE=$p_Commune;
|
||||
$m->MY_TEL=$p_tel;
|
||||
$m->MY_FAX=$p_fax;
|
||||
$m->MY_PAYS=$p_pays;
|
||||
$m->Save();
|
||||
}
|
||||
|
||||
|
|
@ -167,12 +170,15 @@ if ( $p_action=='company') {
|
|||
echo '<form method="post" action="?p_action=company">';
|
||||
echo "<table class=\"result\">";
|
||||
echo "<tr>".$all->IOValue("p_name",$my->MY_NAME,"Nom société")."</tr>";
|
||||
|
||||
echo "<tr>".$all->IOValue("p_tva",$my->MY_TVA,"Numéro de Tva")."</tr>";
|
||||
echo "<tr>".$all->IOValue("p_tel",$my->MY_TEL,"Téléphone")."</tr>";
|
||||
echo "<tr>".$all->IOValue("p_fax",$my->MY_FAX,"Fax")."</tr>";
|
||||
echo "<tr>".$all->IOValue("p_street",$my->MY_STREET,"Rue ")."</tr>";
|
||||
echo "<tr>".$all->IOValue("p_no",$my->MY_NUMBER,"Numéro")."</tr>";
|
||||
echo "<tr>".$all->IOValue("p_cp",$my->MY_CP,"Code Postal")."</tr>";
|
||||
echo "<tr>".$all->IOValue("p_Commune",$my->MY_COMMUNE,"Commune")."</tr>";
|
||||
echo "<tr>".$all->IOValue("p_pays",$my->MY_PAYS,"Pays")."</tr>";
|
||||
echo "<tr>".$all->IOValue("p_tva",$my->MY_TVA,"Numéro de Tva")."</tr>";
|
||||
|
||||
echo "</table>";
|
||||
$submit=new widget("submit");
|
||||
echo $submit->Submit("record_company","Enregistre");
|
||||
|
|
|
|||
|
|
@ -243,16 +243,13 @@ td.selectedcell{
|
|||
a.mtitle {
|
||||
font-size:10px;
|
||||
text-decoration:none;
|
||||
display:block;
|
||||
display:inline;
|
||||
color:blue;
|
||||
}
|
||||
|
||||
a.mtitle:hover {
|
||||
// font-size:10px;
|
||||
// color:white;
|
||||
// background-color:#5D90CD;
|
||||
text-decoration:none;
|
||||
display:block;
|
||||
display:inline;
|
||||
border-style:groove;
|
||||
border-color:gray;
|
||||
}
|
||||
|
|
@ -316,4 +313,73 @@ li.menuv,ol.menuv {
|
|||
display:inline;
|
||||
padding:1em 1em;
|
||||
}
|
||||
div.u_redcontent a {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
color: darkblue;
|
||||
|
||||
}
|
||||
|
||||
div.u_redcontent a:hover {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
color: red;
|
||||
background-color: rgb(93, 144, 205);
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
|
||||
}
|
||||
div.u_content a {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
color: darkblue;
|
||||
|
||||
}
|
||||
|
||||
div.u_content a:hover {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
color: red;
|
||||
background-color: rgb(93, 144, 205);
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
|
||||
}
|
||||
|
||||
div.u_redcontent a.mtitle {
|
||||
font-size:10px;
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
color:blue;
|
||||
|
||||
}
|
||||
|
||||
div.u_redcontent a.mtitle:hover {
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
background-color:yellow;
|
||||
|
||||
|
||||
}
|
||||
div.u_content a.mtitle {
|
||||
font-size:10px;
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
color:blue;
|
||||
|
||||
}
|
||||
|
||||
div.u_content a.mtitle:hover {
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
background-color:yellow;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* </style> */
|
||||
|
|
|
|||
|
|
@ -244,13 +244,10 @@ a.mtitle {
|
|||
}
|
||||
|
||||
a.mtitle:hover {
|
||||
// font-size:10px;
|
||||
// color:white;
|
||||
// background-color:#5D90CD;
|
||||
text-decoration:none;
|
||||
display:block;
|
||||
border-style:groove;
|
||||
border-color:gray;
|
||||
background-color:yellow;
|
||||
|
||||
}
|
||||
a.cell {
|
||||
text-decoration:none;
|
||||
|
|
@ -312,4 +309,71 @@ li.menuv,ol.menuv {
|
|||
display:inline;
|
||||
padding:1em 1em;
|
||||
}
|
||||
div.u_redcontent a {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
color: blue;
|
||||
|
||||
}
|
||||
|
||||
div.u_redcontent a:hover {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
color: white;
|
||||
background-color: rgb(93, 144, 205);
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
|
||||
}
|
||||
div.u_content a {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
color: blue;
|
||||
|
||||
}
|
||||
|
||||
div.u_content a:hover {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
color: white;
|
||||
background-color: rgb(93, 144, 205);
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
|
||||
}
|
||||
div.u_redcontent a.mtitle {
|
||||
font-size:10px;
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
color:blue;
|
||||
|
||||
}
|
||||
|
||||
div.u_redcontent a.mtitle:hover {
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
background-color:yellow;
|
||||
|
||||
|
||||
}
|
||||
div.u_content a.mtitle {
|
||||
font-size:10px;
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
color:blue;
|
||||
|
||||
}
|
||||
|
||||
div.u_content a.mtitle:hover {
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
background-color:yellow;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* </style> */
|
||||
|
|
|
|||
|
|
@ -64,10 +64,10 @@ function cmpDate ($p_date,$p_date_oth) {
|
|||
// si $p_date > $p_date_oth return > 0
|
||||
return $l_mkdate-$l2_mkdate;
|
||||
}
|
||||
/*
|
||||
/*!
|
||||
* \brief check if the argument is a number
|
||||
*
|
||||
* \param $p_int
|
||||
* \param $p_int number to test
|
||||
*
|
||||
* \return
|
||||
* - 1 it's a number
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ function ShowActionList($cn,$retour,$h_url)
|
|||
// permit also a search
|
||||
// show detail
|
||||
$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
|
||||
var_dump($_REQUEST);echo '<hr>';
|
||||
|
||||
if ( $sub_action == "" ) $sub_action="list";
|
||||
|
||||
// if correction is asked go to directly to add_action
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
require_once("class_admin.php");
|
||||
$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
|
||||
var_dump($_REQUEST);
|
||||
|
||||
/*! \file
|
||||
* \brief Called from the module "Gestion" to manage the customer
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ require_once("class_fiche.php");
|
|||
*
|
||||
*/
|
||||
|
||||
var_dump($_REQUEST);
|
||||
|
||||
// First we show the menu
|
||||
// If nothing is asked the propose a blank form
|
||||
// to enter a new invoice
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ where
|
|||
<th>Nom</th>
|
||||
<th>Adresse</th>
|
||||
<th>Solde</th>
|
||||
<th>Action </th>
|
||||
<th colspan="3">Action </th>
|
||||
</TR>';
|
||||
if ( sizeof ($step_client ) == 0 )
|
||||
return $r;
|
||||
|
|
@ -246,14 +246,14 @@ where
|
|||
$r.=sprintf('<TD align="right"> %15.2f€</TD>',$a['solde']);
|
||||
$r.="<TD>";
|
||||
|
||||
$r.=sprintf('<A HREF="%s?p_action=contact&qcode=%s&url=%s" title="Contact">C</A> - ',
|
||||
$r.=sprintf('<A HREF="%s?p_action=contact&qcode=%s&url=%s" title="Contact">Contact</A></td>',
|
||||
$script,$client->strAttribut(ATTR_DEF_QUICKCODE),$url);
|
||||
$r.=sprintf('<A HREF="%s?p_action=suivi_courrier&sa=list&qcode=%s&url=%s" title="Action">A</A> - ',
|
||||
$r.=sprintf('<td><A HREF="%s?p_action=suivi_courrier&sa=list&qcode=%s&url=%s" title="Action">Courrier</A></td> ',
|
||||
$script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$url);
|
||||
|
||||
|
||||
|
||||
$r.='<A HREF="commercial.php?p_action=facture&sa=list&qcode='.$client->strAttribut(ATTR_DEF_QUICKCODE).'&url='.$url.'" title="Historique Facture">F</A> -';
|
||||
$r.='<td><A HREF="commercial.php?p_action=facture&sa=list&qcode='.$client->strAttribut(ATTR_DEF_QUICKCODE).'&url='.$url.'" title="Historique Facture">Facture</A></td>';
|
||||
|
||||
$r.='</TD>';
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class Document
|
|||
echo_debug('class_action',__LINE__,"Dirname is $dirname");
|
||||
// Retrieve the lob and save it into $dirname
|
||||
StartSql($this->db);
|
||||
$dm_info="select md_lob,md_filename,md_mimetype
|
||||
$dm_info="select md_type,md_lob,md_filename,md_mimetype
|
||||
from document_modele where md_id=".$this->md_id;
|
||||
$Res=ExecSql($this->db,$dm_info);
|
||||
|
||||
|
|
@ -76,28 +76,31 @@ class Document
|
|||
chdir($dirname);
|
||||
$filename=$row['md_filename'];
|
||||
pg_lo_export($this->db,$row['md_lob'],$filename);
|
||||
|
||||
$type="n";
|
||||
echo_debug('class_document',__LINE__,'The document type is '.$row['md_mimetype']);
|
||||
// if the doc is a OOo, we need to unzip it first
|
||||
// and the name of the file to change is always content.xml
|
||||
if ( substr($row['md_mimetype'],'vnd.oasis') != 0 )
|
||||
if ( strpos($row['md_mimetype'],'vnd.oasis') != 0 )
|
||||
{
|
||||
echo_debug('class_document',__LINE__,'Unzip the OOo');
|
||||
system("unzip ".$filename);
|
||||
// Remove the file we do not need anymore
|
||||
unlink($filename);
|
||||
$file_to_parse="content.xml";
|
||||
$type="OOo";
|
||||
}
|
||||
else
|
||||
$file_to_parse=$filename;
|
||||
// affect a number
|
||||
$this->d_number=NextSequence($this->db,"seq_doc_type_".$this->md_id);
|
||||
$this->d_number=NextSequence($this->db,"seq_doc_type_".$row['md_type']);
|
||||
|
||||
|
||||
// parse the document - return the doc number ?
|
||||
$this->ParseDocument($dirname,$file_to_parse);
|
||||
$this->ParseDocument($dirname,$file_to_parse,$type);
|
||||
|
||||
Commit($this->db);
|
||||
// if the doc is a OOo, we need to re-zip it
|
||||
if ( substr($row['md_mimetype'],'vnd.oasis') != 0 )
|
||||
if ( strpos($row['md_mimetype'],'vnd.oasis') != 0 )
|
||||
{
|
||||
system ("zip -r ".$filename." *");
|
||||
$file_to_parse=$filename;
|
||||
|
|
@ -121,11 +124,12 @@ class Document
|
|||
*
|
||||
* \param $p_dir directory name
|
||||
* \param $p_file filename
|
||||
* \param $p_type For the OOo document the tag are < and > instead of < and >
|
||||
*/
|
||||
function ParseDocument($p_dir,$p_file)
|
||||
function ParseDocument($p_dir,$p_file,$p_type)
|
||||
{
|
||||
|
||||
|
||||
echo_debug('class_document',__LINE__,'Begin parsing of '.$p_dir.' '.$p_file.'Type = '.$p_type);
|
||||
|
||||
/*!\note Replace in the doc the tags by their values.
|
||||
* - MY_* table parameter
|
||||
|
|
@ -150,6 +154,19 @@ class Document
|
|||
echo "ne peut pas ouvrir le fichier de sortie";
|
||||
exit();
|
||||
}
|
||||
// compute the regex
|
||||
if ( $p_type=='OOo')
|
||||
{
|
||||
$regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
|
||||
$lt="<";
|
||||
$gt=">";
|
||||
}
|
||||
else
|
||||
{
|
||||
$regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
|
||||
$lt="<";
|
||||
$gt=">";
|
||||
}
|
||||
//read the file
|
||||
while(! feof($h))
|
||||
{
|
||||
|
|
@ -157,25 +174,30 @@ class Document
|
|||
$buffer=fgets($h);
|
||||
// search in the buffer the magic << and >>
|
||||
// while ereg finds something to replace
|
||||
while ( ereg ("<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>",$buffer,$f) )
|
||||
while ( ereg ($regex,$buffer,$f) )
|
||||
{
|
||||
|
||||
echo_debug('class_document',__LINE__,var_export( $f,true));
|
||||
echo_debug('class_document',__LINE__,'var_export '.var_export( $f,true));
|
||||
foreach ( $f as $pattern )
|
||||
{
|
||||
echo_debug('class_document',__LINE__, "pattern");
|
||||
echo_debug('class_document',__LINE__, var_export($pattern,true));
|
||||
$to_remove=$pattern;
|
||||
// we remove the < and > from the pattern
|
||||
$pattern=str_replace('<','',$pattern);
|
||||
$pattern=str_replace('>','',$pattern);
|
||||
$pattern=str_replace($lt,'',$pattern);
|
||||
$pattern=str_replace($gt,'',$pattern);
|
||||
|
||||
|
||||
// if the pattern if found we replace it
|
||||
$value=$this->Replace($pattern);
|
||||
// replace into the $buffer
|
||||
$buffer=str_replace($to_remove,$value,$buffer);
|
||||
echo_debug('class_document',__LINE__, $buffer);
|
||||
// take the position in the buffer
|
||||
$pos=strpos($buffer,$to_remove);
|
||||
// get the length of the string to remove
|
||||
$len=strlen($to_remove);
|
||||
$buffer=substr_replace($buffer,$value,$pos,$len);
|
||||
|
||||
// echo_debug('class_document',__LINE__, $buffer);
|
||||
// if the pattern if found we replace it
|
||||
echo_debug('class_document',__LINE__,"Transform $pattern by $value");
|
||||
}
|
||||
|
|
@ -234,7 +256,7 @@ class Document
|
|||
// Start Transaction
|
||||
StartSql($this->db);
|
||||
$new_name=tempnam('/tmp','doc_');
|
||||
var_dump($_FILES);
|
||||
|
||||
// nothing to save
|
||||
if ( sizeof($_FILES) == 0 ) return;
|
||||
// check if a file is submitted
|
||||
|
|
@ -403,6 +425,19 @@ class Document
|
|||
$my=new own($this->db);
|
||||
$r=$my->MY_NUMBER;
|
||||
break;
|
||||
case 'MY_TEL':
|
||||
$my=new own($this->db);
|
||||
$r=$my->MY_TEL;
|
||||
break;
|
||||
case 'MY_FAX':
|
||||
$my=new own($this->db);
|
||||
$r=$my->MY_FAX;
|
||||
break;
|
||||
case 'MY_PAYS':
|
||||
$my=new own($this->db);
|
||||
$r=$my->MY_PAYS;
|
||||
break;
|
||||
|
||||
// customer
|
||||
/*\note The CUST_* are retrieved thx the $_REQUEST['tiers']
|
||||
* which contains the quick_code
|
||||
|
|
@ -483,14 +518,22 @@ class Document
|
|||
$r=${$id};
|
||||
break;
|
||||
|
||||
case 'VEN_ART_TVA_CODE':
|
||||
case 'TVA_CODE':
|
||||
extract ($_POST);
|
||||
$id='e_march'.$counter.'_tva_id';
|
||||
if ( !isset (${$id}) ) return "";
|
||||
if ( ${$id} == -1 ) return "";
|
||||
$qt='e_quant'.$counter;
|
||||
$price='e_march'.$counter.'_sell' ;
|
||||
if ( ${$price} == 0 || ${$qt} == 0
|
||||
|| strlen(trim( $price )) ==0
|
||||
|| strlen(trim($qt)) ==0)
|
||||
return "";
|
||||
|
||||
$r=${$id};
|
||||
break;
|
||||
|
||||
case 'VEN_ART_TVA_LABEL':
|
||||
case 'TVA_LABEL':
|
||||
extract ($_POST);
|
||||
$id='e_march'.$counter.'_tva_id';
|
||||
if ( !isset (${$id}) ) return "";
|
||||
|
|
@ -500,19 +543,22 @@ class Document
|
|||
break;
|
||||
|
||||
|
||||
case 'VEN_ART_TVA_AMOUNT':
|
||||
case 'TVA_AMOUNT':
|
||||
extract ($_POST);
|
||||
$qt='e_quant'.$counter;
|
||||
$price='e_march'.$counter.'_sell' ;
|
||||
$tva='e_march'.$counter.'_tva_id';
|
||||
if ( !isset (${'e_march'.$counter}) ) return "";
|
||||
// check that something is sold
|
||||
if ( ${'e_march'.$counter.'_sell'} == 0 && ${'e_quant'.$counter} == 0 )
|
||||
if ( ${$price} == 0 || ${$qt} == 0
|
||||
|| strlen(trim( $price )) ==0
|
||||
|| strlen(trim($qt)) ==0)
|
||||
return "";
|
||||
$a_tva=GetTvaRate($this->db,${$tva});
|
||||
echo_debug('class_document',__LINE__,'Tva :'.var_export($a_tva,true));
|
||||
// if no vat returns 0
|
||||
if ( $a_tva == null || $a_tva == 0 ) return 0;
|
||||
$r=round($price,2)*$qt*$a_tva['tva_rate'];
|
||||
if ( sizeof($a_tva) == 0 ) return "";
|
||||
$r=round(${$price},2)*${$qt}*$a_tva['tva_rate'];
|
||||
$r=round($r,2);
|
||||
break;
|
||||
|
||||
|
|
@ -521,7 +567,10 @@ class Document
|
|||
$id='e_quant'.$counter;
|
||||
if ( !isset (${$id}) ) return "";
|
||||
// check that something is sold
|
||||
if ( ${'e_march'.$counter.'_sell'} == 0 && ${'e_quant'.$counter} == 0 )
|
||||
if ( ${'e_march'.$counter.'_sell'} == 0
|
||||
|| ${'e_quant'.$counter} == 0
|
||||
|| strlen(trim( ${'e_march'.$counter.'_sell'} )) ==0
|
||||
|| strlen(trim(${'e_quant'.$counter})) ==0 )
|
||||
return "";
|
||||
$r=${$id};
|
||||
break;
|
||||
|
|
@ -530,8 +579,12 @@ class Document
|
|||
extract ($_POST);
|
||||
$id='e_march'.$counter.'_sell' ;
|
||||
$quant='e_quant'.$counter;
|
||||
if ( !isset (${$id}) ) return "";
|
||||
|
||||
// check that something is sold
|
||||
if ( ${'e_march'.$counter.'_sell'} == 0 && ${'e_quant'.$counter} == 0 )
|
||||
if ( ${'e_march'.$counter.'_sell'} == 0 || ${'e_quant'.$counter} == 0
|
||||
|| strlen(trim( ${'e_march'.$counter.'_sell'} )) ==0
|
||||
|| strlen(trim(${'e_quant'.$counter})) ==0)
|
||||
return "";
|
||||
/*!\todo verify that price and quant are numeric
|
||||
*/
|
||||
|
|
@ -545,8 +598,11 @@ class Document
|
|||
extract ($_POST);
|
||||
$id='e_march'.$counter.'_sell' ;
|
||||
$quant='e_quant'.$counter;
|
||||
// if it is exist
|
||||
if ( ! isset(${$id}))
|
||||
return "";
|
||||
// check that something is sold
|
||||
if ( ${'e_march'.$counter.'_sell'} == 0 && ${'e_quant'.$counter} == 0 )
|
||||
if ( ${'e_march'.$counter.'_sell'} == 0 || ${'e_quant'.$counter} == 0 )
|
||||
return "";
|
||||
/*!\todo verify that price and quant are numeric
|
||||
*/
|
||||
|
|
@ -557,15 +613,31 @@ class Document
|
|||
// if there is no vat we return now
|
||||
if ( $tva == null || $tva == 0 ) return $r;
|
||||
// we compute with the vat included
|
||||
$r=$r+$tva['tva_rate'];
|
||||
$r=$r+$r*$tva['tva_rate'];
|
||||
$r=round($r,2);
|
||||
break;
|
||||
case 'TOTAL_VEN_HTVA':
|
||||
extract($_POST);
|
||||
echo_debug('class_document',__LINE__,'TOTAL_VEN_TVA item :'.$nb_item);
|
||||
|
||||
$sum=0.0;
|
||||
for ($i=0;$i<$nb_item;$i++)
|
||||
{
|
||||
$sum+=${'e_march'.$i.'_sell'}*$e{'e_quant'.$i};
|
||||
$sell='e_march'.$i.'_sell';
|
||||
$qt='e_quant'.$i;
|
||||
echo_debug('class_document',__LINE__,'sell :'.$sell.' qt = '.$qt);
|
||||
|
||||
echo_debug('class_document',__LINE__,'counter :'.$i.' sur '.$nb_item);
|
||||
if ( ! isset (${$sell}) ) break;
|
||||
echo_debug('class_document',__LINE__,'sell :'.${$sell}.' qt = '.${$qt});
|
||||
|
||||
if ( strlen(trim(${$sell})) == 0 ||
|
||||
strlen(trim(${$qt})) == 0 ||
|
||||
${$qt}==0 || ${$sell}==0)
|
||||
continue;
|
||||
$sum+=${$sell}*${$qt};
|
||||
echo_debug('class_document',__LINE__,'sum :'.$sum);
|
||||
|
||||
}
|
||||
$r=round($sum,2);
|
||||
break;
|
||||
|
|
@ -576,7 +648,13 @@ class Document
|
|||
{
|
||||
$tva=GetTvaRate($this->db,${'e_march'.$i.'_tva_id'});
|
||||
$tva_rate=( $tva == null || $tva == 0 )?0.0:$tva['tva_rate'];
|
||||
$sum+=${'e_march'.$i.'_sell'}*${'e_quant'.$i}*(1+$tva_rate);
|
||||
echo_debug('class_document',__LINE__,' :'.$i.' sur '.$nb_item);
|
||||
$sell=${'e_march'.$i.'_sell'};
|
||||
$qt=${'e_quant'.$i};
|
||||
echo_debug('class_document',__LINE__,'sell :'.$sell.' qt = '.$qt);
|
||||
|
||||
$sum+=$sell*$qt*(1+$tva_rate);
|
||||
// $sum+=${'e_march'.$i.'_sell'}*${'e_quant'.$i}*(1+$tva_rate);
|
||||
}
|
||||
$r=round($sum,2);
|
||||
|
||||
|
|
|
|||
|
|
@ -125,9 +125,11 @@ class Document_modele {
|
|||
$this->md_sequence="document_".NextSequence($this->cn,"document_seq");
|
||||
// if start is not equal to 0 and he's a number than the user
|
||||
// request a number change
|
||||
echo_debug('class_document_modele',__LINE__, "this->start ".$this->start." a number ".isNumber($this->start));
|
||||
|
||||
if ( $this->start != 0 && isNumber($this->start) == 1 )
|
||||
{
|
||||
$sql="alter sequence seq_doc_type_".$this->md_type." start with ".$this->start;
|
||||
$sql="alter sequence seq_doc_type_".$this->md_type." restart ".$this->start;
|
||||
ExecSql($this->cn,$sql);
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +161,6 @@ class Document_modele {
|
|||
pg_lo_unlink($this->cn,$old_oid);
|
||||
}
|
||||
// Load new document
|
||||
var_dump($_FILES);
|
||||
ExecSql($this->cn,"update document_modele set md_lob=".$oid.", md_mimetype='".$_FILES['doc']['type']."' ,md_filename='".$_FILES['doc']['name']."' where md_id=".$this->md_id);
|
||||
Commit($this->cn);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,10 @@ class Own {
|
|||
$this->UpdateRow('MY_STREET');
|
||||
$this->UpdateRow('MY_NUMBER');
|
||||
$this->UpdateRow('MY_CP');
|
||||
$this->UpdateRow('MY_TEL');
|
||||
$this->UpdateRow('MY_PAYS');
|
||||
$this->UpdateRow('MY_COMMUNE');
|
||||
$this->UpdateRow('MY_FAX');
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class Supplier extends fiche{
|
|||
<th>Nom</th>
|
||||
<th>Adresse</th>
|
||||
<th>Solde</th>
|
||||
<th>Action </th>
|
||||
<th colspan="3">Action </th>
|
||||
</TR>';
|
||||
if ( sizeof ($step_supplier ) == 0 )
|
||||
return $r;
|
||||
|
|
@ -132,16 +132,16 @@ class Supplier extends fiche{
|
|||
$post=new poste($this->cn,$supplier->strAttribut(ATTR_DEF_ACCOUNT));
|
||||
$a=$post->GetSoldeDetail();
|
||||
$r.=sprintf('<TD align="right"> %15.2f€</TD>',$a['solde']);
|
||||
$r.="<TD>";
|
||||
|
||||
$r.=sprintf('<A HREF="%s?p_action=contact&qcode=%s&url=%s" title="Contact">C</A> - ',
|
||||
|
||||
$r.=sprintf('<td><A HREF="%s?p_action=contact&qcode=%s&url=%s" title="Contact">Contact</A></td>',
|
||||
$script,$supplier->strAttribut(ATTR_DEF_QUICKCODE),$url);
|
||||
$r.=sprintf('<A HREF="%s?p_action=suivi_courrier&sa=list&qcode=%s&url=%s" title="Action">A</A> - ',
|
||||
$r.=sprintf('<td><A HREF="%s?p_action=suivi_courrier&sa=list&qcode=%s&url=%s" title="Action">Courrier</A></td> ',
|
||||
$script,$supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$url);
|
||||
|
||||
|
||||
|
||||
$r.='<A HREF="commercial.php?p_action=depense&sa=list&qcode='.$supplier->strAttribut(ATTR_DEF_QUICKCODE).'&url='.$url.'" title="Historique Facture">F</A> -';
|
||||
$r.='<td><A HREF="commercial.php?p_action=depense&sa=list&qcode='.$supplier->strAttribut(ATTR_DEF_QUICKCODE).'&url='.$url.'" title="Historique Facture">Facture</A></td>';
|
||||
|
||||
$r.='</TD>';
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
require_once("class_customer.php");
|
||||
$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
|
||||
var_dump($_REQUEST);
|
||||
|
||||
/*! \file
|
||||
* \brief Called from the module "Gestion" to manage the customer
|
||||
*/
|
||||
|
|
@ -129,15 +129,6 @@ if ( $sub_action == "list" )
|
|||
// echo '<div style="position:absolute;left:15%;width:67%;margin-top:20px;">';
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $client->Summary($search);
|
||||
echo '</div>';
|
||||
echo '<div style="position:absolute;right:1%;width:10%;color:blue;background-color:lightgrey;margin-top:10px;">';
|
||||
echo "<strong>Action :</strong> Ajout, mise à jour ou effacement";
|
||||
echo " <ul>";
|
||||
echo "<li>C - Contact</li>";
|
||||
echo "<li>F - Facture</li>";
|
||||
echo "<li>FC - Courrier</li>";
|
||||
echo "</ul>";
|
||||
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
define ("phpcompta_password","dany");
|
||||
define ("domaine","");
|
||||
define ("domaine","test_");
|
||||
|
||||
define ("DEBUG","true");
|
||||
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ require_once('class_widget.php');
|
|||
*/
|
||||
|
||||
$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
|
||||
var_dump($_REQUEST);
|
||||
|
||||
// if this page is called from another menu (customer, supplier,...)
|
||||
// a button back is added
|
||||
// TODO add function for generating url, hidden tags...
|
||||
if ( isset ($_REQUEST['url']))
|
||||
{
|
||||
$retour=sprintf('<A HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
|
||||
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
|
||||
$h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
|
||||
}
|
||||
else
|
||||
|
|
@ -156,9 +156,11 @@ if ( $sub_action == "list" )
|
|||
{
|
||||
$contact->company=$qcode;
|
||||
}
|
||||
echo $retour;
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $contact->Summary($search);
|
||||
echo '</div>';
|
||||
echo $retour;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ require_once("class_fiche.php");
|
|||
*
|
||||
*/
|
||||
|
||||
var_dump($_REQUEST);
|
||||
|
||||
// First we show the menu
|
||||
// If nothing is asked the propose a blank form
|
||||
// to enter a new invoice
|
||||
|
|
|
|||
|
|
@ -24,10 +24,8 @@
|
|||
|
||||
require_once("class_document_modele.php");
|
||||
$sub_action=(isset ($_REQUEST['sa']))?$_REQUEST['sa']:"";
|
||||
var_dump($_REQUEST);
|
||||
echo "<hr>";
|
||||
// echo ShowMenuDocument();
|
||||
|
||||
echo "<hr>";
|
||||
// show the form for adding a template
|
||||
//
|
||||
$doc=new Document_modele($cn);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ require_once("class_fiche.php");
|
|||
*
|
||||
*/
|
||||
|
||||
var_dump($_REQUEST);
|
||||
|
||||
// First we show the menu
|
||||
// If nothing is asked the propose a blank form
|
||||
// to enter a new invoice
|
||||
|
|
@ -46,7 +46,7 @@ $h_url="";
|
|||
|
||||
if ( isset ($_REQUEST['url']))
|
||||
{
|
||||
$retour=sprintf('<A HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
|
||||
$retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
|
||||
$h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ if ( $sub_action == "list")
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
echo $retour;
|
||||
echo '<div class="u_redcontent">';
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -421,19 +421,23 @@ function ViewFiche($p_cn,$p_type) {
|
|||
$Max=pg_NumRows($Res);
|
||||
echo $bar;
|
||||
|
||||
echo '<table>';
|
||||
for ( $i = 0; $i < $Max; $i++) {
|
||||
$l_line=pg_fetch_array($Res,$i);
|
||||
$div="<DIV>";
|
||||
$span_mod='<span class="mtitle"><A class="mtitle2" href="fiche.php?action=detail&fiche_id='.$l_line['f_id'].'"> Modifie</A></SPAN>';
|
||||
$span_del='<span class="mtitle2" ALIGN="left">'.
|
||||
'<A class="mtitle2" href="fiche.php?f_fd_id='.$p_type.'&action=delete&fiche_id='.$l_line['f_id'].
|
||||
'"> delete</A></SPAN>';
|
||||
$span_id='<SPAN style="background-color:lightgrey;">'.$l_line['j_qcode']."</SPAN>";
|
||||
if ( $i %2 == 0 )
|
||||
$div='<DIV style="background-color:#DDE6FF;">';
|
||||
echo $div.$span_del.' '.' '.' '.' '.' '.' '.
|
||||
$span_mod." "." "." ".$span_id." "." "." ".$l_line['av_text']."</DIV>";
|
||||
if ( $i%2 == 0)
|
||||
echo '<TR class="odd">';
|
||||
else
|
||||
echo '<TR class="even">';
|
||||
|
||||
$span_mod='<TD><A href="fiche.php?action=detail&fiche_id='.$l_line['f_id'].'">'.$l_line['j_qcode'].'</A></TD>';
|
||||
$span_del='<TD>'.
|
||||
'<A href="fiche.php?f_fd_id='.$p_type.'&action=delete&fiche_id='.$l_line['f_id'].
|
||||
'"> delete</A></td>';
|
||||
|
||||
echo $span_del.$span_mod.'<TD>'.$l_line['av_text']."</TD>";
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
echo '<FORM METHOD="POST" action="fiche.php">';
|
||||
echo '<INPUT TYPE="HIDDEN" name="fiche" value="'.$p_type.'">';
|
||||
echo '<INPUT TYPE="SUBMIT" name="add" Value="Ajout fiche">';
|
||||
|
|
@ -672,15 +676,14 @@ function EncodeModele($p_js)
|
|||
***************************************************
|
||||
* \brief Creation of a model of card or correction
|
||||
*
|
||||
* parm :
|
||||
* - $p_cn database connection
|
||||
* - $p_ligne number of lines
|
||||
* - $p_array array
|
||||
* - $p_js class base (javascript code)
|
||||
* gen :
|
||||
* - none
|
||||
* return:
|
||||
* - nothing
|
||||
*
|
||||
* \param $p_cn database connection
|
||||
* \param $p_ligne number of lines
|
||||
* \param $p_array array
|
||||
* \param $p_js class base (javascript code)
|
||||
*
|
||||
* \return nothing
|
||||
*
|
||||
*
|
||||
*/
|
||||
function DefModele ($p_cn,$p_js,$p_array=null,$p_ligne=1)
|
||||
|
|
@ -707,7 +710,7 @@ function DefModele ($p_cn,$p_js,$p_array=null,$p_ligne=1)
|
|||
$display.='<TD><INPUT TYPE="INPUT" NAME="class_base"> '.$p_js;
|
||||
$display.='</TD></TR>';
|
||||
// Checkbox for the creation of a post
|
||||
$display.='<TR><TD> <INPUT TYPE="CHECKBOX" NAME="create" UNCHECKED>Create accounts for each</TD></TR>';
|
||||
$display.='<TR><TD> <INPUT TYPE="CHECKBOX" NAME="create" CHECKED>Create accounts for each</TD></TR>';
|
||||
|
||||
//display the different template
|
||||
$ref=Get_fiche_def_ref($p_cn);
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ function GetPriv($p_dossier,$p_login)
|
|||
/*!
|
||||
* \brief Get the number of rows
|
||||
* from table jnt_use_dos where $p_dossier = dos_id and
|
||||
* use_id=$p_user
|
||||
* use_id=$p_user.
|
||||
*/
|
||||
function ExisteJnt($p_dossier,$p_user)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
require_once("class_supplier.php");
|
||||
$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
|
||||
var_dump($_REQUEST);
|
||||
|
||||
/*! \file
|
||||
* \brief Called from the module "Gestion" to manage the customer
|
||||
*/
|
||||
|
|
@ -129,15 +129,6 @@ if ( $sub_action == "list" )
|
|||
// echo '<div style="position:absolute;left:15%;width:67%;margin-top:20px;">';
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $sup->Summary($search);
|
||||
echo '</div>';
|
||||
echo '<div style="position:absolute;right:1%;width:10%;color:blue;background-color:lightgrey;margin-top:10px;">';
|
||||
echo "<strong>Action :</strong> Ajout, mise à jour ou effacement";
|
||||
echo " <ul>";
|
||||
echo "<li>C - Contact</li>";
|
||||
echo "<li>F - Facture</li>";
|
||||
echo "<li>FC - Courrier</li>";
|
||||
echo "</ul>";
|
||||
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ echo 'P
|
|||
list ($id) = sscanf ($name,"rd_paid%d");
|
||||
|
||||
if ( $id == null ) continue;
|
||||
echo "Mise à jour $id";
|
||||
|
||||
$paid=($paid=='on')?'paid':'';
|
||||
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ echo 'P
|
|||
list ($id) = sscanf ($name,"rd_paid%d");
|
||||
|
||||
if ( $id == null ) continue;
|
||||
echo "Mise ŕ jour $id";
|
||||
|
||||
$paid=($paid=='on')?'paid':'';
|
||||
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
|
@ -311,7 +311,7 @@ if ( $action == 'voir_jrn_non_paye' ) {
|
|||
echo $hid->IOValue();
|
||||
|
||||
|
||||
echo $list;
|
||||
|
||||
if ( $m != 0 )
|
||||
echo $hid->Submit('paid','Mise à jour paiement');
|
||||
|
||||
|
|
|
|||
|
|
@ -684,22 +684,20 @@ function VerifyOperationDate($p_cn,$p_periode,$p_date) {
|
|||
return $p_date;
|
||||
}
|
||||
|
||||
/*! InsertRapt($p_cn,$jr_id,$jr_id2)
|
||||
/*!
|
||||
**************************************************
|
||||
*\brief Insert into jrn_rapt the concerned operations
|
||||
*
|
||||
* parm :
|
||||
* - p_cn database connection
|
||||
* - jr_id (jrn.jr_id) => jrn_rapt.jr_id
|
||||
* - jr_id2 (jrn.jr_id) => jrn_rapt.jra_concerned
|
||||
* gen :
|
||||
* - none
|
||||
* return:
|
||||
* - none
|
||||
*
|
||||
* \param $p_cn database connection
|
||||
* \param $jr_id (jrn.jr_id) => jrn_rapt.jr_id
|
||||
* \param $jr_id2 (jrn.jr_id) => jrn_rapt.jra_concerned
|
||||
*
|
||||
* \return none
|
||||
*
|
||||
*/
|
||||
function InsertRapt($p_cn,$jr_id,$jr_id2) {
|
||||
if ( isNumber($jr_id) == 0 or
|
||||
isNumber($jr_id2) == 0 )
|
||||
if ( isNumber($jr_id) == 0 || isNumber($jr_id2) == 0 )
|
||||
{
|
||||
echo_error(" InsertRapt : invalid jr_id $jr_id, jr_id2 $jr_id2");
|
||||
echo_debug('user_common.php',__LINE__," InsertRapt : invalid jr_id $jr_id, jr_id2 $jr_id2");
|
||||
|
|
@ -720,13 +718,11 @@ function InsertRapt($p_cn,$jr_id,$jr_id2) {
|
|||
*\brief Insert into jrn_rapt the concerned operations
|
||||
*
|
||||
* parm :
|
||||
* - p_cn database connection
|
||||
* - jr_id (jrn.jr_id) => jrn_rapt.jr_id
|
||||
* - jr_id2 (jrn.jr_id) => jrn_rapt.jra_concerned
|
||||
* gen :
|
||||
* - none
|
||||
* return:
|
||||
* - none
|
||||
* \param $p_cn database connection
|
||||
* \param $jr_id (jrn.jr_id) => jrn_rapt.jr_id
|
||||
* \param $jr_id2 (jrn.jr_id) => jrn_rapt.jra_concerned
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
function DeleteRapt($p_cn,$jr_id,$jr_id2) {
|
||||
echo_debug('user_common.php',__LINE__,"DeleteRapt($p_cn,$jr_id,$jr_id2) ");
|
||||
|
|
@ -899,7 +895,7 @@ function jrn_navigation_bar($p_offset,$p_line,$p_size=0,$p_page=1)
|
|||
$step=$_SESSION['g_pagesize'];
|
||||
$offset=($e-1)*$step;
|
||||
|
||||
$r='<A class="one" href="'.$_SERVER['PHP_SELF']."?".$url."&offset=$offset&step=$step&page=$e&size=$step".'">';
|
||||
$r='<A class="mtitle" href="'.$_SERVER['PHP_SELF']."?".$url."&offset=$offset&step=$step&page=$e&size=$step".'">';
|
||||
$r.="Précédent";
|
||||
$r.="</A> ";
|
||||
}
|
||||
|
|
@ -911,7 +907,7 @@ function jrn_navigation_bar($p_offset,$p_line,$p_size=0,$p_page=1)
|
|||
$step=$_SESSION['g_pagesize'];
|
||||
$offset=($e-1)*$step;
|
||||
$go=sprintf($_SERVER['PHP_SELF']."?".$url."&offset=$offset&step=$step&page=$e&size=$step");
|
||||
$r.=sprintf('<A HREF="%s" CLASS="one">%d</A> ',$go,$e);
|
||||
$r.=sprintf('<A class="mtitle" HREF="%s" CLASS="one">%d</A> ',$go,$e);
|
||||
} else {
|
||||
$r.="<b> $e </b>";
|
||||
} //else
|
||||
|
|
@ -926,7 +922,7 @@ function jrn_navigation_bar($p_offset,$p_line,$p_size=0,$p_page=1)
|
|||
$step=$_SESSION['g_pagesize'];
|
||||
$offset=($e-1)*$step;
|
||||
|
||||
$r.=' <A class="one" href="'.$_SERVER['PHP_SELF']."?".$url."&offset=$offset&step=$step&page=$e&size=$step".'">';
|
||||
$r.=' <A class="mtitle" href="'.$_SERVER['PHP_SELF']."?".$url."&offset=$offset&step=$step&page=$e&size=$step".'">';
|
||||
$r.="Suivant";
|
||||
$r.="</A>";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -820,7 +820,7 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
|
|||
if ( $r == false ) { Rollback($p_cn); exit(" Error 'user_form_ach.php' __LINE__");}
|
||||
// Set Internal code and Comment
|
||||
$internal=SetInternalCode($p_cn,$seq,$p_jrn);
|
||||
$comment=(FormatString($e_comm) == null )?$internal." client : ".GetFicheName($p_cn,$e_client):FormatString($e_comm);
|
||||
$comment=(FormatString($e_comm) == null )?$internal." Fournisseur : ".GetFicheName($p_cn,$e_client):FormatString($e_comm);
|
||||
|
||||
// Update and set the invoice's comment
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ function RecordFin($p_cn,$p_array,$p_user,$p_jrn) {
|
|||
|
||||
// Set Internal code and Comment
|
||||
$internal_code=SetInternalCode($p_cn,$seq,$p_jrn);
|
||||
$comment=$internal_code." client : ".GetFicheName($p_cn,$e_bank_account);
|
||||
$comment=$internal_code." compte : ".GetFicheName($p_cn,$e_bank_account);
|
||||
if ( FormatString(${"e_other$i"."_comment"}) == null ) {
|
||||
// Update comment if comment is blank
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ function u_ShowDossier($p_user,$p_admin)
|
|||
$p_array=GetAvailableFolder($p_user,$p_admin);
|
||||
if ( $p_array == 0 ) return " * Aucun dossier *";
|
||||
$result="";
|
||||
$result.="<table>";
|
||||
$result.="<table border=\"0\">";
|
||||
$result.='<TR>';
|
||||
if ( $p_admin == 1 ) {
|
||||
$result.="<TD><A class=\"mtitle\" HREF=\"admin_repo.php\"> Administration : </A></TD>";
|
||||
$result.="<TD class=\"mtitle\" ><A class=\"mtitle\" HREF=\"admin_repo.php\"> Administration </A></TD>";
|
||||
}
|
||||
$result.='<TD><A HREF="logout.php" CLASS="mtitle">: Sortir</a></TD>';
|
||||
$result.='<TD class="mtitle" ><A class="mtitle" HREF="logout.php" > Sortir</a></TD>';
|
||||
$result.="</TR>";
|
||||
$result.="</table>";
|
||||
$result.="<TABLE>";
|
||||
|
|
@ -647,12 +647,12 @@ function MenuJrn($p_dossier)
|
|||
function ShowMenuPcmn($p_start=1)
|
||||
{
|
||||
echo '<TABLE>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=1">1 Immobilisé </A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=2">2 Actif a un an au plus</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=3">3 Stock et commande</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=4">4 Compte tiers</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=1">1 Immobilisé </A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=2">2 Actif a un an au plus</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=3">3 Stock et commande</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=4">4 Compte tiers</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=5">5 Actif</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=6">6 Charges</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=6">6 Charges</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=7">7 Produits</A></TD></TR>';
|
||||
echo "</TABLE>";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/bash
|
||||
# clean all phpcompta related DB.
|
||||
|
||||
dropdb -U phpcompta -h localhost account_repository
|
||||
dropdb -U phpcompta -h localhost dossier1
|
||||
dropdb -U phpcompta -h localhost dossier13
|
||||
dropdb -U phpcompta -h localhost mod1
|
||||
dropdb -U phpcompta -h localhost mod2
|
||||
dropdb -U phpcompta -h localhost test_account_repository
|
||||
dropdb -U phpcompta -h localhost test_dossier1
|
||||
dropdb -U phpcompta -h localhost test_dossier13
|
||||
dropdb -U phpcompta -h localhost test_mod1
|
||||
dropdb -U phpcompta -h localhost test_mod2
|
||||
|
||||
|
|
|
|||
533
sql/upgrade.sql
533
sql/upgrade.sql
|
|
@ -1,530 +1,3 @@
|
|||
-- dropped all the views
|
||||
-- Name: vw_client; Type: VIEW; Schema: public; Owner: phpcompta
|
||||
DROP VIEW vw_client ;
|
||||
-- Name: vw_fiche_attr; Type: VIEW; Schema: public; Owner: phpcompta
|
||||
DROP VIEW vw_fiche_attr ;
|
||||
-- Name: vw_fiche_def; Type: VIEW; Schema: public; Owner: phpcompta
|
||||
DROP VIEW vw_fiche_def ;
|
||||
-- Name: vw_fiche_min; Type: VIEW; Schema: public; Owner: phpcompta
|
||||
DROP VIEW vw_fiche_min ;
|
||||
-- Name: vw_poste_qcode; Type: VIEW; Schema: public; Owner: phpcompta
|
||||
DROP VIEW vw_poste_qcode;
|
||||
|
||||
-- Stan's problem : account were not large enough
|
||||
-- Converted to numeric to avoid integer limit
|
||||
create domain poste_comptable as numeric(25);
|
||||
alter table tmp_pcmn alter pcm_val type poste_comptable;
|
||||
alter table tmp_pcmn alter pcm_val_parent type poste_comptable;
|
||||
alter table jrnx alter j_poste TYPE poste_comptable ;
|
||||
alter table centralized alter c_poste TYPE poste_comptable ;
|
||||
alter table fiche_def alter fd_class_base TYPE poste_comptable ;
|
||||
|
||||
-- recreate all the views
|
||||
CREATE VIEW vw_client AS
|
||||
SELECT a.f_id, a.av_text AS name, a1.av_text AS quick_code, b.av_text AS tva_num, c.av_text AS poste_comptable, d.av_text AS rue, e.av_text AS code_postal, f.av_text AS pays, g.av_text AS telephone, h.av_text AS email FROM (((((((((SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text FROM ((((fiche JOIN fiche_def USING (fd_id)) JOIN fiche_def_ref USING (frd_id)) JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) WHERE (jnt_fic_att_value.ad_id = 1)) a JOIN (SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text FROM ((((fiche JOIN fiche_def USING (fd_id)) JOIN fiche_def_ref USING (frd_id)) JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) WHERE (jnt_fic_att_value.ad_id = 13)) b USING (f_id)) JOIN (SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text FROM ((((fiche JOIN fiche_def USING (fd_id)) JOIN fiche_def_ref USING (frd_id)) JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) WHERE (jnt_fic_att_value.ad_id = 23)) a1 USING (f_id)) JOIN (SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text FROM ((((fiche JOIN fiche_def USING (fd_id)) JOIN fiche_def_ref USING (frd_id)) JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) WHERE (jnt_fic_att_value.ad_id = 5)) c USING (f_id)) JOIN (SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text FROM ((((fiche JOIN fiche_def USING (fd_id)) JOIN fiche_def_ref USING (frd_id)) JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) WHERE (jnt_fic_att_value.ad_id = 14)) d USING (f_id)) JOIN (SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text FROM ((((fiche JOIN fiche_def USING (fd_id)) JOIN fiche_def_ref USING (frd_id)) JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) WHERE (jnt_fic_att_value.ad_id = 15)) e USING (f_id)) JOIN (SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text FROM ((((fiche JOIN fiche_def USING (fd_id)) JOIN fiche_def_ref USING (frd_id)) JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) WHERE (jnt_fic_att_value.ad_id = 16)) f USING (f_id)) JOIN (SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text FROM ((((fiche JOIN fiche_def USING (fd_id)) JOIN fiche_def_ref USING (frd_id)) JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) WHERE (jnt_fic_att_value.ad_id = 17)) g USING (f_id)) LEFT JOIN (SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text FROM ((((fiche JOIN fiche_def USING (fd_id)) JOIN fiche_def_ref USING (frd_id)) JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) WHERE (jnt_fic_att_value.ad_id = 18)) h USING (f_id)) WHERE (a.frd_id = 9);
|
||||
CREATE VIEW vw_fiche_attr AS
|
||||
SELECT a.f_id, a.fd_id, a.av_text AS vw_name, b.av_text AS vw_sell, c.av_text AS vw_buy, d.av_text AS tva_code, tva_rate.tva_id, tva_rate.tva_rate, tva_rate.tva_label, e.av_text AS vw_addr, f.av_text AS vw_cp, j.av_text AS quick_code, fiche_def.frd_id FROM (((((((((SELECT fiche.f_id, fiche.fd_id, attr_value.av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (jnt_fic_att_value.ad_id = 1)) a LEFT JOIN (SELECT fiche.f_id, attr_value.av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (jnt_fic_att_value.ad_id = 6)) b ON ((a.f_id = b.f_id))) LEFT JOIN (SELECT fiche.f_id, attr_value.av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (jnt_fic_att_value.ad_id = 7)) c ON ((a.f_id = c.f_id))) LEFT JOIN (SELECT fiche.f_id, attr_value.av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (jnt_fic_att_value.ad_id = 2)) d ON ((a.f_id = d.f_id))) LEFT JOIN (SELECT fiche.f_id, attr_value.av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (jnt_fic_att_value.ad_id = 14)) e ON ((a.f_id = e.f_id))) LEFT JOIN (SELECT fiche.f_id, attr_value.av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (jnt_fic_att_value.ad_id = 15)) f ON ((a.f_id = f.f_id))) LEFT JOIN (SELECT fiche.f_id, attr_value.av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (jnt_fic_att_value.ad_id = 23)) j ON ((a.f_id = j.f_id))) LEFT JOIN tva_rate ON ((d.av_text = (tva_rate.tva_id)::text))) JOIN fiche_def USING (fd_id));
|
||||
CREATE VIEW vw_fiche_def AS
|
||||
SELECT jnt_fic_attr.fd_id, jnt_fic_attr.ad_id, attr_def.ad_text, attr_value.av_text, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def.frd_id FROM (((((jnt_fic_att_value JOIN attr_value USING (jft_id)) JOIN fiche USING (f_id)) JOIN jnt_fic_attr USING (fd_id)) JOIN attr_def ON ((attr_def.ad_id = jnt_fic_attr.ad_id))) JOIN fiche_def USING (fd_id));
|
||||
CREATE VIEW vw_fiche_min AS
|
||||
SELECT attr_min.frd_id, attr_min.ad_id, attr_def.ad_text, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base FROM ((attr_min JOIN attr_def USING (ad_id)) JOIN fiche_def_ref USING (frd_id));
|
||||
CREATE VIEW vw_poste_qcode AS
|
||||
SELECT a.f_id, a.av_text AS j_poste, b.av_text AS j_qcode FROM ((SELECT jnt_fic_att_value.f_id, attr_value.av_text FROM (attr_value JOIN jnt_fic_att_value USING (jft_id)) WHERE (jnt_fic_att_value.ad_id = 5)) a JOIN (SELECT jnt_fic_att_value.f_id, attr_value.av_text FROM (attr_value JOIN jnt_fic_att_value USING (jft_id)) WHERE (jnt_fic_att_value.ad_id = 23)) b USING (f_id));
|
||||
|
||||
-- comment
|
||||
COMMENT ON VIEW vw_fiche_def IS 'all the attributs for card family';
|
||||
-- Name: VIEW vw_fiche_min; Type: COMMENT; Schema: public; Owner: phpcompta
|
||||
COMMENT ON VIEW vw_fiche_min IS 'minimum attribut for reference card';
|
||||
|
||||
create or replace function account_auto (p_fd_id fiche_def.fd_id%type)
|
||||
returns bool
|
||||
as
|
||||
$$
|
||||
-- account_auto
|
||||
-- param fd_id
|
||||
-- return true if the card generate automatically an account
|
||||
declare
|
||||
l_auto bool;
|
||||
begin
|
||||
|
||||
select fd_create_account into l_auto from fiche_def where fd_id=p_fd_id;
|
||||
if l_auto is null then
|
||||
l_auto:=false;
|
||||
end if;
|
||||
return l_auto;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create or replace function account_compute(p_f_id fiche.f_id%type)
|
||||
returns poste_comptable
|
||||
as
|
||||
$body$
|
||||
-- account_compute
|
||||
-- param f_id
|
||||
-- compute the next account
|
||||
-- return new account
|
||||
declare
|
||||
class_base poste_comptable;
|
||||
maxcode int8;
|
||||
begin
|
||||
-- Get the class base
|
||||
select fd_class_base into class_base
|
||||
from
|
||||
fiche_def join fiche using (fd_id)
|
||||
where
|
||||
f_id=p_f_id;
|
||||
raise notice 'class base %',class_base;
|
||||
select max(pcm_val) into maxcode from tmp_pcmn where pcm_val = class_base;
|
||||
if maxcode = class_base then
|
||||
maxcode=class_base*1000+1;
|
||||
end if;
|
||||
raise notice 'Max code %',maxcode;
|
||||
return maxcode+1;
|
||||
end;
|
||||
$body$ language plpgsql;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION account_insert(p_f_id fiche.f_id%type,p_account tmp_pcmn.pcm_val%type)
|
||||
RETURNS int4 AS
|
||||
$BODY$
|
||||
declare
|
||||
-- account_insert
|
||||
-- parameter f_id,p_account label of account
|
||||
-- purpose : create a new account for a card
|
||||
-- check if the accound needs to be created automatically
|
||||
-- if p_account is empty or null
|
||||
-- into tables attr_value
|
||||
nParent tmp_pcmn.pcm_val_parent%type;
|
||||
sName varchar;
|
||||
nNew tmp_pcmn.pcm_val%type;
|
||||
bAuto bool;
|
||||
nFd_id integer;
|
||||
nCount integer;
|
||||
begin
|
||||
|
||||
-- if p_value empty
|
||||
if length(trim(p_account)) != 0 then
|
||||
-- does the account exist ?
|
||||
select * into nCount from tmp_pcmn where pcm_val=p_account;
|
||||
if nCount !=0 then
|
||||
-- retrieve name
|
||||
select av_text into sName from
|
||||
attr_value join jnt_fic_att_value using (jft_id)
|
||||
where
|
||||
ad_id=1 and f_id=p_f_id;
|
||||
-- get parent
|
||||
nParent:=account_parent(p_account);
|
||||
-- account doesn't exist we need to add id
|
||||
insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent)
|
||||
values (p_account,sName,nParent);
|
||||
-- insert as card's attribute
|
||||
attribut_insert(p_f_id,5,to_char(nNew,'999999999999'));
|
||||
|
||||
end if;
|
||||
else
|
||||
select fd_id into nFd_id from fiche where f_id=p_f_id;
|
||||
bAuto:= account_auto(nFd_id);
|
||||
|
||||
if bAuto = true then
|
||||
-- create automatically the account
|
||||
-- compute the next account
|
||||
nNew:=account_compute(p_f_id);
|
||||
raise debug 'nNew %', nNew;
|
||||
-- retrieve name
|
||||
select av_text into sName from
|
||||
attr_value join jnt_fic_att_value using (jft_id)
|
||||
where
|
||||
ad_id=1 and f_id=p_f_id;
|
||||
|
||||
-- get parent
|
||||
nParent:=account_parent(nNew);
|
||||
-- account doesn't exist we need to add id
|
||||
perform account_add (nNew,sName);
|
||||
-- insert as card's attribute
|
||||
perform attribut_insert(p_f_id,5,to_char(nNew,'999999999999'));
|
||||
|
||||
else
|
||||
perform attribut_insert(p_f_id,5,null);
|
||||
end if;
|
||||
|
||||
end if;
|
||||
|
||||
return 0;
|
||||
end;
|
||||
$BODY$
|
||||
LANGUAGE 'plpgsql' VOLATILE;
|
||||
create or replace function account_parent(p_account tmp_pcmn.pcm_val%type)
|
||||
returns
|
||||
-- account_parent
|
||||
-- parameter pcm_val%type;
|
||||
-- purpose compute the parent account
|
||||
|
||||
poste_comptable
|
||||
as
|
||||
$$
|
||||
declare
|
||||
nParent tmp_pcmn.pcm_val_parent%type;
|
||||
sParent varchar;
|
||||
nCount integer;
|
||||
begin
|
||||
sParent:=to_char(p_account,'9999999999999999');
|
||||
sParent:=trim(sParent);
|
||||
nParent:=0;
|
||||
while nParent = 0 loop
|
||||
select count(*) into nCount
|
||||
from tmp_pcmn
|
||||
where
|
||||
pcm_val = to_number(sParent,'9999999999999999');
|
||||
if nCount != 0 then
|
||||
nParent:=to_number(sParent,'9999999999999999');
|
||||
end if;
|
||||
sParent:= substr(sParent,1,length(sParent)-1);
|
||||
if length(sParent) <= 0 then
|
||||
raise exception 'Impossible de trouver le compte parent pour %',p_account;
|
||||
end if;
|
||||
|
||||
end loop;
|
||||
|
||||
return nParent;
|
||||
end;
|
||||
$$ language plpgsql volatile;
|
||||
-- Function: account_update()
|
||||
|
||||
-- DROP FUNCTION account_update();
|
||||
|
||||
CREATE OR REPLACE FUNCTION account_update(p_f_id fiche.f_id%type,p_account tmp_pcmn.pcm_val%type)
|
||||
RETURNS int4 AS
|
||||
$BODY$
|
||||
-- account_update
|
||||
-- parameter f_id, pcm_val
|
||||
-- purpose update the account of a card and create it into PCMN if it doesn't exist yet
|
||||
--
|
||||
declare
|
||||
nMax fiche.f_id%type;
|
||||
nCount integer;
|
||||
nParent tmp_pcmn.pcm_val_parent%type;
|
||||
sName varchar;
|
||||
nJft_id attr_value.jft_id%type;
|
||||
begin
|
||||
|
||||
-- if p_value empty
|
||||
if length(trim(p_account)) != 0 then
|
||||
-- does the account exist ?
|
||||
select count(*) into nCount from tmp_pcmn where pcm_val=p_account;
|
||||
if nCount = 0 then
|
||||
-- retrieve name
|
||||
select av_text into sName from
|
||||
attr_value join jnt_fic_att_value using (jft_id)
|
||||
where
|
||||
ad_id=1 and f_id=p_f_id;
|
||||
-- get parent
|
||||
nParent:=fiche_account_parent(p_f_id);
|
||||
-- account doesn't exist we need to add id
|
||||
insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_account,sName,nParent);
|
||||
end if;
|
||||
end if;
|
||||
-- we retrieve jft_id
|
||||
select jft_id into njft_id from jnt_fic_att_value where f_id=p_f_id and ad_id=5;
|
||||
-- we update the account
|
||||
update attr_value set av_text=p_account where jft_id=njft_id;
|
||||
|
||||
return njft_id;
|
||||
end;
|
||||
$BODY$
|
||||
LANGUAGE 'plpgsql' VOLATILE;
|
||||
|
||||
|
||||
create or replace function attribut_insert ( p_f_id integer, p_ad_id integer, p_value varchar)
|
||||
returns void
|
||||
as
|
||||
$$
|
||||
-- attribut_integer
|
||||
-- parameter : f_id, ad_id, p_value
|
||||
-- purpose add an attribute to a card
|
||||
-- it inserts a row into jnt_fic_att_value and attr_value
|
||||
declare
|
||||
n_jft_id integer;
|
||||
begin
|
||||
select nextval('s_jnt_fic_att_value') into n_jft_id;
|
||||
insert into jnt_fic_att_value (jft_id,f_id,ad_id) values (n_jft_id,p_f_id,p_ad_id);
|
||||
insert into attr_value (jft_id,av_text) values (n_jft_id,p_value);
|
||||
return;
|
||||
end;
|
||||
$$
|
||||
language plpgsql volatile;
|
||||
create or replace function account_add (p_id tmp_pcmn.pcm_val%type,p_name varchar)
|
||||
returns void
|
||||
as
|
||||
$$
|
||||
-- account_add (p_id tmp_pcmn.pcm_val%type,p_name varchar)
|
||||
-- parameter
|
||||
-- p_id id of the account
|
||||
-- name account's name
|
||||
-- purpose insert a new account if it doesn't exist yet
|
||||
declare
|
||||
nParent tmp_pcmn.pcm_val_parent%type;
|
||||
nCount integer;
|
||||
begin
|
||||
select count(*) into nCount from tmp_pcmn where pcm_val=p_id;
|
||||
if nCount = 0 then
|
||||
nParent=account_parent(p_id);
|
||||
insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent)
|
||||
values (p_id, p_name,nParent);
|
||||
end if;
|
||||
return;
|
||||
end ;
|
||||
$$ language plpgsql;
|
||||
|
||||
|
||||
create table document_type (
|
||||
dt_id serial primary key,
|
||||
dt_value varchar(80)
|
||||
);
|
||||
|
||||
comment on table document_type is 'Type of document : meeting, invoice,...';
|
||||
CREATE or replace FUNCTION t_document_type_insert() RETURNS trigger AS $body$
|
||||
BEGIN
|
||||
execute 'create sequence seq_doc_type_'||NEW.dt_id;
|
||||
raise notice 'Creating sequence seq_doc_type_%',NEW.dt_id;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$body$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER trigger_document_type_i after INSERT oN document_type
|
||||
FOR EACH ROW EXECUTE PROCEDURE t_document_type_insert();
|
||||
|
||||
INSERT INTO document_type VALUES (1,'Rendez-vous');
|
||||
INSERT INTO document_type VALUES (2,'Bons de commande client');
|
||||
INSERT INTO document_type VALUES (3,'Bon de commande Fournisseur');
|
||||
INSERT INTO document_type VALUES (4,'Facture');
|
||||
INSERT INTO document_type VALUES (5,'Lettre de rappel');
|
||||
INSERT INTO document_type VALUES (6,'Courrier');
|
||||
INSERT INTO document_type VALUES (7,'Proposition');
|
||||
INSERT INTO document_type VALUES (8,'Email');
|
||||
alter sequence document_type_dt_id_seq restart with 9;
|
||||
|
||||
create table document_modele (
|
||||
md_id serial primary key,
|
||||
md_name text not null,
|
||||
md_lob oid,
|
||||
md_type integer not null ,
|
||||
md_filename text,
|
||||
md_mimetype text
|
||||
);
|
||||
|
||||
|
||||
comment on table document_modele is ' contains all the template for the documents';
|
||||
|
||||
alter table document_modele add constraint md_type foreign key (md_type) references document_type(dt_id);
|
||||
|
||||
|
||||
|
||||
create or replace function card_class_base(p_f_id fiche.f_id%type)
|
||||
returns poste_comptable
|
||||
as
|
||||
$$
|
||||
|
||||
declare
|
||||
n_poste fiche_def.fd_class_base%type;
|
||||
begin
|
||||
-- card_class_base (integer)
|
||||
-- param: $1 fiche.f_id
|
||||
-- purpose : retrieve the class of a card
|
||||
--
|
||||
|
||||
select fd_class_base into n_poste from fiche_def join fiche using (fd_id)
|
||||
where f_id=p_f_id;
|
||||
if not FOUND then
|
||||
raise exception 'Invalid fiche card_class_base(%)',p_f_id;
|
||||
end if;
|
||||
return;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
-- fiche_account_parent
|
||||
create or replace function fiche_account_parent(p_f_id integer)
|
||||
returns poste_comptable as $$
|
||||
declare
|
||||
-- fiche_account_parent returns the fd_class_base
|
||||
-- parameter f_id (from fiche)
|
||||
ret poste_comptable;
|
||||
begin
|
||||
select fd_class_base into ret from fiche_def join fiche using (fd_id) where f_id=p_f_id;
|
||||
if not FOUND then
|
||||
raise exception '% N''existe pas',p_f_id;
|
||||
end if;
|
||||
return ret;
|
||||
end;
|
||||
$$
|
||||
language plpgsql ;
|
||||
delete from form where fo_fr_id=3000000;
|
||||
delete from formdef where fr_id=3000000;
|
||||
|
||||
INSERT INTO formdef (fr_id, fr_label) VALUES (3000000, 'TVA déclaration Belge');
|
||||
--
|
||||
-- Data for TOC entry 2 (OID 315304)
|
||||
-- Name: formdef; Type: TABLE DATA; Schema: public; Owner: dany
|
||||
--
|
||||
--
|
||||
|
||||
INSERT INTO form VALUES (3000398, 3000000, 1, 'Prestation [ case 03 ]', '[700%]-[7000005]');
|
||||
INSERT INTO form VALUES (3000399, 3000000, 2, 'Prestation intra [ case 47 ]', '[7000005]');
|
||||
INSERT INTO form VALUES (3000400, 3000000, 3, 'Tva due [case 54]', '[4513]+[4512]+[4511] FROM=01.2005');
|
||||
INSERT INTO form VALUES (3000401, 3000000, 4, 'Marchandises, matière première et auxiliaire [case 81 ]', '[60%]');
|
||||
INSERT INTO form VALUES (3000402, 3000000, 7, 'Service et bien divers [case 82]', '[61%]');
|
||||
INSERT INTO form VALUES (3000403, 3000000, 8, 'bien d''invest [ case 83 ]', '[2400%]');
|
||||
INSERT INTO form VALUES (3000404, 3000000, 9, 'TVA déductible [ case 59 ]', 'abs([4117]-[411%])');
|
||||
INSERT INTO form VALUES (3000405, 3000000, 8, 'TVA non ded -> voiture', '[610022]*0.21/2');
|
||||
INSERT INTO form VALUES (3000406, 3000000, 9, 'Acompte TVA', '[4117]');
|
||||
|
||||
-- create the table document
|
||||
|
||||
create table document
|
||||
(
|
||||
d_id serial primary key,
|
||||
ag_id int4 not null,
|
||||
d_lob oid,
|
||||
d_number int8 not null,
|
||||
d_filename text,
|
||||
d_mimetype text
|
||||
);
|
||||
|
||||
alter table document add constraint fk_ag_id foreign key (ag_id) references action_gestion(ag_id);
|
||||
|
||||
comment on table document is 'This table contains all the documents : summary and lob files';
|
||||
|
||||
create sequence document_seq;
|
||||
|
||||
comment on sequence document_seq is 'Sequence for the sequence bound to the document modele';
|
||||
|
||||
CREATE TABLE document_state (
|
||||
s_id serial NOT NULL,
|
||||
s_value character varying(50) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
COMMENT ON TABLE document_state IS 'State of the document';
|
||||
|
||||
SELECT pg_catalog.setval(pg_catalog.pg_get_serial_sequence('document_state', 's_id'), 3, true);
|
||||
|
||||
|
||||
INSERT INTO document_state VALUES (1, 'Envoyé');
|
||||
INSERT INTO document_state VALUES (2, 'Brouillon');
|
||||
INSERT INTO document_state VALUES (3, 'A envoyer');
|
||||
|
||||
ALTER TABLE ONLY document_state ADD CONSTRAINT document_state_pkey PRIMARY KEY (s_id);
|
||||
|
||||
insert into attr_def (ad_id,ad_text) values (24,'Ville');
|
||||
insert into attr_min values(9,24);
|
||||
insert into attr_min values(8,24);
|
||||
insert into attr_min values(14,24);
|
||||
-- upgrade all customer
|
||||
insert into jnt_fic_attr select fd_id,24 from jnt_fic_attr join fiche_def using (fd_id) where frd_id=9 and ad_id=1;
|
||||
-- supplier
|
||||
insert into jnt_fic_attr select fd_id,24 from jnt_fic_attr join fiche_def using (fd_id) where frd_id=8 and ad_id=1;
|
||||
-- administration
|
||||
|
||||
insert into jnt_fic_attr select fd_id,24 from jnt_fic_attr join fiche_def using (fd_id) where frd_id=9 and ad_id=14;
|
||||
|
||||
--
|
||||
create table action_gestion (
|
||||
ag_id serial primary key,
|
||||
ag_type int4,
|
||||
f_id int4 not null,
|
||||
ag_title varchar(70),
|
||||
ag_timestamp timestamp default now(),
|
||||
ag_cal char(1) default 'C',
|
||||
ag_comment text
|
||||
);
|
||||
|
||||
comment on table action_gestion is 'Action for Managing';
|
||||
-- add contact
|
||||
insert into fiche_def_ref(frd_text) values ('Contact');
|
||||
insert into attr_def(ad_text) values ('Société');
|
||||
insert into attr_def(ad_text) values ('Fax');
|
||||
insert into attr_min values(16,1);
|
||||
insert into attr_min values(16,17);
|
||||
insert into attr_min values(16,18);
|
||||
insert into attr_min values(16,25);
|
||||
insert into attr_min values(16,26);
|
||||
|
||||
CREATE or replace FUNCTION t_jrn_def_sequence() RETURNS trigger AS $body$
|
||||
BEGIN
|
||||
execute 'create sequence s_jrn_'||NEW.jrn_def_id;
|
||||
raise notice 'Creating sequence s_jrn_%',NEW.jrn_def_id;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$body$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER trigger_jrn_def_sequence_i after INSERT oN jrn_def
|
||||
FOR EACH ROW EXECUTE PROCEDURE t_jrn_def_sequence();
|
||||
|
||||
create view vw_supplier as SELECT a.f_id, a.av_text AS name, a1.av_text AS quick_code, b.av_text AS tva_num, c.av_text AS poste_comptable, d.av_text AS rue, e.av_text AS code_postal, f.av_text AS pays, g.av_text AS telephone, h.av_text AS email
|
||||
FROM ( SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text
|
||||
FROM fiche
|
||||
JOIN fiche_def USING (fd_id)
|
||||
JOIN fiche_def_ref USING (frd_id)
|
||||
JOIN jnt_fic_att_value USING (f_id)
|
||||
JOIN attr_value USING (jft_id)
|
||||
WHERE jnt_fic_att_value.ad_id = 1) a
|
||||
JOIN ( SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text
|
||||
FROM fiche
|
||||
JOIN fiche_def USING (fd_id)
|
||||
JOIN fiche_def_ref USING (frd_id)
|
||||
JOIN jnt_fic_att_value USING (f_id)
|
||||
JOIN attr_value USING (jft_id)
|
||||
WHERE jnt_fic_att_value.ad_id = 13) b USING (f_id)
|
||||
JOIN ( SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text
|
||||
FROM fiche
|
||||
JOIN fiche_def USING (fd_id)
|
||||
JOIN fiche_def_ref USING (frd_id)
|
||||
JOIN jnt_fic_att_value USING (f_id)
|
||||
JOIN attr_value USING (jft_id)
|
||||
WHERE jnt_fic_att_value.ad_id = 23) a1 USING (f_id)
|
||||
JOIN ( SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text
|
||||
FROM fiche
|
||||
JOIN fiche_def USING (fd_id)
|
||||
JOIN fiche_def_ref USING (frd_id)
|
||||
JOIN jnt_fic_att_value USING (f_id)
|
||||
JOIN attr_value USING (jft_id)
|
||||
WHERE jnt_fic_att_value.ad_id = 5) c USING (f_id)
|
||||
JOIN ( SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text
|
||||
FROM fiche
|
||||
JOIN fiche_def USING (fd_id)
|
||||
JOIN fiche_def_ref USING (frd_id)
|
||||
JOIN jnt_fic_att_value USING (f_id)
|
||||
JOIN attr_value USING (jft_id)
|
||||
WHERE jnt_fic_att_value.ad_id = 14) d USING (f_id)
|
||||
JOIN ( SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text
|
||||
FROM fiche
|
||||
JOIN fiche_def USING (fd_id)
|
||||
JOIN fiche_def_ref USING (frd_id)
|
||||
JOIN jnt_fic_att_value USING (f_id)
|
||||
JOIN attr_value USING (jft_id)
|
||||
WHERE jnt_fic_att_value.ad_id = 15) e USING (f_id)
|
||||
JOIN ( SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text
|
||||
FROM fiche
|
||||
JOIN fiche_def USING (fd_id)
|
||||
JOIN fiche_def_ref USING (frd_id)
|
||||
JOIN jnt_fic_att_value USING (f_id)
|
||||
JOIN attr_value USING (jft_id)
|
||||
WHERE jnt_fic_att_value.ad_id = 16) f USING (f_id)
|
||||
JOIN ( SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text
|
||||
FROM fiche
|
||||
JOIN fiche_def USING (fd_id)
|
||||
JOIN fiche_def_ref USING (frd_id)
|
||||
JOIN jnt_fic_att_value USING (f_id)
|
||||
JOIN attr_value USING (jft_id)
|
||||
WHERE jnt_fic_att_value.ad_id = 17) g USING (f_id)
|
||||
LEFT JOIN ( SELECT jnt_fic_att_value.jft_id, fiche.f_id, fiche_def.frd_id, fiche.fd_id, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base, jnt_fic_att_value.ad_id, attr_value.av_text
|
||||
FROM fiche
|
||||
JOIN fiche_def USING (fd_id)
|
||||
JOIN fiche_def_ref USING (frd_id)
|
||||
JOIN jnt_fic_att_value USING (f_id)
|
||||
JOIN attr_value USING (jft_id)
|
||||
WHERE jnt_fic_att_value.ad_id = 18) h USING (f_id)
|
||||
WHERE a.frd_id = 8;
|
||||
|
||||
insert into parameter (pr_id) values ('MY_TEL');
|
||||
insert into parameter (pr_id) values ('MY_PAYS');
|
||||
insert into parameter (pr_id) values ('MY_FAX');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue