noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Document_Type Class Reference

class for the table document_type , a document_type is a kind of action in the follow up More...

+ Collaboration diagram for Document_Type:

Public Member Functions

 __construct (\Database $p_cn, int $dt_id=-1)
 constructor document_type
 
 __toString ()
 
 get ()
 Get all the data for this dt_id.
 
 set_number (int $p_int)
 Restart the increment of the document.
 

Static Public Member Functions

static get_list ($p_cn)
 get a list
 
static test_me ()
 unit test for Document_Type
 

Data Fields

 $db
 Database Connection.
 
 $dt_id
 primary key see SQL DOCUMENT_TYPE.DT_ID
 
 $dt_prefix
 prefix for numbering see SQL DOCUMENT_TYPE.DT_PREFIX
 
 $dt_value
 description of the document see SQL DOCUMENT_TYPE.DT_VALUE
 

Detailed Description

class for the table document_type , a document_type is a kind of action in the follow up

Definition at line 31 of file document_type.class.php.

Constructor & Destructor Documentation

◆ __construct()

Document_Type::__construct ( \Database $p_cn,
int $dt_id = -1 )

constructor document_type

Parameters
$p_cndatabase connx
$dt_idprimary key see SQL DOCUMENT_TYPE.DT_ID

Definition at line 44 of file document_type.class.php.

45 {
46 $this->db = $p_cn;
47 $this->dt_id = $dt_id;
48 }
$dt_id
primary key see SQL DOCUMENT_TYPE.DT_ID
$SecUser db

References $dt_id, and db.

Member Function Documentation

◆ __toString()

Document_Type::__toString ( )

Definition at line 118 of file document_type.class.php.

118 : string
119 {
120 return sprintf("dt_id : [%d] \n dt_value [%s] \n dt_prefix [%s]\n",$this->dt_id,$this->dt_value,$this->dt_prefix);
121 }

◆ get()

Document_Type::get ( )

Get all the data for this dt_id.

Definition at line 54 of file document_type.class.php.

55 {
56 $sql = "select * from document_type where dt_id=$1";
57 $r = $this->db->get_row($sql, array($this->dt_id));
58 if ( $r == null ) return 1;
59
60 $this->dt_id = $r['dt_id'];
61 $this->dt_value = $r['dt_value'];
62 $this->dt_prefix = $r['dt_prefix'];
63 return 0;
64 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r

References $r, $sql, and db.

◆ get_list()

static Document_Type::get_list ( $p_cn)
static

get a list

Parameters
$p_cndatabase connection
Returns
array of data from document_type

Definition at line 71 of file document_type.class.php.

72 {
73 $sql = "select * from document_type order by dt_value";
74 $r = $p_cn->get_array($sql);
75 $array = array();
76 for ($i = 0; $i < count($r); $i++)
77 {
78 $tmp=array();
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 }
_("actif, passif,charge,...")
static id()
return the 'gDossier' value after a check

References $array, $i, $r, $sql, $tmp, and _.

Referenced by test_me().

◆ set_number()

Document_Type::set_number ( int $p_int)

Restart the increment of the document.

Parameters
type$p_int

Definition at line 106 of file document_type.class.php.

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 alert("Erreur " . $e->getMessage());
115 }
116 }
alert($p_msg, $buffer=false)
alert in javascript

References $e, alert(), and db.

+ Here is the call graph for this function:

◆ test_me()

static Document_Type::test_me ( )
static

unit test for Document_Type

Returns
void

Definition at line 127 of file document_type.class.php.

128 {
129 // if (! defined('TEST_UNIT')) return;
131 function prv_echo_error($msg,int $lineno) {
132 print '<p class="p-2 alert-danger">';
133 print "ERROR : $lineno";
134 print $msg;
135 print '</p>';
136 }
137 // prepare test
138 $old_value=[];
139 try {
140 $cn->start();
141 $old_value[0]=$cn->get_row('select * from document_type where dt_id=$1',[8]);
142 $old_value[1]=$cn->get_row('select * from document_type where dt_id=$1',[6]);
143
144 $cn->exec_sql("update document_type set dt_value='Email' where dt_id=$1",[6]);
145 $cn->exec_sql("update document_type set dt_prefix='PML' where dt_id=$1",[8]);
146 $document_type=new Document_Type($cn,8);
147 echo $document_type;
148
149 if ( $document_type->get() == 1 ) {
150 }
151
152 if ( $document_type->dt_prefix!='PML') {
153 prv_echo_error("PREFIX :". $document_type,__LINE__);
154 }
155
156 $document_type->set_number(6);
157 $document_type->get();
158
159 if ( $document_type->dt_value!='Email') {
160 prv_echo_error("VALUE :". $document_type,__LINE__);
161 }
163
164 // list array > 1 and key =5
165 if (count ($list) == 0) {
166 prv_echo_error("GET_LIST :EMPTY",__LINE__);
167 } else {
168 foreach (['js_mod','dt_id','dt_value','dt_prefix','js_remove'] as $key) {
169 if ( ! isset ($list[0][$key])) {
170 prv_echo_error ('NOT SET '.$key,__LINE__);
171 } else {
172 echo '<pre>';
173 var_dump( $list[0][$key]);
174 echo '</pre>';
175 }
176 }
177 }
178 } catch (\Exception $e) {
179 prv_echo_error("EXCEPTION :". $document_type,__LINE__);
180 print_r($e->getTraceAsString());
181 }
182 $cn->rollback();
183 }
static get_list($p_cn)
get a list
static connect()
$document_type[]
print
Type of printing.

References $cn, $document_type, $e, $list, $msg, get_list(), and print.

+ Here is the call graph for this function:

Field Documentation

◆ $db

Document_Type::$db

Database Connection.

Definition at line 34 of file document_type.class.php.

◆ $dt_id

Document_Type::$dt_id

primary key see SQL DOCUMENT_TYPE.DT_ID

Definition at line 35 of file document_type.class.php.

Referenced by __construct().

◆ $dt_prefix

Document_Type::$dt_prefix

prefix for numbering see SQL DOCUMENT_TYPE.DT_PREFIX

Definition at line 37 of file document_type.class.php.

◆ $dt_value

Document_Type::$dt_value

description of the document see SQL DOCUMENT_TYPE.DT_VALUE

Definition at line 36 of file document_type.class.php.


The documentation for this class was generated from the following file: