diff --git a/include/cat_document.inc.php b/include/cat_document.inc.php
index d179cab95..08a39be48 100644
--- a/include/cat_document.inc.php
+++ b/include/cat_document.inc.php
@@ -31,11 +31,13 @@ require_once ('class_document_type.php');
if ( isset($_POST['add']) )
{
$catDoc=new Document_Type($cn);
- $catDoc->insert($_POST['cat']);
+ $catDoc->insert($_POST['cat'],$_POST['prefix']);
}
$aList=Document_Type::get_list($cn);
$addCat=new IText('cat');
+$addPrefix=new IText('prefix');
$str_addCat=$addCat->input();
+$str_addPrefix=$addPrefix->input();
$str_submit=HtmlInput::submit('add',_('Ajout'));
echo '
';
require_once('template/list_category_document.php');
diff --git a/include/class_document_type.php b/include/class_document_type.php
index 373b78dae..1f9868707 100644
--- a/include/class_document_type.php
+++ b/include/class_document_type.php
@@ -61,6 +61,7 @@ class Document_type
for ($i=0;$ilabel=_('Effacer');
@@ -74,15 +75,15 @@ class Document_type
}
return $array;
}
- function insert($p_value)
+ function insert($p_value,$p_prefix)
{
- $sql="insert into document_type(dt_value) values ($1)";
+ $sql="insert into document_type(dt_value,dt_prefix) values ($1,$2)";
try
{
if( $this->db->count_sql('select * from document_type where upper(dt_value)=upper(trim($1))',array($p_value))>0)
throw new Exception('Nom en double');
if ( strlen(trim($p_value))>0)
- $this->db->exec_sql($sql,array($p_value));
+ $this->db->exec_sql($sql,array($p_value,$p_prefix));
}
catch (Exception $e)
{
diff --git a/include/class_follow_up.php b/include/class_follow_up.php
index bdcbf029c..ce0e34edc 100644
--- a/include/class_follow_up.php
+++ b/include/class_follow_up.php
@@ -271,10 +271,7 @@ class Follow_Up
// ag_ref
// Always false for update
- $ag_ref = new IText();
- $ag_ref->readonly = $upd;
- $ag_ref->name = "ag_ref";
- $ag_ref->value = sql_string($this->ag_ref);
+
$client_label = new ISpan();
/* Add button */
@@ -366,7 +363,10 @@ class Follow_Up
$h_agrefid = new IHidden();
- $str_ag_ref = "" . (($this->ag_ref != "") ? $this->ag_ref : " Nouveau ") . "";
+ $iag_ref=new IText("ag_ref");
+ $iag_ref->value=$this->ag_ref;
+ $iag_ref->readOnly = ($p_view == "NEW")?true:false;
+ $str_ag_ref =$iag_ref->input();
// Preparing the return string
$r = "";
@@ -586,8 +586,9 @@ class Follow_Up
$this->ag_id = $this->db->get_next_seq('action_gestion_ag_id_seq');
// Create the reference
- $ref = $this->dt_id . '/' . $this->ag_id;
- $this->ag_ref = $ref;
+ $ag_ref=$this->db->get_value('select dt_prefix from document_type where dt_id=$1',array($this->dt_id)).'-'.$this->db->get_next_seq($seq_name);
+ $this->ag_ref = $ag_ref;
+
if ($this->ag_cal == 'on')
$ag_cal = 'C';
else
@@ -617,7 +618,7 @@ class Follow_Up
$this->dt_id, /* 3 */
$this->ag_title, /* 4 */
$exp->id, /* 5 */
- $ref, /* 6 */
+ $ag_ref, /* 6 */
$this->ag_dest, /* 7 */
$this->ag_hour, /* 8 */
$this->ag_priority, /* 9 */
@@ -858,12 +859,10 @@ class Follow_Up
$contact->id = 0;
- $ref = $this->dt_id . '/' . $this->ag_id;
if ($this->ag_cal == 'on')
$ag_cal = 'C';
else
$ag_cal = 'I';
- $this->ag_ref = $ref;
if ($this->ag_dest == 0)
{
$this->ag_dest = null;
@@ -979,6 +978,7 @@ class Follow_Up
function fromArray($p_array)
{
$this->ag_id = (isset($p_array['ag_id'])) ? $p_array['ag_id'] : "";
+ $this->ag_ref = (isset($p_array['ag_ref'])) ? $p_array['ag_ref'] : "";
$this->qcode_dest = (isset($p_array['qcode_dest'])) ? $p_array['qcode_dest'] : "";
$this->f_id_dest = (isset($p_array['f_id_dest'])) ? $p_array['f_id_dest'] : 0;
$this->ag_timestamp = (isset($p_array['ag_timestamp'])) ? $p_array['ag_timestamp'] : date('d.m.Y');
diff --git a/include/template/list_category_document.php b/include/template/list_category_document.php
index e8428dcf0..beedbca38 100644
--- a/include/template/list_category_document.php
+++ b/include/template/list_category_document.php
@@ -9,7 +9,10 @@ for ($i=0;$i
|
-=$row['dt_value'];?>
+=h($row['dt_value']);?>
+ |
+
+=h($row['dt_prefix']);?>
|
=$row['js_remove'];?>
@@ -22,6 +25,9 @@ endfor;
|
=$str_addCat?>
|
+
+=$str_addPrefix?>
+ |
=$str_submit?>
|
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 563770c15..9b73528b5 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -182,4 +182,10 @@ update menu_ref set me_menu='Action Gestion' where me_code='FOLLOW';
DROP FUNCTION comptaproc.action_get_tree(bigint);
insert into menu_ref(me_code,me_menu,me_type) values ('CSV:ActionGestion','Export Action Gestion','PR');
-insert into profile_menu(me_code,p_id,p_type_display,pm_default) values ('CSV:ActionGestion',1,'P',0);
\ No newline at end of file
+insert into profile_menu(me_code,p_id,p_type_display,pm_default) values ('CSV:ActionGestion',1,'P',0);
+
+
+ALTER TABLE document_type ADD COLUMN dt_prefix text;
+COMMENT ON COLUMN document_type.dt_prefix IS 'Prefix for ag_ref';
+
+update document_type set dt_prefix= upper(substr(replace(dt_value,' ',''),0,7))||dt_id::text
\ No newline at end of file