diff -urN ./glpi-origin/cron.php ./glpi-modified/cron.php --- ./glpi-origin/cron.php 1970-01-01 01:00:00.000000000 +0100 +++ ./glpi-modified/cron.php 2010-11-19 09:13:14.000000000 +0100 @@ -0,0 +1,142 @@ +query($sql); + +if (!$result) { + echo "Impossible d'exécuter la requête ($sql) dans la base : " . mysql_error(); + exit; +} + +if ($DB->numrows($result) > 0) { + + //$mmail=new glpi_phpmailer(); + $intro_mail = ""; + $intro_mail .= "\n\nService de gestion d'incident\n\n\n"; + $intro_mail .= "

Bonjour,

\n"; + $intro_mail .= "

Vous recevez ce message automatique de la part de l'application GLPI.

\n"; + $intro_mail .= "

Plusieurs tickets ouverts dépassent le pourcentage de délais de résolution autorisé.

\n"; + $intro_mail .= "

Voici la liste de ces tickets :

\n"; + + $fin_mail = ""; + $fin_mail .= "

------------------------------------------------------------------------------------------------

\n"; + $fin_mail .= "

Merci de ne pas répondre à ce mail,il est généré par un robot.

\n"; + $fin_mail .= "\n + \n"; + + // traitement des résultats + $tab_destinataire = array(); + + while($data = $DB->fetch_assoc($result)) + { + $date_creation_ticket = strtotime($data["date"]); + $date_today = time(); + $date_limite = strtotime($data["date_limite"]); + $pourcentage_avant_envoi = $data["pourcentage_avant_envoi"]; + //$email = $data["uemail"]; // email du demandeur + $email = $data["email_assign"]; // email de la personne a laquelle le ticket est affectée + $id_ticket = $data["id"]; + $name = $data["name"]; + $duree_totale = $date_limite - $date_creation_ticket; + $duree_entame = abs($date_today - $date_creation_ticket); + $pourcentage_delais_resolution = round(($duree_entame*100)/$duree_totale); + if($pourcentage_delais_resolution>$pourcentage_avant_envoi) + { + $tab_destinataire[$email][]=array("id"=>$id_ticket,"name"=>$name,"date_limite_resolution"=>$data["date_limite"]); + } + } + foreach($tab_destinataire as $destinataire=>$tickets ) + { + $recipient = $destinataire; + $mmail=new NotificationMail(); // instanciation du mailer + $texte_mail =''; + $texte_mail .= "\n"; + $nb_tickets=0; + foreach($tickets as $ticket) + { + $texte_mail .= ""; + $texte_mail .= ""; + $texte_mail .= ""; + $texte_mail .= ""; + $nb_tickets++; + } + $texte_mail .= "
Nom du ticketDate limite théorique de résolution
".$ticket["name"]."".convDateTime($ticket["date_limite_resolution"])."
\n"; + $subject = "Attention, ".$nb_tickets." ticket(s) dépasse(nt) le taux de résolution critique !"; + $body = $intro_mail.$texte_mail.$fin_mail; + // email du responsable hotline : + //$mmail->AddAddress('admin@votredomaine.fr', 'responsable hotline'); + if($recipient!='') + { + $mmail->AddAddress($recipient); + } + $mmail->FromName = "Service de gestion des tickets GLPI"; + $mmail->Subject=$subject; + $mmail->Body=$body; + $mmail->isHTML(true); + if(!$mmail->Send()) + { + addMessageAfterRedirect($LANG['setup'][206],false,ERROR); + } + else + { + echo "message correctement envoyé à ".$recipient."
"; + } + } +} +?> diff -urN ./glpi-origin/cron.sh ./glpi-modified/cron.sh --- ./glpi-origin/cron.sh 1970-01-01 01:00:00.000000000 +0100 +++ ./glpi-modified/cron.sh 2010-11-08 10:51:30.000000000 +0100 @@ -0,0 +1,2 @@ +cd /var/www/html/glpi_prod/ +php cron.php diff -urN ./glpi-origin/inc/ruleaction.class.php ./glpi-modified/inc/ruleaction.class.php --- ./glpi-origin/inc/ruleaction.class.php 2010-11-22 13:42:47.000000000 +0100 +++ ./glpi-modified/inc/ruleaction.class.php 2010-11-16 09:37:54.000000000 +0100 @@ -285,6 +285,13 @@ $display=true; break; + // debut ajout probesys + case "dropdown_catalogueservice" : + PluginGestioncatalogueservicesGestioncatalogueservices::dropdownCatalogueservice("value"); + $display=true; + break; + // fin ajout probesys + case "yesonly" : Dropdown::showYesNo("value",0,0); $display=true; diff -urN ./glpi-origin/inc/rule.class.php ./glpi-modified/inc/rule.class.php --- ./glpi-origin/inc/rule.class.php 2010-11-22 13:42:45.000000000 +0100 +++ ./glpi-modified/inc/rule.class.php 2010-11-17 12:04:45.000000000 +0100 @@ -658,7 +658,23 @@ $hook_params["ruleid"]=$this->fields["id"]; $hook_params["input"]=$input; $hook_params["output"]=$output; - doHook("rule_matched",$hook_params); + // debut modification probesys + if(array_key_exists("catalogueservice",$hook_params["output"])) + { + global $DB; + $id_catalogueservice = $hook_params["output"]["catalogueservice"]; + $query = "SELECT MAX(id) AS LASTID FROM glpi_tickets"; + $result = $DB->query($query); + $row = $DB->fetch_assoc($result); + $lastid = $row['LASTID']; + $lastid++; + if(array_key_exists("date",$hook_params["output"])) + if(array_key_exists("date",$hook_params["output"])) + { + // on est pas dans le cas d'un test + $date_ticket = $hook_params["output"]["date"]; + $catalogueservice = new PluginGestioncatalogueservicesGestioncatalogueservices(); + $donnees = array("id"=>$lastid,"catalogueservices_id"=>$id_catalogueservice,"date_ticket"=>$date_ticket); + $catalogueservice->addorupdateCatalogueServices2Tickets($donnees); + } + } + // fin modification probesys + doHook("rule_matched",$hook_params); $output["_rule_process"]=true; unset($output["_no_rule_matches"]); } @@ -1223,6 +1239,11 @@ case "dropdown_priority" : return Ticket::getPriorityName($value); + + // debut ajout probesys + case "dropdown_catalogueservice" : + return PluginGestioncatalogueservicesGestioncatalogueservices::getCatalogueServiceName($value); + // fin ajout probesys } } return $value; diff -urN ./glpi-origin/inc/rulecriteria.class.php ./glpi-modified/inc/rulecriteria.class.php --- ./glpi-origin/inc/rulecriteria.class.php 2010-11-22 13:42:47.000000000 +0100 +++ ./glpi-modified/inc/rulecriteria.class.php 2010-11-16 09:54:42.000000000 +0100 @@ -148,6 +148,11 @@ case "dropdown_priority" : return Ticket::getPriorityName($initValue); + + // debut ajout probesys + case "dropdown_categorieservice" : + return PluginGestioncatalogueservicesGestioncatalogueservices::getCatalogueServiceName($initValue); + // fin ajout probesys } } return $initValue; diff -urN ./glpi-origin/inc/ruleticket.class.php ./glpi-modified/inc/ruleticket.class.php --- ./glpi-origin/inc/ruleticket.class.php 2010-11-22 13:42:47.000000000 +0100 +++ ./glpi-modified/inc/ruleticket.class.php 2010-11-16 09:57:54.000000000 +0100 @@ -276,6 +276,12 @@ $actions['priority']['type'] = 'dropdown_priority'; $actions['priority']['force_actions'] = array('assign','compute'); + /* debut modif probesys*/ + $actions['catalogueservice']['name']= $LANG['job'][5]." - ".$LANG['plugin_gestioncatalogueservices'][30]; + $actions['catalogueservice']['type'] = 'dropdown_catalogueservice'; + $actions['catalogueservice']['table'] = 'glpi_plugin_gestioncatalogueservices_gestioncatalogueservices'; + /* fin modif probesys*/ + $actions['status']['name'] = $LANG['joblist'][0]; $actions['status']['type'] = 'dropdown_status'; @@ -286,4 +292,4 @@ } } -?> \ Pas de fin de ligne à la fin du fichier. +?> diff -urN ./glpi-origin/inc/ticket.class.php ./glpi-modified/inc/ticket.class.php --- ./glpi-origin/inc/ticket.class.php 2010-11-22 13:42:45.000000000 +0100 +++ ./glpi-modified/inc/ticket.class.php 2010-11-22 12:34:59.000000000 +0100 @@ -252,7 +252,7 @@ function prepareInputForUpdate($input) { - global $LANG,$CFG_GLPI; + global $LANG,$CFG_GLPI; if (isset($input["date"]) && empty($input["date"])) { unset($input["date"]); @@ -327,7 +327,7 @@ if (isset($input["items_id"])) { $ret["items_id"] = $input["items_id"]; } - + $input=$ret; } @@ -415,6 +415,11 @@ $input["_old_soltype"] = $this->fields["ticketsolutiontypes_id"]; } */ + + // ajout probesys pour lancement des règles metiers eventuelles + $output = doOneHook("gestioncatalogueservices","processSpecificsRules", $input); + // fin ajout probesys + return $input; }