diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 58f149669..a2a4362d7 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -209,7 +209,9 @@ $path = array(
// search operation to reconcile
'search_op'=>'ajax_search_operation',
// delete operation
- 'delete_search_operation'=>'ajax_search_filter'
+ 'delete_search_operation'=>'ajax_search_filter',
+ // template category of card
+ 'template_cat_card'=>'ajax_template_cat_card'
) ;
if (array_key_exists($op, $path)) {
diff --git a/include/ajax/ajax_template_cat_card.php b/include/ajax/ajax_template_cat_card.php
new file mode 100644
index 000000000..d5625c5d6
--- /dev/null
+++ b/include/ajax/ajax_template_cat_card.php
@@ -0,0 +1,67 @@
+
+
+if (!defined('ALLOWED'))
+ die('Appel direct ne sont pas permis');
+
+/**
+ * @file
+ * @brief Manage the template of category of card
+ */
+
+require_once NOALYSS_INCLUDE."/class/template_card_category.class.php";
+/**
+ * @todo ajax_template_cat_card add security
+ */
+
+$http=new HttpInput();
+$action=$http->request("action");
+$p_id=$http->request("p_id");
+$ctl=$http->request("ctl");
+
+$cat_sql=new Fiche_Def_Ref_SQL($cn, $p_id);
+$cat=new Template_Card_Category($cat_sql);
+$cat->set_callback("ajax_misc.php");
+$cat->add_json_param("gDossier", Dossier::id());
+$cat->add_json_param("op", "template_cat_card");
+$cat->set_object_name($ctl);
+
+switch ($action)
+{
+ case "input":
+ // Display a box with the data
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $cat->ajax_input()->saveXML();
+ return;
+ break;
+ case "save":
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $cat->ajax_save()->saveXML();
+ return;
+ break;
+ case "delete":
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $cat->ajax_delete()->saveXML();
+ return;
+ break;
+ default:
+ break;
+}
diff --git a/include/class/fiche_def.class.php b/include/class/fiche_def.class.php
index 6bfb60b26..55ded5b89 100644
--- a/include/class/fiche_def.class.php
+++ b/include/class/fiche_def.class.php
@@ -59,10 +59,10 @@ class Fiche_Def
$class_base->set_attribute('account','class_base');
$class_base->set_attribute('label','acc_label');
$f_class_base=$class_base->input();
- $fd_description=new ITextarea('fd_description');
- $fd_description->width=80;
- $fd_description->heigh=4;
- $fd_description->style='class="itextarea" style="margin-left:0px;vertical-align:text-top"';
+ $fd_description=new ITextarea('fd_description');
+ $fd_description->width=80;
+ $fd_description->heigh=4;
+ $fd_description->style='class="itextarea" style="margin-left:0px;vertical-align:text-top"';
require_once NOALYSS_TEMPLATE.'/fiche_def_input.php';
return;
}
diff --git a/include/class/fiche_def_ref.class.php b/include/class/fiche_def_ref.class.php
index c8aa5c195..2c3b604d1 100644
--- a/include/class/fiche_def_ref.class.php
+++ b/include/class/fiche_def_ref.class.php
@@ -40,99 +40,7 @@ class Fiche_Def_Ref
$this->frd_id=$p_frd_id;
$this->attribut=array('frd_id','frd_text','frd_class_base');
}
- /*!
- **************************************************
- * \brief Load all the fiche_def_ref data and
- * return an array of fiche_def_ref objects
- *
- * \return array
- */
- function LoadAll()
- {
- $sql="select * from fiche_def_ref order by frd_id";
- $Res=$this->db->exec_sql($sql);
- $all=Database::fetch_all($Res);
- if ( $Res == false ) return array();
- $idx=0;
- $array=array();
- foreach ($all as $row)
- {
- $o=new Fiche_Def_Ref($this->db);
-
- foreach ( $this->attribut as $value)
- {
- $o->$value=$row[$value];
- }
- $array[$idx]=$o;
- $idx++;
- }
- return $array;
- }
- /*!
- **************************************************
- * \brief Display data between
tag
- *
- * \return string
- */
- function Display()
- {
- $r="";
- foreach ( $this->attribut as $value)
- {
- $r.=" | ".$this->$value.' | ';
- }
- return $r;
- }
- /*!
- **************************************************
- * \brief Input Data between tag
- *
- * \return string
- */
- function Input()
- {
- $r="";
- $h=new IHidden();
- $r.='Id :'.$h->input('frd_id',$this->frd_id).$this->frd_id."";
- $w=new IText();
- $r.=''._('Commentaire ').' :'.$w->input('frd_text',$this->frd_text)."";
- $t=new IText();
- $r.=''._('Poste de base').':'.$t->input('frd_class_base',$this->frd_class_base)."";
-
- return $r;
- }
- /*!
- **************************************************
- * \brief Store data into the database: update the
- * record
- *
- * -
- * \return none
- */
- function Save()
- {
- $sql="update fiche_def_ref set frd_text=$1 ".
- " , frd_class_base=$2 ".
- " where frd_id= $3";
- $Res=$this->db->exec_sql($sql,array($this->frd_text,$this->frd_class_base,$this->frd_id));
- }
- /*!
- **************************************************
- * \brief Get the data with the p_code and complete
- * the current object
- *
- * \return none
- */
- function Get()
- {
- $sql="select * from fiche_def_ref ".
- " where frd_id=".$this->frd_id;
- $Res=$this->db->exec_sql($sql);
- if ( Database::num_row($Res) == 0 ) return null;
- $r=Database::fetch_array($Res,0);
- $this->frd_text=$r['frd_text'];
- $this->frd_class_base=$r['frd_class_base'];
- }
+
/**
* get category of cards by model
* @param $p_modele if the FRD_ID
diff --git a/include/class/template_card_category.class.php b/include/class/template_card_category.class.php
new file mode 100644
index 000000000..81b6f6fe5
--- /dev/null
+++ b/include/class/template_card_category.class.php
@@ -0,0 +1,84 @@
+
+
+require_once NOALYSS_INCLUDE.'/lib/manage_table_sql.class.php';
+require_once NOALYSS_INCLUDE.'/database/fiche_def_ref_sql.class.php';
+
+/**
+ * @file
+ * @brief Manage the template of card category
+ */
+
+/**
+ * @class
+ * @brief Manage the template of card category
+ */
+class Template_Card_Category extends Manage_Table_SQL
+{
+ function __construct(Fiche_def_ref_SQL $p_table)
+ {
+ $this->table=$p_table;
+ parent::__construct($p_table);
+ // Label of the columns
+ $this->set_col_label("frd_text", _("Nom"));
+ $this->set_col_label("frd_class_base", _("Poste comptable de base"));
+ $this->set_col_label("frd_id", _("ID"));
+ // Cannot update frd_id
+ $this->set_property_updatable("frd_id", FALSE);
+ $this->a_order=["frd_id","frd_text","frd_class_base"];
+ }
+ function delete()
+ {
+ $cn=Dossier::connect();
+
+ if ( $cn->get_value("select count(*) from fiche_def where frd_id=$1",[$this->table->frd_id])>0)
+ {
+ throw new Exception(_("Effacement impossible : catégorie utilisée"));
+ }
+ }
+ /**
+ * Check before inserting or updating, return TRUE if ok otherwise FALSE.
+ * @return boolean
+ */
+ function check()
+ {
+ $cn=Dossier::connect();
+ $error=0;
+ if ( trim($this->table->frd_text) == "" ) {
+ $this->set_error("frd_text",_("Le nom ne peut pas être vide"));
+ $error++;
+ }
+ if ( trim($this->table->frd_class_base) != "" ) {
+ $cnt=$cn->get_value("select count(*) from tmp_pcmn where pcm_val=$1"
+ ,[$this->table->frd_class_base]);
+ if ($cnt == 0) {
+ $this->set_error("frd_class_base",_("Poste comptable n'existe pas"));
+ $error++;
+ }
+ }
+
+ if ( $error != 0) {
+ return false;
+ }
+ return true;
+
+ }
+}
\ No newline at end of file
diff --git a/include/database/fiche_def_ref_sql.class.php b/include/database/fiche_def_ref_sql.class.php
new file mode 100644
index 000000000..5ad8b9939
--- /dev/null
+++ b/include/database/fiche_def_ref_sql.class.php
@@ -0,0 +1,67 @@
+
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file
+ * @brief Manage the table public.fiche_def_ref , which concerns the template of
+ * category of card
+ */
+require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
+require_once NOALYSS_INCLUDE.'/lib/database.class.php';
+
+/**
+ * @class
+ * @file Manage the table public.fiche_def_ref , which concerns the template of
+ * category of card
+ */
+class Fiche_def_ref_SQL extends Noalyss_SQL
+{
+
+ function __construct(Database $p_cn, $p_id=-1)
+ {
+ $this->table="public.fiche_def_ref";
+ $this->primary_key="frd_id";
+ /*
+ * List of columns
+ */
+ $this->name=array(
+ "frd_id"=>"frd_id"
+ , "frd_text"=>"frd_text"
+ , "frd_class_base"=>"frd_class_base"
+ );
+ /*
+ * Type of columns
+ */
+ $this->type=array(
+ "frd_id"=>"numeric"
+ , "frd_text"=>"text"
+ , "frd_class_base"=>"text"
+ );
+
+
+ $this->default=array(
+ "frd_id"=>"auto"
+ );
+
+ $this->date_format="DD.MM.YYYY";
+ parent::__construct($p_cn, $p_id);
+ }
+
+}
diff --git a/include/fiche_def.inc.php b/include/fiche_def.inc.php
index 4930c6de5..cf302201a 100644
--- a/include/fiche_def.inc.php
+++ b/include/fiche_def.inc.php
@@ -20,68 +20,18 @@
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
require_once NOALYSS_INCLUDE.'/lib/ihidden.class.php';
require_once NOALYSS_INCLUDE.'/class/fiche_def.class.php';
+require_once NOALYSS_INCLUDE.'/class/template_card_category.class.php';
-/*! \file
- * \brief Let customise the fiche_def_ref for the user
+/*!
+ * @file
+ * @brief Let customise the fiche_def_ref for the user
*/
echo '';
-// record change
-if ( isset ($_POST['confirm_mod']))
-{
- extract ($_POST);
- $update=new Fiche_Def_Ref($cn);
- $update->frd_id=sql_string($frd_id);
- $update->frd_text=sql_string($frd_text);
- $update->frd_class_base=sql_string($frd_class_base);
- $update->Save();
-}
-// Load All Fiche_def
-$fiche_def=new Fiche_Def_Ref($cn);
-$all=$fiche_def->LoadAll();
-
-// Display Them
-echo ' ';
-for ($i=0;$i';
- echo $all[$i]->Display();
- echo "| ";
- echo '";
- echo " | ";
- echo '';
-}
-echo " ";
-// modify input
-if ( isset ($_POST['mod']) )
-{
- extract ($_POST);
- echo ' ';
- echo _("Voulez-vous modifier ?");
- echo " ";
- echo _("Attention, ne changer pas la signification de ce poste.");
- echo hi(_("par exemple ne pas changer Client par fournisseur"))." ";
- echo _("sinon le programme fonctionnera mal, ".
- "utiliser uniquement des chiffres pour la classe de base ou rien")."";
-
- $mod=new Fiche_Def_Ref($cn);
- $mod->frd_id=$idx;
- $mod->Get();
- echo ' ';
- echo ' ';
-}
-echo ' ';
+$fiche_def_ref=new Fiche_def_ref_SQL($cn);
+$cat=new Template_Card_Category($fiche_def_ref);
+$cat->set_callback("ajax_misc.php");
+$cat->add_json_param("gDossier", Dossier::id());
+$cat->add_json_param("op", "template_cat_card");
+$cat->create_js_script();
+$cat->display_table();
+echo "";
\ No newline at end of file
|