Plugins  LAST
 All Data Structures Files Functions Variables Pages
Public Member Functions | Static Public Member Functions
RAPAV_Formulaire Class Reference
Inheritance diagram for RAPAV_Formulaire:
Inheritance graph
Collaboration diagram for RAPAV_Formulaire:
Collaboration graph

Public Member Functions

 __construct ($f_id=-1)
 
 anchor_document ()
 Anchor to the template. More...
 
 load_definition ()
 Get data from database, from the table rapport_advanced.formulaire_param. More...
 
 input_formulaire ()
 
 input_definition ()
 input the definition More...
 
 echo_formulaire ()
 
 input_parameter ()
 
 remove_doc_template ()
 remove a doc template More...
 

Static Public Member Functions

static listing ()
 show a list of all existing declaration type $cn database connection More...
 
static save_definition ($p_array)
 save the definition $p_array contains More...
 
static verify_definition (&$p_array)
 Check data and change them if needed database connection $cn. More...
 
static update_definition ($p_array)
 
static load_file (RAPAV_Formulaire $p_rapav)
 
static generate_code ()
 

Detailed Description

Definition at line 32 of file class_rapav_formulaire.php.

Constructor & Destructor Documentation

RAPAV_Formulaire::__construct (   $f_id = -1)

Definition at line 35 of file class_rapav_formulaire.php.

36  {
37  $this->f_id = $f_id;
38  $this->definition = array();
39  parent::__construct($f_id);
40  }

Member Function Documentation

RAPAV_Formulaire::anchor_document ( )

Anchor to the template.

Returns
html anchor string

Definition at line 57 of file class_rapav_formulaire.php.

References $url.

58  {
59  $url=HtmlInput::request_to_string(array('gDossier','ac','plugin_code'));
60  $url='extension.raw.php'.$url.'&act=export_definition_modele&id='.$this->f_id;
61  return HtmlInput::anchor($this->f_filename,$url);
62  }
$url
RAPAV_Formulaire::echo_formulaire ( )

Definition at line 243 of file class_rapav_formulaire.php.

244  {
245  echo '<h2>' . h($this->f_title) . '</h2>';
246  echo '<p>' . h($this->f_description) . '<p>';
247  }
static RAPAV_Formulaire::generate_code ( )
static

Definition at line 272 of file class_rapav_formulaire.php.

References $max.

Referenced by update_definition(), and verify_definition().

