id_tache = $id_tache; } //formulaire spécifique au type de tâche function show_form ($param='') { global $dbh; //paramètres pré-enregistré $liste_bannettes = array(); if ($param['list_bann']) { foreach ($param['list_bann'] as $id_bann) { $liste_bannettes[$id_bann] = $id_bann; } } if ($param['action']) { foreach ($param['action'] as $action) { $liste_actions[$action] = $action; } } $requete = "select id_bannette, nom_bannette from bannettes where bannette_auto=1"; $result = mysql_query($requete,$dbh); //size select $nb_rows = mysql_num_rows($result); if (($nb_rows > 0) && ($nb_rows < 10)) { $size_select = $nb_rows; } elseif ($nb_rows == 0) { $size_select = 1; } else { $size_select = 10; } //Choix de la bannette à diffuser $form_task .= "
".$this->msg["planificateur_dsi_bannette_all"]."
".$this->msg["planificateur_dsi_bannette_public"]."
".$this->msg["planificateur_dsi_bannette_private"]."
 
".$this->msg["task_dsi_full"]."
".$this->msg["task_dsi_flush"]."
".$this->msg["task_dsi_fill"]."
".$this->msg["task_dsi_diffuse"].""; //
// ".$this->msg["task_dsi_export"]." $form_task .= "
"; return $form_task; } function task_execution() { global $dbh,$msg, $PMBusername; if (SESSrights & DSI_AUTH) { $parameters = $this->unserialize_task_params(); if ($parameters["radio_bannette"] == "2") { $restrict_sql = " and proprio_bannette = 0"; } else if ($parameters["radio_bannette"] == "3") { $restrict_sql = " and proprio_bannette <> 0"; } else { $restrict_sql = ""; } // requete $requete = "SELECT id_bannette, nom_bannette, proprio_bannette FROM bannettes "; $requete .= " WHERE (DATE_ADD(date_last_envoi, INTERVAL periodicite DAY) <= sysdate()) and bannette_auto=1 " ; $requete .= $restrict_sql; $res = mysql_query($requete, $dbh); //lister les bannettes sélectionnées en vérifiant qu'elles soient toujours en automatique if ($parameters["radio_bannette"] == "4") { if ($parameters["list_bann"]) { while(($bann=mysql_fetch_object($res))) { foreach ($parameters["list_bann"] as $id_bann) { //récupération des bannettes sélectionnées if ($bann->id_bannette == $id_bann) { $t=array(); $t["id_bann"] = $id_bann; $t["nom_bann"] = $bann->nom_bannette; $this->liste_bannette[] = $t; } } } } } else { while(($bann=mysql_fetch_object($res))) { $t=array(); $t["id_bann"] = $bann->id_bannette; $t["nom_bann"] = $bann->nom_bannette; $this->liste_bannette[] = $t; } } mysql_free_result($res); $this->report[] = "".$this->msg["dsi_report_header"].""; if ($this->liste_bannette) { //liste des actions à réaliser if ($parameters["action"]) { $lst_actions=array(); foreach ($parameters["action"] as $act) { $lst_actions[$act] = $act; } $percent = 0; //progression en fn de : nbre bannettes & nbre actions $p_value = (int) 100/(count($this->liste_bannette)*count($lst_actions)); $this->indice_tableau = 0; foreach($this->liste_bannette as $bann) { $this->listen_commande(array(&$this, 'traite_commande')); //fonction a rappeller (traite commande) if($this->statut == WAITING) { $this->send_command(RUNNING); } if($this->statut == RUNNING) { $this->report[] = "".$this->msg["dsi_report_action"]." : ".$bann["nom_bann"].""; foreach ($lst_actions as $action) { $this->report[] = ""; switch ($action) { case 'full' : if (method_exists($this->proxy, 'pmbesDSI_diffuseBannetteFullAuto')) { $this->report[] = $this->proxy->pmbesDSI_diffuseBannetteFullAuto($bann["id_bann"]); $percent += $p_value; } else { $this->report[] = "".sprintf($msg["planificateur_function_rights"],"diffuseBannetteFullAuto","pmbesDSI",$PMBusername).""; } break; case 'flush' : if (method_exists($this->proxy, 'pmbesDSI_flushBannette')) { $this->report[] = $this->proxy->pmbesDSI_flushBannette($bann["id_bann"]); $percent += $p_value; } else { $this->report[] = "".sprintf($msg["planificateur_function_rights"],"flushBannette","pmbesDSI",$PMBusername).""; } break; case 'fill' : if (method_exists($this->proxy, 'pmbesDSI_fillBannette')) { $this->report[] = $this->proxy->pmbesDSI_fillBannette($bann["id_bann"]); $percent += $p_value; } else { $this->report[] = "".sprintf($msg["planificateur_function_rights"],"fillBannette","pmbesDSI",$PMBusername).""; } break; case 'diffuse' : if (method_exists($this->proxy, 'pmbesDSI_diffuseBannette')) { $this->report[] = $this->proxy->pmbesDSI_diffuseBannette($bann["id_bann"]); $percent += $p_value; } else { $this->report[] = "".sprintf($msg["planificateur_function_rights"],"diffuseBannette","pmbesDSI", $PMBusername).""; } break; // case 'export' : // $this->report[] = "".$this->msg['dsi_diff_export'].": ".$bann["id_bann"]."
" ; // $object_fpdf = $this->proxy->pmbesDSI_exportBannette($id_bann); // //génération d'un pdf // $create_success = $this->generate_docnum($object_fpdf); // if (!$create_success) { // $this->statut = FAILED; // } // break; } $this->report[] = ""; $this->update_progression($percent); $this->indice_tableau++; } } } } else { $this->report[] = "".$this->msg["dsi_action_unknown"].""; } } else { $this->report[] = "".$this->msg["dsi_bannette_unknown"].""; } } else { $this->report[] = "".sprintf($msg["planificateur_rights_bad_user_rights"], $PMBusername).""; } } function traite_commande($cmd,$message) { switch ($cmd) { case RESUME: $this->send_command(WAITING); break; case SUSPEND: $this->suspend_dsi(); break; case STOP: $this->stop_dsi(); $this->finalize(); die(); break; case FAIL: $this->stop_dsi(); $this->finalize(); die(); break; } } function show_report($task_rapport) { global $charset; if ($task_rapport != "") { $report_execution = ""; foreach ($task_rapport as $ligne) { $report_execution .= html_entity_decode($ligne, ENT_QUOTES, $charset); } $report_execution .= "
"; } return $report_execution; } function make_serialized_task_params() { global $list_bann, $radio_bannette, $action; $t = parent::make_serialized_task_params(); if ($radio_bannette) { $t["radio_bannette"]=$radio_bannette; //liste de bannettes sélectionnées dans le cas où on choisi.. if ($radio_bannette == "4") { if ($list_bann) { foreach ($list_bann as $id_bann) { $t["list_bann"][$id_bann]=stripslashes($id_bann); } } } } if ($action) { foreach ($action as $act) { $t["action"][$act]=$act; } } return serialize($t); } function unserialize_task_params() { $params = $this->get_task_params(); return $params; } function suspend_dsi() { while ($this->statut == SUSPENDED) { sleep(20); $this->listen_commande(array(&$this,"traite_commande")); } } /*Récupère les bannettes non traitées*/ function stop_dsi() { $this->report[] = "".$this->msg["dsi_stopped"].""; $chaine = "".$this->msg["dsi_no_proceed"]." :
"; for($i=$this->indice_tableau; $i <= count($this->liste_bannette); $i++) { $chaine .= $this->liste_bannette[$i]["nom_bann"]."
"; } $chaine .= ""; $this->report[] = $chaine; } }