noalyss Version-9
Public Member Functions | Static Public Member Functions | Data Fields | Static Private Attributes
Dossier Class Reference

manage the current dossier, everywhere we need to know to which folder we are connected, because we can't use $_SESSION, we need to pass the dossier_id via a _GET or a POST variable private static $variable=array("id"=>"dos_id", "name"=>"dos_name", "desc"=>"dos_description"); More...

+ Collaboration diagram for Dossier:

Public Member Functions

 __construct ($p_id)
 
 count ()
 Count the number of folder in the repository. More...
 
 get_info ()
 
 get_parameter ($p_string)
 
 get_user_folder ($sql="")
 Return all the users as an array but NOALYSS_ADMINISTRATOR, that user cannot be changed by the interface for administrating user. More...
 
 load ()
 
 save ()
 
 set_parameter ($p_string, $p_value)
 
 update ()
 

Static Public Member Functions

static check ()
 check if gDossier is set ?? dead code ??? More...
 
static connect ()
 
static get ()
 return a string to put to gDossier into a GET More...
 
static get_version ($p_cn)
 
static hidden ()
 return a string to set gDossier into a FORM More...
 
static id ()
 return the 'gDossier' value after a check More...
 
static name ($id=0)
 retrieve the name of the current dossier More...
 
static set_current ($p_dossier)
 Set the current dossier to $p_dossier. More...
 
static show_dossier ($p_type, $p_login="", $p_text="", $limit=0)
 Show the folder where user have access. More...
 
static synchro_admin ($p_id)
 connect to folder and give to admin. More...
 
static upgrade ()
 Upgrade check if the folder ACCOUNT_REPOSITORY needs to be upgrade thanks the variable DBVERSIONREPO and run all the SQL script named ac-upgradeX.sql from the folder noalyss/include/sql/patch until X equal DBVERSIONREPO-1 After it will call the function apply_patch, remove_inexistant_user and clean_orphan_log for each folder. More...
 

Data Fields

 $cn
 Database connexion. More...
 
 $dos_description
 
 $dos_email
 
 $dos_id
 number of db More...
 
 $dos_name
 

Static Private Attributes

static $variable
 

Detailed Description

manage the current dossier, everywhere we need to know to which folder we are connected, because we can't use $_SESSION, we need to pass the dossier_id via a _GET or a POST variable private static $variable=array("id"=>"dos_id", "name"=>"dos_name", "desc"=>"dos_description");

Definition at line 39 of file dossier.class.php.

Constructor & Destructor Documentation

◆ __construct()

Dossier::__construct (   $p_id)

Definition at line 53 of file dossier.class.php.

54 {
55 $this->cn=new Database(); // Connect to the repository
56 $this->dos_id=$p_id;
57 }
$input_from cn
Definition: balance.inc.php:66
contains the class for connecting to Noalyss

References $p_id, and cn.

Member Function Documentation

◆ check()

static Dossier::check ( )
static

check if gDossier is set ?? dead code ???

Definition at line 175 of file dossier.class.php.

176 {
177 try {
178 $http=new HttpInput();
179 $id=$http->request("gDossier","number");
180 if ($id > 999999 || $id < 0) throw new \Exception(_("Dossier max dépassé "));
181 } catch (\Exception $e) {
182
183 die('Dossier invalide ');
184 }
185
186 }
manage the http input (get , post, request) and extract from an array

References $e, $http, and $id.

Referenced by set_current().

◆ connect()

static Dossier::connect ( )
static
Examples
acc_ledger_historyTest.php, and inplace_edit.test.php.

Definition at line 295 of file dossier.class.php.

296 {
297 static $cn=null;
298 if ($cn!=null)
299 return $cn;
301 $cn=new Database($id);
302 return $cn;
303 }
static id()
return the 'gDossier' value after a check
$cn
Database connexion.

References $cn, $id, and id().

Referenced by Periode_Ledger_Table\__construct(), Operation_Exercice\__construct(), Acc_Ledger_Search\__construct(), Anc_Account_Table\__construct(), Template_Card_Category\add_mandatory_attr(), Print_Ledger\available_ledger(), Acc_Report_MTable\build(), Mobile_Device_MTable\build(), Acc_Other_Tax_MTable\build(), Forecast_Category_MTable\build(), Forecast_Item_MTable\build(), Parameter_Extra_MTable\build(), Print_Operation_Currency\build(), Acc_Operation_Note\build_jrn_id(), Card_Multiple\build_sql(), Document_Option\can_add_comment(), Acc_Plan_MTable\check(), Anc_Account_Table\check(), Template_Card_Category\check(), Tva_Rate_MTable\check(), Periode_Ledger\close(), Card_Multiple\count_sql(), Operation_Exercice\delete(), Anc_Account_Table\delete(), Template_Card_Category\delete(), Tva_Rate_MTable\delete(), Calendar\display(), ITva_Popup\display(), Noalyss\Mobile\display_menu(), Card_Multiple\display_option(), Periode\display_periode_global(), Operation_Exercice\display_result(), Acc_Plan_MTable\display_row(), Anc_Account_Table\display_row(), Acc_Other_Tax_MTable\display_row_custom(), Operation_Exercice\display_total(), Calendar\fill_from_action(), Periode\filter_exercice(), find_default_menu(), Periode\form_exercice_add(), Periode\form_exercice_label(), Periode\form_periode_add(), Fiche\from_qcode(), Calendar\get_preference(), Acc_Account_Ledger\get_used_accounting(), Template_Card_Category\input(), Acc_Other_Tax_MTable\input_custom(), Acc_Plan_MTable\input_custom(), Tag_Group_MTable\input_tag(), Operation_Closing\insert(), Operation_Opening\insert(), Document_Option\is_enable_comment(), Document_Option\is_enable_contact_multiple(), Document_Option\is_enable_editable_description(), Document_Option\is_enable_make_feenote(), Document_Option\is_enable_make_invoice(), Document_Option\is_enable_operation_detail(), Document_Option\is_enable_video_conf(), Html_Input_Noalyss\ledger_supplemental_tax(), Noalyss_Appearance\load(), Noalyss\Mobile\load_module(), Document_Option\option_comment(), Document_Option\option_operation_detail(), Document_Option\option_video_conf(), rebuild_access_code(), Periode_Ledger\reopen(), Acc_Operation_Note\save(), Action_Document_Type_MTable\save(), Currency_MTable\save(), Noalyss_Appearance\save(), Tva_Rate_MTable\save(), Calendar\set_month_year(), Operation_Exercice\submit_transfer(), Acc_Ledger\test_me(), Acc_Bilan\test_me(), Acc_Operation\test_me(), Acc_Reconciliation\test_me(), Anc_Balance_Double\test_me(), Anc_Balance_Simple\test_me(), Anc_Group\test_me(), Anc_Group_Operation\test_me(), Anc_Operation\test_me(), Anc_Plan\test_me(), Fiche\test_me(), Html_Table\test_me(), Operation_Exercice\transform(), Calendar\zoom_calendar(), and Calendar\zoom_list().

+ Here is the call graph for this function:

◆ count()

Dossier::count ( )

Count the number of folder in the repository.

Returns
integer

Definition at line 129 of file dossier.class.php.

130 {
131 $nb_folder=$this->cn->get_value('select count(*) from ac_dossier');
132 return $nb_folder;
133 }

References cn.

Referenced by synchro_admin().

◆ get()

static Dossier::get ( )
static

return a string to put to gDossier into a GET

Definition at line 192 of file dossier.class.php.

193 {
194 $http=new \HttpInput();
195 return "gDossier=".$http->request("gDossier","number");
196 }

References $http.

◆ get_info()

Dossier::get_info ( )

Definition at line 243 of file dossier.class.php.