272  {
273  $a_possible= explode(',', 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9');
274  $max=count($a_possible);
275  $max--;
276  $code=$a_possible[rand(0,$max)].
277  $a_possible[rand(0,$max)].
278  $a_possible[rand(0,$max)].
279  $a_possible[rand(0, $max)].
280  $a_possible[rand(0, $max)].
281  $a_possible[rand(0, $max)]
282  ;
283  return$code;
284 
285  }
RAPAV_Formulaire::input_definition ( )

input the definition

Definition at line 89 of file class_rapav_formulaire.php.

References $cn, and $max.

90  {
91  $max = count($this->definition);
92  global $cn;
93 
94  require 'template/formulaire_definition.php';
95  }
global $cn
RAPAV_Formulaire::input_formulaire ( )

Definition at line 80 of file class_rapav_formulaire.php.

81  {
82  $this->load();
83  require_once 'template/formulaire_titre.php';
84  }
RAPAV_Formulaire::input_parameter ( )

Definition at line 249 of file class_rapav_formulaire.php.

References $max, $obj, and Formulaire_Param\factory().

250  {
251  $max = count($this->definition);
252  for ($i = 0; $i < $max; $i++)
253  {
254  $obj = Formulaire_Param::factory($this->definition[$i]);
255 
256  $obj->input();
257  }
258  }
static factory(Formulaire_Param_Sql $form)
Factory, create an object following the $form->p_type,.
static RAPAV_Formulaire::listing ( )
static

show a list of all existing declaration type $cn database connection

Definition at line 46 of file class_rapav_formulaire.php.

References $cn.

47  {
48  global $cn;
49  $alist = $cn->get_array("select f_id,f_title,f_description
50  from rapport_advanced.formulaire order by 2");
51  require 'template/formulaire_listing.php';
52  }
global $cn
RAPAV_Formulaire::load_definition ( )

Get data from database, from the table rapport_advanced.formulaire_param.

Definition at line 66 of file class_rapav_formulaire.php.

References $f, $max, and $ret.

67  {
68  $f = new Formulaire_Param_Sql();
69  $ret = $f->seek(" where f_id=" . sql_string($this->f_id) . " order by p_order ");
70  $max = Database::num_row($ret);
71 
72  for ($i = 0; $i < $max; $i++)
73  {
74  $o = new Formulaire_Param_Sql();
75  $o = $f->next($ret, $i);
76  $this->definition[] = clone $o;
77  }
78  }
$f
Definition: show_field.php:4
$ret
static RAPAV_Formulaire::load_file ( RAPAV_Formulaire  $p_rapav)
static

Definition at line 206 of file class_rapav_formulaire.php.

References $cn, and $name.

207  {
208  global $cn;
209  // nothing to save
210  if (sizeof($_FILES) == 0)
211  return;
212 
213  // Start Transaction
214  $cn->start();
215  $name = $_FILES['rapav_template']['name'];
216  $new_name = tempnam($_ENV['TMP'], 'rapav_template');
217  // check if a file is submitted
218  if (strlen($_FILES['rapav_template']['tmp_name']) != 0)
219  {
220  // upload the file and move it to temp directory
221  if (move_uploaded_file($_FILES['rapav_template']['tmp_name'], $new_name))
222  {
223  $oid = $cn->lo_import($new_name);
224  // check if the lob is in the database
225  if ($oid == false)
226  {
227  $cn->rollback();
228  return 1;
229  }
230  }
231  // the upload in the database is successfull
232  $p_rapav->f_lob = $oid;
233  $p_rapav->f_filename = $_FILES['rapav_template']['name'];
234  $p_rapav->f_mimetype = $_FILES['rapav_template']['type'];
235  $p_rapav->f_size= $_FILES['rapav_template']['size'];
236 
237  // update rapav
238  $p_rapav->update();
239  }
240  $cn->commit();
241  }
global $cn
$name
RAPAV_Formulaire::remove_doc_template ( )

remove a doc template

Definition at line 262 of file class_rapav_formulaire.php.

References $cn.

263  {
264  global $cn;
265  $cn->lo_unlink($this->f_lob);
266  $this->f_filename=null;
267  $this->f_size=null;
268  $this->f_mimetype=null;
269  $this->f_lob=null;
270  $this->update();
271  }
global $cn
static RAPAV_Formulaire::save_definition (   $p_array)
static

save the definition $p_array contains

  • f_id id of the formulaire
  • f_title title of the formulaire
  • f_description description of the formulaire
  • p_id array of the row in formulaire_param
  • p_code array of the row in formulaire_param
  • p_libelle array of the row in formulaire_param
  • p_type array of the row in formulaire_param
  • t_id array of the row in formulaire_param
  • p_order array of the row in formulaire_param

Definition at line 111 of file class_rapav_formulaire.php.

112  {
113  self::verify_definition($p_array);
114  self::update_definition($p_array);
115  return;
116  }
static RAPAV_Formulaire::update_definition (   $p_array)
static
See Also
save_definition
Parameters
type$p_array

Definition at line 153 of file class_rapav_formulaire.php.

References $cn, $ret, and generate_code().

154  {
155  global $cn;
156  $rapav = new RAPAV_Formulaire($p_array['f_id']);
157  // save into table formulaire
158  $rapav->f_title = $p_array['f_title'];
159  $rapav->f_description = $p_array['f_description'];
160  $rapav->update();
161  $nb_line=count($p_array['p_id']);
162  for ($i = 0; $i < $nb_line ; $i++)
163  {
164  $form_param = new formulaire_param_sql($p_array['p_id'][$i]);
165  $form_param->p_code = (trim($p_array['p_code'][$i])!="")?$p_array['p_code'][$i]: RAPAV_Formulaire::generate_code();
166  // remove space from p_code
167  $form_param->p_code=str_replace(' ', "",$form_param->p_code);
168 
169  $form_param->p_libelle = trim($p_array['p_libelle'][$i]);
170  if ( $form_param->p_libelle == '') continue;
171  $form_param->p_type = $p_array['p_type'][$i];
172  $form_param->p_order = (isNumber($p_array['p_order'][$i]) == 0) ? ($i+1) * 10 : $p_array['p_order'][$i];
173  $form_param->t_id = $p_array['t_id'][$i];
174  $form_param->f_id = $p_array['f_id'];
175  // update or insert the row
176  if ($p_array['p_id'][$i] == -1)
177  $form_param->insert();
178  else
179  $form_param->update();
180  }
181 
182  // delete checked rows
183  if ( isset ($p_array["del_row"]))
184  {
185  for ($i=0;$i<count($p_array['del_row']);$i++)
186  {
187  if (isNumber($p_array['del_row'][$i]) == 1 && $p_array['del_row'][$i]!=-1) {
188  $cn->exec_sql('delete from rapport_advanced.formulaire_param where p_id=$1',array($p_array['del_row'][$i]));
189  }
190  }
191  }
192  // Reorder
193  //
194  $order_param=new formulaire_param_sql();
195  $ret=$order_param->seek(' where f_id=$1 order by p_order',array($p_array['f_id']));
196  $nb_rows=Database::num_row($ret);
197  for ($i=0;$i < $nb_rows;$i++)
198  {
199  $param=$order_param->next($ret,$i);
200  $param->p_order=($i+1)*10;
201  $param->update();
202  }
203  self::load_file($rapav);
204  }
$ret
global $cn
static RAPAV_Formulaire::verify_definition ( $p_array)
static

Check data and change them if needed database connection $cn.

Parameters
array$p_arraynormally $_POST

Definition at line 122 of file class_rapav_formulaire.php.

References $cn, and generate_code().

123  {
124  global $cn;
125  $count_code=count($p_array['p_code']);
126  for ($i=0;$i<$count_code;$i++)
127  {
128  $c=$cn->get_value('select count(*) from rapport_advanced.formulaire_param
129  where p_code=$1 and p_id <> $2 and f_id=$3',
130  array($p_array['p_code'][$i],$p_array['p_id'][$i],$p_array['f_id']));
131 
132  if ( $c > 0 ) {
133  $p_array['p_code'][$i]=RAPAV_Formulaire::generate_code();
134  }
135  }
136 
137  for ($i=0;$i<$count_code;$i++)
138  {
139  for ($e=0;$e<$count_code;$e++) {
140  if ($p_array['p_code'][$i] == $p_array['p_code'][$e] && $i != $e)
141  {
142  $p_array['p_code'][$e]= RAPAV_Formulaire::generate_code();
143  }
144  }
145  }
146  }
global $cn

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