diff --git a/html/admin/setup.php b/html/admin/setup.php index 0e4545c52..47f32683c 100644 --- a/html/admin/setup.php +++ b/html/admin/setup.php @@ -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)) { diff --git a/html/admin/sql/patch/ac-upgrade7.sql b/html/admin/sql/patch/ac-upgrade7.sql index 4b2a6d95d..2b5ffb674 100644 --- a/html/admin/sql/patch/ac-upgrade7.sql +++ b/html/admin/sql/patch/ac-upgrade7.sql @@ -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; diff --git a/html/admin/sql/patch/upgrade12.sql b/html/admin/sql/patch/upgrade12.sql index baae8c61c..b1193b9ab 100644 --- a/html/admin/sql/patch/upgrade12.sql +++ b/html/admin/sql/patch/upgrade12.sql @@ -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; diff --git a/html/admin/sql/patch/upgrade13.sql b/html/admin/sql/patch/upgrade13.sql index c40d16571..5bb82f57b 100644 --- a/html/admin/sql/patch/upgrade13.sql +++ b/html/admin/sql/patch/upgrade13.sql @@ -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; diff --git a/html/parametre.php b/html/parametre.php index 591474d9a..8eb1a83eb 100644 --- a/html/parametre.php +++ b/html/parametre.php @@ -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 '
'; echo ""; echo "".$all->IOValue("p_name",$my->MY_NAME,"Nom société").""; - - echo "".$all->IOValue("p_tva",$my->MY_TVA,"Numéro de Tva").""; + echo "".$all->IOValue("p_tel",$my->MY_TEL,"Téléphone").""; + echo "".$all->IOValue("p_fax",$my->MY_FAX,"Fax").""; echo "".$all->IOValue("p_street",$my->MY_STREET,"Rue ").""; echo "".$all->IOValue("p_no",$my->MY_NUMBER,"Numéro").""; echo "".$all->IOValue("p_cp",$my->MY_CP,"Code Postal").""; echo "".$all->IOValue("p_Commune",$my->MY_COMMUNE,"Commune").""; + echo "".$all->IOValue("p_pays",$my->MY_PAYS,"Pays").""; + echo "".$all->IOValue("p_tva",$my->MY_TVA,"Numéro de Tva").""; + echo "
"; $submit=new widget("submit"); echo $submit->Submit("record_company","Enregistre"); diff --git a/html/style-color.css b/html/style-color.css index 96c8c1e08..ed1b82ffc 100644 --- a/html/style-color.css +++ b/html/style-color.css @@ -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; + + +} + + /* */ diff --git a/html/style-light.css b/html/style-light.css index 554798a59..db6a7b901 100644 --- a/html/style-light.css +++ b/html/style-light.css @@ -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; + + +} + /* */ diff --git a/include/ac_common.php b/include/ac_common.php index fb12f0a8f..25149955a 100644 --- a/include/ac_common.php +++ b/include/ac_common.php @@ -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 diff --git a/include/action.inc.php b/include/action.inc.php index ce8be3856..320d331f4 100644 --- a/include/action.inc.php +++ b/include/action.inc.php @@ -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 '
'; + if ( $sub_action == "" ) $sub_action="list"; // if correction is asked go to directly to add_action diff --git a/include/admin.inc.php b/include/admin.inc.php index 4753056ec..e60733842 100644 --- a/include/admin.inc.php +++ b/include/admin.inc.php @@ -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 */ diff --git a/include/bank.inc.php b/include/bank.inc.php index 68c012ee8..ef4639871 100644 --- a/include/bank.inc.php +++ b/include/bank.inc.php @@ -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 diff --git a/include/class_customer.php b/include/class_customer.php index 4b78945a7..6237ff202 100644 --- a/include/class_customer.php +++ b/include/class_customer.php @@ -225,7 +225,7 @@ where Nom Adresse Solde -Action +Action '; if ( sizeof ($step_client ) == 0 ) return $r; @@ -246,14 +246,14 @@ where $r.=sprintf(' %15.2f€',$a['solde']); $r.=""; - $r.=sprintf('C - ', + $r.=sprintf('Contact', $script,$client->strAttribut(ATTR_DEF_QUICKCODE),$url); - $r.=sprintf('A - ', + $r.=sprintf('Courrier ', $script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$url); - $r.='F -'; + $r.='Facture'; $r.=''; diff --git a/include/class_document.php b/include/class_document.php index 72f5e3fc6..59ef51166 100644 --- a/include/class_document.php +++ b/include/class_document.php @@ -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); diff --git a/include/class_document_modele.php b/include/class_document_modele.php index c2efac1e2..2019b5c6a 100644 --- a/include/class_document_modele.php +++ b/include/class_document_modele.php @@ -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); } diff --git a/include/class_own.php b/include/class_own.php index e4ce3b6c6..958b8b121 100644 --- a/include/class_own.php +++ b/include/class_own.php @@ -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'); } diff --git a/include/class_supplier.php b/include/class_supplier.php index 8eb819637..e76f10469 100644 --- a/include/class_supplier.php +++ b/include/class_supplier.php @@ -113,7 +113,7 @@ class Supplier extends fiche{ Nom Adresse Solde -Action +Action '; 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(' %15.2f€',$a['solde']); - $r.=""; - $r.=sprintf('C - ', + + $r.=sprintf('Contact', $script,$supplier->strAttribut(ATTR_DEF_QUICKCODE),$url); - $r.=sprintf('A - ', + $r.=sprintf('Courrier ', $script,$supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$url); - $r.='F -'; + $r.='Facture'; $r.=''; diff --git a/include/client.inc.php b/include/client.inc.php index a55affa54..7827457f4 100644 --- a/include/client.inc.php +++ b/include/client.inc.php @@ -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 '
'; echo '
'; echo $client->Summary($search); - echo '
'; - echo '
'; - echo "Action : Ajout, mise à jour ou effacement"; - echo "
    "; - echo "
  • C - Contact
  • "; - echo "
  • F - Facture
  • "; - echo "
  • FC - Courrier
  • "; - echo "
"; - echo '
'; echo '
'; diff --git a/include/constant.php b/include/constant.php index 5ef7eaeee..d90df00de 100644 --- a/include/constant.php +++ b/include/constant.php @@ -24,7 +24,7 @@ */ define ("phpcompta_password","dany"); -define ("domaine",""); +define ("domaine","test_"); define ("DEBUG","true"); diff --git a/include/contact.inc.php b/include/contact.inc.php index 78d5ca669..a281dc585 100644 --- a/include/contact.inc.php +++ b/include/contact.inc.php @@ -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('',urldecode($_REQUEST['url'])); + $retour=sprintf('',urldecode($_REQUEST['url'])); $h_url=sprintf('',urldecode($_REQUEST['url'])); } else @@ -156,9 +156,11 @@ if ( $sub_action == "list" ) { $contact->company=$qcode; } + echo $retour; echo '
'; echo $contact->Summary($search); echo '
'; + echo $retour; } diff --git a/include/depense.inc.php b/include/depense.inc.php index 6a0a380d6..5aef3b430 100644 --- a/include/depense.inc.php +++ b/include/depense.inc.php @@ -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 diff --git a/include/document_modele.inc.php b/include/document_modele.inc.php index 1f3e15502..149d59185 100644 --- a/include/document_modele.inc.php +++ b/include/document_modele.inc.php @@ -24,10 +24,8 @@ require_once("class_document_modele.php"); $sub_action=(isset ($_REQUEST['sa']))?$_REQUEST['sa']:""; -var_dump($_REQUEST); -echo "
"; -// echo ShowMenuDocument(); +echo "
"; // show the form for adding a template // $doc=new Document_modele($cn); diff --git a/include/facture.inc.php b/include/facture.inc.php index ab6c86f99..a741ea17c 100644 --- a/include/facture.inc.php +++ b/include/facture.inc.php @@ -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('',urldecode($_REQUEST['url'])); + $retour=sprintf('',urldecode($_REQUEST['url'])); $h_url=sprintf('',urldecode($_REQUEST['url'])); } @@ -87,7 +87,7 @@ if ( $sub_action == "list") } } - + echo $retour; echo '
'; diff --git a/include/fiche_inc.php b/include/fiche_inc.php index f51d8e49c..ea806b4a1 100644 --- a/include/fiche_inc.php +++ b/include/fiche_inc.php @@ -421,19 +421,23 @@ function ViewFiche($p_cn,$p_type) { $Max=pg_NumRows($Res); echo $bar; + echo ''; for ( $i = 0; $i < $Max; $i++) { $l_line=pg_fetch_array($Res,$i); - $div="
"; - $span_mod=' Modifie'; - $span_del=''. - ' delete'; - $span_id=''.$l_line['j_qcode'].""; - if ( $i %2 == 0 ) - $div='
'; - echo $div.$span_del.' '.' '.' '.' '.' '.' '. - $span_mod." "." "." ".$span_id." "." "." ".$l_line['av_text']."
"; + if ( $i%2 == 0) + echo '
'; + else + echo ''; + + $span_mod=''; + $span_del=''; + + echo $span_del.$span_mod.'"; + echo ''; } + echo '
'.$l_line['j_qcode'].''. + ' delete'.$l_line['av_text']."
'; echo ''; echo ''; echo ''; @@ -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.=' '.$p_js; $display.=''; // Checkbox for the creation of a post - $display.=' Create accounts for each'; + $display.=' Create accounts for each'; //display the different template $ref=Get_fiche_def_ref($p_cn); diff --git a/include/postgres.php b/include/postgres.php index e37bfd54d..2fbde50cf 100644 --- a/include/postgres.php +++ b/include/postgres.php @@ -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) { diff --git a/include/supplier.inc.php b/include/supplier.inc.php index 6fe46d9cc..48951c6f4 100644 --- a/include/supplier.inc.php +++ b/include/supplier.inc.php @@ -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 '
'; echo '
'; echo $sup->Summary($search); - echo '
'; - echo '
'; - echo "Action : Ajout, mise à jour ou effacement"; - echo "
    "; - echo "
  • C - Contact
  • "; - echo "
  • F - Facture
  • "; - echo "
  • FC - Courrier
  • "; - echo "
"; - echo '
'; echo '
'; diff --git a/include/user_action_ach.php b/include/user_action_ach.php index 17d56be93..c2d6a21c9 100644 --- a/include/user_action_ach.php +++ b/include/user_action_ach.php @@ -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); diff --git a/include/user_action_ven.php b/include/user_action_ven.php index ed4affe32..868220784 100644 --- a/include/user_action_ven.php +++ b/include/user_action_ven.php @@ -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'); diff --git a/include/user_common.php b/include/user_common.php index 4a3e3fff4..786cf4ba4 100644 --- a/include/user_common.php +++ b/include/user_common.php @@ -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=''; + $r=''; $r.="Précédent"; $r.="  "; } @@ -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('%d ',$go,$e); + $r.=sprintf('%d ',$go,$e); } else { $r.=" $e "; } //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.=' '; + $r.=' '; $r.="Suivant"; $r.=""; } diff --git a/include/user_form_ach.php b/include/user_form_ach.php index 82ff1f10f..81f033c53 100644 --- a/include/user_form_ach.php +++ b/include/user_form_ach.php @@ -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); diff --git a/include/user_form_fin.php b/include/user_form_fin.php index a7db94b95..4cc7c8517 100644 --- a/include/user_form_fin.php +++ b/include/user_form_fin.php @@ -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); diff --git a/include/user_menu.php b/include/user_menu.php index fee406697..89c50c4dc 100644 --- a/include/user_menu.php +++ b/include/user_menu.php @@ -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.=""; + $result.="
"; $result.=''; if ( $p_admin == 1 ) { - $result.=""; + $result.=""; } - $result.=''; + $result.=''; $result.=""; $result.="
Administration : Administration : Sortir Sortir
"; $result.=""; @@ -647,12 +647,12 @@ function MenuJrn($p_dossier) function ShowMenuPcmn($p_start=1) { echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; - echo ''; + echo ''; echo ''; echo "
1 Immobilisé
2 Actif a un an au plus
3 Stock et commande
4 Compte tiers
1 Immobilisé
2 Actif a un an au plus
3 Stock et commande
4 Compte tiers
5 Actif
6 Charges
6 Charges
7 Produits
"; } diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh index 59c5f2fa8..de00376b2 100755 --- a/scripts/cleanup.sh +++ b/scripts/cleanup.sh @@ -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 diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 5eeae600c..e4da5fef8 100644 --- a/sql/upgrade.sql +++ b/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');