Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 class Document_type
00031 {
00032
00033
00034
00035
00036
00037 function document_type($p_cn, $p_id = -1)
00038 {
00039 $this->db = $p_cn;
00040 $this->dt_id = $p_id;
00041 }
00042
00043
00044
00045
00046
00047 function get()
00048 {
00049 $sql = "select * from document_type where dt_id=$1";
00050 $R = $this->db->exec_sql($sql, array($this->dt_id));
00051 if (count($R) == 0) return 1;
00052 $r = Database::fetch_array($R, 0);
00053 $this->dt_id = $r['dt_id'];
00054 $this->dt_value = $r['dt_value'];
00055 $this->dt_prefix = $r['dt_prefix'];
00056 return 0;
00057 }
00058
00059
00060
00061
00062
00063
00064 static function get_list($p_cn)
00065 {
00066 $sql = "select * from document_type order by dt_value";
00067 $r = $p_cn->get_array($sql);
00068 $array = array();
00069 for ($i = 0; $i < count($r); $i++)
00070 {
00071 $tmp['dt_value'] = $r[$i]['dt_value'];
00072 $tmp['dt_prefix'] = $r[$i]['dt_prefix'];
00073
00074 $bt = new IButton('X' . $r[$i]['dt_id']);
00075 $bt->label = _('Modifier');
00076 $bt->javascript = "cat_doc_change('" . $r[$i]['dt_id'] . "','" . Dossier::id() . "');";
00077
00078 $tmp['js_mod'] = $bt->input();
00079 $tmp['dt_id'] = $r[$i]['dt_id'];
00080
00081 $bt = new IButton('X' . $r[$i]['dt_id']);
00082 $bt->label = _('Effacer');
00083 $bt->javascript = "if (confirm('" . _('Vous confirmez') . "')==true) {";
00084 $bt->javascript.="cat_doc_remove('" . $r[$i]['dt_id'] . "','" . Dossier::id() . "');";
00085 $bt->javascript.='}';
00086
00087 $tmp['js_remove'] = $bt->input();
00088
00089
00090 $array[$i] = $tmp;
00091 }
00092 return $array;
00093 }
00094
00095 function insert($p_value, $p_prefix)
00096 {
00097 $sql = "insert into document_type(dt_value,dt_prefix) values ($1,$2)";
00098 try
00099 {
00100 if ($this->db->count_sql('select * from document_type where upper(dt_value)=upper(trim($1))', array($p_value)) > 0)
00101 throw new Exception('Nom en double');
00102 if (strlen(trim($p_value)) > 0)
00103 $this->db->exec_sql($sql, array($p_value, $p_prefix));
00104 }
00105 catch (Exception $e)
00106 {
00107 alert(j(_("Impossible d'ajouter [$p_value] ") . $e->getMessage()));
00108 }
00109 }
00110
00111
00112
00113
00114 function update()
00115 {
00116 try
00117 {
00118 $this->db->exec_sql("update document_type set dt_value=$1,dt_prefix=$2 where dt_id=$3", array($this->dt_value,
00119 $this->dt_prefix, $this->dt_id));
00120 }
00121 catch (Exception $e)
00122 {
00123 alert(" Erreur " . $e->getMessage());
00124 }
00125 }
00126
00127 function set_number($p_int)
00128 {
00129 try
00130 {
00131 $this->db->exec_sql("alter sequence seq_doc_type_" . $this->dt_id . " restart " . $p_int);
00132 }
00133 catch (Exception $e)
00134 {
00135 alert("Erreur " . $e->getMessage());
00136 }
00137 }
00138 }