244 {
245 return var_export(self::$variable, true);
246 }

References $variable.

◆ get_parameter()

Dossier::get_parameter (   $p_string)

Definition at line 221 of file dossier.class.php.

222 {
223 if (array_key_exists($p_string, self::$variable))
224 {
225 $idx=self::$variable[$p_string];
226 return $this->$idx;
227 }
228 else
229 throw new Exception("Attribut inexistant $p_string");
230 }
$idx

References $idx, and $variable.

◆ get_user_folder()

Dossier::get_user_folder (   $sql = "")

Return all the users as an array but NOALYSS_ADMINISTRATOR, that user cannot be changed by the interface for administrating user.

Parameters
SQL$sqlsql string to add to the query :
Note
that string MUST be the result of Database::escape_string

Definition at line 141 of file dossier.class.php.

142 {
143
144 $sql="
145 select
146 use_id,
147 use_first_name,
148 use_name,
149 use_email,
150 use_login,
151 use_active,
152 use_admin,
153 ag_dossier
154 from
155 ac_users as ac
156 left join
157 (select array_to_string(array_agg(dos_name),',') as ag_dossier,
158 jt.use_id as jt_use_id
159 from ac_dossier as ds
160 join jnt_use_dos as jt on (jt.dos_id=ds.dos_id)
161 group by jt.use_id) as dossier_name on (jt_use_id=ac.use_id)
162 where
163 use_login!=$1
164 $sql
165 ";
166
167 $res=$this->cn->get_array($sql, array(NOALYSS_ADMINISTRATOR));
168 return $res;
169 }
NOALYSS_ADMINISTRATOR
Definition: install.php:735

References $res, $sql, cn, and NOALYSS_ADMINISTRATOR.

◆ get_version()

static Dossier::get_version (   $p_cn)
static

Definition at line 290 of file dossier.class.php.

291 {
292 return $p_cn->get_value('select max(val) from version');
293 }

◆ hidden()

static Dossier::hidden ( )
static

return a string to set gDossier into a FORM

Examples
acc_ledger_historyTest.php.

Definition at line 202 of file dossier.class.php.

203 {
204 $http=new \HttpInput();
205
206 return '<input type="hidden" id="gDossier" name="gDossier" value="'.$http->request("gDossier","number").'">';
207 }

References $http.

Referenced by Operation_Exercice\display_result(), Acc_Parm_Code\form(), Acc_Operation\form_clone_operation(), Tax_Summary\form_export_csv(), Tax_Summary\form_export_pdf(), and Periode\form_periode_add().

◆ id()

static Dossier::id ( )
static

return the 'gDossier' value after a check

Examples
html_tab.test.php, inplace_edit.test.php, and progress-bar.test.php.

Definition at line 61 of file dossier.class.php.

62 {
63 $http=new HttpInput();
64
65 return $http->request('gDossier','number');
66 }

References $http.

Referenced by Card_Attribut_MTable\__construct(), Manage_Table_SQL\__construct(), Tag_Action\add_clear_button(), Tag_Operation\add_clear_button(), Document\anchor(), Acc_Ledger_Search\build_name_filter(), Acc_Ledger_Search\build_search_filter(), Follow_Up_Other_Concerned\button_action_add_concerned_card(), Acc_Account_Ledger\button_csv(), Fiche\button_csv(), Acc_Account_Ledger\button_pdf(), Fiche\button_pdf(), Acc_Ledger_Search\button_propose_filter(), connect(), Acc_Ledger\CurrencyInput(), Pre_Op_Advanced\display(), Follow_Up\display_children(), Acc_Bilan\display_form(), Follow_Up_Other_Concerned\display_linked_count(), Follow_Up\display_parent(), Operation_Exercice\display_result(), Follow_Up_Other_Concerned\display_row(), Acc_Plan_MTable\display_row(), Follow_Up\display_saved_search(), Noalyss\Mobile\execute_menu(), Anc_Plan\form(), Acc_Operation\form_clone_operation(), Document\generate(), Document_Type\get_list(), Acc_Ledger\input(), ICard\input(), Acc_Plan_MTable\input(), Template_Card_Category\input(), Tva_Rate_MTable\input(), Acc_Other_Tax_MTable\input_custom(), Acc_Report_MTable\input_custom(), Anticipation\input_form(), Acc_Report\input_name(), Tag_Group_MTable\input_tag(), Operation_Closing\insert(), Acc_Ledger_Search\list_operation_to_reconcile(), Profile_Menu\printing(), Acc_Ledger_Search\search_form(), Tag_Action\select_tag_search(), and Profile_Menu\sub_menu().

◆ load()

Dossier::load ( )

Definition at line 272 of file dossier.class.php.

273 {
274
275 $sql="select * from ac_dossier where dos_id=$1";
276
277 $res=$this->cn->exec_sql(
278 $sql, array($this->dos_id)
279 );
280
281 if (Database::num_row($res)==0)
282 return;
284 foreach ( self::$variable as $idx)
285 {
286 $this->$idx=$row[$idx];
287 }
288 }
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows

References $idx, $res, $row, $sql, $variable, cn, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ name()

static Dossier::name (   $id = 0)
static

retrieve the name of the current dossier

Definition at line 211 of file dossier.class.php.

212 {
213
214 $http=new \HttpInput();
215 $cn=new Database();
216 $id=($id==0)?$http->request("gDossier","number"):$id;
217 $name=$cn->get_value("select dos_name from ac_dossier where dos_id=$1", array($id));
218 return $name;
219 }

References $cn, $http, $id, and $name.

◆ save()

Dossier::save ( )

Definition at line 248 of file dossier.class.php.

249 {
250 $this->update();
251 }

References update().

+ Here is the call graph for this function:

◆ set_current()

static Dossier::set_current (   $p_dossier)
static

Set the current dossier to $p_dossier.

Parameters
numeric$p_dossier

Definition at line 430 of file dossier.class.php.

430 {
431
432 self::check($p_dossier);
433 put_global([ [ "key"=>"gDossier","value"=>$p_dossier]]);
434
435 }
put_global($array)
Put in superglobal (get,post,request) the value contained in the parameter field (me_parameter)
Definition: ac_common.php:1233
static check()
check if gDossier is set ?? dead code ???

References check(), and put_global().

+ Here is the call graph for this function:

◆ set_parameter()

Dossier::set_parameter (   $p_string,
  $p_value 
)

Definition at line 232 of file dossier.class.php.

233 {
234 if (array_key_exists($p_string, self::$variable))
235 {
236 $idx=self::$variable[$p_string];
237 $this->$idx=$p_value;
238 }
239 else
240 throw new Exception("Attribut inexistant $p_string");
241 }

References $idx, and $variable.

◆ show_dossier()

static Dossier::show_dossier (   $p_type,
  $p_login = "",
  $p_text = "",
  $limit = 0 
)
static

Show the folder where user have access.

Parameters
p_typestring
  • A for all dossiers
  • R for accessible folders
  • X forbidden folders
p_loginis the user name
p_textis a part of the name where are looking for
Returns
nothing

Definition at line 79 of file dossier.class.php.

