Document_Modele : add document_component to ease
generating document from plugin.
This commit is contained in:
parent
b787a63a91
commit
639f739b67
5 changed files with 66 additions and 17 deletions
|
|
@ -27,6 +27,7 @@ if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
|
|||
/* 1. Check security */
|
||||
$cn=Dossier::connect();
|
||||
/* 2. find the document */
|
||||
global $doc;
|
||||
$doc=new Document_Modele($cn,$id);
|
||||
|
||||
/* 3. display it */
|
||||
|
|
|
|||
|
|
@ -263,11 +263,7 @@ class Document_modele
|
|||
$r.=td(_('Affectation'));
|
||||
$waffect=new ISelect();
|
||||
$waffect->name='md_affect';
|
||||
$waffect->value=array(
|
||||
array('value'=>'ACH','label'=>_('Uniquement journaux achat')),
|
||||
array('value'=>'VEN','label'=>_('Uniquement journaux vente')),
|
||||
array('value'=>'GES','label'=>_('Partie gestion'))
|
||||
);
|
||||
$waffect->value=$this->cn->make_array("select dc_code,dc_comment from public.document_component order by dc_code");
|
||||
|
||||
$r.=td($waffect->input());
|
||||
$r.='</tr>';
|
||||
|
|
@ -285,7 +281,13 @@ class Document_modele
|
|||
$r.='<td class="notice">Si vous laissez à 0, la numérotation ne changera pas, la prochaine facture sera n+1, n étant le n° que vous avez donné</td>';
|
||||
$r.="</tr>";
|
||||
$r.='</table>';
|
||||
$r.='<ul class="aligned-block">';
|
||||
$r.='<li>';
|
||||
$r.=HtmlInput::submit('add_document','Ajout');
|
||||
$r.='</li>';
|
||||
$r.='<li>';
|
||||
$r.=HtmlInput::button_hide("add_modele");
|
||||
$r.='</li>';
|
||||
$r.="</form></p>";
|
||||
return $r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
//This file is part of NOALYSS and is under GPL
|
||||
//see licence.txt
|
||||
global $doc,$cn;
|
||||
?>
|
||||
<?php echo HtmlInput::title_box("Modèle de document","mod_doc",'hide')?>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
|
|
@ -44,12 +45,9 @@ echo $a->input();
|
|||
|
||||
$waffect=new ISelect();
|
||||
$waffect->name='md_affect';
|
||||
$waffect->value=array(
|
||||
array('value'=>'ACH','label'=>_('Uniquement journaux achat')),
|
||||
array('value'=>'VEN','label'=>_('Uniquement journaux vente')),
|
||||
array('value'=>'GES','label'=>_('Partie gestion'))
|
||||
);
|
||||
$waffect->selected=$doc->md_affect;
|
||||
$waffect->value=$cn->make_array("select dc_code,dc_comment from public.document_component order by dc_code");
|
||||
|
||||
$waffect->selected=$doc->md_affect;
|
||||
echo $waffect->input();
|
||||
?>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -1,2 +1,46 @@
|
|||
update menu_ref set me_menu='Journal' where me_code='CFGLED';
|
||||
|
||||
CREATE OR REPLACE FUNCTION comptaproc.four_upper_letter()
|
||||
RETURNS trigger
|
||||
AS $function$
|
||||
begin
|
||||
new.dc_code=transform_to_code(new.dc_code);
|
||||
new.dc_code:=substr(new.dc_code,1,4);
|
||||
return new;
|
||||
END;
|
||||
$function$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
COMMENT ON FUNCTION comptaproc.four_upper_letter() IS 'Cut to the 4 first letter in uppercase';
|
||||
|
||||
|
||||
DROP TABLE if exists document_component ;
|
||||
|
||||
CREATE TABLE document_component (
|
||||
dc_id int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY, -- PK
|
||||
dc_code text NOT NULL, -- Code used in document_modele
|
||||
dc_comment text not null , -- description
|
||||
CONSTRAINT document_component_pk PRIMARY KEY (dc_id),
|
||||
CONSTRAINT document_component_un UNIQUE (dc_code)
|
||||
);
|
||||
COMMENT ON TABLE public.document_component IS 'Give the component of NOALYSS that is using is';
|
||||
|
||||
-- Column comments
|
||||
|
||||
COMMENT ON COLUMN public.document_component.dc_id IS 'PK';
|
||||
COMMENT ON COLUMN public.document_component.dc_code IS 'Code used in document_modele';
|
||||
COMMENT ON COLUMN public.document_component.dc_comment IS 'Code used in document_modele';
|
||||
|
||||
-- Table Triggers
|
||||
|
||||
create trigger t_code before insert
|
||||
or update on
|
||||
public.document_component for each row execute function comptaproc.four_upper_letter();
|
||||
|
||||
|
||||
INSERT INTO document_component (dc_comment, dc_code) VALUES('Journaux achat', 'ACH');
|
||||
INSERT INTO document_component (dc_comment, dc_code) VALUES('Journaux vente', 'VEN');
|
||||
INSERT INTO document_component (dc_comment, dc_code) VALUES('Gestion', 'GES');
|
||||
|
||||
ALTER TABLE public.document_modele ADD CONSTRAINT document_modele_fk FOREIGN KEY (md_affect) REFERENCES public.document_component(dc_code) ON UPDATE CASCADE;
|
||||
|
||||
|
|
|
|||
|
|
@ -63,8 +63,10 @@ class Document_ModeleTest extends TestCase
|
|||
|
||||
$g_connection->exec_sql("delete from document_modele where md_affect='TST'");
|
||||
$g_connection->exec_sql("delete from document_type where dt_value='PHPUNIT'");
|
||||
$g_connection->exec_sql("delete from document_component where dc_code='TST'");
|
||||
|
||||
$this->type_id=$g_connection->get_value("insert into document_type (dt_value,dt_prefix) values ('PHPUNIT','TST')returning dt_id");
|
||||
$g_connection->get_value("insert into document_component (dc_code,dc_comment) values ('TST','PHPUnit Test')");
|
||||
|
||||
$md_id=$g_connection->get_next_seq('document_modele_md_id_seq');
|
||||
$sql="insert into document_modele(md_id,md_name,md_type,md_affect)
|
||||
|
|
@ -102,13 +104,13 @@ class Document_ModeleTest extends TestCase
|
|||
*/
|
||||
static function tearDownAfterClass(): void
|
||||
{
|
||||
// include 'global.php';
|
||||
$g_connection=\Dossier::connect();
|
||||
|
||||
$g_connection->exec_sql("delete from document_modele where md_affect='TST'");
|
||||
$g_connection->exec_sql("delete from document_type where dt_value='PHPUNIT'");
|
||||
$g_connection->exec_sql("delete from document_component where dc_code='TST'");
|
||||
$g_connection->exec_sql("delete from document_component where dc_code='E'");
|
||||
}
|
||||
//
|
||||
// public function dataExample()
|
||||
// {
|
||||
// return array([1], [2], [3]);
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -149,6 +151,7 @@ class Document_ModeleTest extends TestCase
|
|||
$this->assertTrue(! empty($lob_save),"Document no loaded");
|
||||
|
||||
//unset ($_FILES);
|
||||
$g_connection->get_value("insert into document_component (dc_code,dc_comment) values ('E','PHPUnit Test')");
|
||||
|
||||
$document_modele->update(['md_name'=>'XXXX',"md_type"=>"1","md_affect"=>'E','seq'=>0]);
|
||||
|
||||
|
|
@ -188,5 +191,6 @@ class Document_ModeleTest extends TestCase
|
|||
$this->assertEquals($document_modele->md_type,$this->type_id);
|
||||
$this->assertEquals($document_modele->md_affect,'TST');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue