noalyss Version-9
document_type.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright Author Dany De Bontridder danydb@aevalys.eu
22/**
23 * \file
24 * \brief class for the table document_type
25 */
26
27/**
28 * @class Document_Type
29 *@brief class for the table document_type , a document_type is a kind of action in the follow up
30 *
31 * < dt_id pk document_type
32 * < dt_value value
33 */
35{
36 /** document_type
37 * \brief constructor
38 * \param $p_cn database connx
39 */
40
41 function __construct($p_cn, $p_id = -1)
42 {
43 $this->db = $p_cn;
44 $this->dt_id = $p_id;
45 }
46
47 /**
48 * \brief Get all the data for this dt_id
49 */
50
51 function get()
52 {
53 $sql = "select * from document_type where dt_id=$1";
54 $R = $this->db->exec_sql($sql, array($this->dt_id));
55 if ($this->db->count($R) == 0) return 1;
57 $this->dt_id = $r['dt_id'];
58 $this->dt_value = $r['dt_value'];
59 $this->dt_prefix = $r['dt_prefix'];
60 return 0;
61 }
62
63 /**
64 * @brief get a list
65 * @param $p_cn database connection
66 * @return array of data from document_type
67 */
68 static function get_list($p_cn)
69 {
70 $sql = "select * from document_type order by dt_value";
71 $r = $p_cn->get_array($sql);
72 $array = array();
73 for ($i = 0; $i < count($r); $i++)
74 {
75 $tmp['dt_value'] = $r[$i]['dt_value'];
76 $tmp['dt_prefix'] = $r[$i]['dt_prefix'];
77
78 $bt = new IButton('M' . $r[$i]['dt_id']);
79 $bt->label = _('Modifier');
80 $bt->javascript = "cat_doc_change('" . $r[$i]['dt_id'] . "','" . Dossier::id() . "');";
81
82 $tmp['js_mod'] = $bt->input();
83 $tmp['dt_id'] = $r[$i]['dt_id'];
84
85 $bt = new IButton('X' . $r[$i]['dt_id']);
86 $bt->label = _('Effacer');
87 $bt->javascript = "confirm_box('X{$r[$i]['dt_id']}','" . _('Vous confirmez') . "',";
88 $bt->javascript.="function () { cat_doc_remove('{$r[$i]['dt_id']}','" . Dossier::id() . "');})";
89
90 $tmp['js_remove'] = $bt->input();
91
92
93 $array[$i] = $tmp;
94 }
95 return $array;
96 }
97
98 /**
99 * Restart the increment of the document
100 * @param type $p_int
101 */
102 function set_number($p_int)
103 {
104 try
105 {
106 $this->db->exec_sql("alter sequence seq_doc_type_" . $this->dt_id . " restart " . $p_int);
107 }
108 catch (Exception $e)
109 {
110 record_log($e);
111 alert("Erreur " . $e->getMessage());
112 }
113 }
114}
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
class for the table document_type , a document_type is a kind of action in the follow up
__construct($p_cn, $p_id=-1)
document_type
set_number($p_int)
Restart the increment of the document.
static get_list($p_cn)
get a list
static id()
return the 'gDossier' value after a check
Html Input.
$SecUser db