80 {
81 $cn=new Database();
82 $str_limit=($limit==0)?'':' limit '.$limit;
83 if ($p_type=="A")
84 {
85 $l_sql="select *, 'W' as priv_priv "
86 ."from ac_dossier "
87 ."where "
88 ."dos_name ilike '%'|| $2 ||'%'"
89 ."or dos_description ilike '%'|| $2 || '%' "
90 ."ORDER BY dos_name $str_limit ";
91 $a_row=$cn->get_array($l_sql, $p_text);
92 return $a_row;
93 }
94 else if ($p_type=="R")
95 {
96 $l_sql="select * from jnt_use_dos
97 natural join ac_dossier
98 natural join ac_users
99 where
100 use_login=$1
101 and ( dos_name ilike '%'|| $2 || '%' or dos_description ilike '%'|| $2|| '%' )
102
103 order by dos_name
104 $str_limit
105 ";
106
107 $a_row=$cn->get_array($l_sql, array($p_login, $p_text));
108 return $a_row;
109 }
110 else if ($p_type=='X')
111 {
112 $l_sql=" select * from ac_dossier where dos_id not in
113 (select dos_id from jnt_use_dos where use_id=$1)
114 and ( dos_name ilike '%'|| $2|| '%' or dos_description ilike '%'|| $2 || '%')
115 order by dos_name ".$str_limit;
116 $a_row=$cn->get_array($l_sql, array($p_login, $p_text));
117 return $a_row;
118 }
119 else
120 {
121 throw new Exception(_("Erreur paramètre"));
122 }
123 }

References $a_row, $cn, $limit, and $p_type.

◆ synchro_admin()

static Dossier::synchro_admin (   $p_id)
static

connect to folder and give to admin.

the profile Admin(builtin)

Parameters
int$p_iddossier::id()

synchro global

Definition at line 309 of file dossier.class.php.

