upgrade SQL and add missing files

This commit is contained in:
sparkyx 2007-12-27 17:14:05 +00:00
parent 21e91d74e4
commit cf81081543
3 changed files with 226 additions and 21 deletions

130
html/bud_search_poste.php Normal file
View file

@ -0,0 +1,130 @@
<?php
/*
* This file is part of PhpCompta.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
/*! \file
* \brief Search a account in a popup window
*/
include_once ("ac_common.php");
require_once('class_acc_ledger.php');
print_r($_GET);
include_once ("postgres.php");
include_once("jrn.php");
/* Admin. Dossier */
$rep=DbConnect();
html_page_start($_SESSION['g_theme'],'onLoad="window.focus();"');
include_once ("class_user.php");
$User=new cl_user($rep);
$User->Check();
echo JS_BUD_SCRIPT;
require_once('class_dossier.php');
$gDossier=dossier::id();
$c_comment="";
$c_class="";
$condition="";
$cn=DbConnect($gDossier);
extract ($_GET);
if ( isset($_GET['search']) ) {
$condition="";
if ( isset($p_comment) && strlen(trim($p_comment)) != 0 ) {
$condition=" where (upper(pcm_lib) like upper('%$p_comment%') or ".
" pcm_val::text like '$p_comment%') ".
" and (pcm_val::text like '7%' or pcm_val::text like '6%') ";
} else {
$condition="where pcm_val::text like '7%' or pcm_val::text like '6%' ";
}
}
// Control to update in the calling doc.
if ( isset($_GET['p_ctl'])) {
$p_ctl=$_GET['p_ctl'];
}
echo '<FORM METHOD="GET">';
echo dossier::hidden();
if ( isset($p_ctl) ) {
if ($p_ctl != 'not') echo '<INPUT TYPE="hidden" name="p_ctl" value="'.$p_ctl.'">';
}
echo '<TABLE>';
echo '<TR>';
echo '<TD> Libellé ou poste comptable</TD>';
echo '<TD> contient </TD>';
if ( ! isset ($p_comment) ) $p_comment="";
echo '<TD> <INPUT TYPE="text" name="p_comment" VALUE="'.$p_comment.'"></TD></TR>';
echo '</TABLE>';
echo '<INPUT TYPE="submit" name="search" value="cherche">';
echo '</FORM>';
// if request search
if ( isset($_GET['search'])){
$Res=ExecSql($cn,"select pcm_val,pcm_lib from tmp_pcmn $condition order by pcm_val::text");
$MaxLine=pg_NumRows($Res);
if ( $MaxLine==0) {
html_page_stop();
return;
}
echo '<TABLE BORDER="0">';
$l_id="";
for ( $i=0; $i < $MaxLine; $i++) {
$l_line=pg_fetch_array($Res,$i);
echo "<TR>";
// if p_ctl is set we need to be able to return the value
if (isset($p_ctl) && $p_ctl != 'not' ){
echo '<TD>';
$slabel=FormatString($l_line['pcm_lib']);
echo '<input type="checkbox" onClick="SetItChild(\''.$p_ctl.'\',\''.$l_line['pcm_val'].'\',\''.
$slabel.'\')">';
echo '</td>';
}
echo '<TD>';
echo $l_line['pcm_val'];
echo '</TD>';
echo '<TD>';
echo $l_line['pcm_lib'];
echo '</TD>';
echo "</TR>";
}
echo '</TABLE>';
}
echo '<INPUT TYPE="BUTTON" Value="Close" onClick=\'GetIt()\'>';
html_page_stop();
?>

View file

