noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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 var $db; //!< Database conx
37 var $dt_id; //!< $dt_id (int) primary key of DOCUMENT_TYPE
38 var $dt_value; //!< $dt_value (text) description of document type
39 var $dt_prefix; //!< $dt_prefix (text) prefix to use for this
40 /** document_type
41 * \brief constructor
42 * \param $p_cn database connx
43 */
44
45 function __construct(Database $p_cn, $p_id = -1)
46 {
47 $this->db = $p_cn;
48 $this->dt_id = $p_id;
49 }
50
51 /**
52 * \brief Get all the data for this dt_id
53 */
54
55 function get()
56 {
57 $sql = "select * from document_type where dt_id=$1";
58 $R = $this->db->exec_sql($sql, array($this->dt_id));
59 if ($this->db->count($R) == 0) return 1;
61 $this->dt_id = $r['dt_id'];
62 $this->dt_value = $r['dt_value'];
63 $this->dt_prefix = $r['dt_prefix'];
64 return 0;
65 }
66
67 /**
68 * @brief get a list
69 * @param $p_cn database connection
70 * @return array of data from document_type
71 */
72 static function get_list($p_cn)
73 {
74 $sql = "select * from document_type order by dt_value";
75 $r = $p_cn->get_array($sql);
76 $array = array();
77 for ($i = 0; $i < count($r); $i++)
78 {
79 $tmp['dt_value'] = $r[$i]['dt_value'];
80 $tmp['dt_prefix'] = $r[$i]['dt_prefix'];
81
82 $bt = new IButton('M' . $r[$i]['dt_id']);
83 $bt->label = _('Modifier');
84 $bt->javascript = "cat_doc_change('" . $r[$i]['dt_id'] . "','" . Dossier::id() . "');";
85
86 $tmp['js_mod'] = $bt->input();
87 $tmp['dt_id'] = $r[$i]['dt_id'];
88
89 $bt = new IButton('X' . $r[$i]['dt_id']);
90 $bt->label = _('Effacer');
91 $bt->javascript = "confirm_box('X{$r[$i]['dt_id']}','" . _('Vous confirmez') . "',";
92 $bt->javascript.="function () { cat_doc_remove('{$r[$i]['dt_id']}','" . Dossier::id() . "');})";
93
94 $tmp['js_remove'] = $bt->input();
95
96
97 $array[$i] = $tmp;
98 }
99 return $array;
100 }
101
102 /**
103 * Restart the increment of the document
104 * @param type $p_int
105 */
106 function set_number($p_int)
107 {
108 try
109 {
110 $this->db->exec_sql("alter sequence seq_doc_type_" . $this->dt_id . " restart " . $p_int);
111 }
112 catch (Exception $e)
113 {
114 record_log($e);
115 alert("Erreur " . $e->getMessage());
116 }
117 }
118}
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
alert($p_msg, $buffer=false)
alert in javascript
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
_("actif, passif,charge,...")
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
contains the class for connecting to Noalyss
class for the table document_type , a document_type is a kind of action in the follow up
$dt_prefix
$dt_prefix (text) prefix to use for this
__construct(Database $p_cn, $p_id=-1)
document_type
$dt_id
$dt_id (int) primary key of DOCUMENT_TYPE
$dt_value
$dt_value (text) description of document type
set_number($p_int)
Restart the increment of the document.
static get_list($p_cn)
get a list
Html Input.
$SecUser db