module."/infos";
if(file_exists($filepath."_subst.xml")){
$filepath.="_subst.xml";
}else{
$filepath.=".xml";
}
if(file_exists($filepath)){
$xml->load($filepath);
$elements = $xml->getElementsByTagName("information");
for($i=0 ; $i<$elements->length ; $i++){
$name = $this->charset_normalize($elements->item($i)->getElementsByTagName('name')->item(0)->nodeValue,"utf-8");
if(isset($elements->item($i)->getElementsByTagName('query')->item(0)->nodeValue)) {
$query = $this->charset_normalize($elements->item($i)->getElementsByTagName('query')->item(0)->nodeValue,"utf-8");
} else {
$query = '';
}
if(!$query){
$fonction = $elements->item($i)->getElementsByTagName('fonction')->item(0);
$class = $contruct = $params = $internal = "";
if($fonction->attributes->length>0){
$type = $this->charset_normalize($fonction->attributes->item(0)->nodeValue,"utf-8");
}
$class_infos = $elements->item($i)->getElementsByTagName('class');
if($class_infos->length){
$class_name = $this->charset_normalize($class_infos->item(0)->attributes->item(0)->nodeValue,"utf-8");
$contructor_params = $class_infos->item(0)->getElementsByTagName('contruct_param');
$constructor_parameters = array();
for ($j=0 ; $j<$contructor_params->length ; $j++){
$constructor_parameters[] = $this->charset_normalize($contructor_params->item($j)->nodeValue,"utf-8");
}
}
$params = $fonction->getElementsByTagName('param');
$parameters = array();
for ($j=0 ; $j<$params->length ; $j++){
$parameters[] = $this->charset_normalize($params->item($j)->nodeValue,"utf-8");
}
$method = $this->charset_normalize($fonction->getElementsByTagName("method")->item(0)->nodeValue,"utf-8");
if($type="internal"){
$this->infos[$name] = call_user_func_array(array($this,$method), $parameters);
}else if($class_name != ""){
$reflectionObject = new ReflectionClass($class_name);
$obj = $reflectionObject->newInstanceArgs($constructor_parameters);
$this->infos[$name] = call_user_func_array(array($obj,$method), $parameters);
}else{
$this->infos[$name] = call_user_func_array($method, $parameters);
}
}else{
$vars = array();
$variables = $elements->item($i)->getElementsByTagName('variables');
if($variables->length){
for ($j=0 ; $j<$variables->length ; $j++){
$var = $variables->item($j)->getElementsByTagName('var');
for ($k=0 ; $k<$var->length ; $k++){
$vars[] = array(
"type" => $var->item($k)->getAttribute("type"),
"name" => $var->item($k)->getAttribute("name")
);
}
}
}
if (count($vars)) {
$list = array();
foreach ($vars as $var) {
if ($var["type"] == "global") {
$var_name = $var["name"];
global ${$var_name};
$query = str_replace("!!".$var_name."!!", ${$var_name}, $query);
}
}
}
$result = pmb_mysql_query($query,$dbh);
$this->infos[$name]=array();
if(pmb_mysql_num_rows($result)){
while($row = pmb_mysql_fetch_assoc($result)){
$this->infos[$name][] = $row;
}
}
}
$action ="";
if($elements->item($i)->getElementsByTagName('action')->length){
$action = $this->charset_normalize($elements->item($i)->getElementsByTagName('action')->item(0)->nodeValue,"utf-8");
}
}
}
}
public function render_infos($template=""){
$template = $this->load_template($template);
if(!count($this->infos)) $this->get_infos();
if(count($this->infos)){
$rendered = array(
array(
'name' => $this->module_name,
'alert_url' => $this->alert_url,
'module' => $this->module,
'id' => "dashboard_".$this->module."_0",
'html' => h2o($template)->render($this->infos)
)
);
}else{
$rendered = array();
}
return $rendered;
}
public function render($template="template"){
$html = array();
$html[]=$this->render_infos($template);
// $html.=$this->render_alert();
return $html;
}
public function get_quick_params_form(){
}
public function get_plugins_form(){
//Evenement publié à chaque affichage d'un formulaire de paramétrage rapide
$evt_handler = events_handler::get_instance();
$event = new event_dashboard("dashboard", "show");
$event->set_module($this->module);
$evt_handler->send($event);
return $event->get_content();
}
public function save_quick_params(){
return true;
}
protected function get_user_param_form($field){
global $msg,$dbh,$charset;
global ${$field};
global $pmb_droits_explr_localises;
global $PMBuserid;
global $location_user_section;
$field_deb = substr($field,0,6);
$html="";
switch ($field_deb) {
case "deflt_" :
if ($field=="deflt_styles") {
$html_style="
".$msg[$field]." :
".make_user_style_combo(${$field})."
\n";
} elseif ($field=="deflt_docs_location") {
//visibilité des exemplaires
$explr_visible_mod = user::get_param($PMBuserid, 'explr_visible_mod');
if ($pmb_droits_explr_localises && $explr_visible_mod) $where_clause_explr = "idlocation in (".$explr_visible_mod.") and";
else $where_clause_explr = "";
$selector = gen_liste ("select distinct idlocation, location_libelle from docs_location, docsloc_section where $where_clause_explr num_location=idlocation order by 2 ", "idlocation", "location_libelle", 'form_'.$field, "dashboard_calcule_section(this);", ${$field}, "", "","","",0);
$html.="
".$msg[$field]." :
\n
".$selector."
\n";
//localisation de l'utilisateur pour le calcul de la section
$location_user_section = ${$field};
} elseif ($field=="deflt_collstate_location") {
$selector = gen_liste ("select distinct idlocation, location_libelle from docs_location order by 2 ", "idlocation", "location_libelle", 'form_'.$field, "", ${$field}, "", "","0",$msg["all_location"],0);
$html.="
".
$msg[$field]." :
\n
"
.$selector.
"
\n";
} elseif ($field=="deflt_resas_location") {
$selector = gen_liste ("select distinct idlocation, location_libelle from docs_location order by 2 ", "idlocation", "location_libelle", 'form_'.$field, "", ${$field}, "", "","0",$msg["all_location"],0);
$html.="
".
$msg[$field]." :
\n
"
.$selector.
"
\n";
} elseif ($field=="deflt_docs_section") {
// calcul des sections
$selector="";
if (!$location_user_section) $location_user_section = $deflt_docs_location;
$explr_visible_mod = user::get_param($PMBuserid, 'explr_visible_mod');
if ($pmb_droits_explr_localises && $explr_visible_mod) $where_clause_explr = "where idlocation in (".$explr_visible_mod.")";
else $where_clause_explr = "";
$rqtloc = "SELECT idlocation FROM docs_location $where_clause_explr order by location_libelle";
$resloc = pmb_mysql_query($rqtloc, $dbh);
while ($loc=pmb_mysql_fetch_object($resloc)) {
$requete = "SELECT idsection, section_libelle FROM docs_section, docsloc_section where idsection=num_section and num_location='$loc->idlocation' order by section_libelle";
$result = pmb_mysql_query($requete, $dbh);
$nbr_lignes = pmb_mysql_num_rows($result);
if ($nbr_lignes) {
if ($loc->idlocation==$location_user_section ) $selector .= "