310 {
311// connect to target
312 $cn=new Database($p_id);
313
314 if (!$cn->exist_table("profile_menu"))
315 {
316 echo_warning("Dossier invalide");
317 return;
318 }
319// connect to repo
320 $repo=new Database();
321
322 $a_admin=$repo->get_array("select use_login from ac_users where
323 use_admin=1 and use_active=1");
324 try
325 {
326 /**
327 * synchro global
328 */
329 $cn->start();
330 for ($i=0; $i<count($a_admin); $i++)
331 {
332 Noalyss_user::grant_admin_access($a_admin[$i]['use_login'], $p_id);
333 }
334 $cn->commit();
335 }
336 catch (Exception $e)
337 {
338
339 echo_warning($e->getMessage());
340 record_log($e);
341 $cn->rollback();
342 }
343 }
echo_warning($p_string)
warns
Definition: ac_common.php:589
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
if(isset($_REQUEST['gDossier']) && $http->request("gDossier","number", 0) !=0) $repo
count()
Count the number of folder in the repository.

References $cn, $e, $i, $p_id, $repo, count(), echo_warning(), and record_log().

Referenced by upgrade().

+ Here is the call graph for this function:

◆ update()

Dossier::update ( )

Definition at line 253 of file dossier.class.php.

254 {
255 if (noalyss_strlentrim($this->dos_name)==0)
256 return;
257
258 if ($this->cn->get_value("select count(*) from ac_dossier "
259 ." where dos_name=$1 and dos_id<>$2", array($this->dos_name, $this->dos_id))!=0)
260 return;
261
262 $sql="update ac_dossier set dos_name=$1,dos_description=$2 ,dos_email=$3".
263 " where dos_id = $4";
264 $res=$this->cn->exec_sql(
265 $sql, array(trim($this->dos_name),
266 trim($this->dos_description),
267 $this->dos_email,
268 $this->dos_id)
269 );
270 }
noalyss_strlentrim($p_string)
Definition: ac_common.php:1549

References $res, $sql, cn, and noalyss_strlentrim().

Referenced by save().

+ Here is the call graph for this function:

◆ upgrade()

static Dossier::upgrade ( )
static

Upgrade check if the folder ACCOUNT_REPOSITORY needs to be upgrade thanks the variable DBVERSIONREPO and run all the SQL script named ac-upgradeX.sql from the folder noalyss/include/sql/patch until X equal DBVERSIONREPO-1 After it will call the function apply_patch, remove_inexistant_user and clean_orphan_log for each folder.

Definition at line 351 of file dossier.class.php.

352 {
353 $rep=new Database();
354 /* If multi folders */
355 $Resdossier=$rep->exec_sql("select dos_id, dos_name from ac_dossier");
356 $MaxDossier=$rep->size($Resdossier);
357
358 //----------------------------------------------------------------------
359 // Upgrade the account_repository
360 //----------------------------------------------------------------------
361 echo "<h2>"._("Mise à jour de la base de données principale")."</h2>";
362 $cn=new Database();
363 if (DEBUGNOALYSS == 0)
364 ob_start();
365 $MaxVersion=DBVERSIONREPO-1;
366 for ($i=4; $i<=$MaxVersion; $i++)
367 {
368 if ($cn->get_version()<=$i)
369 {
370 $cn->execute_script(NOALYSS_INCLUDE.'/sql/patch/ac-upgrade'.$i.'.sql');
371 }
372 }
373 if (DEBUGNOALYSS == 0) ob_end_clean();
374 //----------------------------------------------------------------------
375 // Upgrade the folders
376 //----------------------------------------------------------------------
377 echo "<h2>"._("Mise à jour dossiers")."</h2>";
378
379 for ($e=0; $e<$MaxDossier; $e++)
380 {
381 $db_row=Database::fetch_array($Resdossier, $e);
382 $name=$rep->format_name($db_row['dos_id'], 'dos');
383 echo "<h3>Patching ".$db_row['dos_name'].'</h3>';
384 echo _('Base de données')." ".$name;
385
386 if ($rep->exist_database($name)>0)
387 {
388 $db=new Database($db_row['dos_id'], 'dos');
389 $db->apply_patch($db_row['dos_name']);
390 Dossier::synchro_admin($db_row['dos_id']);
391 Noalyss_user::remove_inexistant_user($db_row['dos_id']);
392 $db->clean_orphan_lob();
393 }
394 else
395 {
396 echo_warning(_("Dossier inexistant")." $name");
397 }
398 }
399
400 //----------------------------------------------------------------------
401 // Upgrade the template
402 //----------------------------------------------------------------------
403 $Resdossier=$rep->exec_sql("select mod_id, mod_name from modeledef");
404 $MaxDossier=$rep->size();
405 echo "<h2>"._("Mise à jour modèles")."</h2>";
406
407 for ($e=0; $e<$MaxDossier; $e++)
408 {
409 $db_row=Database::fetch_array($Resdossier, $e);
410 $name=$rep->format_name($db_row['mod_id'], 'mod');
411 echo "<h3>Patching ".$db_row['mod_name']."</h3>";
412 echo _('Base de données')." ".$name;
413 if ($rep->exist_database($name)>0)
414 {
415 $db=new Database($db_row['mod_id'], 'mod');
416 $db->apply_patch($db_row['mod_name']);
417 $db->clean_orphan_lob();
418 }
419 else
420 {
421 echo_warning(_("Modèle inexistant")." $name");
422 }
423 }
424 }
static synchro_admin($p_id)
connect to folder and give to admin.
const DBVERSIONREPO
Definition: constant.php:37

References $cn, $e, $i, $name, $rep, DBVERSIONREPO, echo_warning(), DatabaseCore\fetch_array(), and synchro_admin().

+ Here is the call graph for this function:

Field Documentation

◆ $cn

Dossier::$cn

Database connexion.

Definition at line 47 of file dossier.class.php.

Referenced by connect(), name(), show_dossier(), synchro_admin(), and upgrade().

◆ $dos_description

Dossier::$dos_description

Definition at line 50 of file dossier.class.php.

◆ $dos_email

Dossier::$dos_email

Definition at line 51 of file dossier.class.php.

◆ $dos_id

Dossier::$dos_id

number of db

Definition at line 48 of file dossier.class.php.

◆ $dos_name

Dossier::$dos_name

Definition at line 49 of file dossier.class.php.

◆ $variable

Dossier::$variable
staticprivate
Initial value:
=array("id"=>"dos_id",
"name"=>"dos_name",
"desc"=>"dos_description",
"max_email"=>'dos_email')

Definition at line 42 of file dossier.class.php.


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