@ -65,7 +65,7 @@ class Bud_Data {
if ( $this->po_id == -1)
$sql_po_id="po_id is null";
else
$sql_po_id=".$this->po_id";
$sql_po_id="po_id = $this->po_id";
$sql=" select bd_id,bc_id,bc_code,bd.bh_id,bd.bh_name,".
" tmp_pcmn.pcm_val as pcm_val,pcm_lib ".
" from bud_detail ".

View file

@ -1,4 +1,61 @@
begin;
alter table import_tmp alter montant numeric (20,4);
alter table import_tmp alter montant set default 0;
alter table import_tmp alter montant set not null;
alter table import_tmp alter code set not null;
alter table import_tmp alter date_exec set not null;
alter table import_tmp alter date_valeur set not null;
COMMENT ON TABLE import_tmp IS 'Table temporaire pour l''importation des banques en format CSV';
COMMENT ON COLUMN import_tmp.status IS 'Status w waiting, d delete t transfert'
alter table poste_analytique add column ga_id varchar (10);
CREATE or replace FUNCTION t_document_validate() RETURNS "trigger"
AS $$
declare
lText text;
modified document%ROWTYPE;
begin
modified:=NEW;
modified.d_filename:=replace(NEW.d_filename,' ','_');
return modified;
end;
$$
LANGUAGE plpgsql;
CREATE or replace FUNCTION t_document_type_insert() RETURNS "trigger"
AS $$
declare
nCounter integer;
BEGIN
select count(*) into nCounter from pg_class where relname='seq_doc_type_'||NEW.dt_id;
if nCounter = 0 then
execute 'create sequence seq_doc_type_'||NEW.dt_id;
raise notice 'Creating sequence seq_doc_type_%',NEW.dt_id;
end if;
RETURN NEW;
END;
$$
LANGUAGE plpgsql;
CREATE or replace FUNCTION t_document_modele_validate() RETURNS "trigger"
AS $$
declare
lText text;
modified document_modele%ROWTYPE;
begin
modified:=NEW;
modified.md_filename:=replace(NEW.md_filename,' ','_');
return modified;
end;
$$
LANGUAGE plpgsql;
CREATE TABLE groupe_analytique
(
ga_id varchar(10) NOT NULL,
@ -88,7 +145,7 @@ CREATE TRIGGER t_plan_analytique_ins_upd
EXECUTE PROCEDURE plan_analytic_ins_upd();
CREATE TRIGGER t_group_analytic_del
AFTER DELETE
before DELETE
ON groupe_analytique
FOR EACH ROW
EXECUTE PROCEDURE group_analytique_del();
@ -121,7 +178,7 @@ WITHOUT OIDS;
create sequence seq_bud_hypothese_bh_id;
alter table bud_hypothese alter bh_id default nextval('seq_bud_hypothese_bh_id');
alter table bud_hypothese alter bh_id set default nextval('seq_bud_hypothese_bh_id');
--
-- Name: bud_card; Type: TABLE; Schema: public; Owner: phpcompta; Tablespace:
@ -198,23 +255,6 @@ ALTER TABLE bud_card ALTER COLUMN bh_id SET NOT NULL;
--
-- Name: t_bud_card_ins_up; Type: TRIGGER; Schema: public; Owner: phpcompta
--
CREATE TRIGGER t_bud_card_ins_up
BEFORE INSERT OR UPDATE ON bud_card
FOR EACH ROW
EXECUTE PROCEDURE bud_card_ins_upd();
--
-- Name: bud_hypothese_bh_id; Type: FK CONSTRAINT; Schema: public; Owner: phpcompta
--
ALTER TABLE ONLY bud_card
ADD CONSTRAINT bud_hypothese_bh_id FOREIGN KEY (bh_id) REFERENCES bud_hypothese(bh_id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- Name: bud_detail; Type: TABLE; Schema: public; Owner: phpcompta; Tablespace:
--
@ -322,7 +362,7 @@ ALTER TABLE ONLY bud_detail
ADD CONSTRAINT fk_bud_card FOREIGN KEY (bc_id) REFERENCES bud_card(bc_id) ON UPDATE CASCADE ON DELETE CASCADE;;
ALTER TABLE ONLY bud_detail
set fk_bud_hypothese_not_null FOREIGN KEY (bh_id) REFERENCES bud_hypothese(bh_id) ON UPDATE CASCADE ON DELETE CASCADE;;
add constraint fk_bud_hypothese_not_null FOREIGN KEY (bh_id) REFERENCES bud_hypothese(bh_id) ON UPDATE CASCADE ON DELETE CASCADE;;
--
@ -432,6 +472,41 @@ return mline;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE OR REPLACE FUNCTION bud_card_ins_upd()
RETURNS "trigger" AS
$BODY$declare
sCode text;
begin
sCode:=trim(upper(NEW.bc_code));
sCode:=replace(sCode,' ','_');
sCode:=substr(sCode,1,10);
raise notice 'sCode is %',sCode;
NEW.bc_code:=sCode;
return NEW;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION bud_card_ins_upd() OWNER TO phpcompta;
--
-- Name: t_bud_card_ins_up; Type: TRIGGER; Schema: public; Owner: phpcompta
--
CREATE TRIGGER t_bud_card_ins_up
BEFORE INSERT OR UPDATE ON bud_card
FOR EACH ROW
EXECUTE PROCEDURE bud_card_ins_upd();
--
-- Name: bud_hypothese_bh_id; Type: FK CONSTRAINT; Schema: public; Owner: phpcompta
--
ALTER TABLE ONLY bud_card
ADD CONSTRAINT bud_hypothese_bh_id FOREIGN KEY (bh_id) REFERENCES bud_hypothese(bh_id) ON UPDATE CASCADE ON DELETE CASCADE;
CREATE TRIGGER t_bud_detail_ins_upd
BEFORE INSERT OR UPDATE
ON bud_detail