diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 4b83100ae..1bcf63f09 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -289,7 +289,9 @@ $path = array( // add or update forecast_category "forecast_category"=>"ajax_forecast_category", // manage forecast - "forecast"=>"ajax_forecast" + "forecast"=>"ajax_forecast", + // manage company + "company"=>"ajax_company" ) ; if (array_key_exists($op, $path)) { diff --git a/html/css/style-classic7.css b/html/css/style-classic7.css index 5d3947528..4afe5abba 100644 --- a/html/css/style-classic7.css +++ b/html/css/style-classic7.css @@ -202,7 +202,7 @@ div.recherche_form{ div.content{ padding-top:0.0030%; margin-top:0.0030%; - width:100%; + width:98%; font-family: Arial, Helvetica, "Liberation Sans", FreeSans, sans-serif; font-family: 'OpenSansRegular'; font-size:12px; @@ -2809,4 +2809,39 @@ span.tagcell { /**========*/ #sold_item { width: 100%; - } \ No newline at end of file + } + + /*** + * w-20 width is 20 rem + **** **/ + .w-20 { + /* width: 20rem !important;*/ + width: 100% !important; + } + /* SM */ + @media (min-width: 576px) { + .w-20 { + /* width: 20rem !important;*/ + width: 100% !important; + } +} + /* MD */ + @media (min-width: 768px) { + .w-20 { + /* width: 20rem !important;*/ + width: 100% !important; + } + + } + /* LG */ + @media (min-width: 992px) { + .w-20 { + /* width: 20rem !important;*/ + width: 40% !important; + } + } + /* XL */ + @media (min-width: 1200px) { + + } + /**========*/ \ No newline at end of file diff --git a/html/menuarrow.gif b/html/menuarrow.gif deleted file mode 100644 index ed2dee0e6..000000000 Binary files a/html/menuarrow.gif and /dev/null differ diff --git a/include/ajax/ajax_company.php b/include/ajax/ajax_company.php new file mode 100644 index 000000000..dd817d974 --- /dev/null +++ b/include/ajax/ajax_company.php @@ -0,0 +1,61 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); + +/** + * @file + * @brief called from company.inc.php , add or modify extra parameter + */ +global $g_user; + +if ($g_user->check_module("COMPANY")==0) die(); + +require_once NOALYSS_INCLUDE.'/class/parameter_extra_mtable.class.php'; + +$http=new HttpInput(); +try { + $table=$http->request('table'); + $action=$http->request('action'); + $p_id=$http->request('p_id', "number"); + $ctl_id=$http->request('ctl'); + +} catch(Exception $e) { + echo $e->getMessage(); + return; +} +$parameter_extra =Parameter_Extra_MTable::build($p_id); +$parameter_extra->set_object_name($ctl_id); +if ($action=="input") +{ + $parameter_extra->send_header(); + echo $parameter_extra->ajax_input()->saveXML(); + return; +}elseif ($action == "save") { + $parameter_extra->send_header(); + echo $parameter_extra->ajax_save()->saveXML(); + return; +} elseif ($action == "delete") { + $parameter_extra->send_header(); + echo $parameter_extra->ajax_delete()->saveXML(); + return; +} \ No newline at end of file diff --git a/include/class/document.class.php b/include/class/document.class.php index 36854cf05..193fe7d34 100644 --- a/include/class/document.class.php +++ b/include/class/document.class.php @@ -698,6 +698,7 @@ class Document static $aTag=NULL; static $counter_tag=0; /* MY_PAYS; break; + + // customer /* \note The CUST_* are retrieved thx the $p_array['tiers'] @@ -1634,6 +1637,7 @@ class Document where ag_id=$1", array($p_array["ag_id"])); } return $ret; + } // end switch /* * retrieve the value of ATTR for e_march @@ -1646,6 +1650,7 @@ class Document { $id=$p_array['e_march'.$this->counter]; $r=$this->replace_special_tag($id, $p_tag); + return $r; } } /* @@ -1657,6 +1662,7 @@ class Document $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:''; // Retrieve f_id $r=$this->replace_special_tag($qcode, $p_tag); + return $r; } if (preg_match('/^CUSTATTR/', $p_tag)==1) { @@ -1666,7 +1672,13 @@ class Document $qcode=(isset($p_array['qcode_dest']))?$p_array['qcode_dest']:$p_array['e_client']; $r=$this->replace_special_tag($qcode, $p_tag); } + return $r; } + + // check also if the tag does exist in parameter_extra table + $pe_value=$this->db->get_value("select pe_value from parameter_extra where pe_code=$1",[$p_tag]); + if ( $this->db->count() > 0 ) { return $pe_value;} + return $r; } diff --git a/include/class/parameter_extra_mtable.class.php b/include/class/parameter_extra_mtable.class.php new file mode 100644 index 000000000..67d59b5f7 --- /dev/null +++ b/include/class/parameter_extra_mtable.class.php @@ -0,0 +1,87 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); + +/** + * @file + * @brief + */ +require_once NOALYSS_INCLUDE."/database/parameter_extra_sql.class.php"; +require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php"; + +class Parameter_Extra_MTable extends Manage_Table_SQL +{ + function __construct(\Data_SQL $p_table) + { + parent::__construct($p_table); + } + static function build ($p_id=-1) + { + $cn=Dossier::connect(); + $object_sql=new Parameter_Extra_SQL($cn,$p_id); + $object=new Parameter_Extra_MTable($object_sql); + $object->set_button_add_top(false); + $object->set_col_label("pe_code", _("Code")); + $object->set_col_label("pe_label", _("Intitulé")); + $object->set_col_label("pe_value", _("Valeur")); + $object->set_order(['pe_code','pe_label','pe_value']); + $object->set_search_table(false); + $object->set_callback("ajax_misc.php"); + $object->add_json_param("op", "company"); + $object->setCssClass("inner_box w-20"); + + return $object; + + } + /** + * Check before insert or update + */ + function check() { + $object=$this->get_table(); + $cn=$object->cn; + $error=0; + // duplicate + $code=$cn->get_value("select comptaproc.transform_to_code($1)",[ $object->getp("pe_code")]); + if ( $cn->get_value("select count(*) from parameter_extra where pe_code =$1 and id != $2", + [$code,$object->getp("id")]) > 0 ) { + $this->set_error("pe_code", _("Code déjà utilisé")); + $error++; + } + // pe_code cannot be empyt + if ( $code == "") { + $this->set_error("pe_code", _("ne peut être vide")); + $error++; + } + // pe_code cannot be empyt + if ( preg_match('/^ATTR/', $code) == 1 || + preg_match('/^CUSTATTR/', $code) == 1 || + preg_match('/^BENEFATTR/', $code) == 1 ) + { + $this->set_error("pe_code", _("ne peut être pas commencer par ATTR , BENEFATTR ou CUSTATTR")); + $error++; + } + if ($error > 0) { return false;} + + return true; + } +} \ No newline at end of file diff --git a/include/company.inc.php b/include/company.inc.php index b9749d67a..d096b338d 100644 --- a/include/company.inc.php +++ b/include/company.inc.php @@ -17,185 +17,300 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Copyright Author Dany De Bontridder danydb@aevalys.eu -/*! +/* ! * \file - *\brief Manage the company setting : address, vat number, Check period, VAT, + * \brief Manage the company setting : address, vat number, Check period, VAT, * CA .... */ -if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); require_once NOALYSS_INCLUDE.'/class/noalyss_parameter_folder.class.php'; +require_once NOALYSS_INCLUDE.'/class/parameter_extra_mtable.class.php'; global $g_user; $http=new HttpInput(); echo '
'; if (isset($_POST['record_company'])) { - $m = new Noalyss_Parameter_Folder($cn); - $m->MY_NAME = $http->post("p_name"); - $m->MY_TVA = $http->post("p_tva"); - $m->MY_STREET = $http->post("p_street"); - $m->MY_NUMBER = $http->post("p_no"); - $m->MY_CP = $http->post("p_cp"); - $m->MY_COMMUNE = $http->post("p_Commune"); - $m->MY_TEL = $http->post("p_tel"); - $m->MY_FAX = $http->post("p_fax"); - $m->MY_PAYS = $http->post("p_pays"); - $m->MY_CHECK_PERIODE =$http->post("p_check_periode"); - $m->MY_DATE_SUGGEST = $http->post("p_date_suggest"); - $m->MY_ANALYTIC =$http->post("p_compta"); - $m->MY_STRICT = $http->post("p_strict"); - $m->MY_TVA_USE = $http->post("p_tva_use"); - $m->MY_PJ_SUGGEST = $http->post("p_pj"); - $m->MY_ALPHANUM = $http->post("p_alphanum"); - $m->MY_UPDLAB = $http->post("p_updlab"); - $m->MY_STOCK =$http->post("p_stock"); - $m->MY_CURRENCY =$http->post("p_currency"); - $m->MY_DEFAULT_ROUND_ERROR_DEB=$http->post("p_round_error_deb"); - $m->MY_DEFAULT_ROUND_ERROR_CRED=$http->post("p_round_error_cred"); - $m->MY_ANC_FILTER=$http->post("p_anc_filter"); - try{ - $m->update(); - } catch (Exception $e) { - alert($e->getMessage()); - } + $m=new Noalyss_Parameter_Folder($cn); + $m->MY_NAME=$http->post("p_name"); + $m->MY_TVA=$http->post("p_tva"); + $m->MY_STREET=$http->post("p_street"); + $m->MY_NUMBER=$http->post("p_no"); + $m->MY_CP=$http->post("p_cp"); + $m->MY_COMMUNE=$http->post("p_Commune"); + $m->MY_TEL=$http->post("p_tel"); + $m->MY_FAX=$http->post("p_fax"); + $m->MY_PAYS=$http->post("p_pays"); + $m->MY_CHECK_PERIODE=$http->post("p_check_periode"); + $m->MY_DATE_SUGGEST=$http->post("p_date_suggest"); + $m->MY_ANALYTIC=$http->post("p_compta"); + $m->MY_STRICT=$http->post("p_strict"); + $m->MY_TVA_USE=$http->post("p_tva_use"); + $m->MY_PJ_SUGGEST=$http->post("p_pj"); + $m->MY_ALPHANUM=$http->post("p_alphanum"); + $m->MY_UPDLAB=$http->post("p_updlab"); + $m->MY_STOCK=$http->post("p_stock"); + $m->MY_CURRENCY=$http->post("p_currency"); + $m->MY_DEFAULT_ROUND_ERROR_DEB=$http->post("p_round_error_deb"); + $m->MY_DEFAULT_ROUND_ERROR_CRED=$http->post("p_round_error_cred"); + $m->MY_ANC_FILTER=$http->post("p_anc_filter"); + try + { + $m->update(); + } + catch (Exception $e) + { + alert($e->getMessage()); + } } -$my = new Noalyss_Parameter_Folder($cn); +$my=new Noalyss_Parameter_Folder($cn); ///// Compta analytic -$array = array( - array("value" => "ob", 'label' => _("obligatoire")), - array("value" => "op", 'label' => _("optionnel")), - array("value" => "nu", 'label' => _("non utilisé")) +$array=array( + array("value"=>"ob", 'label'=>_("obligatoire")), + array("value"=>"op", 'label'=>_("optionnel")), + array("value"=>"nu", 'label'=>_("non utilisé")) ); -$strict_array = array( - array('value' => 'N', 'label' => _('Non')), - array('value' => 'Y', 'label' => _('Oui')) +$strict_array=array( + array('value'=>'N', 'label'=>_('Non')), + array('value'=>'Y', 'label'=>_('Oui')) ); -$alpha_num_array[0] = array('value' => 'N', 'label' => _('Non')); -$alpha_num_array[1] = array('value' => 'Y', 'label' => _('Oui')); +$alpha_num_array[0]=array('value'=>'N', 'label'=>_('Non')); +$alpha_num_array[1]=array('value'=>'Y', 'label'=>_('Oui')); -$updlab_array[0] = array('value' => 'N', 'label' => _('Non')); -$updlab_array[1] = array('value' => 'Y', 'label' => _('Oui')); +$updlab_array[0]=array('value'=>'N', 'label'=>_('Non')); +$updlab_array[1]=array('value'=>'Y', 'label'=>_('Oui')); -$compta = new ISelect(); -$compta->table = 1; -$compta->selected = $my->MY_ANALYTIC; +$compta=new ISelect(); +$compta->selected=$my->MY_ANALYTIC; -$strict = new ISelect(); -$strict->table = 1; -$strict->selected = $my->MY_STRICT; +$strict=new ISelect(); +$strict->selected=$my->MY_STRICT; -$tva_use = new ISelect(); -$tva_use->table = 1; -$tva_use->selected = $my->MY_TVA_USE; +$tva_use=new ISelect(); +$tva_use->selected=$my->MY_TVA_USE; -$pj_suggest = new ISelect(); -$pj_suggest->table = 1; -$pj_suggest->selected = $my->MY_PJ_SUGGEST; +$pj_suggest=new ISelect(); +$pj_suggest->selected=$my->MY_PJ_SUGGEST; -$date_suggest = new ISelect(); -$date_suggest->table = 1; -$date_suggest->selected = $my->MY_DATE_SUGGEST; +$date_suggest=new ISelect(); +$date_suggest->selected=$my->MY_DATE_SUGGEST; -$check_periode = new ISelect(); -$check_periode->table = 1; -$check_periode->selected = $my->MY_CHECK_PERIODE; -$alpha_num = new ISelect(); -$alpha_num->table = 1; -$alpha_num->value = $alpha_num_array; -$alpha_num->selected = $my->MY_ALPHANUM; +$check_periode=new ISelect(); +$check_periode->selected=$my->MY_CHECK_PERIODE; +$alpha_num=new ISelect(); +$alpha_num->value=$alpha_num_array; +$alpha_num->selected=$my->MY_ALPHANUM; -$updlab = new ISelect(); -$updlab->table = 1; -$updlab->value = $updlab_array; -$updlab->selected = $my->MY_UPDLAB; +$updlab=new ISelect(); +$updlab->value=$updlab_array; +$updlab->selected=$my->MY_UPDLAB; -$stock = new ISelect('p_stock'); -$stock->value = array( - array('value' => 'N', 'label' => _('Non')), - array('value' => 'Y', 'label' => _('Oui')) +$stock=new ISelect('p_stock'); +$stock->value=array( + array('value'=>'N', 'label'=>_('Non')), + array('value'=>'Y', 'label'=>_('Oui')) ); -$stock->selected = $my->MY_STOCK; -$stock->table = 1; +$stock->selected=$my->MY_STOCK; $anc_filter=new IText("p_anc_filter", $my->MY_ANC_FILTER); $anc_filter->placeholder='6,7'; $anc_filter->title=_("Uniquement des chiffres séparés par des virgules"); -$use_currency= new ISelect(); -$use_currency->table = 1; -$use_currency->value = $updlab_array; -$use_currency->selected = $my->MY_CURRENCY; +$use_currency=new ISelect(); +$use_currency->value=$updlab_array; +$use_currency->selected=$my->MY_CURRENCY; -$default_error_deb=new IPoste("p_round_error_deb",$my->MY_DEFAULT_ROUND_ERROR_DEB); -$default_error_deb->name = 'p_round_error_deb'; -$default_error_deb->set_attribute('gDossier',Dossier::id()); -$default_error_deb->set_attribute('jrn',0); -$default_error_deb->set_attribute('account','p_round_error_deb'); +$default_error_deb=new IPoste("p_round_error_deb", $my->MY_DEFAULT_ROUND_ERROR_DEB); +$default_error_deb->name='p_round_error_deb'; +$default_error_deb->set_attribute('gDossier', Dossier::id()); +$default_error_deb->set_attribute('jrn', 0); +$default_error_deb->set_attribute('account', 'p_round_error_deb'); -$default_error_cred=new IPoste("p_round_error_deb",$my->MY_DEFAULT_ROUND_ERROR_CRED); -$default_error_cred->name = 'p_round_error_cred'; -$default_error_cred->set_attribute('gDossier',Dossier::id()); -$default_error_cred->set_attribute('jrn',0); -$default_error_cred->set_attribute('account','p_round_error_cred'); +$default_error_cred=new IPoste("p_round_error_cred", $my->MY_DEFAULT_ROUND_ERROR_CRED); +$default_error_cred->name='p_round_error_cred'; +$default_error_cred->set_attribute('gDossier', Dossier::id()); +$default_error_cred->set_attribute('jrn', 0); +$default_error_cred->set_attribute('account', 'p_round_error_cred'); // other parameters -$all = new IText(); -$all->table = 1; -echo '
'; -echo dossier::hidden(); -echo ""; -echo "" . td(_('Nom société'), 'style="text-align:right"') . $all->input("p_name", $my->MY_NAME) . ""; -$all->value = ''; -echo "" . td(_("Téléphone"), 'style="text-align:right"') . $all->input("p_tel", $my->MY_TEL) . ""; -$all->value = ''; -echo "" . td(_("Fax"), 'style="text-align:right"') . $all->input("p_fax", $my->MY_FAX) . ""; -$all->value = ''; -echo "" . td(_("Rue "), 'style="text-align:right"') . $all->input("p_street", $my->MY_STREET) . ""; -$all->value = ''; -echo "" . td(_("Numéro"), 'style="text-align:right"') . $all->input("p_no", $my->MY_NUMBER) . ""; -$all->value = ''; -echo "" . td(_("Code Postal"), 'style="text-align:right"') . $all->input("p_cp", $my->MY_CP) . ""; -$all->value = ''; -echo "" . td(_("Commune"), 'style="text-align:right"') . $all->input("p_Commune", $my->MY_COMMUNE) . ""; -$all->value = ''; -echo "" . td(_("Pays"), 'style="text-align:right"') . $all->input("p_pays", $my->MY_PAYS) . ""; -$all->value = ''; -echo "" . td(_("Numéro de Tva"), 'style="text-align:right"') . $all->input("p_tva", $my->MY_TVA) . ""; -echo "" . td(_("Utilisation de la compta. analytique"), 'style="text-align:right"') . - $compta->input("p_compta", $array) . ""; -echo ''. td(_("Opération analytique uniquement pour les postes comptables commençant par")). - ''. - ''; -echo "" . td(_("Utilisation des stocks"), 'style="text-align:right"') . $stock->input() . ""; - -echo "" . td(_("Utilisation de devises étrangères"), 'style="text-align:right"') . $use_currency->input("p_currency", $strict_array) . ""; -echo "" . td(_("Utilisation du mode strict "), 'style="text-align:right"') . $strict->input("p_strict", $strict_array) . ""; -echo "" . td(_("Assujetti à la tva"), 'style="text-align:right"') . $tva_use->input("p_tva_use", $strict_array) . ""; -echo "" . td(_("Suggérer le numéro de pièce justificative"), 'style="text-align:right"') . $pj_suggest->input("p_pj", $strict_array) . ""; -echo "" . td(_("Suggérer la date"), 'style="text-align:right"') . $date_suggest->input("p_date_suggest", $strict_array) . ""; -echo '' . td(_('Afficher la période comptable pour éviter les erreurs de date'), 'style="text-align:right"') . $check_periode->input('p_check_periode', $strict_array) . ''; -echo '' . td(_('Utilisez des postes comptables alphanumérique'), 'style="text-align:right"') . $alpha_num->input('p_alphanum') . ''; -echo '' . td(_('Changer le libellé des détails'), 'style="text-align:right"') . $updlab->input('p_updlab') . ''; -echo '' . - td(_("Poste comptable de CHARGE (D) pour les différences d'arrondi pour les opérations en devise")). - ''. - ''; - -echo '' . - td(_("Poste comptable en PRODUIT (C) pour les différences d'arrondi pour les opérations en devise")). - ''. - ''; - -echo "
'. - $anc_filter->input(). - Icon_Action::tips($anc_filter->title); - '
'.$default_error_deb->input(). - '
'.$default_error_cred->input(). - '
"; -echo HtmlInput::submit("record_company", _("Sauve")); -echo "
"; -echo '
'; -return; +$all=new IText(); +$all->table=1; +$all->style=' class="input_text"'; ?> +
+ +
+ + +
+

Société

+
+ + + input("p_name", $my->MY_NAME) ?> +
+
+ + + input("p_name", $my->MY_TEL) ?> +
+
+ + + input("p_name", $my->MY_FAX) ?> +
+
+ + + input("p_name", $my->MY_STREET) ?> +
+
+ + + input("p_name", $my->MY_NUMBER) ?> +
+
+ + + input("p_name", $my->MY_CP) ?> +
+
+ + + input("p_name", $my->MY_COMMUNE) ?> +
+
+ + + input("p_name", $my->MY_PAYS) ?> +
+
+ + + input("p_name", $my->MY_TVA) ?> +
+
+
+
+ + +
+
+
+
+
+

Paramètre supplémentaire

+ create_js_script(); + $object->display_table(); + ?> +
+
+
+ +
+

Fonctionnement

+ + + +
+ + input("p_compta", $array) ?> +
+ +
+ + +input(); +echo Icon_Action::tips($anc_filter->title); +?> +
+ +
+ +input() ?> +
+ +
+ +input("p_strict", $strict_array) ?> +
+ + +
+ +input("p_tva_use", $strict_array) ?> +
+ +
+ +input("p_pj", $strict_array) ?> +
+ + +
+ +input("p_date_suggest", $strict_array) ?> +
+ + +
+ +input('p_check_periode', $strict_array) ?> +
+ + +
+ + input('p_alphanum') ?> +
+ +
+ + input('p_updlab') ?> +
+ +
+ + input() ?> +
+ +
+ + input() ?> +
+ +
+
+
+ + +
+
+
+
+
+ +
diff --git a/include/constant.php b/include/constant.php index 08ae2b758..75363bedf 100644 --- a/include/constant.php +++ b/include/constant.php @@ -110,7 +110,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) { if ( ! defined ("SYSINFO_DISPLAY")) { define ("SYSINFO_DISPLAY",TRUE); } -define ("DBVERSION",154); +define ("DBVERSION",155); define ("MONO_DATABASE",25); define ("DBVERSIONREPO",19); define ('NOTFOUND','--not found--'); diff --git a/include/database/parameter_extra_sql.class.php b/include/database/parameter_extra_sql.class.php new file mode 100644 index 000000000..91c1ab107 --- /dev/null +++ b/include/database/parameter_extra_sql.class.php @@ -0,0 +1,66 @@ +table = "public.parameter_extra"; + $this->primary_key = "id"; +/* + * List of columns + */ + $this->name=array( + "id"=>"id" + ,"pe_code"=>"pe_code" + ,"pe_label"=>"pe_label" + ,"pe_value"=>"pe_value" + ); +/* + * Type of columns + */ + $this->type = array( + "id"=>"numeric" + ,"pe_code"=>"text" + ,"pe_label"=>"text" + ,"pe_value"=>"text" + ); + + + $this->default = array( + "id" => "auto" + ); + + $this->date_format = "DD.MM.YYYY"; + parent::__construct($p_cn,$p_id); + } + + +} diff --git a/include/sql/patch/upgrade154.sql b/include/sql/patch/upgrade154.sql new file mode 100644 index 000000000..946a50503 --- /dev/null +++ b/include/sql/patch/upgrade154.sql @@ -0,0 +1,72 @@ +begin; +create table parameter_extra (id serial primary key , pe_code text,pe_label text ,pe_value text); +alter table parameter_extra add constraint pe_code_ux unique (pe_code); +comment on table parameter_extra is 'Extra parameter for the folder'; +comment on column parameter_extra.pe_code is 'Code used in the Document:generate'; +comment on column parameter_extra.pe_label is 'Label description'; +comment on column parameter_extra.pe_value is 'Value which will replace the tag in Document:generate'; + + +CREATE OR REPLACE FUNCTION comptaproc.transform_to_code(p_account text) + RETURNS text + AS $function$ + +declare + +sResult text; + +begin +sResult := lower(p_account); + +sResult := translate(sResult,E'éèêëàâäïîüûùöôç','eeeeaaaiiuuuooc'); +sResult := translate(sResult,E' $€µ£%.+-/\\!(){}(),;&|"#''^<>*',''); + +return upper(sResult); + +end; +$function$ +LANGUAGE plpgsql; + + +create or replace function comptaproc.t_parameter_extra_code () returns trigger +as $fct$ +begin + new.pe_code := comptaproc.transform_to_code (new.pe_code); + return new; +end; +$fct$ +language plpgsql; + + +create trigger trigger_parameter_extra_format_code_biu +before insert or update on parameter_extra for each row execute procedure comptaproc.t_parameter_extra_code(); + +create or replace function tmp_1 () returns void +as +$fct$ +declare + sCountry text; +begin + select pr_value into sCountry from parameter where pr_id='MY_COUNTRY'; + +if sCountry = 'BE' then + insert into parameter_extra(pe_code,pe_label) values ('RPM','RPM'), ('ONSS','Numéro ONSS'); + +end if; + +if sCountry = 'FR' then + insert into parameter_extra(pe_code,pe_label) values ('SIRET','SIRET'), ('SIREN','SIREN'); +end if; +insert into parameter_extra (pe_code,pe_label) values ('email_company','Email Société'),('web_company','Site Web'); + +end; +$fct$ +language plpgsql; + +select tmp_1(); + +drop function tmp_1; +insert into version (val,v_description) values (155,'Rewriting of COMPANY add extra parameter'); + + +commit; \ No newline at end of file