You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2007-05-28 17:34:42

guilaumin
Member
Registered: 2007-05-28
Posts: 44

créateur du ticket different de l'utilisateur en faisant la demande

Bonjour,

Je me présente dans ce sujet pour soumettre une fonctionnalité bien sur, mais également le code que j'ai écrit pour l'obtenir afin de débattre du besoin et de la pertinence de celle-ci.

Tout d'abord, j'ai été embauché dans mon entreprise pour monter un helpdesk qui doit gérer plusieurs clients. Je ne connaissais pas GLPI avant ça, quand suis arrivé ils avaient déjà installé deux instances différentes de GLPI 0.65 pour deux clients différents. Ma première tache a donc consisté à modifier GLPI pour les besoins internes.

La première chose a donc été de passer en 0.68.2
De la j'ai rajouté un chronomètre lors de la création d'un ticket pour avoir sans possibilité de changement le temps mis à saisir le ticket.
Ensuite je me suis occupé des modifications pour ce que j'ai pompeusement appelé la "Gestion multi-client" Le but étant vous l'aurez compris de gérer avec une seule interface plusieurs clients au niveau du helpdesk, les clients pouvant bien entendu se connecter directement sur leur interface, pour mon plus grand bonheur, je pense que ce qui a été fait au niveau de la 0.7 avec les entités solutionnera cette attente smile
Enfin je me suis occupé de ce qui m'amène ici, gérer la différence entre l'utilisateur qui créé le ticket, celui qui en fait la demande, et enfin celui le traite. Pour le dernier pas de problème, c'est l'utilisateur à qui on attribue le ticket, mais pour les deux premiers ben je n'ai que l'auteur.
Pourquoi cette différence ? Tout simplement car notre GLPI doit pouvoir être renseigné par les "hotliner" (auteur) lorsqu'un utilisateur (demandeur) appelle, ce niveau est essentielle pour nos statistiques au niveau du helpdesk, et je pense que ce doit être le cas pour beaucoup de hotline également. Par exemple, il est intéressant de savoir combien de temps en moyenne un hotliner mets à saisir/résoudre un incident, quel est l'utilisateur qui appelle le plus souvent, quel est le hotliner qui prend le plus d'appel, etc. ....

Je prends contact ici pour deux raisons, la première c’est que si ce morceau de code peut servir a quelqu’un j’en serai très content (je n’ai pas eu le temps de vérifier mais je suppose qu’il n’y aura pas de différence majeur avec la 0.68.3), la deuxième c’est que vous êtes trop productif pour que j’arrive a vous suivre smile une nouvelle version tous les 6-12 mois je n’arriverai pas a suivre le rythme et refaire a chaque fois les modifications qui seront surement différentes fonction des version des GLPI, de plus  la 0.7 est encore en beta et si jamais cette suggestions doit être retenue c’est je pense le bon pour ajouter les modifications.

Voilà les différents fichiers que j’ai modifiés :


GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#2 2007-05-28 17:35:51

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

/locales/*.php

$lang["common"][48]="Demandeur"; // Pour Auteur-Demandeur.
$lang["mailing"][110]="Pas de demandeur"; // Pour auteur-demandeur
$lang["mailing"][111]="Changement du demandeur du ticket"; // Pour auteur-demandeur
$lang["setup"][262]="Demandeur"; // Pour auteur-demandeur
$lang["profiles"][27]="Modifier l'auteur d'un ticket"; // Pour auteur-demandeur
/config/config.php dans la section : « MAILING USERS TYPE »
Ligne 176    define("TECH_MAILING","5");
        // Ajout par GP pour auteur-demandeur
        define("CREATOR_MAILING","6");
        define("CALLER_MAILING","7");
        // Fin ajout
/front/helpdesk.php
Ligne 42    commonHeader("Helpdesk",$_SERVER["PHP_SELF"]);

// Modification GP pour Auteur-demandeur
/* Avant modification :
if (!isset($_POST["user"])) $user=$_SESSION["glpiID"];
else $user=$_POST["user"];
*/
if (!isset($_POST["creator"])){
            ResetUserID($_SESSION["glpiname"]);
     $creator=$_SESSION["glpiID"];
} else $creator=$_POST["creator"];
if (!isset($_POST["caller"])) $caller=0;
else $caller=$_POST["caller"];
// Fin Modification

Ligne 95    if (isset($_POST["priority"]) && empty($_POST["contents"]))
{
            $error=$lang["tracking"][8] ;
                // Modification GP pour Auteur-demandeur, remplacement de la variable $user par $caller, ajout de la variable $creator
                // et de '' ($searchauthor dans la fonction)
    
addFormTracking($device_type,$computer,$caller,$assign,$_SERVER["PHP_SELF"],$error,'',$creator);
}
elseif (isset($_POST["priority"]) && !empty($_POST["contents"]))
{

            if ($track->add($_POST)){
                $error=$lang["tracking"][9];
                displayMessageAfterRedirect();
                // Modification GP pour Auteur-demandeur, remplacement de la variable $user par $caller, ajout de la variable $creator
                // et de '' ($searchauthor dans la fonction)
addFormTracking($device_type,$computer,$caller,$assign,$_SERVER["PHP_SELF"],$error,'',$creator);
        }
        else {
            $error=$lang["tracking"][10];
            displayMessageAfterRedirect();
            // Modification GP pour Auteur-demandeur, remplacement de la variable $user par $caller, ajout de la variable $creator
            // et de '' ($searchauthor dans la fonction)
addFormTracking($device_type,$computer,$caller,$assign,$_SERVER["PHP_SELF"],$error,'',$creator);
        }
} 
else
{
            // Modification GP pour Auteur-demandeur, remplacement de la variable $user par $caller, ajout de la variable $creator
            // et de '' ($searchauthor dans la fonction)
addFormTracking($device_type,$computer,$caller,$assign,$_SERVER["PHP_SELF"],$error,'',$creator);
}
/front/tracking.php
Ligne 77    if (!isset($tab["contains2"])||isset($tab['reset'])) $tab["contains2"]="";
// Modification par GP pour auteur-demandeur
/* Avant modification :
if (!isset($tab["author"])||isset($tab['reset'])) $tab["author"]=0;*/
if (!isset($tab["creator"])||isset($tab['reset'])) $tab["creator"]=0;
if (!isset($tab["caller"])||isset($tab['reset'])) $tab["caller"]=0;
// Fin modification

Ligne 134    if (!haveRight("show_ticket","1")){
            searchSimpleFormTracking($_SERVER["PHP_SELF"],$tab["status"]);
showTrackingList($_SERVER["PHP_SELF"],$tab["start"],$tab["sort"],$tab["order"],$tab["status"],$_SESSION["glpiID"],-1);
} else {
// Dans les lignes en dessous, remplacement de author par caller et ajout de : $tab["creator] pour faire correspondre les variables de la fonction
        if (!$tab["extended"])
searchFormTracking($tab["extended"],$_SERVER["PHP_SELF"],$tab["start"],$tab["status"],$tab["caller"],$tab["group"],$tab["assign"],$tab["assign_ent"],$tab["category"],$tab["priority"],$tab["request_type"],$tab["item"],$tab["type"],$tab["showfollowups"],$tab["field2"],$tab["contains2"],$tab["creator"]);
        else 
searchFormTracking($tab["extended"],$_SERVER["PHP_SELF"],$tab["start"],$tab["status"],$tab["caller"],$tab["group"],$tab["assign"],$tab["assign_ent"],$tab["category"],$tab["priority"],$tab["request_type"],$tab["item"],$tab["type"],$tab["showfollowups"],$tab["field2"],$tab["contains2"],$tab["creator"],$tab["field"],$tab["contains"],$tab["date1"],$tab["date2"],$tab["only_computers"],$tab["enddate1"],$tab["enddate2"]);

        if (!$tab["extended"])
showTrackingList($_SERVER["PHP_SELF"],$tab["start"],$tab["sort"],$tab["order"],$tab["status"],$tab["caller"],$tab["group"],$tab["assign"],$tab["assign_ent"],$tab["category"],$tab["priority"],$tab["request_type"],$tab["item"],$tab["type"],$tab["showfollowups"],$tab["field2"],$tab["contains2"],$tab["creator"]);
else
showTrackingList($_SERVER["PHP_SELF"],$tab["start"],$tab["sort"],$tab["order"],$tab["status"],$tab["caller"],$tab["group"],$tab["assign"],$tab["assign_ent"],$tab["category"],$tab["priority"],$tab["request_type"],$tab["item"],$tab["type"],$tab["showfollowups"],$tab["field2"],$tab["contains2"],$tab["creator"],$tab["field"],$tab["contains"],$tab["date1"],$tab["date2"],$tab["only_computers"],$tab["enddate1"],$tab["enddate2"]);
}
/front/tracking.injector.php
Ligne 50    // Sauvegarde des données dans le cas de retours avec des navigateurs pourris style IE
// Remplacement uemail par cremail pour auteur-demandeur
$varstosav = array('emailupdates', 'cremail', 'computer', 'device_type', 'contents','_my_items','category');

Ligne 76        nullFooter();
            exit;
}
// Remplacement de uemail par cremail pour auteur-demandeur
elseif (isset($_POST["emailupdates"]) && $_POST["emailupdates"] == "yes" && isset($_POST["cremail"]) && $_POST["cremail"] =="")
/inc/db.function.php
// Ajout par GP pour gestion multi-client et auteur-demandeur

function ResetUserID($name){
// cette fonction va permettre de récupérer l'ID de l'utilisateur dans la base courante
// L'id n'est pas forcement le meme dans toutes les bases. Cela suppose que l'on utilise
// le meme "name" dans chaque base.
// Je redefini directement la variable $_SESSION["glpiID"]

    global $db;

    $query="SELECT ID 
        FROM glpi_users 
        WHERE name='$name'";
    $result=$db->query($query);
        
    $data=$db->fetch_assoc($result);
    
    if($data["ID"]>1){
        $_SESSION["glpiID"]=$data["ID"];
        return true;
    } else {
        return false;
    }

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#3 2007-05-28 17:37:29

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

/inc/display.function.php
Ligne 844        if (isset($_SESSION["helpdeskSaved"]["email"]))
            $email = stripslashes($_SESSION["helpdeskSaved"]["cremail"]); // Remplacement uemail par cremail pour auteur-demandeur

Ligne 879            echo "<td>".$lang["help"][11].":</td>";
                echo "<td>    <input name='cremail' value=\"$email\" size='20'>"; // Remplacement uemail par cremail pour auteur-demandeur
                // Ajout par GP pour auteur-demandeur
                echo "<input type='hidden' name='caemail' value=\"$email\">";
                // Fin Ajout
/inc/dropdown.function.php
En fin de fichier

// Ajout pour Auteur-demandeur
function dropDownUniqueUser($myname,$value,$right,$all=0,$display_comments=1) {
// Copié a partir de dropdownUsers()
// Make a text box with all glpi users
// @param $myname select name
// @param $value default value
// Les paramètres suivant ont été gardé pour ne pas gener le fonctionnement de glpi
// @param $right limit user who have specific right : interface -> central ; ID -> only current user ; all -> all users ; sinon specific right like show_ticket, create_ticket....
// @param $all Nobody or All display for none selected
// @param $display_comments display comments near the dropdown
// @return nothing (print out an HTML select box)
// $all =0 -> Nobody $all=1 -> All $all=-1-> nothing

    global $HTMLRel,$cfg_glpi,$lang,$phproot,$db;

    $rand=mt_rand();

    displaySearchTextAjaxDropdown($myname.$rand);

    echo "<script type='text/javascript' >\n";
    echo "   new Form.Element.Observer('search_$myname$rand', 1, \n";
    echo "      function(element, value) {\n";
    echo "          new Ajax.Updater('results_$myname$rand','".$cfg_glpi["root_doc"]."/ajax/dropdownUsers.php',{asynchronous:true, evalScripts:true, \n";
    echo "           onComplete:function(request)\n";
    echo "            {Element.hide('search_spinner_$myname$rand');}, \n";
    echo "           onLoading:function(request)\n";
    echo "            {Element.show('search_spinner_$myname$rand');},\n";
    echo "           method:'post', parameters:'searchText=' + value+'&value=$value&myname=$myname&all=$all&right=$right&comments=$display_comments&rand=$rand'\n";
    echo "})})\n";
    echo "</script>\n";

    echo "<div id='search_spinner_$myname$rand' style=' position:absolute;   filter:alpha(opacity=70); -moz-opacity:0.7; opacity: 0.7; display:none;'><img src=\"".$HTMLRel."pics/wait.png\" title='Processing....' alt='Processing....' /></div>\n";

    $nb=0;
    if ($cfg_glpi["use_ajax"])
        $nb=countElementsInTable("glpi_users");

    if (!$cfg_glpi["use_ajax"]||$nb<$cfg_glpi["ajax_limit_count"]){
        echo "<script type='text/javascript' >\n";
        echo "document.getElementById('search_spinner_$myname$rand').style.visibility='hidden';";
        echo "Element.hide('search_$myname$rand');";
        echo "</script>\n";
    }

    $default_display="";
    $comments_display="";

    $user=getUserName($value,2);
    $default_display="<input type='hidden' name='$myname' value='$value'>".substr($user["name"],0,$cfg_glpi["dropdown_limit"])."&nbsp;&nbsp;\n";
    if ($display_comments) {
        $comments_display="<a href='".$user["link"]."'>";
        $comments_display.="<img alt='".$lang["common"][25]."' src='".$HTMLRel."pics/aide.png' onmouseout=\"cleanhide('comments_$myname$rand')\" onmouseover=\"cleandisplay('comments_$myname$rand')\">";
        $comments_display.="</a>";
        $comments_display.="<span class='over_link' id='comments_$myname$rand'>".$user["comments"]."</span>";
    }

    echo $default_display;
    echo $comments_display;

    return $rand;
}
/inc/mailing.class.php
Ligne 146                                    break;
                            // Modification par GP pour auteur-demandeur
                            /* Avant modification :
                                // USER SEND
                            case USER_MAILING :
                                if ($this->job->fields["emailupdates"]=="yes"&&isValidEmail($this->job->fields["uemail"])&&!in_array($this->job->fields["uemail"],$emails)){
                                    $emails[]=$this->job->fields["uemail"];

                                }
                                break;*/
                                // CALLER SEND
                            case CALLER_MAILING :
                                if ($this->job->fields["emailupdates"]=="yes"&&isValidEmail($this->job->fields["caemail"])&&!in_array($this->job->fields["caemail"],$emails)){
                                    $emails[]=$this->job->fields["caemail"];

                                }
                                break;
                                // CREATOR SEND
                            case CREATOR_MAILING :
                                if ($this->job->fields["emailupdates"]=="yes"&&isValidEmail($this->job->fields["cremail"])&&!in_array($this->job->fields["cremail"],$emails)){
                                    $emails[]=$this->job->fields["cremail"];

                                }
                                break;
                            // Fin Modification

Ligne 328            switch ($this->type){
            case "new":
                // Modification par GP pour auteur-demandeur
                /* Avant modification :
                if (isValidEmail($this->job->fields["uemail"])) $replyto=$this->job->fields["uemail"];*/
                // Il s'agit de l'email pour le "reply to"  mettons donc celui du tech qui a créé le ticket.
                if (isValidEmail($this->job->fields["cremail"])) $replyto=$this->job->fields["cremail"];
                // Fin Modification

Ligne 442                                // ADMIN SEND
                            case ADMIN_MAILING :
                                if (isValidEmail($cfg_glpi["admin_email"])&&!in_array($cfg_glpi["admin_email"],$emails))
                                    $emails[]=$cfg_glpi["admin_email"];
                                break;
                                // CREATOR SEND // Modification par GP pour auteur-demandeur USER-> CREATOR
                            case CREATOR_MAILING :
                                $user = new User;
                                if ($user->getFromDB($this->resa->fields["id_user"]))
                                    if (isValidEmail($user->fields["email"])&&!in_array($user->fields["email"],$emails)){
                                        $emails[]=$user->fields["email"];
                                    }
                                break;

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#4 2007-05-28 17:38:29

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

/inc/profile.class.php
Ligne 145        function cleanProfile(){ 
    // Ajout par GP de update_creator dans le tableau car il ne doit pas figurer au niveau du helpdesk : pour auteur-demandeur
        $helpdesk=array("name","interface","faq","reservation_helpdesk","create_ticket","comment_ticket","observe_ticket","password_update","helpdesk_hardware","helpdesk_hardware_type","show_group_ticket","update_creator");

Ligne 466             echo "<td>".$lang["profiles"][26]."</td><td>";
        dropdownYesNoInt("show_group_ticket",$this->fields["show_group_ticket"]);
        echo "</td></tr>";

        // Ajout par GP pour auteur-demandeur
        echo "<tr class='tab_bg_2'>";
        echo "<td>".$lang["profiles"][27].":</td><td>";
        dropdownYesNoInt("update_creator",$this->fields["update_creator"]);
        echo "</td><td colspan='4'>&nbsp;</td></tr>";
        // Fin ajout
/inc/setup.function.php
Ligne 1582        } else if ($_SESSION['glpi_mailconfig']==2)    {

        $profiles[USER_MAILING_TYPE."_".ADMIN_MAILING]=$lang["setup"][237];
        $profiles[USER_MAILING_TYPE."_".TECH_MAILING]=$lang["common"][10];
        // Modification par GP pour auteur-demandeur
        /* Avant modification :
        $profiles[USER_MAILING_TYPE."_".USER_MAILING]=$lang["setup"][238];*/
        $profiles[USER_MAILING_TYPE."_".CREATOR_MAILING]=$lang["setup"][238];
        $profiles[USER_MAILING_TYPE."_".CALLER_MAILING]=$lang["setup"][262];
        // Fin Modification

Ligne 1707                    case ASSIGN_MAILING: $name=$lang["setup"][239];break;
                // Modification par GP pour auteur-demandeur
                /* Avant modification :
                case USER_MAILING: $name=$lang["setup"][238];break;*/
                case CREATOR_MAILING: $name=$lang["setup"][238];break;
                case CALLER_MAILING: $name=$lang["setup"][262];break;
                // Fin Modification

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#5 2007-05-28 17:40:00

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

Ici je vous mets le code complet parce qu’il y avait trop de chose a trier, les commentaires concernant le chronomètre ainsi que la « gestion multi-client » n'ont evidement rien a voir avec le cas present :

/inc/tracking.class.php

    function prepareInputForUpdate($input) {
        global $lang,$cfg_glpi;
        // Security checks
        if (!haveRight("update_ticket","1")){
            if (haveRight("assign_ticket","1")){
                $ret["ID"]=$input["ID"];
                $ret["assign"]=$input["assign"];
                $ret["assign_ent"]=$input["assign_ent"];
            // Ajout GP pour Auteur-demandeur
                if (haveRight("update_creator","1")) $ret["creator"]=$input["creator"];
            // Fin Ajout
                $input=$ret;
            } else if (haveRight("steal_ticket","1")&&$input["assign"]==$_SESSION["glpiID"]){
                $ret["ID"]=$input["ID"];
                $ret["assign"]=$input["assign"];
            // Ajout GP pour Auteur-demandeur
                if (haveRight("update_creator","1")) $ret["creator"]=$input["creator"];
            // Fin Ajout
                $input=$ret;
            } else { // Default case can only update contents if no followups already added
                $ret["ID"]=$input["ID"];
                if (isset($input["contents"]))
                    $ret["contents"]=$input["contents"];
            // Ajout GP pour Auteur-demandeur
                if (haveRight("update_creator","1")) $ret["creator"]=$input["creator"];
            // Fin Ajout
                $input=$ret;
            }
        }

        if (isset($input["item"])&& $input["item"]!=0){
            $input["computer"]=$input["item"];
            $input["device_type"]=$input["type"];

            if ($this->fields['FK_group']){
                $ci=new CommonItem;
                $ci->getFromDB($input["device_type"],$input["computer"]);
                if (isset($ci->obj->fields['FK_groups'])&&$ci->obj->fields['FK_groups']!=0){
                    $input["FK_group"] = $ci->obj->fields['FK_groups'];
                }
            }
        } else if (isset($input["type"])&&$input["type"]!=0)
            $input["device_type"]=0;

        // add Document if exists
        if (isset($_FILES['filename'])&&count($_FILES['filename'])>0&&$_FILES['filename']["size"]>0){
            $input2=array();
            $input2["name"]=$lang["tracking"][24]." ".$input["ID"];
            $input2["FK_tracking"]=$input["ID"];
            $input2["_only_if_upload_succeed"]=1;
            $doc=new Document();
            if ($docID=$doc->add($input2)){
                addDeviceDocument($docID,TRACKING_TYPE,$input["ID"]);
            }
        }
        if (isset($input["document"])&&$input["document"]>0){
            addDeviceDocument($input["document"],TRACKING_TYPE,$input["ID"]);
            unset($input["document"]);
        }

        // Old values for add followup in change
        if ($cfg_glpi["followup_on_update_ticket"]){
            $this->getFromDB($input["ID"]);
            $input["_old_assign_name"]=getAssignName($this->fields["assign"],USER_TYPE);
            $this->fields["_old_assign"]=$this->fields["assign"];
            $input["_old_assign_ent_name"]=getAssignName($this->fields["assign_ent"],ENTERPRISE_TYPE);
            $input["_old_category"]=$this->fields["category"];
            $input["_old_item"]=$this->fields["computer"];
            $input["_old_item_type"]=$this->fields["device_type"];
            $input["_old_caller"]=$this->fields["caller"]; // Pour Auteur-Demandeur remplacement author par caller
            $input["_old_group"]=$this->fields["FK_group"];
            $input["_old_priority"]=$this->fields["priority"];
            $input["_old_status"]=$this->fields["status"];
            // Ajout GP pour Auteur-demandeur
            $input["_old_creator"]=$this->fields["creator"];
            // Fin Ajout
        }
        return $input;
    }

    function pre_updateInDB($input,$updates) {
        if (((in_array("assign",$updates)&&$input["assign"]>0)||(in_array("assign_ent",$updates)&&$input["assign_ent"]>0))&&$this->fields["status"]=="new"){
            $updates[]="status";
            $this->fields["status"]="assign";
        }
        if (isset($input["status"])){
            if ($input["assign_ent"]==0&&$input["assign"]==0&&$input["status"]=="assign"){
                $updates[]="status";
                $this->fields["status"]="new";
            }

            if (in_array("status",$updates)&&ereg("old_",$input["status"])){
                $updates[]="closedate";
                $this->fields["closedate"]=date("Y-m-d H:i:s");
            }
        }

        // Modification par GP pour Auteur-demandeur
        /* Avant Modification :
        if (in_array("author",$updates)){
            $user=new User;
            $user->getfromDB($input["author"]);
            if (!empty($user->fields["email"])){
                $updates[]="uemail";
                $this->fields["uemail"]=$user->fields["email"];
            }
        }*/
        if (in_array("caller",$updates)){
            $caller=new User;
            $caller->getfromDB($input["caller"]);
            if (!empty($caller->fields["email"])){
                $updates[]="caemail";
                $this->fields["caemail"]=$caller->fields["email"];
            }
        }

        if (in_array("creator",$updates)){
            $creator=new User;
            $creator->getfromDB($input["creator"]);
            if (!empty($creator->fields["email"])){
                $updates[]="cremail";
                $this->fields["cremail"]=$creator->fields["email"];
            }
        }
        // Fin Modification        

        if (!haveRight("update_ticket","1")){
            if (haveRight("assign_ticket","1"))
                $updates=array_intersect($updates,array("assign","assign_ent"));
            else if (haveRight("steal_ticket","1")){
                if ($input["assign"]==$_SESSION["glpiID"])
                    $updates=array_intersect($updates,array("assign"));
                else $updates=array();
            // Modification par GP pour Auteur-demandeur
            /* Avant Modification :
            } else if ($this->fields["author"]==$_SESSION["glpiID"]&&$this->numberOfFollowups()==0){ // Helpdesk case
            */
            } else if ($this->fields["creator"]==$_SESSION["glpiID"]&&$this->numberOfFollowups()==0){ // Helpdesk case
            // Fin Modification
                $updates=array_intersect($updates,array("contents"));
            }
        }

        return array($input,$updates);
    }

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#6 2007-05-28 17:41:37

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

    function post_updateItem($input,$updates,$history=1) {
        global $cfg_glpi,$lang;

        // New values for add followup in change
        $change_followup_content="";
        $global_mail_change_count=0;

        if ($cfg_glpi["followup_on_update_ticket"]){
            if (in_array("assign",$updates)){
                $new_assign_name=getAssignName($this->fields["assign"],USER_TYPE);
                if ($input["_old_assign_name"]=="[Nobody]")
                    $input["_old_assign_name"]=$lang["mailing"][105];
                $change_followup_content.=$lang["mailing"][12].": ".$input["_old_assign_name"]." -> ".$new_assign_name."\n";
                $global_mail_change_count++;
            } else unset($this->fields["_old_assign"]);

            if (in_array("assign_ent",$updates)){
                $new_assign_ent_name=getAssignName($this->fields["assign_ent"],ENTERPRISE_TYPE);
                $change_followup_content.=$lang["mailing"][12].": ".$input["_old_assign_ent_name"]." -> ".$new_assign_ent_name."\n";
                $global_mail_change_count++;
            }
            if (in_array("category",$updates)){
                $new_category=$this->fields["category"];
                $old_category_name=ereg_replace("&nbsp;",$lang["mailing"][100],getDropdownName("glpi_dropdown_tracking_category",$input["_old_category"]));
                $new_category_name=ereg_replace("&nbsp;",$lang["mailing"][100],getDropdownName("glpi_dropdown_tracking_category",$new_category));
                $change_followup_content.=$lang["mailing"][14].": ".$old_category_name." -> ".$new_category_name."\n";
                $global_mail_change_count++;
            }
            if (in_array("computer",$updates)||in_array("device_type",$updates)){    
                $ci=new CommonItem;
                $ci->getfromDB($input["_old_item_type"],$input["_old_item"]);
                $old_item_name=$ci->getName();
                if ($old_item_name=="N/A"||empty($old_item_name))
                    $old_item_name=$lang["mailing"][107];
                $ci->getfromDB($this->fields["device_type"],$this->fields["computer"]);
                $new_item_name=$ci->getName();
                if ($new_item_name=="N/A"||empty($new_item_name))
                    $new_item_name=$lang["mailing"][107];

                $change_followup_content.=$lang["mailing"][17].": $old_item_name -> ".$new_item_name."\n";
                if (in_array("computer",$updates)) $global_mail_change_count++;
                if (in_array("device_type",$updates)) $global_mail_change_count++;
            }
            // Modification par GP pour Auteur-demandeur
            /* Avant Modification :
            if (in_array("author",$updates)){
                $author=new User;
                $author->getFromDB($input["_old_author"]);
                $old_author_name=$author->getName();
                $author->getFromDB($this->fields["author"]);
                $new_author_name=$author->getName();
                $change_followup_content.=$lang["mailing"][18].": $old_author_name -> ".$new_author_name."\n";

                $global_mail_change_count++;
            }*/
            if (in_array("caller",$updates)){
                $caller=new User;
                $caller->getFromDB($input["_old_caller"]);
                $old_caller_name=$caller->getName();
                $caller->getFromDB($this->fields["caller"]);
                $new_caller_name=$caller->getName();
                $change_followup_content.=$lang["mailing"][111].": $old_caller_name -> ".$new_caller_name."\n";

                $global_mail_change_count++;
            }
            $privfup=0;
            if (in_array("creator",$updates)){
                $creator=new User;
                $creator->getFromDB($input["_old_creator"]);
                $old_creator_name=$creator->getName();
                $creator->getFromDB($this->fields["creator"]);
                $new_creator_name=$creator->getName();
                $change_followup_content.=$lang["mailing"][18].": $old_creator_name -> ".$new_creator_name."\n";
                $privfup=1;

                $global_mail_change_count++;
            }
            // Fin Modification
            
            if (in_array("FK_group",$updates)){
                $new_group=$this->fields["FK_group"];
                $old_group_name=ereg_replace("&nbsp;",$lang["mailing"][109],getDropdownName("glpi_groups",$input["_old_group"]));
                $new_group_name=ereg_replace("&nbsp;",$lang["mailing"][109],getDropdownName("glpi_groups",$new_group));
                $change_followup_content.=$lang["mailing"][20].": ".$old_group_name." -> ".$new_group_name."\n";
                $global_mail_change_count++;
            }

            if (in_array("priority",$updates)){
                $new_priority=$this->fields["priority"];
                $change_followup_content.=$lang["mailing"][15].": ".getPriorityName($input["_old_priority"])." -> ".getPriorityName($new_priority)."\n";
                $global_mail_change_count++;        
            }
            if (in_array("status",$updates)){
                $new_status=$this->fields["status"];
                $change_followup_content.=$lang["mailing"][27].": ".getStatusName($input["_old_status"])." -> ".getStatusName($new_status)."\n";

                if (ereg("old_",$new_status))
                    $newinput["add_close"]="add_close";
                if (in_array("closedate",$updates))    
                    $global_mail_change_count++; // Manage closedate

                $global_mail_change_count++;
            }
            if (in_array("emailupdates",$updates)){
                if ($this->fields["emailupdates"]=="yes")
                    $change_followup_content.=$lang["mailing"][101]."\n";
                else if ($this->fields["emailupdates"]=="no")
                    $change_followup_content.=$lang["mailing"][102]."\n";
                $global_mail_change_count++;
            }
        }

        $mail_send=false;

        if (!empty($change_followup_content)){ // Add followup if not empty

            $newinput["contents"]=addslashes($change_followup_content);
            $newinput["author"]=$_SESSION['glpiID']; // Pas de changement ici pour Auteur-dedmandeur car il s'agit juste du suivi de ticket
            $newinput["private"]=$privfup; // GP : auteur-demandeur privfup est a 0 ou 1 selon que le createur a été modifié ou non.
            $newinput["hour"]=$newinput["minute"]=$newinput["secondes"]=0;
            $newinput["tracking"]=$this->fields["ID"];
            $newinput["type"]="update";
            // pass _old_assign if assig changed
            if (isset($this->fields["_old_assign"]))
                $newinput["_old_assign"]=$this->fields["_old_assign"];
            if (in_array("status",$updates)&&ereg("old_",$input["status"]))
                $newinput["type"]="finish";
            $fup=new Followup();
            $fup->add($newinput);
            $mail_send=true;
        }

        // Clean content to mail
        $this->fields["contents"]=stripslashes($this->fields["contents"]);

        if (!$mail_send&&count($updates)>$global_mail_change_count&&$cfg_glpi["mailing"]){
            $user=new User;
            $user->getfromDBbyName($_SESSION["glpiname"]);
            $mailtype="update";
            if (in_array("status",$updates)&&ereg("old_",$input["status"]))
                $mailtype="finish";
            else $mail_send++;

            $mail = new Mailing($mailtype,$this,$user);
            $mail->send();
        }

    }

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#7 2007-05-28 17:43:03

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

    function prepareInputForAdd($input) {
        global $cfg_glpi;

        // Manage helpdesk.html submission type
        unset($input["type"]);

        if (!isset($input["request_type"])) $input["request_type"]=1;
        if (!isset($input["status"])) $input["status"]="new";
        if (!isset($input["assign"])) $input["assign"]=0;

        // Modification par GP pour Auteur-demandeur
        /* Avant Modification :
        if (!isset($input["author"])){
            if (isset($_SESSION["glpiID"])&&$_SESSION["glpiID"]>0)
                $input["author"]=$_SESSION["glpiID"];
            else $input["author"]=1; // Helpdesk injector
        }*/
        if (!isset($input["creator"])){
            if (isset($_SESSION["glpiID"])&&$_SESSION["glpiID"]>0) 
                $input["creator"]=$_SESSION["glpiID"];
            else $input["creator"]=1; // Helpdesk injector
        }
        if (!isset($input["cremail"])&&$input["creator"]!=1){
                $creator=new User();
                $creator->getFromDB($input["creator"]);
                $input["cremail"]=$creator->fields["email"];
        }
        // Il faut tester egalement si on passe par le helpdesk public, si oui le caller est par defaut l'utilisateur connecté
        if (!isset($input["caller"])&&isset($input["_from_helpdesk"])&&$input["_from_helpdesk"]){
            if (isset($_SESSION["glpiID"])&&$_SESSION["glpiID"]>0) 
                $input["caller"]=$_SESSION["glpiID"];
            else $input["caller"]=1; // Helpdesk injector
        }        
        // Fin Modification
        
        if ($input["assign"]>0&&$input["status"]=="new")
            $input["status"] = "assign";

        if (isset($input["computer"])&&$input["computer"]==0)
            $input["device_type"]=0;    

        if ($input["device_type"]==0)
            $input["computer"]=0;

        if ($input["computer"]&&$input["device_type"]){
            $ci=new CommonItem;
            $ci->getFromDB($input["device_type"],$input["computer"]);
            if (isset($ci->obj->fields['FK_groups'])&&$ci->obj->fields['FK_groups']!=0){
                $input["FK_group"] = $ci->obj->fields['FK_groups'];
            }
        }

        // Modification par GP pour Auteur-demandeur
        /* Avant Modification :
        if (isset($input["emailupdates"])&&$input["emailupdates"]=="yes"&&empty($input["uemail"])){
            $user=new User();
            $user->getFromDB($input["author"]);
            $input["uemail"]=$user->fields["email"];
        }*/
        // Je considere que par defaut les hotliner feront partis du groupe de suivi des emails
        // je n'applique donc la modification qu'aux demandeurs
        if (isset($input["emailupdates"])&&$input["emailupdates"]=="yes"&&empty($input["caemail"])){
            $caller=new User();
            $caller->getFromDB($input["caller"]);
            $input["caemail"]=$caller->fields["email"];
        }
        // Fin Modification

        if ($cfg_glpi["auto_assign"]&&$input["assign"]==0&&isset($input["computer"])&&$input["computer"]>0&&isset($input["device_type"])&&$input["device_type"]>0){
            $ci=new CommonItem;
            $ci->getFromDB($input["device_type"],$input["computer"]);
            if (isset($ci->obj->fields['tech_num'])&&$ci->obj->fields['tech_num']!=0){
                $input["assign"] = $ci->obj->fields['tech_num'];
                if ($input["assign"]>0)
                    $input["status"] = "assign";
            }
        }

    // Modification chronomètre pour la saisie automatique de la durée dans les tickets par GP
    /* Avant modification :
        if (isset($input["hour"])&&isset($input["minute"])){
            $input["realtime"]=$input["hour"]+$input["minute"]/60;
            $input["_hour"]=$input["hour"];
            $input["_minute"]=$input["minute"];
            unset($input["hour"]);
            unset($input["minute"]);
        }
        */
        if (isset($input["hour"])&&isset($input["minute"])&&isset($input["secondes"])){
            $input["realtime"]=$input["hour"]+$input["minute"]/60+$input["secondes"]/3600;
            $input["_hour"]=$input["hour"];
            $input["_minute"]=$input["minute"];
            $input["_secondes"]=$input["secondes"];
            unset($input["hour"]);
            unset($input["minute"]);
            unset($input["secondes"]);
        }    
        //fin Modification
        
        // Add and close for central helpdesk
        if (isset($input["add_close"])){
            $input["status"]="old_done";
            unset($input["add_close"]);
        }

        if (!isset($input["date"]))
            $input["date"] = date("Y-m-d H:i:s");

        if (strstr($input["status"],"old_"))
            $input["closedate"] = $input["date"];

        return $input;
    }

    function postAddItem($newID,$input) {
        global $lang,$cfg_glpi;

        // add Document if exists
        if (isset($_FILES['filename'])&&count($_FILES['filename'])>0&&$_FILES['filename']["size"]>0){
            $input2=array();
            $input2["name"]=$lang["tracking"][24]." $newID";
            $input2["FK_tracking"]=$newID;
            $input2["_only_if_upload_succeed"]=1;
            $doc=new Document();
            if ($docID=$doc->add($input2))
                addDeviceDocument($docID,TRACKING_TYPE,$newID);
        }

        // Log this event
        // remplacement de author par creator : GP pour Auteur-demandeur
        logEvent($newID,"tracking",4,"tracking",getUserName($input["creator"])." ".$lang["log"][20]);

        $already_mail=false;
        if ((isset($input["_followup"])&&strlen($input["_followup"]))||(isset($input["_hour"])&&isset($input["_minute"])&&isset($input["_secondes"])&&isset($input["realtime"])&&$input["realtime"]>0)){

            $fup=new Followup();
            $type="new";
            if (isset($this->fields["status"])&&ereg("old_",$this->fields["status"])) $type="finish";
            $toadd=array("type"=>$type,"tracking"=>$newID);
            if (isset($input["_hour"])) $toadd["hour"]=$input["_hour"];
            if (isset($input["_minute"])) $toadd["minute"]=$input["_minute"];
            if (isset($input["_secondes"])) $toadd["secondes"]=$input["_secondes"];
            if (isset($input["_followup"])&&strlen($input["_followup"])) $toadd["contents"]=$input["_followup"];
            if ($input["assign"]>0)
                // pas de remplacement de author par creator car il s'agit d'ajouter un suivi
                $toadd["author"]=$input["assign"];

            $fup->add($toadd);
            $already_mail=true;
        }

        // Processing Email
        if ($cfg_glpi["mailing"]&&!$already_mail)
        {
            // Modification par GP pour Auteur-demandeur
            /* Avant Modification :
            $user=new User();
            $user->getFromDB($input["author"]);

            $this->fields=stripslashes_deep($this->fields);
            $type="new";
            if (isset($this->fields["status"])&&ereg("old_",$this->fields["status"])) $type="finish";
            $mail = new Mailing($type,$this,$user);
            $mail->send();*/
            // Il s'agit ici d'envoyer l'email a la personne qui est anciennement l'auteur du ticket
            // et que je considere maintenant comme un demandeur.
            $caller=new User();
            $caller->getFromDB($input["caller"]);

            $this->fields=stripslashes_deep($this->fields);
            $type="new";
            if (isset($this->fields["status"])&&ereg("old_",$this->fields["status"])) $type="finish";
            $mail = new Mailing($type,$this,$caller);
            $mail->send();
        
        }

    }

    // SPECIFIC FUNCTIONS

    function numberOfFollowups($with_private=1,$client){
    // Ajout du parametre $client pour la gestion multi-client
        global $db;
        $RESTRICT="";
        if ($with_private!=1) $RESTRICT = " AND private='0'";
        // Set number of followups
        
        // Ajout pour gestion Multi-client par GP
        if (isset($client)&&$client!="") $client = "`glpi-".$client."`";
        // Fin ajout
        $query = "SELECT count(*) FROM ".$client.".glpi_followups WHERE tracking = '".$this->fields["ID"]."' $RESTRICT";
        $result = $db->query($query);
        return $db->result($result,0,0);

    }

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#8 2007-05-28 17:44:24

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

    function updateRealTime() {
        // update Status of Job

        global $db;
        $query = "SELECT SUM(realtime) FROM glpi_followups WHERE tracking = '".$this->fields["ID"]."'";
        if ($result = $db->query($query)) {
            $sum=$db->result($result,0,0);
            if (is_null($sum)) $sum=0;
            $query2="UPDATE glpi_tracking SET realtime='".$sum."' WHERE ID='".$this->fields["ID"]."'";
            $db->query($query2);
            return true;
        } else {
            return false;
        }
    }


    function textFollowups($format="text") {
        // get the last followup for this job and give its contents as
        global $db,$lang;

        if (isset($this->fields["ID"])){
            $query = "SELECT * FROM glpi_followups WHERE tracking = '".$this->fields["ID"]."' AND private = '0' ORDER by date DESC";
            $result=$db->query($query);
            $nbfollow=$db->numrows($result);
            if($format=="html"){
                $message = "<div class='description'><strong>".$lang["mailing"][4]." : $nbfollow<br>"."</div><br>";

                if ($nbfollow>0){
                    $fup=new Followup();
                    while ($data=$db->fetch_array($result)){
                        $fup->getfromDB($data['ID']);
                        $message .= "<strong>[ ".convDateTime($fup->fields["date"])." ]</strong><br>";
                        $message .= "<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["common"][37].":</span> ".$fup->getAuthorName()."<br>";
                        $message .= "<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["mailing"][3].":</span><br>".nl2br($fup->fields["contents"])."<br>";
                        if ($fup->fields["realtime"]>0)
                            $message .= "<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["mailing"][104].":</span> ".getRealtime($fup->fields["realtime"])."<br>";

                        $message.="<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["mailing"][25].":</span> ";
                        $query2="SELECT * from glpi_tracking_planning WHERE id_followup='".$data['ID']."'";
                        $result2=$db->query($query2);
                        if ($db->numrows($result2)==0)
                            $message.=$lang["job"][32]."<br>";
                        else {
                            $data2=$db->fetch_array($result2);
                            $message.=convDateTime($data2["begin"])." -> ".convDateTime($data2["end"])."<br>";
                        }

                        $message.=$lang["mailing"][0]."<br>";    
                    }    
                }
            }else{ // text format
                $message = $lang["mailing"][1]."\n".$lang["mailing"][4]." : $nbfollow\n".$lang["mailing"][1]."\n";

                if ($nbfollow>0){
                    $fup=new Followup();
                    while ($data=$db->fetch_array($result)){
                        $fup->getfromDB($data['ID']);
                        $message .= "[ ".convDateTime($fup->fields["date"])." ]\n";
                        $message .= $lang["common"][37].": ".$fup->getAuthorName()."\n";
                        $message .= $lang["mailing"][3]."\n".$fup->fields["contents"]."\n";
                        if ($fup->fields["realtime"]>0)
                            $message .= $lang["mailing"][104].": ".getRealtime($fup->fields["realtime"])."\n";

                        $message.=$lang["mailing"][25]." ";
                        $query2="SELECT * from glpi_tracking_planning WHERE id_followup='".$data['ID']."'";
                        $result2=$db->query($query2);
                        if ($db->numrows($result2)==0)
                            $message.=$lang["job"][32]."\n";
                        else {
                            $data2=$db->fetch_array($result2);
                            $message.=convDateTime($data2["begin"])." -> ".convDateTime($data2["end"])."\n";
                        }

                        $message.=$lang["mailing"][0]."\n";    
                    }    
                }


            }
            return $message;
        } else return "";
    }

    function textDescription($format="text"){
        global $db,$lang;


        $m= new CommonItem;
        $name=$lang["help"][30];
        $contact=0;
        $tech=0;
        if ($m->getfromDB($this->fields["device_type"],$this->fields["computer"])){
            $name=$m->getType()." ".$m->getName();
            if (isset($m->obj->fields["tech_num"])&&$m->obj->fields["tech_num"]>0){
                    $tech=getUserName($m->obj->fields["tech_num"]);
            }
            if (isset($m->obj->fields["contact"]))
                $contact=$m->obj->fields["contact"];
            if (isset($m->obj->fields["FK_users"]))
                $contact=getUserName($m->obj->fields["FK_users"]);
            if (isset($m->obj->fields["FK_groups"])){
                if (!empty($contact)) $contact.=" / ";
                    $contact.=getDropdownName("glpi_groups",$m->obj->fields["FK_groups"]);
            }
                
            
        }

        if($format=="html"){
            $message= "<html><head> <style type=\"text/css\">";
            $message.=".description{ color: inherit; background: #ebebeb; border-style: solid; border-color: #8d8d8d; border-width: 0px 1px 1px 0px; }";
            $message.=" </style></head><body>";

            $message.="<div class='description'><strong>".$lang["mailing"][5]."</strong></div><br>";
            // Modification par GP pour auteur-demandeur
            /* Avant Modification :
            $author=$this->getAuthorName();
            if (empty($author)) $author=$lang["mailing"][108];
            $message.="<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["common"][37].":</span> ".$author."<br>";
            */
            $caller=$this->getCallerName();
            if (empty($caller)) $caller=$lang["mailing"][110];
            $message.="<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["common"][48].":</span> ".$caller."<br>";
            // Fin Modification
            $message.="<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>". $lang["search"][8].":</span> ".convDateTime($this->fields["date"])."<br>";
            $message.="<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>". $lang["job"][44].":</span> ".getRequestTypeName($this->fields["request_type"])."<br>";
            $message.="<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>". $lang["mailing"][7]."</span> ".$name."<br>";
            if ($tech)
                $message.="<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>". $lang["common"][10].":</span> ".$tech."<br>";
            $message.= "<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["joblist"][0].":</span> ".getStatusName($this->fields["status"])."<br>";
            $assign=getAssignName($this->fields["assign"],USER_TYPE);
            if ($assign=="[Nobody]")
                $assign=$lang["mailing"][105];
            $message.= "<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["mailing"][8]."</span> ".$assign."<br>";
            $message.="<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["joblist"][2].":</span> ".getPriorityName($this->fields["priority"])."<br>";
            if ($this->fields["device_type"]!=SOFTWARE_TYPE&&$contact)
                $message.= "<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["mailing"][28]."</span> ".$contact."<br>";
            if ($this->fields["emailupdates"]=="yes"){
                $message.="<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["mailing"][103]."</span> ".$lang["choice"][1]."<br>";
            } else {
                $message.="<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["mailing"][103]."</span> ".$lang["choice"][0]."<br>";
            }

            $message.= "<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>".$lang["common"][36].":</span> ";
            if (isset($this->fields["category"])&&$this->fields["category"]){
                $message.= getDropdownName("glpi_dropdown_tracking_category",$this->fields["category"]);
            } else $message.=$lang["mailing"][100];
            $message.= "<br>";

            $message.="<span style='color:#8B8C8F; font-weight:bold;  text-decoration:underline; '>". $lang["mailing"][3]."</span><br>".nl2br($this->fields["contents"])."<br><br>";    

        } else { //text format
            $message = $lang["mailing"][1]."\n*".$lang["mailing"][5]."*\n".$lang["mailing"][1]."\n";
            // Modification par GP pour auteur-demandeur
            /* Avant Modification :
            $author=$this->getAuthorName();
            if (empty($author)) $author=$lang["mailing"][108];
            $message.= $lang["common"][37].": ".$author."\n";*/
            $caller=$this->getCallerName();
            if (empty($caller)) $caller=$lang["mailing"][110];
            $message.= $lang["common"][48].": ".$caller."\n";
            // Fin Modification
            $message.= $lang["search"][8].": ".convDateTime($this->fields["date"])."\n";
            $message.= $lang["job"][44].": ".getRequestTypeName($this->fields["request_type"])."\n";
            $message.= $lang["mailing"][7]." ".$name."\n";
            if ($tech)
                $message.= $lang["common"][10].": ".$tech."\n";
            $message.= $lang["joblist"][0].": ".getStatusName($this->fields["status"])."\n";
            $assign=getAssignName($this->fields["assign"],USER_TYPE);
            if ($assign=="[Nobody]")
                $assign=$lang["mailing"][105];
            $message.= $lang["mailing"][8]." ".$assign."\n";
            $message.= $lang["joblist"][2].": ".getPriorityName($this->fields["priority"])."\n";
            if ($this->fields["device_type"]!=SOFTWARE_TYPE&&$contact)
                $message.= $lang["mailing"][28]." ".$contact."\n";
            if ($this->fields["emailupdates"]=="yes"){
                $message.=$lang["mailing"][103]." ".$lang["choice"][1]."\n";
            } else {
                $message.=$lang["mailing"][103]." ".$lang["choice"][0]."\n";
            }

            $message.= $lang["common"][36].": ";
            if (isset($this->fields["category"])&&$this->fields["category"]){
                $message.= getDropdownName("glpi_dropdown_tracking_category",$this->fields["category"]);
            } else $message.=$lang["mailing"][100];
            $message.= "\n";

            $message.= $lang["mailing"][3]."\n".$this->fields["contents"]."\n";    
            $message.="\n\n";

        }

        return $message;
    }


    function getAuthorName($link=0){
        return getUserName($this->fields["author"],$link);
    }

    // Ajout par GP pour auteur-demandeur
    function getCallerName($link=0,$client){
        $callername = getUserName($this->fields["caller"],$link,$client);
        if (isset($callername)&&$callername!="")
            return $callername;
        else
            return "[Nobody]";
    }

    // Ajout par GP pour auteur-demandeur
    function getCreatorName($link=0,$client){
        return getUserName($this->fields["creator"],$link,$client);
    }

}

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#9 2007-05-28 17:45:27

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

class Followup  extends CommonDBTM {

    function Followup () {
        $this->table="glpi_followups";
        $this->type=-1;
    }


    function post_addToDB(){

        if (isset($this->fields["realtime"])&&$this->fields["realtime"]>0) {
            $job=new Job();
            $job->getfromDB($this->fields["tracking"]);
            $job->updateRealTime();
        }
    }

    function post_updateInDB($updates)  {

        for ($i=0; $i < count($updates); $i++) {
            if ($updates[$i]=="realtime") {
                $job=new Job();
                $job->getFromDB($this->fields["tracking"]);
                $job->updateRealTime();
            }
        }
    }

    function cleanDBonPurge($ID) {
        global $db;
        $querydel="DELETE FROM glpi_tracking_planning WHERE id_followup = '$ID'";
        $db->query($querydel);                
    }

    function post_deleteFromDB($ID){
        $job=new Job();
        $job->getFromDB($this->fields['tracking']);
        $job->updateRealtime();        
    }


    function prepareInputForUpdate($input) {
    // Modification chronomètre pour la saisie automatique de la durée dans les tickets par GP
    /* Avant modification :
        $input["realtime"]=$input["hour"]+$input["minute"]/60;
    */
        $input["realtime"]=$input["hour"]+$input["minute"]/60+$input["secondes"]/3600;
    //fin Modification

        $input["author"]=$_SESSION["glpiID"];

        return $input;
    }

    function post_updateItem($input,$updates,$history=1) {
        global $cfg_glpi;
        $job=new Job;
        $job->getFromDBwithData($input["tracking"],1);

        if (in_array("contents",$updates)&&$cfg_glpi["mailing"]){
            $user=new User;
            $user->getfromDBbyName($_SESSION["glpiname"]);
            $mail = new Mailing("followup",$job,$user);
            $mail->send();
        }
    }

    function prepareInputForAdd($input) {

        $input["_isadmin"]=haveRight("comment_all_ticket","1");

        $input["_job"]=new Job;
        $input["_job"]->getFromDB($input["tracking"]);

        // Security to add unauthorized followups
        // Modification par GP pour auteur-demandeur
        /* Avant modification :
        if (!$input["_isadmin"]&&$input["_job"]->fields["author"]!=$_SESSION["glpiID"]) return false;*/
        if (!$input["_isadmin"]&&$input["_job"]->fields["creator"]!=$_SESSION["glpiID"]) return false;        
        // Fin Modification

        // Pass old assign From Job in case of assign change
        if (isset($input["_old_assign"]))
            $input["_job"]->fields["_old_assign"]=$input["_old_assign"];


        if (!isset($input["type"])) $input["type"]="followup";
        $input["_type"]=$input["type"];
        unset($input["type"]);

        $input['_close']=0;
        unset($input["add"]);

        if (!isset($input["author"]))
            $input["author"]=$_SESSION["glpiID"]; // Pas de changement ici pour auteur-demandeur car il s'agit d'ajouter un suivi

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#10 2007-05-28 17:57:25

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

Dans ce fichier également il y avait trop a trier, je pense que ça aurait fini par gener le lisibilité si j’avais tout decouper :

/inc/tracking.function.php
Ligne 96                            // Postonly could post followup in helpdesk area    
            echo "<li class='actif'><span style='float: left;display: block;color: #666;text-decoration: none;padding: 3px;'><a href=\"".$cfg_glpi["root_doc"]."/front/helpdesk.public.php?show=user&amp;ID=$ID\">".$lang["job"][38]." $ID</span></a></li>";

            // Modification par GP pour auteur-demandeur : author -> creator
            if (!ereg("old_",$job->fields["status"])&&$job->fields["creator"]==$_SESSION["glpiID"]){
                echo "<li class='invisible'>&nbsp;</li>";

                echo "<li onClick=\"showAddFollowup(); Effect.Appear('viewfollowup');\" id='addfollowup'><a href='#'>".$lang["job"][29]."</span></a></li>";
            }
        }

    }

    echo "</ul></div>";     

}

function commonTrackingListHeader($output_type=HTML_OUTPUT,$target="",$parameters="",$sort="",$order=""){
    global $lang,$cfg_glpi;

    // New Line for Header Items Line
    echo displaySearchNewLine($output_type);
    // $show_sort if 
    $header_num=1;
    // Only display sort on tracking list
    $display_sort=ereg("tracking.php",$target);

    if ($_SESSION["client_actif"]=="all") {
        $items=array(
            $lang["joblist"][28]=>"client",
            $lang["joblist"][0]=>"glpi_tracking.status",
            $lang["common"][27]=>"glpi_tracking.date",
            $lang["joblist"][2]=>"glpi_tracking.priority",
            // Modification par GP pour auteur-demandeur
            /* Avant Modification :
            $lang["common"][37]=>"author.name",*/
            $lang["common"][48]=>"caller.name",
            $lang["common"][37]=>"creator.name",
            // Fin Modification
            $lang["joblist"][4]=>"assign.name",
            $lang["common"][1]=>"glpi_tracking.device_type,glpi_tracking.computer",
            $lang["common"][36]=>"glpi_dropdown_tracking_category.completename",
            $lang["joblist"][6]=>"glpi_tracking.contents",
         );
    } else {
        $items=array(
            $lang["joblist"][0]=>"glpi_tracking.status",
            $lang["common"][27]=>"glpi_tracking.date",
            $lang["joblist"][2]=>"glpi_tracking.priority",
            // Modification par GP pour auteur-demandeur
            /* Avant Modification :
            $lang["common"][37]=>"author.name",*/
            $lang["common"][48]=>"caller.name",
            $lang["common"][37]=>"creator.name",
            // Fin Modification
            $lang["joblist"][4]=>"assign.name",
            $lang["common"][1]=>"glpi_tracking.device_type,glpi_tracking.computer",
            $lang["common"][36]=>"glpi_dropdown_tracking_category.completename",
            $lang["joblist"][6]=>"glpi_tracking.contents",
         );
    }
    
    foreach ($items as $key => $val){
        $issort=0;
        $link="";
        if ($display_sort){
            if ($sort==$val) $issort=1;
            $link=$target."?".$parameters."&amp;order=".($order=="ASC"?"DESC":"ASC")."&amp;sort=$val";
        }
        echo displaySearchHeaderItem($output_type,$key,$header_num,$link,$issort,$order);
    }

    echo displaySearchHeaderItem($output_type,"",$header_num,"",0,$order);

    // End Line for column headers        
    echo displaySearchEndLine($output_type);
}

function getTrackingOrderPrefs ($ID) {
    // Returns users preference settings for job tracking
    // Currently only supports sort order


    if($_SESSION["glpitracking_order"] == "yes")
    {
        return "DESC";
    } 
    else
    {
        return "ASC";
    }

}

function showCentralJobList($target,$start,$status="process") {
    // Lists all Jobs, needs $show which can have keywords 
    // (individual, unassigned) and $contains with search terms.
    // If $item is given, only jobs for a particular machine
    // are listed.

    global $db,$cfg_glpi, $lang, $HTMLRel;

    if (!haveRight("show_ticket","1")) return false;

    if($status=="waiting"){ // on affiche les tickets en attente
        $query = "SELECT ID FROM glpi_tracking WHERE (assign = '".$_SESSION["glpiID"]."') AND (status ='waiting' ) ORDER BY date ".getTrackingOrderPrefs($_SESSION["glpiID"]);

        $title=$lang["central"][11];

    }else{ // on affiche les tickets planifiés ou assignés à glpiID

        $query = "SELECT ID FROM glpi_tracking WHERE (assign = '".$_SESSION["glpiID"]."') AND (status ='plan' OR status = 'assign') ORDER BY date ".getTrackingOrderPrefs($_SESSION["glpiID"]);

        $title=$lang["central"][9];
    }

    $lim_query = " LIMIT ".$start.",".$cfg_glpi["list_limit"]."";    

    $result = $db->query($query);
    $numrows = $db->numrows($result);

    $query .= $lim_query;

    $result = $db->query($query);
    $i = 0;
    $number = $db->numrows($result);

    if ($number > 0) {
        echo "<div align='center'>";
        echo "<table class='tab_cadrehov'>";

        echo "<tr><th colspan='5'><b><a href=\"".$cfg_glpi["root_doc"]."/front/tracking.php?assign=".$_SESSION["glpiID"]."&amp;status=$status&amp;reset=reset_before\">".$title."</a></b></th></tr>";
        echo "<tr><th></th>";
        echo "<th>".$lang["common"][37]."</th>";
        echo "<th>".$lang["common"][1]."</th>";
        echo "<th colspan='2'>".$lang["joblist"][6]."</th></tr>";
        while ($i < $number) {
            $ID = $db->result($result, $i, "ID");
            showJobVeryShort($ID);
            $i++;
        }
        echo "</table>";
        echo "<br><div align='center'>";
    }
    else
    {
        echo "<br><div align='center'>";
        echo "<table class='tab_cadrehov'>";
        echo "<tr><th>".$title."</th></tr>";

        echo "</table>";
        echo "</div><br>";
    }
}

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#11 2007-05-28 17:59:34

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

function showCentralJobCount(){
    // show a tab with count of jobs in the central and give link    

    global $db,$cfg_glpi, $lang, $HTMLRel;

    if (!haveRight("show_ticket","1")) return false;    

    // Modification pour gestion multi-client par GP
    // Afin d'afficher la somme des valeurs dans chaque base dans le cas ou l'on se trouve sur la vue générale.
    /*Avant Modification :
    $query="SELECT status, COUNT(*) AS COUNT FROM glpi_tracking GROUP BY status";
    */
    if ($_SESSION["client_actif"]!="all") {
        $query="SELECT status, COUNT(*) AS COUNT FROM glpi_tracking GROUP BY status";
    }
    else {
    // Ici cela veut dire que la variable "client_actif" est sur all, il faut donc créer une autre requete pour
    // selectionner dans chaque base, il se trouve que la suite du code permet de faire la somme sans autre modification
    // Cette partie a été entièrement ajoutée pour la gestion multiclient.
    // Modification par GP
        foreach ($_SESSION["liste_client"] as $key => $val) {
            if ($key == 0) { $query = ""; }
            else { $query .= "\nUNION ALL\n";}
            $query.="(SELECT status, COUNT(*) AS COUNT FROM `glpi-".$val."`.glpi_tracking GROUP BY status) ";
        }
    }
    // Fin modif
    $status=array("new"=>0, "assign"=>0, "plan"=>0, "waiting"=>0);

    $result = $db->query($query);


    $status=array("new"=>0, "assign"=>0, "plan"=>0, "waiting"=>0);

    if ($db->numrows($result)>0)
        while ($data=$db->fetch_assoc($result)){
            $status[$data["status"]]+=$data["COUNT"];
        }

    echo "<div align='center'><table class='tab_cadrehov' style='text-align:center'>";

    echo "<tr><th colspan='2'><b><a href=\"".$cfg_glpi["root_doc"]."/front/tracking.php?status=notold&amp;reset=reset_before\">".$lang["tracking"][0]."</a></b></th></tr>";
    echo "<tr><th ><b>".$lang["tracking"][28]."</b></th><th>".$lang["tracking"][29]."</th></tr>";
    echo "<tr class='tab_bg_2'>";
    echo "<td><a href=\"".$cfg_glpi["root_doc"]."/front/tracking.php?status=new&amp;reset=reset_before\">".$lang["tracking"][30]."</a> </td>";
    echo "<td>".$status["new"]."</td></tr>";
    echo "<tr class='tab_bg_2'>";
    echo "<td><a href=\"".$cfg_glpi["root_doc"]."/front/tracking.php?status=assign&amp;reset=reset_before\">".$lang["tracking"][31]."</a></td>";
    echo "<td>".$status["assign"]."</td></tr>";
    echo "<tr class='tab_bg_2'>";
    echo "<td><a href=\"".$cfg_glpi["root_doc"]."/front/tracking.php?status=plan&amp;reset=reset_before\">".$lang["tracking"][32]."</a></td>";
    echo "<td>".$status["plan"]."</td></tr>";
    echo "<tr class='tab_bg_2'>";
    echo "<td><a href=\"".$cfg_glpi["root_doc"]."/front/tracking.php?status=waiting&amp;reset=reset_before\">".$lang["tracking"][33]."</a></td>";
    echo "<td>".$status["waiting"]."</td></tr>";


    echo "</table></div><br>";


}

function showOldJobListForItem($username,$item_type,$item) {
    // $item is required
    // affiche toutes les vielles intervention pour un $item donn� 


    global $db,$cfg_glpi, $lang,$HTMLRel;

    if (!haveRight("show_ticket","1")) return false;
    $candelete=haveRight("delete_ticket","1");

    // Form to delete old item
    if ($candelete){
        echo "<form method='post' action=\"".$_SERVER["PHP_SELF"]."?ID=$item\" name='oldTrackingForm' id='oldTrackingForm'>";
        echo "<input type='hidden' name='ID' value='$item'>";
    }

    $where = "(status = 'old_done' OR status = 'old_notdone')";    
    $query = "SELECT ID FROM glpi_tracking WHERE $where and (device_type = '$item_type' and computer = '$item') ORDER BY date ".getTrackingOrderPrefs($_SESSION["glpiID"]);

    $result = $db->query($query);

    $i = 0;
    $number = $db->numrows($result);

    if ($number > 0)
    {
        echo "<div align='center'>&nbsp;<table class='tab_cadre_fixe'>";
        echo "<tr><th colspan=9>".$number." ".$lang["job"][18]."  ".$lang["job"][17]."";
        if ($number > 1) { echo "s"; }
        echo " ".$lang["job"][16].":</th></tr>";

        commonTrackingListHeader();

        while ($i < $number)
        {
            $ID = $db->result($result, $i, "ID");
            showJobShort($ID, 0);
            $i++;
        }

        echo "</table></div>";

        if ($candelete){
            echo "<br><div align='center'>";

            echo "<table class ='delete-old-job' cellpadding='5' width='950'>";
            echo "<tr><td><img src=\"".$HTMLRel."pics/arrow-left.png\" alt='' ></td><td><a  onclick= \"if ( markAllRows('oldTrackingForm') ) return false;\" href='".$_SERVER["PHP_SELF"]."?select=all&amp;ID=$item'>".$lang["buttons"][18]."</a></td>";

            echo "<td>/</td><td><a onclick= \"if ( unMarkAllRows('oldTrackingForm') ) return false;\" href='".$_SERVER["PHP_SELF"]."?select=none&amp;ID=$item'>".$lang["buttons"][19]."</a>";
            echo "</td><td>";
            echo "<input type='submit' value=\"".$lang["buttons"][6]."\" name='delete_inter' class='submit'></td>";
            echo "<td width='75%'>&nbsp;</td></tr></table></div>";
        }
    } 
    else
    {
        echo "<br><div align='center'>";
        echo "<table class='tab_cadre_fixe'>";
        echo "<tr><th>".$lang["joblist"][22]."</th></tr>";
        echo "</table>";
        echo "</div><br>";
    }

    // End form for delete item
    if ($candelete)
        echo "</form>";

}

function showJobListForItem($username,$item_type,$item) {
    // $item is required
    //affiche toutes les vielles intervention pour un $item donn� 

    global $db,$cfg_glpi, $lang;

    if (!haveRight("show_ticket","1")) return false;


    $where = "(status = 'new' OR status= 'assign' OR status='plan' OR status='waiting')";    
    $query = "SELECT ID FROM glpi_tracking WHERE $where and (computer = '$item' and device_type= '$item_type') ORDER BY date ".getTrackingOrderPrefs($_SESSION["glpiID"]);


    $result = $db->query($query);

    $i = 0;
    $number = $db->numrows($result);

    if ($number > 0)
    {
        echo "<div align='center'>&nbsp;<table class='tab_cadre_fixe'>";
        echo "<tr><th colspan='9'>".$number." ".$lang["job"][17]."";
        if ($number > 1) { echo "s"; }
        echo " ".$lang["job"][16].":</th></tr>";

        if ($item)
        {
            echo "<tr><td align='center' class='tab_bg_2' colspan='9'>";
            echo "<a href=\"".$cfg_glpi["root_doc"]."/front/helpdesk.php?computer=$item&amp;device_type=$item_type\"><strong>";
            echo $lang["joblist"][7];
            echo "</strong></a>";
            echo "</td></tr>";
        }

        commonTrackingListHeader();

        while ($i < $number)
        {
            $ID = $db->result($result, $i, "ID");
            showJobShort($ID, 0);
            $i++;
        }
        echo "</table></div>";
    } 
    else
    {
        echo "<br><div align='center'>";
        echo "<table class='tab_cadre_fixe'>";
        echo "<tr><th>".$lang["joblist"][8]."</th></tr>";

        if ($item)
        {

            echo "<tr><td align='center' class='tab_bg_2' colspan='8'>";
            echo "<a href=\"".$cfg_glpi["root_doc"]."/front/helpdesk.php?computer=$item&amp;device_type=$item_type\"><strong>";
            echo $lang["joblist"][7];
            echo "</strong></a>";
            echo "</td></tr>";
        }
        echo "</table>";
        echo "</div><br>";
    }
}

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#12 2007-05-28 18:00:44

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

function showJobShort($ID, $followups,$output_type=HTML_OUTPUT,$row_num=0,$client) {
    // Prints a job in short form
    // Should be called in a <table>-segment
    // Print links or not in case of user view
    // Ajout du parametre $client par GP pour la gestion multi clients

    global $cfg_glpi, $lang, $HTMLRel;

    // Make new job object and fill it from database, if success, print it
    $job = new Job($client);// Ajout du parametre $client par GP pour la gestion multi clients
    $candelete=haveRight("delete_ticket","1");
    $viewusers=haveRight("user","r");
    $align="align='center'";
    $align_desc="align='left'";
    if ($followups) { 
        $align.=" valign='top' ";
        $align_desc.=" valign='top' ";
    }
    if ($job->getfromDBwithData($ID,0))

    {
        $item_num=1;
        $bgcolor=$cfg_glpi["priority_".$job->fields["priority"]];

        echo displaySearchNewLine($output_type);
        
        // Ajout Par GP pour gestion multi client
        // Zero Column
        if ($_SESSION["client_actif"]=="all") {
            $zero_column= "<strong>".$client."</strong>";
            echo displaySearchItem($output_type,$zero_column,$item_num,$row_num,0,$align);
        }
        // Fin Ajout

        // First column
        $first_col= "ID: ".$job->fields["ID"];
        if ($output_type==HTML_OUTPUT)
            $first_col.="<br><img src=\"".$HTMLRel."pics/".$job->fields["status"].".png\" alt='".getStatusName($job->fields["status"])."' title='".getStatusName($job->fields["status"])."'>";
        else $first_col.=" - ".getStatusName($job->fields["status"]);

        if ($candelete&&$output_type==HTML_OUTPUT&&ereg("old_",$job->fields["status"])){
            $sel="";
            if (isset($_GET["select"])&&$_GET["select"]=="all") $sel="checked";
            $first_col.="<input type='checkbox' name='todel[".$job->fields["ID"]."]' value='1' $sel>";
        }

        echo displaySearchItem($output_type,$first_col,$item_num,$row_num,0,$align);

        // Second column
        $second_col="";    
        if (!ereg("old_",$job->fields["status"]))
        {
            $second_col.="<small>".$lang["joblist"][11].":";
            if ($output_type==HTML_OUTPUT) $second_col.="<br>";
            $second_col.= "&nbsp;".convDateTime($job->fields["date"])."</small>";
        }
        else
        {
            $second_col.="<small>".$lang["joblist"][11].":";
            if ($output_type==HTML_OUTPUT) $second_col.="<br>";
            $second_col.="&nbsp;".convDateTime($job->fields["date"]);
            $second_col.="<br>";
            $second_col.="<i>".$lang["joblist"][12].":";
            if ($output_type==HTML_OUTPUT) $second_col.="<br>";
            $second_col.="&nbsp;".convDateTime($job->fields["closedate"])."</i>";
            $second_col.="<br>";
            if ($job->fields["realtime"]>0) $second_col.=$lang["job"][20].": ";
            if ($output_type==HTML_OUTPUT) $second_col.="<br>";
            $second_col.="&nbsp;".getRealtime($job->fields["realtime"]);
            $second_col.="</small>";
        }

        echo displaySearchItem($output_type,$second_col,$item_num,$row_num,0,$align." width=130");

        // Third Column
        echo displaySearchItem($output_type,"<strong>".getPriorityName($job->fields["priority"])."</strong>",$item_num,$row_num,0,"$align bgcolor='$bgcolor'");

        // Fourth Column
        // Modification par GP pour auteur-demandeur
        /* Avant Modification :
        if ($viewusers)
            $fourth_col="<strong>".$job->getAuthorName(1)."</strong>";
        else
            $fourth_col="<strong>".$job->getAuthorName()."</strong>";*/
        if ($viewusers)
            $fourth_col="<strong>".$job->getCallerName(1,$client)."</strong>";
        else
            $fourth_col="<strong>".$job->getCallerName(0,$client)."</strong>";
        // Fin Modification

        if ($job->fields["FK_group"])
            $fourth_col.="<br>".getDropdownName("glpi_groups",$job->fields["FK_group"]);

        echo displaySearchItem($output_type,$fourth_col,$item_num,$row_num,0,$align);

        // Ajout par GP pour auteur-demandeur
        if ($viewusers)
            $half_fourth_col="<strong>".$job->getCreatorName(1,$client)."</strong>";
        else
            $half_fourth_col="<strong>".$job->getCreatorName(0,$client)."</strong>";

        if ($job->fields["FK_group"])
            $half_fourth_col.="<br>".getDropdownName("glpi_groups",$job->fields["FK_group"]);

        echo displaySearchItem($output_type,$half_fourth_col,$item_num,$row_num,0,$align);
        // Fin Ajout

        // Fifth column
        $fifth_col="";
        if ($viewusers)
            $fifth_col.=getAssignName($job->fields["assign"],USER_TYPE,1);
        else
            $fifth_col.="<strong>".getAssignName($job->fields["assign"],USER_TYPE)."</strong>";

        if ($job->fields["assign_ent"]>0){
            $fifth_col.="<br>";
            if ($viewusers)
                $fifth_col.=getAssignName($job->fields["assign_ent"],ENTERPRISE_TYPE,1);
            else
                $fifth_col.="<strong>".getAssignName($job->fields["assign_ent"],ENTERPRISE_TYPE)."</strong>";

        }
        echo displaySearchItem($output_type,$fifth_col,$item_num,$row_num,0,$align);


        // Sixth Colum
        $sixth_col="";
        $deleted=0;
        $m= new CommonItem;
        if ($m->getfromDB($job->fields["device_type"],$job->fields["computer"]))

            if (haveTypeRight($job->fields["device_type"],"r")){

                if (isset($m->obj->fields["deleted"])&&$m->obj->fields["deleted"]=='Y')
                    $deleted=1;
                $sixth_col.=$m->getType();

                if ($job->fields["device_type"]>0){
                    $sixth_col.="<br><strong>";
                    if ($job->computerfound) $sixth_col.=$m->getLink();
                    else $sixth_col.=$m->getNameID();
                    $sixth_col.="</strong>";
                } 

            }
            else {
                $m= new CommonItem;
                if ($m->getfromDB($job->fields["device_type"],$job->fields["computer"]))
                    if (isset($m->obj->fields["deleted"])&&$m->obj->fields["deleted"]=='Y')
                        $deleted=1;
                $sixth_col.=$m->getType();
                $sixth_col.="<br><strong>".$job->computername;
                if ($cfg_glpi["view_ID"])
                    $sixth_col.=" (".$job->fields["computer"].")";
                $sixth_col.="</strong>";
            }
        echo displaySearchItem($output_type,$sixth_col,$item_num,$row_num,$deleted,$align);

        // Seventh column
        echo displaySearchItem($output_type,"<strong>".getDropdownName("glpi_dropdown_tracking_category",$job->fields["category"])."</strong>",$item_num,$row_num,0,$align);

        // Eigth column

        $stripped_content=resume_text($job->fields["contents"],400);
        if ($followups){$stripped_content=resume_text($job->fields["contents"],$cfg_glpi["cut"]);}

        $eigth_column="<strong>".$stripped_content."</strong>";
        if ($followups&&$output_type==HTML_OUTPUT)
        {
            $eigth_column.=showFollowupsShort($job->fields["ID"]);
        }


        echo displaySearchItem($output_type,$eigth_column,$item_num,$row_num,0,$align_desc."width='300'");


        // Nineth column
        $nineth_column="";
        // Job Controls

        // Ajout pour gestion multi-client
        $var_cli_link = "";
        if (isset($client)) { $var_cli_link = "&client=".$client; }
        // Fin ajout
        if ($_SESSION["glpiprofile"]["interface"]=="central"){
            // Modification par GP pour auteur-demandeur : author -> creator
            if (!haveRight("show_ticket","1")&&$job->fields["creator"]!=$_SESSION["glpiID"]&&$job->fields["assign"]!=$_SESSION["glpiID"]) 
                $nineth_column.="&nbsp;";
            else 
                $nineth_column.="<a href=\"".$cfg_glpi["root_doc"]."/front/tracking.form.php?ID=".$job->fields["ID"].$var_cli_link."\"><strong>".$lang["joblist"][13]."</strong></a>&nbsp;(".$job->numberOfFollowups(1,$client).")";
        }
        else
            $nineth_column.="<a href=\"".$cfg_glpi["root_doc"]."/front/helpdesk.public.php?show=user&amp;ID=".$job->fields["ID"].$var_cli_link."\">".$lang["joblist"][13]."</a>&nbsp;(".$job->numberOfFollowups(haveRight("show_full_ticket","1"),$client).")";

        echo displaySearchItem($output_type,$nineth_column,$item_num,$row_num,0,$align." width='40'");

        // Finish Line
        echo displaySearchEndLine($output_type);
    }
    else
    {
        echo "<tr class='tab_bg_2'><td colspan='6' ><i>".$lang["joblist"][16]."</i></td></tr>";
    }
}

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#13 2007-05-28 18:01:56

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

function showJobVeryShort($ID) {
    // Prints a job in short form
    // Should be called in a <table>-segment
    // Print links or not in case of user view

    global $cfg_glpi, $lang;

    // Make new job object and fill it from database, if success, print it
    $job = new Job;
    $viewusers=haveRight("user","r");
    if ($job->getfromDBwithData($ID,0))
    {
        $bgcolor=$cfg_glpi["priority_".$job->fields["priority"]];
        if ($job->fields["status"] == "new")
        {
            echo "<tr class='tab_bg_2'>";
            echo "<td align='center' bgcolor='$bgcolor' >ID: ".$job->fields["ID"]."</td>";

        }
        else
        {
            echo "<tr class='tab_bg_2'>";
            echo "<td align='center' bgcolor='$bgcolor' >ID: ".$job->fields["ID"];
            echo "</td>";
        }


        echo "<td align='center'>";

        // Modification par GP pour auteur-demandeur
        /* Avant Modification :
        if ($viewusers)
            echo "<strong>".$job->getAuthorName(1)."</strong>";
        else
            echo "<strong>".$job->getAuthorName()."</strong>";*/
        if ($viewusers)
            echo "<strong>".$job->getCallerName(1)."</strong>";
        else
            echo "<strong>".$job->getCallerName()."</strong>";
        // Fin Modification

        if ($job->fields["FK_group"])
            echo "<br>".getDropdownName("glpi_groups",$job->fields["FK_group"]);


        echo "</td>";

        $m= new CommonItem;
        $m->getfromDB($job->fields["device_type"],$job->fields["computer"]);

        if (haveTypeRight($job->fields["device_type"],"r")){
            echo "<td align='center' ";
            if (isset($m->obj)&&isset($m->obj->fields["deleted"])&&$m->obj->fields["deleted"]=='Y')
                echo "class='tab_bg_1_2'";
            echo ">";
            echo $m->getType()."<br>";
            echo "<strong>";
            if ($job->computerfound) echo $m->getLink();
            else echo $m->getNameID();
            echo "</strong>";

            echo "</td>";
        }
        else
            echo "<td  align='center' >".$m->getType()."<br><strong>$job->computername (".$job->fields["computer"].")</strong></td>";

        $stripped_content =resume_text($job->fields["contents"],100);
        echo "<td ><strong>".$stripped_content."</strong>";
        echo "</td>";

        // Job Controls
        echo "<td width='40' align='center'>";

        if ($_SESSION["glpiprofile"]["interface"]=="central")
            echo "<a href=\"".$cfg_glpi["root_doc"]."/front/tracking.form.php?ID=".$job->fields["ID"]."\"><strong>".$lang["joblist"][13]."</strong></a>&nbsp;(".$job->numberOfFollowups().")&nbsp;<br>";
        else
            echo "<a href=\"".$cfg_glpi["root_doc"]."/front/helpdesk.public.php?show=user&amp;ID=".$job->fields["ID"]."\">".$lang["joblist"][13]."</a>&nbsp;(".$job->numberOfFollowups().")&nbsp;<br>";

        // Finish Line
        echo "</tr>";
    }
    else
    {
        echo "<tr class='tab_bg_2'><td colspan='6' ><i>".$lang["joblist"][16]."</i></td></tr>";
    }
}

function addFormTracking ($device_type=0,$ID=0,$caller,$assign,$target,$error,$searchauthor='',$creator) {
    // Prints a nice form to add jobs
    // Modification par GP  pour auteur-demandeur : $author -> $caller ajout de $creator
    
    global $cfg_glpi, $lang,$cfg_glpi,$REFERER,$db;
    if (!haveRight("create_ticket","1")) return false;

    if (!empty($error)) {
        echo "<div align='center'><strong>$error</strong></div>";
    }
    echo "<form name='form_ticket' method='post' action='$target' enctype=\"multipart/form-data\">";
    echo "<div align='center'>";

    //    if ($device_type!=0){
    echo "<input type='hidden' name='_referer' value='$REFERER'>";
    echo "<p><a class='icon_consol' href='$REFERER'>".$lang["buttons"][13]."</a></p>";
    //    }    
    echo "<table class='tab_cadre'><tr><th><a href='$target'>".$lang["buttons"][16]."</a></th><th colspan='3'>".$lang["job"][13].": <br>";
    if ($device_type!=0){
        $m=new CommonItem;
        $m->getfromDB($device_type,$ID);
        echo $m->getType()." - ".$m->getNameID();
    }
    echo "</th></tr>";

    //echo "<tr class='tab_bg_1' align='center'><td>".$lang["common"][27].":</td>";
    //echo "<td align='center' colspan='3'>".convDateTime(date("Y-m-d H:i:s"))."</td></tr>";

    if ($device_type==0&&$_SESSION["glpiprofile"]["helpdesk_hardware"]!=0){
        echo "<tr class='tab_bg_2'>";
        echo "<td align='center'>".$lang["help"][24].": </td>";
        echo "<td align='center' colspan='3'>";
     // Modification par GP pour auteur-demandeur
     /* Avant Modification :
        dropdownTrackingDeviceType("device_type",$device_type,$_SESSION["glpiID"]);*/
        dropdownTrackingDeviceType("device_type",$device_type,$caller);        
        // Fin Modification
        echo "</td></tr>";
    } else {
        echo "<tr class='tab_bg_2'><td colspan='4'>";
        echo "<input type='hidden' name='device_type' value='0'>";
        echo "</td></tr>";
    }


    if (haveRight("update_ticket","1")){
        echo "<tr class='tab_bg_2'><td align='center'>".$lang["common"][27].":</td>";
        echo "<td align='center' class='tab_bg_2'>";
        showCalendarForm("form_ticket","date",date("Y-m-d H:i"),0,1);    
        echo "</td>";

        echo "<td align='center'>".$lang["job"][44].":</td>";
        echo "<td align='center'>";
        $request_type=1;
        if (isset($_POST["request_type"])) $request_type=$_POST["request_type"];
        dropdownRequestType("request_type",$request_type);
        echo "</td></tr>";
    }


    // Need comment right to add a followup with the realtime
    if (haveRight("comment_all_ticket","1")){
        echo "\n<tr  class='tab_bg_2'>";
        echo "\n<td align='center'>";
        echo $lang["job"][20].":</td>";

    // Modification chronomètre pour la saisie automatique de la durée dans les tickets par GP
    /* Avant modification :
        echo "<td align='center' colspan='3'><select name='hour'>";
        for ($i=0;$i<100;$i++){
            $selected="";
            if (isset($_POST["hour"])&&$_POST["hour"]==$i) $selected="selected";
            echo "<option value='$i' $selected>$i</option>";
        }            

        echo "</select>".$lang["job"][21]."&nbsp;&nbsp;";
        echo "<select name='minute'>";
        for ($i=0;$i<60;$i++){
            $selected="";
            if (isset($_POST["minute"])&&$_POST["minute"]==$i) $selected="selected";
            echo "<option value='$i' $selected>$i</option>";
        }
        echo "</select>".$lang["job"][22]."&nbsp;&nbsp;";
        */

        echo "\n<td align='center' colspan='3'>";
        echo "\n<input type=\"text\" size=2 readonly name=\"hour\" value=\"00\" style=\"background-color: #d7d7d2; border: 0px;\"> :";
        echo "\n<input type=\"text\" size=2 readonly name=\"minute\" value=\"00\" style=\"background-color: #d7d7d2; border: 0px;\"> :";
        echo "\n<input type=\"text\" size=2 readonly name=\"secondes\" value=\"00\" style=\"background-color: #d7d7d2; border: 0px;\">";
        // Fin Modification
        
        echo "\n</td></tr>\n";
    }


    echo "<tr class='tab_bg_2'>";

    echo "<td class='tab_bg_2' align='center'>".$lang["joblist"][2].":</td>";
    echo "<td align='center' class='tab_bg_2'>";
    $priority=3;
    if (isset($_POST["priority"])) $priority=$_POST["priority"];
    dropdownPriority("priority",$priority);
    echo "</td>";

    echo "<td>".$lang["common"][36].":</td>";
    echo "<td align='center'>";
    $category=0;
    if (isset($_POST["category"])) $category=$_POST["category"];
    dropdownValue("glpi_dropdown_tracking_category","category",$category);
    echo "</td></tr>";


    // Modification Auteur-Demandeur par GP
    /* Avant modification :
    $author_rand=0;
    if (haveRight("update_ticket","1")){
        echo "<tr class='tab_bg_2' align='center'><td>".$lang["common"][37].":</td>";
        echo "<td align='center'>";
        $author_rand=dropdownAllUsers("author",$author);

        echo "<script type='text/javascript' >";
        echo "   new Form.Element.Observer('dropdown_author$author_rand', 1, ";
        echo "      function(element, value) {";
        echo "          new Ajax.Updater('tracking_device_type_selecter','".$cfg_glpi["root_doc"]."/ajax/updateTrackingDeviceType.php',{asynchronous:true, evalScripts:true, ";
        echo "           method:'post', parameters:'userID=' + value+'&device_type=$device_type'";
        echo "})})";
        echo "</script>";    
    */
    $caller_rand=0;
    if (haveRight("update_ticket","1")||haveRight("create_ticket","1")){
        echo "<tr class='tab_bg_2' align='center'><td>".$lang["common"][48].":</td>";
        echo "<td align='center'>";
        $caller_rand=dropdownAllUsers("caller",$caller);

        echo "<script type='text/javascript' >";
        echo "   new Form.Element.Observer('dropdown_caller$caller_rand', 1, ";
        echo "      function(element, value) {";
        echo "          new Ajax.Updater('tracking_device_type_selecter','".$cfg_glpi["root_doc"]."/ajax/updateTrackingDeviceType.php',{asynchronous:true, evalScripts:true, ";
        echo "           method:'post', parameters:'userID=' + value+'&device_type=$device_type'";
        echo "})})";
        echo "</script>";    
    // Fin Modification

        echo "</td>";
    } else {
        echo "<tr class='tab_bg_2'><td>&nbsp;</td><td>&nbsp;</td>";
    }

    if (haveRight("update_ticket","1")||haveRight("assign_ticket","1")){
        echo "<td>".$lang["buttons"][3].":</td>";
        echo "<td align='center'>";
        dropdownUsers("assign",$assign,"own_ticket");
        echo "</td></tr>";
    } else if (haveRight("steal_ticket","1")) {
        echo "<td>".$lang["buttons"][3].":</td>";
        echo "<td align='center'>";
        dropdownUsers("assign",$assign,"ID");
        echo "</td></tr>";
    }else {
        echo "<td>&nbsp;</td><td>&nbsp;</td></tr>";
    }




    if($cfg_glpi["mailing"] == 1){

        $query="SELECT email from glpi_users WHERE ID='$caller'";
        
        $result=$db->query($query);
        $email="";
        if ($result&&$db->numrows($result))
            $email=$db->result($result,0,"email");

        echo "<tr class='tab_bg_1'>";
        echo "<td align='center'>".$lang["help"][8].":</td>";
        echo "<td align='center'>    <select name='emailupdates'>";
        echo "<option value='no'>".$lang["choice"][0]."";
        echo "<option value='yes' selected>".$lang["choice"][1]."";
        echo "</select>";
        echo "</td>";
        echo "<td align='center'>".$lang["help"][11].":</td>";
        echo "<td><span id='uemail_result'>";
        echo "<input type='text' size='30' name='caemail' value='$email'>"; // Remplacement de uemail par camail pour auteur-demandeur par GP
        echo "</span>";

        if (haveRight("update_ticket","1")||haveRight("create_ticket","1")){
            echo "<script type='text/javascript' >\n";
            echo "   new Form.Element.Observer('dropdown_caller$caller_rand', 1, \n";
            echo "      function(element, value) {\n";
            echo "          new Ajax.Updater('uemail_result','".$cfg_glpi["root_doc"]."/ajax/uemailUpdate.php',{asynchronous:true, evalScripts:true, \n";
            echo "           method:'post', parameters:'value='+value\n";
            echo "})})\n";
            echo "</script>\n";
        }

        echo "</td></tr>";
        // Ajout GP pour Auteur-demandeur
        if (haveRight("update_creator","1")){ // Normalement seul les admins auront le droit de modifier le createur d'un ticket.
            $creator_rand=0;
            echo "<tr class='tab_bg_2' align='center'><td>".$lang["common"][37].":</td>";
            echo "<td align='center'>";
            $creator_rand=dropdownUsers("creator",$creator,"create_ticket");
            echo "</td>";

            echo "<script type='text/javascript' >";
            echo "   new Form.Element.Observer('dropdown_creator$creator_rand', 1, ";
            echo "      function(element, value) {";
            echo "          new Ajax.Updater('tracking_device_type_selecter','".$cfg_glpi["root_doc"]."/ajax/updateTrackingDeviceType.php',{asynchronous:true, evalScripts:true, ";
            echo "           method:'post', parameters:'userID=' + value+'&device_type=$device_type'";
            echo "})})";
            echo "</script>";    

            echo "<td align='center' colspan=2> </td></tr>";
        } else {
            $creator_rand=0;
            echo "<tr class='tab_bg_2' align='center'><td>".$lang["common"][37].":</td>";
            echo "<td align='center'>";
            $creator_rand=dropdownUniqueUser("creator",$creator);
            echo "</td>";
            
            echo "<script type='text/javascript' >";
            echo "   new Form.Element.Observer('dropdown_creator$creator_rand', 1, ";
            echo "      function(element, value) {";
            echo "          new Ajax.Updater('tracking_device_type_selecter','".$cfg_glpi["root_doc"]."/ajax/updateTrackingDeviceType.php',{asynchronous:true, evalScripts:true, ";
            echo "           method:'post', parameters:'userID=' + value+'&device_type=$device_type'";
            echo "})})";
            echo "</script>";    
            echo "<td align='center' colspan=2> </td></tr>";
        }
        // Fin Ajout
    }

    echo "<tr><th colspan='4' align='center'>".$lang["job"][11].":";
    if ($device_type!=0){
        echo "<input type='hidden' name='computer' value=\"$ID\">";
        echo "<input type='hidden' name='device_type' value=\"$device_type\">";
    }

    echo "</th></tr>";

    echo "<tr class='tab_bg_1'><td colspan='4' align='center'><textarea cols='80' rows='8'  name='contents'></textarea></td></tr>";

    $max_size=return_bytes_from_ini_vars(ini_get("upload_max_filesize"));
    $max_size/=1024*1024;
    $max_size=round($max_size,1);

    echo "<tr class='tab_bg_1'><td>".$lang["document"][2]." (".$max_size." ".$lang["common"][45]."):    ";
    echo "<img src=\"".$cfg_glpi["root_doc"]."/pics/aide.png\" style='cursor:pointer;' alt=\"aide\"onClick=\"window.open('".$cfg_glpi["root_doc"]."/front/typedoc.list.php','Help','scrollbars=1,resizable=1,width=1000,height=800')\">";
    echo "</td>";
    echo "<td colspan='3'><input type='file' name='filename' value=\"\" size='25'></td>";
    echo "</tr>";

    echo "<tr class='tab_bg_1'><td colspan='2' align='center'>";
    echo "<input type='submit' name='add' value=\"".$lang["buttons"][2]."\" class='submit'>";
    echo "</td><td colspan='2' align='center'>";
    if (haveRight("comment_all_ticket","1"))
        echo "<input type='submit' name='add_close' value=\"".$lang["buttons"][26]."\" class='submit'>";
    else echo "&nbsp;";
    echo "</td></tr>";

    if (haveRight("comment_all_ticket","1")){
        echo "<tr><th colspan='4' align='center'>".$lang["job"][45].":</th></tr>";
        // Modification Chronomètre par GP
        /* Avant modification :
        echo "<tr class='tab_bg_1'><td colspan='4' align='center'><textarea cols='80' rows='8' name='_followup'></textarea></td></tr>";
        */
        echo "\n<tr class='tab_bg_1'>\n";
        echo "<td colspan='4' align='center'>\n<textarea cols='80' rows='8' name='_followup'>".$lang["job"][46]."</textarea>\n</td>\n</tr>";
        // Fin Modification
    }

    echo "</table></div></form>";

}

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#14 2007-05-28 18:04:08

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

function getRealtime($realtime){
    global $lang;    
    $output="";
    $hour=floor($realtime);
    if ($hour>0) $output.=$hour." h ";

    // Modification chronomètre pour la saisie automatique de la durée dans les tickets par GP
    /* Avant modification :
    $output.=round((($realtime-floor($realtime))*60))." ".$lang["job"][22];
    */
    $minutes=round(($realtime-floor($realtime))*60);
    if ($hour>0||$minutes>0) $output.=$minutes." mm ";
    $secondes=round(($realtime-floor($realtime))*3600)-($minutes*60);
    if ($secondes>0||$output=="") $output.=$secondes." s";
    //fin Modification

    return $output;
}

function searchSimpleFormTracking($target,$status="all"){

global $cfg_glpi,  $lang,$HTMLRel,$phproot;


    echo "<div align='center' >";

    echo "<form method='get' name=\"form\" action=\"".$target."\">";
    echo "<table class='tab_cadre_fixe'>";
    echo "<tr class='tab_bg_1'>";
    echo "<td colspan='1' align='center'>".$lang["joblist"][0].":&nbsp;";
    echo "<select name='status'>";
    echo "<option value='new' ".($status=="new"?" selected ":"").">".$lang["joblist"][9]."</option>";
    echo "<option value='assign' ".($status=="assign"?" selected ":"").">".$lang["joblist"][18]."</option>";
    echo "<option value='plan' ".($status=="plan"?" selected ":"").">".$lang["joblist"][19]."</option>";
    echo "<option value='waiting' ".($status=="waiting"?" selected ":"").">".$lang["joblist"][26]."</option>";
    echo "<option value='old_done' ".($status=="old_done"?" selected ":"").">".$lang["joblist"][10]."</option>";
    echo "<option value='old_notdone' ".($status=="old_notdone"?" selected ":"").">".$lang["joblist"][17]."</option>";
    echo "<option value='notold' ".($status=="notold"?"selected":"").">".$lang["joblist"][24]."</option>";    
    echo "<option value='process' ".($status=="process"?"selected":"").">".$lang["joblist"][21]."</option>";
    echo "<option value='old' ".($status=="old"?"selected":"").">".$lang["joblist"][25]."</option>";    
    echo "<option value='all' ".($status=="all"?"selected":"").">".$lang["joblist"][20]."</option>";
    echo "</select></td>";
    echo "<td align='center' colspan='1'><input type='submit' value=\"".$lang["buttons"][0]."\" class='submit'></td>";
    echo "</tr>";
    echo "</table></div>";
    echo "<input type='hidden' name='start' value='0'>";
    // helpdesk case
    if (ereg("helpdesk.public.php",$target)){
        echo "<input type='hidden' name='show' value='user'>";
    }
    echo "</form>";

}

function searchFormTracking($extended=0,$target,$start="",$status="new",$caller=0,$group=0,$assign=0,$assign_ent=0,$category=0,$priority=0,$request_type=0,$item=0,$type=0,$showfollowups="",$field2="",$contains2="", $creator=0, $field="",$contains="",$date1="",$date2="",$computers_search="",$enddate1="",$enddate2="") {
    // Print Search Form
    // Modification par GP pour auteur-demandeur, $author->$caller et ajout de $creator après $contains2
    // cela correspond a la fin des parametre si la recherche n'est pas etendue, voir front/tracking.php

    global $cfg_glpi,  $lang,$HTMLRel,$phproot;

    // Modification par GP pour auteur-demandeur
    /* Avant modification :
    if (!haveRight("show_ticket","1")) {
        if ($author==0&&$assign==0)
            if (!haveRight("own_ticket","1"))
                $author=$_SESSION["glpiID"];
            else $assign=$_SESSION["glpiID"];
    }*/
    if (!haveRight("show_ticket","1")) {
        if ($creator==0&&$assign==0)
            if (!haveRight("own_ticket","1"))
                $creator=$_SESSION["glpiID"];
            else $assign=$_SESSION["glpiID"];
    }
    // Fin modification

    if ($extended==1){
        $option["comp.ID"]                = $lang["common"][2];
        $option["comp.name"]                = $lang["common"][16];
        $option["glpi_dropdown_locations.name"]        = $lang["common"][15];
        $option["glpi_type_computers.name"]        = $lang["common"][17];
        $option["glpi_dropdown_model.name"]        = $lang["common"][22];
        $option["glpi_dropdown_os.name"]        = $lang["computers"][9];
        $option["processor.designation"]        = $lang["computers"][21];
        $option["comp.serial"]                = $lang["common"][19];
        $option["comp.otherserial"]            = $lang["common"][20];
        $option["ram.designation"]            = $lang["computers"][23];
        $option["iface.designation"]            = $lang["setup"][9];
        $option["sndcard.designation"]            = $lang["devices"][7];
        $option["gfxcard.designation"]            = $lang["devices"][2];
        $option["moboard.designation"]            = $lang["devices"][5];
        $option["hdd.designation"]            = $lang["computers"][36];
        $option["comp.comments"]            = $lang["common"][25];
        $option["comp.contact"]                = $lang["common"][18];
        $option["comp.contact_num"]                = $lang["common"][21];
        $option["comp.date_mod"]            = $lang["common"][26];
        $option["glpi_networking_ports.ifaddr"]     = $lang["networking"][14];
        $option["glpi_networking_ports.ifmac"]         = $lang["networking"][15];
        $option["glpi_dropdown_netpoint.name"]        = $lang["networking"][51];
        $option["glpi_enterprises.name"]        = $lang["common"][5];
        $option["resptech.name"]            =$lang["common"][10];
    }
    echo "<form method='get' name=\"form\" action=\"".$target."\">";


    echo "<div align='center' >";

    echo "<table class='tab_cadre_fixe'>";


    echo "<tr><th colspan='6' style='vertical-align:middle' ><div style='position: relative'><span><strong>".$lang["search"][0]."</strong></span>";
    if ($extended)
        echo "<span style='  position:absolute; right:0; margin-right:5px; font-size:10px;'><a href='$target?extended=0'><img src=\"".$HTMLRel."pics/deplier_up.png\" alt=''>".$lang["buttons"][36]."</a></span>";
    else echo "<span  style='  position:absolute; right:0; margin-right:5px; font-size:10px;'><a href='$target?extended=1'><img src=\"".$HTMLRel."pics/deplier_down.png\" alt=''>".$lang["buttons"][35]."</a></span>";
    echo "</div></th></tr>";



    echo "<tr class='tab_bg_1'>";
    // Modification par GP pour auteur-demandeur, echange entre la case du tableau statut et la case createur :
    // Debut createur
    echo "<td  colspan='1' align='center'>".$lang["common"][37].":<br>\n";
    dropdownUsers("creator",$creator,"create_ticket",1);
    echo "\n</td>\n";
    // Fin createur
    // Debut statut
    echo "<td colspan='1' align='center'>".$lang["joblist"][0].":<br>\n\t";
    echo "<select name='status'>\n\t\t";
    echo "<option value='new' ".($status=="new"?" selected ":"").">".$lang["joblist"][9]."</option>\n\t\t";
    echo "<option value='assign' ".($status=="assign"?" selected ":"").">".$lang["joblist"][18]."</option>\n\t\t";
    echo "<option value='plan' ".($status=="plan"?" selected ":"").">".$lang["joblist"][19]."</option>\n\t\t";
    echo "<option value='waiting' ".($status=="waiting"?" selected ":"").">".$lang["joblist"][26]."</option>\n\t\t";
    echo "<option value='old_done' ".($status=="old_done"?" selected ":"").">".$lang["joblist"][10]."</option>\n\t\t";
    echo "<option value='old_notdone' ".($status=="old_notdone"?" selected ":"").">".$lang["joblist"][17]."</option>\n\t\t";
    echo "<option value='notold' ".($status=="notold"?"selected":"").">".$lang["joblist"][24]."</option>\n\t\t";    
    echo "<option value='process' ".($status=="process"?"selected":"").">".$lang["joblist"][21]."</option>\n\t\t";
    echo "<option value='old' ".($status=="old"?"selected":"").">".$lang["joblist"][25]."</option>\n\t\t";    
    echo "<option value='all' ".($status=="all"?"selected":"").">".$lang["joblist"][20]."</option>\n\t";
    echo "</select>\n</td>";
    // Fin statut
    // Fin modification
    
    echo "<td  colspan='1' align='center'>".$lang["common"][35].":<br>";
    dropdownValue("glpi_groups","group",$group);
    echo "</td>";

    echo "<td colspan='1' align='center'>".$lang["joblist"][2].":<br>";
    dropdownPriority("priority",$priority,1);
    echo "</td>";

    echo "<td colspan='2' align='center'>".$lang["common"][36].":<br>";
    dropdownValue("glpi_dropdown_tracking_category","category",$category);
    echo "</td>";

    echo "</tr>";
    echo "<tr class='tab_bg_1'>";

    // Ajout par GP pour auteur-demandeur
    echo "\n\t<td  colspan='1' align='center'>".$lang["common"][48].":<br>";
    dropdownUsersTracking("caller",$caller,"caller");
    echo "\n\t</td>\n";
    // Fin ajout
    
    echo "<td align='center' colspan='1'>"; // Modification par GP pour auteur-demandeur colspan=2 -> colspan=1
    echo "<table border='0'><tr><td>".$lang["common"][1].":</td><td>";
    dropdownAllItems("item",$type,$item);
    echo "</td></tr></table>";
    echo "</td>";
    echo "<td colspan='3' align='center'>".$lang["job"][5].":<br>";

    echo $lang["job"][27].":&nbsp;";
    dropdownUsers("assign",$assign,"own_ticket",1);
    echo "<br>";
    echo $lang["job"][28].":&nbsp;";
    dropdownValue("glpi_enterprises","assign_ent",$assign_ent);

    echo "</td>";
    echo "<td align='center'>".$lang["job"][44].":<br>";
    dropdownRequestType("request_type",$request_type);
    echo "</td>";
    echo "</tr>";

    if ($extended){
        echo "<tr class='tab_bg_1'>";
        echo "<td align='center' colspan='6'>";
        $selected="";
        if ($computers_search) $selected="checked";
        echo "<input type='checkbox' name='only_computers' value='1' $selected>".$lang["reports"][24].":&nbsp;";

        echo "<input type='text' size='15' name=\"contains\" value=\"". stripslashes($contains) ."\" >";
        echo "&nbsp;";
        echo $lang["search"][10]."&nbsp;";

        echo "<select name='field' size='1'>";
        echo "<option value='all' ";
        if($field == "all") echo "selected";
        echo ">".$lang["search"][7]."</option>";
        reset($option);
        foreach ($option as $key => $val) {
            echo "<option value=\"".$key."\""; 
            if($key == $field) echo "selected";
            echo ">". $val ."</option>\n";
        }
        echo "</select>&nbsp;";

        echo "</td></tr>";
    }
    if($extended)    {
        echo "<tr class='tab_bg_1'><td colspan='2' align='right'>".$lang["reports"][60].":</td><td align='center' colspan='2'>".$lang["search"][8].":&nbsp;";
        showCalendarForm("form","date1",$date1);
        echo "</td><td align='center' colspan='2'>";
        echo $lang["search"][9].":&nbsp;";
        showCalendarForm("form","date2",$date2);
        echo "</td></tr>";

        echo "<tr class='tab_bg_1'><td colspan='2' align='right'>".$lang["reports"][61].":</td><td align='center' colspan='2'>".$lang["search"][8].":&nbsp;";
        showCalendarForm("form","enddate1",$enddate1);
        echo "</td><td align='center' colspan='2'>";
        echo $lang["search"][9].":&nbsp;";
        showCalendarForm("form","enddate2",$enddate2);
        echo "</td></tr>";
    }
    echo "<tr  class='tab_bg_1'>";

    echo "<td align='center' colspan='2'>";
    $elts=array("both"=>$lang["joblist"][6]." / ".$lang["job"][7],"contents"=>$lang["joblist"][6],"followup" => $lang["job"][7],"ID"=>"ID");
    echo "<select name='field2'>";
    foreach ($elts as $key => $val){
        $selected="";
        if ($field2==$key) $selected="selected";
        echo "<option value=\"$key\" $selected>$val</option>";
    }
    echo "</select>";



    echo "&nbsp;".$lang["search"][2]."&nbsp;";
    echo "<input type='text' size='15' name=\"contains2\" value=\"".stripslashes($contains2)."\">";
    echo "</td>";

    echo "<td align='center' colspan='1'><input type='submit' value=\"".$lang["buttons"][0]."\" class='submit'></td>";
    echo "<td align='center'  colspan='1'><input type='submit' name='reset' value=\"".$lang["buttons"][16]."\" class='submit'></td>";

    echo "<td align='center' colspan='2'>".$lang["reports"][59].":<select name='showfollowups'>";
    echo "<option value='1' ".($showfollowups=="1"?"selected":"").">".$lang["choice"][1]."</option>";
    echo "<option value='0' ".($showfollowups=="0"?"selected":"").">".$lang["choice"][0]."</option>";    
    echo "</select></td>";
    echo "</tr>";

    echo "</table></div>";
    echo "<input type='hidden' name='start' value='0'>";
    echo "</form>";


}

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#15 2007-05-28 18:09:50

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

function showTrackingList($target,$start="",$sort="",$order="",$status="new",$caller=0,$group=0,$assign=0,$assign_ent=0,$category=0,$priority=0,$request_type=0,$item=0,$type=0,$showfollowups="",$field2="",$contains2="",$creator=0,$field="",$contains="",$date1="",$date2="",$computers_search="",$enddate1="",$enddate2="") {
    // Lists all Jobs, needs $show which can have keywords 
    // (individual, unassigned) and $contains with search terms.
    // If $item is given, only jobs for a particular machine
    // are listed.
    // group = 0 : not use
    // group = -1 : groups of the author if session variable OK
    // group > 0 : specific group

    // Modification par GP pour auteur-demandeur, $author->$caller et ajout de $creator après $contains2
    // cela correspond a la fin des parametre si la recherche n'est pas etendue, voir front/tracking.php

    global $db,$cfg_glpi, $lang,$HTMLRel;

    $candelete=haveRight("delete_ticket","1");

    // Modification par GP pour auteur-demandeur
    /* Avant modification :
    if (!haveRight("show_ticket","1")) {
        if ($author==0&&$assign==0)
            if (!haveRight("own_ticket","1"))
                $author=$_SESSION["glpiID"];
            else $assign=$_SESSION["glpiID"];
    }*/
    if (!haveRight("show_ticket","1")) { 
        if ($creator==0&&$assign==0)
            if (!haveRight("own_ticket","1"))
                $creator=$_SESSION["glpiID"];
            else $assign=$_SESSION["glpiID"];
    }
    // Fin modification

    // Reduce computer list
    if ($computers_search){
        $SEARCH=makeTextSearch($contains);
        // Build query
        if($field == "all") {
            $wherecomp = " (";
            $query = "SHOW COLUMNS FROM glpi_computers";
            $result = $db->query($query);
            $i = 0;

            while($line = $db->fetch_array($result)) {
                if($i != 0) {
                    $wherecomp .= " OR ";
                }
                if(IsDropdown($line["Field"])) {
                    $wherecomp .= " glpi_dropdown_". $line["Field"] .".name $SEARCH" ;
                }
                elseif($line["Field"] == "location") {
                    $wherecomp .= " glpi_dropdown_locations.name $SEARCH";
                }
                else {
                    $wherecomp .= "comp.".$line["Field"] . $SEARCH;
                }
                $i++;
            }
            foreach($cfg_glpi["devices_tables"] as $key => $val) {
                if ($val!="drive"&&$val!="control"&&$val!="pci"&&$val!="case"&&$val!="power")
                    $wherecomp .= " OR ".$val.".designation ".makeTextSearch($contains,0);
            }
            $wherecomp .= " OR glpi_networking_ports.ifaddr $SEARCH";
            $wherecomp .= " OR glpi_networking_ports.ifmac $SEARCH";
            $wherecomp .= " OR glpi_dropdown_netpoint.name $SEARCH";
            $wherecomp .= " OR glpi_enterprises.name $SEARCH";
            $wherecomp .= " OR resptech.name $SEARCH";

            $wherecomp .= ")";
        }
        else {
            if(IsDevice($field)) {
                $wherecomp = "(glpi_device_".$field." $SEARCH )";
            }
            else {
                $wherecomp = "($field $SEARCH)";
            }
        }
    }
    if (!$start) {
        $start = 0;
    }

// Modification pour affichage de la liste de tous les clients
// simultanement dans le cadre de la gestion multi client par GP
if ($_SESSION["client_actif"]!="all") {
// On teste le client actif s'il est sur un client en particulier on ne change rien a la requête de base sinon voir le else
    $query = "select DISTINCT glpi_tracking.ID as ID from glpi_tracking";
    if ($computers_search){
        $query.= " LEFT JOIN glpi_computers as comp on ( comp.ID=glpi_tracking.computer AND glpi_tracking.device_type='".COMPUTER_TYPE."' )";
        $query.= " LEFT JOIN glpi_computer_device as gcdev ON (comp.ID = gcdev.FK_computers) ";
        $query.= "LEFT JOIN glpi_device_moboard as moboard ON (moboard.ID = gcdev.FK_device AND gcdev.device_type = '".MOBOARD_DEVICE."') ";
        $query.= "LEFT JOIN glpi_device_processor as processor ON (processor.ID = gcdev.FK_device AND gcdev.device_type = '".PROCESSOR_DEVICE."') ";
        $query.= "LEFT JOIN glpi_device_gfxcard as gfxcard ON (gfxcard.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".GFX_DEVICE."') ";
        $query.= "LEFT JOIN glpi_device_hdd as hdd ON (hdd.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".HDD_DEVICE."') ";
        $query.= "LEFT JOIN glpi_device_iface as iface ON (iface.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".NETWORK_DEVICE."') ";
        $query.= "LEFT JOIN glpi_device_ram as ram ON (ram.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".RAM_DEVICE."') ";
        $query.= "LEFT JOIN glpi_device_sndcard as sndcard ON (sndcard.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".SND_DEVICE."') ";
        $query.= "LEFT JOIN glpi_networking_ports on (comp.ID = glpi_networking_ports.on_device AND  glpi_networking_ports.device_type='1')";
        $query.= "LEFT JOIN glpi_dropdown_netpoint on (glpi_dropdown_netpoint.ID = glpi_networking_ports.netpoint)";
        $query.= "LEFT JOIN glpi_dropdown_os on (glpi_dropdown_os.ID = comp.os)";
        $query.= "LEFT JOIN glpi_dropdown_locations on (glpi_dropdown_locations.ID = comp.location)";
        $query.= "LEFT JOIN glpi_dropdown_model on (glpi_dropdown_model.ID = comp.model)";
        $query.= "LEFT JOIN glpi_type_computers on (glpi_type_computers.ID = comp.type)";
        $query.= " LEFT JOIN glpi_enterprises ON (glpi_enterprises.ID = comp.FK_glpi_enterprise ) ";
        $query.= " LEFT JOIN glpi_users as resptech ON (resptech.ID = comp.tech_num ) ";
    }

    if ($contains2!=""&&$field2!="contents"&&$field2!="ID") {
        $query.= " LEFT JOIN glpi_followups ON ( glpi_followups.tracking = glpi_tracking.ID)";
    }

    // Modification par GP pour auteur-demandeur
    /* Avant modification :
    if ($sort=="author.name"){
        $query.= " LEFT JOIN glpi_users as author ON ( glpi_tracking.author = author.ID) ";
    }*/
    if ($sort=="caller.name"){
        $query.= " LEFT JOIN glpi_users as caller ON ( glpi_tracking.caller = caller.ID) ";
    }
    if ($sort=="creator.name"){
        $query.= " LEFT JOIN glpi_users as creator ON ( glpi_tracking.creator = creator.ID) ";
    }
    // Fin modification
    if ($sort=="assign.name"){
        $query.= " LEFT JOIN glpi_users as assign ON ( glpi_tracking.assign = assign.ID) ";
    }
    if ($sort=="glpi_dropdown_tracking_category.completename"){
        $query.= " LEFT JOIN glpi_dropdown_tracking_category ON ( glpi_tracking.category = glpi_dropdown_tracking_category.ID) ";
    }

    $where=" WHERE '1' = '1'";

    if ($computers_search)
        $where.=" AND glpi_tracking.device_type= '1'";
    if ($category > 0){
        $where.=" AND ".getRealQueryForTreeItem("glpi_dropdown_tracking_category",$category,"glpi_tracking.category");
    }

    if ($computers_search) $where .= " AND $wherecomp";
    if (!empty($date1)&&$date1!="0000-00-00") $where.=" AND glpi_tracking.date >= '$date1'";
    if (!empty($date2)&&$date2!="0000-00-00") $where.=" AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) ";
    if (!empty($enddate1)&&$enddate1!="0000-00-00") $where.=" AND glpi_tracking.closedate >= '$enddate1'";
    if (!empty($enddate2)&&$enddate2!="0000-00-00") $where.=" AND glpi_tracking.closedate <= adddate( '". $enddate2 ."' , INTERVAL 1 DAY ) ";


    if ($type!=0)
        $where.=" AND glpi_tracking.device_type='$type'";    

    if ($item!=0&&$type!=0)
        $where.=" AND glpi_tracking.computer = '$item'";    

    switch ($status){
        case "new": $where.=" AND glpi_tracking.status = 'new'"; break;
        case "notold": $where.=" AND (glpi_tracking.status = 'new' OR glpi_tracking.status = 'plan' OR glpi_tracking.status = 'assign' OR glpi_tracking.status = 'waiting')"; break;
        case "old": $where.=" AND ( glpi_tracking.status = 'old_done' OR glpi_tracking.status = 'old_notdone')"; break;
        case "process": $where.=" AND ( glpi_tracking.status = 'plan' OR glpi_tracking.status = 'assign' )"; break;
        case "waiting": $where.=" AND ( glpi_tracking.status = 'waiting' )"; break;
        case "old_done": $where.=" AND ( glpi_tracking.status = 'old_done' )"; break;
        case "old_notdone": $where.=" AND ( glpi_tracking.status = 'old_notdone' )"; break;
        case "assign": $where.=" AND ( glpi_tracking.status = 'assign' )"; break;
        case "plan": $where.=" AND ( glpi_tracking.status = 'plan' )"; break;
    }

    if ($assign_ent!=0) $where.=" AND glpi_tracking.assign_ent = '$assign_ent'";
    if ($assign!=0) $where.=" AND glpi_tracking.assign = '$assign'";

    // Modification par GP pour auteur-demandeur
    /* Avant modification :
    if ($author!=0) $where.=" AND glpi_tracking.author = '$author'";*/
    if ($caller!=0) $where.=" AND glpi_tracking.caller = '$caller'";
    if ($creator!=0) $where.=" AND glpi_tracking.creator = '$creator'";
    // Fin modification

    if ($request_type!=0) $where.=" AND glpi_tracking.request_type = '$request_type'";

    if ($priority>0) $where.=" AND glpi_tracking.priority = '$priority'";
    if ($priority<0) $where.=" AND glpi_tracking.priority >= '".abs($priority)."'";

    if ($group>0) $where.=" AND glpi_tracking.FK_group = '$group'";
    // Modification par GP pour auteur-demandeur : $author -> $creator
    // cela veut dire que l'on peut voir les tickets de son groupe pas du groupe du demandeur.
    else if ($group==-1&&$creator!=0&&haveRight("show_group_ticket",1)){
        // Get Author group's
        if (count($_SESSION["glpigroups"])){
            $where.=" OR ( ";
            $i=0;
            foreach ($_SESSION["glpigroups"] as $gp){
                if ($i>0) $where.=" OR ";
                $where.=" glpi_tracking.FK_group = '$gp' ";
                $i++;
            }
            $where.=")";
        }
    }

    if ($contains2!=""){
        $SEARCH2=makeTextSearch($contains2);
        switch ($field2){
            case "both" :
                $where.= " AND (glpi_followups.contents $SEARCH2 OR glpi_tracking.contents $SEARCH2)";
            break;
            case "followup" :
                $where.= " AND (glpi_followups.contents $SEARCH2)";
            break;
            case "contents" :
                $where.= " AND (glpi_tracking.contents $SEARCH2)";
            break;
            case "ID" :
                $where= " WHERE (glpi_tracking.ID = '".$contains2."')";
            break;

        }
    }

// GP : Modification de l'ordre de tri par défaut
// Avant modification :
/*    if ($sort=="")
        $sort="glpi_tracking.date";
        if ($order=="")
        $order=getTrackingOrderPrefs($_SESSION["glpiID"]);*/

    if ($sort=="")
        $sort="glpi_tracking.priority DESC, glpi_tracking.date DESC";
    elseif ($order=="")
        $order=getTrackingOrderPrefs($_SESSION["glpiID"]);
// Fin mofication

    $query.=$where." ORDER BY $sort $order";
} else {
// Ici cela veut dire que la variable "client_actif" est sur all, il faut donc créer une autre requete pour afficher tous les clients
// Cette partie a été entièrement ajoutée pour la gestion multiclient.
// Modification par GP
    
    foreach ($_SESSION["liste_client"] as $key => $val) {
        if ($key == 0) { $query = ""; }
        else { $query .= "\nUNION\n";}
        $clitext = $val;
        $val = "`glpi-".$val."`";
        $query .= "(SELECT DISTINCT ".$val.".glpi_tracking.ID as ID, ".$val.".glpi_tracking.priority as priority, ";
        $query .= $val.".glpi_tracking.date as date, '".$clitext."' as client";
        $query .= " FROM ".$val.".glpi_tracking ";

        if ($computers_search){
            $query.= " LEFT JOIN ".$val.".glpi_computers as comp on ( comp.ID=".$val.".glpi_tracking.computer AND ".$val.".glpi_tracking.device_type='".COMPUTER_TYPE."' )";
            $query.= " LEFT JOIN ".$val.".glpi_computer_device as gcdev ON (comp.ID = gcdev.FK_computers) ";
            $query.= "LEFT JOIN ".$val.".glpi_device_moboard as moboard ON (moboard.ID = gcdev.FK_device AND gcdev.device_type = '".MOBOARD_DEVICE."') ";
            $query.= "LEFT JOIN ".$val.".glpi_device_processor as processor ON (processor.ID = gcdev.FK_device AND gcdev.device_type = '".PROCESSOR_DEVICE."') ";
            $query.= "LEFT JOIN ".$val.".glpi_device_gfxcard as gfxcard ON (gfxcard.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".GFX_DEVICE."') ";
            $query.= "LEFT JOIN ".$val.".glpi_device_hdd as hdd ON (hdd.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".HDD_DEVICE."') ";
            $query.= "LEFT JOIN ".$val.".glpi_device_iface as iface ON (iface.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".NETWORK_DEVICE."') ";
            $query.= "LEFT JOIN ".$val.".glpi_device_ram as ram ON (ram.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".RAM_DEVICE."') ";
            $query.= "LEFT JOIN ".$val.".glpi_device_sndcard as sndcard ON (sndcard.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".SND_DEVICE."') ";
            $query.= "LEFT JOIN ".$val.".glpi_networking_ports on (comp.ID = glpi_networking_ports.on_device AND  glpi_networking_ports.device_type='1')";
            $query.= "LEFT JOIN ".$val.".glpi_dropdown_netpoint on (".$val.".glpi_dropdown_netpoint.ID = ".$val.".glpi_networking_ports.netpoint)";
            $query.= "LEFT JOIN ".$val.".glpi_dropdown_os on (".$val.".glpi_dropdown_os.ID = comp.os)";
            $query.= "LEFT JOIN ".$val.".glpi_dropdown_locations on (".$val.".glpi_dropdown_locations.ID = comp.location)";
            $query.= "LEFT JOIN ".$val.".glpi_dropdown_model on (".$val.".glpi_dropdown_model.ID = comp.model)";
            $query.= "LEFT JOIN ".$val.".glpi_type_computers on (".$val.".glpi_type_computers.ID = comp.type)";
            $query.= " LEFT JOIN ".$val.".glpi_enterprises ON (".$val.".glpi_enterprises.ID = comp.FK_glpi_enterprise ) ";
            $query.= " LEFT JOIN ".$val.".glpi_users as resptech ON (resptech.ID = comp.tech_num ) ";
        }
    
        if ($contains2!=""&&$field2!="contents"&&$field2!="ID") {
            $query.= " LEFT JOIN ".$val.".glpi_followups ON ( ".$val.".glpi_followups.tracking = ".$val.".glpi_tracking.ID)";
        }
        
        // Modification par GP pour auteur-demandeur
        /* Avant modification :
        if ($sort=="author.name"){
            $query.= " LEFT JOIN ".$val.".glpi_users as author ON ( ".$val.".glpi_tracking.author = author.ID) ";
        }*/
        if ($sort=="caller.name"){
            $query.= " LEFT JOIN ".$val.".glpi_users as caller ON ( ".$val.".glpi_tracking.caller = caller.ID) ";
        }
        if ($sort=="creator.name"){
            $query.= " LEFT JOIN ".$val.".glpi_users as creator ON ( ".$val.".glpi_tracking.creator = creator.ID) ";
        }
        // Fin modification
        if ($sort=="assign.name"){
            $query.= " LEFT JOIN ".$val.".glpi_users as assign ON ( ".$val.".glpi_tracking.assign = assign.ID) ";
        }
        if ($sort=="glpi_dropdown_tracking_category.completename"){
            $query.= " LEFT JOIN ".$val.".glpi_dropdown_tracking_category ON ( ".$val.".glpi_tracking.category = ".$val.".glpi_dropdown_tracking_category.ID) ";
        }
    
        $where=" WHERE '1' = '1'";
    
        if ($computers_search)
            $where.=" AND ".$val.".glpi_tracking.device_type= '1'";
        if ($category > 0){
            $where.=" AND ".getRealQueryForTreeItem($val.".glpi_dropdown_tracking_category",$category,$val.".glpi_tracking.category");
        }
    
        if ($computers_search) $where .= " AND $wherecomp";
        if (!empty($date1)&&$date1!="0000-00-00") $where.=" AND ".$val.".glpi_tracking.date >= '$date1'";
        if (!empty($date2)&&$date2!="0000-00-00") $where.=" AND ".$val.".glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) ";
        if (!empty($enddate1)&&$enddate1!="0000-00-00") $where.=" AND ".$val.".glpi_tracking.closedate >= '$enddate1'";
        if (!empty($enddate2)&&$enddate2!="0000-00-00") $where.=" AND ".$val.".glpi_tracking.closedate <= adddate( '". $enddate2 ."' , INTERVAL 1 DAY ) ";
    
    
        if ($type!=0)
            $where.=" AND ".$val.".glpi_tracking.device_type='$type'";    
    
        if ($item!=0&&$type!=0)
            $where.=" AND ".$val.".glpi_tracking.computer = '$item'";    
    
        switch ($status){
            case "new": $where.=" AND ".$val.".glpi_tracking.status = 'new'"; break;
            case "notold": $where.=" AND (".$val.".glpi_tracking.status = 'new' OR ".$val.".glpi_tracking.status = 'plan' OR ".$val.".glpi_tracking.status = 'assign' OR ".$val.".glpi_tracking.status = 'waiting')"; break;
            case "old": $where.=" AND ( ".$val.".glpi_tracking.status = 'old_done' OR ".$val.".glpi_tracking.status = 'old_notdone')"; break;
            case "process": $where.=" AND ( ".$val.".glpi_tracking.status = 'plan' OR ".$val.".glpi_tracking.status = 'assign' )"; break;
            case "waiting": $where.=" AND ( ".$val.".glpi_tracking.status = 'waiting' )"; break;
            case "old_done": $where.=" AND ( ".$val.".glpi_tracking.status = 'old_done' )"; break;
            case "old_notdone": $where.=" AND ( ".$val.".glpi_tracking.status = 'old_notdone' )"; break;
            case "assign": $where.=" AND ( ".$val.".glpi_tracking.status = 'assign' )"; break;
            case "plan": $where.=" AND ( ".$val.".glpi_tracking.status = 'plan' )"; break;
        }
    
        if ($assign_ent!=0) $where.=" AND ".$val.".glpi_tracking.assign_ent = '$assign_ent'";
        if ($assign!=0) $where.=" AND ".$val.".glpi_tracking.assign = '$assign'";
    
        // Modification par GP pour auteur-demandeur
        /* Avant modification :
        if ($author!=0) $where.=" AND ".$val.".glpi_tracking.author = '$author'";*/
        if ($caller!=0) $where.=" AND ".$val.".glpi_tracking.caller = '$caller'";
        if ($creator!=0) $where.=" AND ".$val.".glpi_tracking.creator = (select id from ".$val.".glpi_users where name='".$_SESSION["glpiname"]."')";
//        if ($creator!=0) $where.=" AND ".$val.".glpi_tracking.creator = '$creator'";
        // Fin modification
    
    
        if ($request_type!=0) $where.=" AND ".$val.".glpi_tracking.request_type = '$request_type'";
    
        if ($priority>0) $where.=" AND ".$val.".glpi_tracking.priority = '$priority'";
        if ($priority<0) $where.=" AND ".$val.".glpi_tracking.priority >= '".abs($priority)."'";
    
        if ($group>0) $where.=" AND ".$val.".glpi_tracking.FK_group = '$group'";
        // Modification par GP pour auteur-demandeur : $author -> $creator
        // cela veut dire que l'on peut voir les tickets de son groupe pas du groupe du demandeur.
        else if ($group==-1&&$creator!=0&&haveRight("show_group_ticket",1)){
            // Get Author group's
            if (count($_SESSION["glpigroups"])){
                $where.=" OR ( ";
                $i=0;
                foreach ($_SESSION["glpigroups"] as $gp){
                    if ($i>0) $where.=" OR ";
                    $where.=" ".$val.".glpi_tracking.FK_group = '$gp' ";
                    $i++;
                }
                $where.=")";
            }
        }
    
        if ($contains2!=""){
            $SEARCH2=makeTextSearch($contains2);
            switch ($field2){
                case "both" :
                    $where.= " AND (".$val.".glpi_followups.contents $SEARCH2 OR ".$val.".glpi_tracking.contents $SEARCH2)";
                break;
                case "followup" :
                    $where.= " AND (".$val.".glpi_followups.contents $SEARCH2)";
                break;
                case "contents" :
                    $where.= " AND (".$val.".glpi_tracking.contents $SEARCH2)";
                break;
                case "ID" :
                    $where= " WHERE (".$val.".glpi_tracking.ID = '".$contains2."')";
                break;
    
            }
        }

        $query.=$where.") ";
    }
    if ($sort=="")
        $sort="priority DESC, date DESC";
    $query.= " ORDER BY $sort, client ";

}
// echo $query;
// Fin modification

    // Get it from database    
    if ($result = $db->query($query)) {
    
        $numrows= $db->numrows($result);

        if ($start<$numrows) {

            // Set display type for export if define
            $output_type=HTML_OUTPUT;
            if (isset($_GET["display_type"]))
                $output_type=$_GET["display_type"];


            // Pager
            // Modification par GP pour auteur-demandeur : author -> caller, et ajout de creator
            $parameters2="field=$field&amp;contains=$contains&amp;date1=$date1&amp;date2=$date2&amp;only_computers=$computers_search&amp;field2=$field2&amp;contains2=$contains2&amp;assign=$assign&amp;assign_ent=$assign_ent&amp;caller=$caller&amp;creator=$creator&amp;group=$group&amp;start=$start&amp;status=$status&amp;category=$category&amp;priority=$priority&amp;type=$type&amp;showfollowups=$showfollowups&amp;enddate1=$enddate1&amp;enddate2=$enddate2&amp;item=$item&amp;request_type=$request_type";
            $parameters=$parameters2."&amp;sort=$sort&amp;order=$order";
            if (ereg("user.info.php",$_SERVER["PHP_SELF"])) $parameters.="&amp;ID=$caller"; // Modification par GP pour auteur-demandeur : author -> caller
            // Manage helpdesk
            if (ereg("helpdesk",$target)) 
                $parameters.="&amp;show=user";
            if ($output_type==HTML_OUTPUT){
                if (!ereg("helpdesk",$target)) 
                    printPager($start,$numrows,$target,$parameters,TRACKING_TYPE);
                else printPager($start,$numrows,$target,$parameters);
            }

            $nbcols=9;

            // Form to delete old item
            if ($candelete&&$output_type==HTML_OUTPUT&&($status=="old"||$status=="all"||ereg("old_",$status))){
                echo "<form method='post' id='TrackingForm' name='TrackingForm' action=\"$target\">";
            }

            $i=$start;
            if (isset($_GET['export_all']))
                $i=0;

            $end_display=$start+$cfg_glpi["list_limit"];
            if (isset($_GET['export_all']))
                $end_display=$numrows;
            // Display List Header
            echo displaySearchHeader($output_type,$end_display-$start+1,$nbcols,1);

            commonTrackingListHeader($output_type,$target,$parameters2,$sort,$order);

            if ($_SESSION["client_actif"]=="all") {
            // Si on affiche tous les clients, il faut passer en parametre supplementaire
            // de la fonction le nom du client. Ajout par GP
                while ($i < $numrows && $i<$end_display){
                    $ID = $db->result($result, $i, "ID");
                    $client = $db->result($result, $i, "client");
                    showJobShort($ID, $showfollowups,$output_type,$i-$start+1,$client);
                    $i++;
                }
            } else {
                while ($i < $numrows && $i<$end_display){
                    $ID = $db->result($result, $i, "ID");
                    showJobShort($ID, $showfollowups,$output_type,$i-$start+1);
                    $i++;
                }
            }            

            $title="";
            // Title for PDF export
            if ($output_type==PDF_OUTPUT){
                $title.=$lang["joblist"][0]." = ";
                switch($status){
                    case "new": $title.=$lang["joblist"][9];break;
                    case "assign": $title.=$lang["joblist"][18];break;
                    case "plan": $title.=$lang["joblist"][19];break;
                    case "waiting": $title.=$lang["joblist"][26];break;
                    case "old_done": $title.=$lang["joblist"][10];break;
                    case "old_notdone": $title.=$lang["joblist"][17];break;
                    case "notold": $title.=$lang["joblist"][24];break;
                    case "process": $title.=$lang["joblist"][21];break;
                    case "old": $title.=$lang["joblist"][25];break;
                    case "all": $title.=$lang["joblist"][20];break;
                }
                // Modification par GP pour auteur-demandeur
                /* Avant modification :
                if ($author!=0) $title.=" - ".$lang["common"][37]." = ".getUserName($author);*/
                if ($caller!=0) $title.=" - ".$lang["common"][48]." = ".getUserName($caller);
                if ($creator!=0) $title.=" - ".$lang["common"][37]." = ".getUserName($creator);
                // Fin modification
                if ($group>0) $title.=" - ".$lang["common"][35]." = ".getDropdownName("glpi_groups",$group);
                if ($assign!=0) $title.=" - ".$lang["job"][27]." = ".getUserName($assign);
                if ($request_type!=0) $title.=" - ".$lang["job"][44]." = ".getRequestTypeName($request_type);
                if ($category!=0) $title.=" - ".$lang["common"][36]." = ".getDropdownName("glpi_dropdown_tracking_category",category);
                if ($assign_ent!=0) $title.=" - ".$lang["job"][27]." = ".getDropdownName("glpi_enterprises",$assign_ent);
                if ($priority!=0) $title.=" - ".$lang["joblist"][2]." = ".getPriorityName($priority);
                if ($type!=0&&$item!=0){
                    $ci=new CommonItem();
                    $ci->getFromDB($type,$item);
                    $title.=" - ".$lang["common"][1]." = ".$ci->getType()." / ".$ci->getNameID();

                }
            }
            // Display footer
            echo displaySearchFooter($output_type,$title);

            // Delete selected item
            if ($candelete&&$output_type==HTML_OUTPUT&&($status=="old"||$status=="all"||ereg("old_",$status))){
                echo "<div align='center'>";
                echo "<table cellpadding='5' width='900'>";
                echo "<tr><td><img src=\"".$HTMLRel."pics/arrow-left.png\" alt=''></td><td><a onclick= \"if ( markAllRows('TrackingForm') ) return false;\" href='".$_SERVER["PHP_SELF"]."?$parameters&amp;select=all&amp;start=$start'>".$lang["buttons"][18]."</a></td>"; 

                echo "<td>/</td><td><a onclick=\"if ( unMarkAllRows('TrackingForm') ) return false;\" href='".$_SERVER["PHP_SELF"]."?$parameters&amp;select=none&amp;start=$start'>".$lang["buttons"][19]."</a>";
                echo "</td><td>";
                echo "<input type='submit' value=\"".$lang["buttons"][6]."\" name='delete_inter' class='submit'></td>";
                echo "<td width='75%'>&nbsp;</td></table></div>";
                // End form for delete item
                echo "</form>";
            }


            // Pager
            if ($output_type==HTML_OUTPUT) // In case of HTML display
                printPager($start,$numrows,$target,$parameters);

        } else {
            echo "<div align='center'><strong>".$lang["joblist"][8]."</strong></div>";

        }
    }
}

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#16 2007-05-28 18:10:59

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

function showFollowupsShort($ID) {
    // Print Followups for a job

    global $db,$cfg_glpi, $lang;

    // Get Number of Followups

    $query="SELECT * FROM glpi_followups WHERE tracking='$ID' ORDER BY date DESC";
    $result=$db->query($query);

    $out="";
    if ($db->numrows($result)>0) {
        $out.="<div align='center'><table class='tab_cadre' width='100%' cellpadding='2'>\n";
        $out.="<tr><th>".$lang["common"][27]."</th><th>".$lang["common"][37]."</th><th>".$lang["joblist"][6]."</th></tr>\n";

        while ($data=$db->fetch_array($result)) {

            $out.="<tr class='tab_bg_3'>";
            $out.="<td align='center'>".convDateTime($data["date"])."</td>";
            $out.="<td align='center'>".getUserName($data["author"],1)."</td>";
            $out.="<td width='70%'><strong>".resume_text($data["contents"],$cfg_glpi["cut"])."</strong></td>";
            $out.="</tr>";
        }        

        $out.="</table></div>";

    }
    return $out;
}

function dropdownPriority($name,$value=0,$complete=0){
    global $lang;

    echo "<select name='$name'>";
    if ($complete){
        echo "<option value='0' ".($value==1?" selected ":"").">".$lang["search"][7]."</option>";
        echo "<option value='-5' ".($value==-5?" selected ":"").">".$lang["search"][16]." ".$lang["help"][3]."</option>";
        echo "<option value='-4' ".($value==-4?" selected ":"").">".$lang["search"][16]." ".$lang["help"][4]."</option>";
        echo "<option value='-3' ".($value==-3?" selected ":"").">".$lang["search"][16]." ".$lang["help"][5]."</option>";
        echo "<option value='-2' ".($value==-2?" selected ":"").">".$lang["search"][16]." ".$lang["help"][6]."</option>";
        echo "<option value='-1' ".($value==-1?" selected ":"").">".$lang["search"][16]." ".$lang["help"][7]."</option>";
    }
    echo "<option value='5' ".($value==5?" selected ":"").">".$lang["help"][3]."</option>";
    echo "<option value='4' ".($value==4?" selected ":"").">".$lang["help"][4]."</option>";
    echo "<option value='3' ".($value==3?" selected ":"").">".$lang["help"][5]."</option>";
    echo "<option value='2' ".($value==2?" selected ":"").">".$lang["help"][6]."</option>";
    echo "<option value='1' ".($value==1?" selected ":"").">".$lang["help"][7]."</option>";

    echo "</select>";    
}


function getPriorityName($value){
    global $lang;

    switch ($value){
        case 5 :
            return $lang["help"][3];
            break;
        case 4 :
            return $lang["help"][4];
            break;
        case 3 :
            return $lang["help"][5];
            break;
        case 2 :
            return $lang["help"][6];
            break;
        case 1 :
            return $lang["help"][7];
            break;
    }    
}

function getRequestTypeName($value){
    global $lang;

    switch ($value){
        case 1 :
            return $lang["Menu"][31];
            break;
        case 2 :
            return $lang["setup"][14];
            break;
        case 3 :
            return $lang["title"][41];
            break;
        case 4 :
            return $lang["tracking"][34];
            break;
        case 5 :
            return $lang["tracking"][35];
            break;
        case 6 :
            return $lang["tracking"][36];
            break;
        default : return "";
    }    
}

function dropdownRequestType($name,$value=0){
    global $lang;

    echo "<select name='$name'>";
    echo "<option value='0' ".($value==0?" selected ":"").">-----</option>";
    echo "<option value='1' ".($value==1?" selected ":"").">".$lang["Menu"][31]."</option>"; // Helpdesk
    echo "<option value='2' ".($value==2?" selected ":"").">".$lang["setup"][14]."</option>"; // mail
    echo "<option value='3' ".($value==3?" selected ":"").">".$lang["title"][41]."</option>"; // phone
    echo "<option value='4' ".($value==4?" selected ":"").">".$lang["tracking"][34]."</option>"; // direct
    echo "<option value='5' ".($value==5?" selected ":"").">".$lang["tracking"][35]."</option>"; // writing
    echo "<option value='6' ".($value==6?" selected ":"").">".$lang["tracking"][36]."</option>"; // other

    echo "</select>";    
}


function getAssignName($ID,$type,$link=0){
    global $cfg_glpi;

    if ($type==USER_TYPE){
        if ($ID==0) return "[Nobody]";
        return getUserName($ID,$link);

    } else if ($type==ENTERPRISE_TYPE){
        $ent=new Enterprise();
        if ($ent->getFromDB($ID)){
            $before="";
            $after="";
            if ($link){
                $before="<a href=\"".$cfg_glpi["root_doc"]."/front/enterprise.form.php?ID=".$ID."\">";
                $after="</a>";
            }

            return $before.$ent->fields["name"].$after;
        } else return "";
    }

}
function dropdownStatus($name,$value=0){
    global $lang;

    echo "<select name='$name'>";
    echo "<option value='new' ".($value=="new"?" selected ":"").">".$lang["joblist"][9]."</option>";
    echo "<option value='assign' ".($value=="assign"?" selected ":"").">".$lang["joblist"][18]."</option>";
    echo "<option value='plan' ".($value=="plan"?" selected ":"").">".$lang["joblist"][19]."</option>";
    echo "<option value='waiting' ".($value=="waiting"?" selected ":"").">".$lang["joblist"][26]."</option>";
    echo "<option value='old_done' ".($value=="old_done"?" selected ":"").">".$lang["joblist"][10]."</option>";
    echo "<option value='old_notdone' ".($value=="old_notdone"?" selected ":"").">".$lang["joblist"][17]."</option>";
    echo "</select>";    
}

GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#17 2007-05-28 18:13:44

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

function getStatusName($value){
    global $lang;

    switch ($value){
        case "new" :
            return $lang["joblist"][9];
        break;
        case "assign" :
            return $lang["joblist"][18];
        break;
        case "plan" :
            return $lang["joblist"][19];
        break;
        case "waiting" :
            return $lang["joblist"][26];
        break;
        case "old_done" :
            return $lang["joblist"][10];
        break;
        case "old_notdone" :
            return $lang["joblist"][17];
        break;
    }    
}


function showJobDetails ($target,$ID){
    global $db,$cfg_glpi,$lang,$HTMLRel;
    $job=new Job();

    $canupdate=haveRight("update_ticket","1");


    if ($job->getfromDB($ID)) {

        if (!haveRight("show_ticket","1")
            // Modification auteur demandeur par GP
            // Ici le champ author n'existe plus il s'agit de savoir si c'est le createur du ticket qui l'ouvre ou non.
            /* avant modification :
            &&$job->fields["author"]!=$_SESSION["glpiID"]*/
            &&$job->fields["creator"]!=$_SESSION["glpiID"]
            // Fin Modification
            &&$job->fields["assign"]!=$_SESSION["glpiID"]
            &&!($_SESSION["glpiprofile"]["show_group_ticket"]&&in_array($job->fields["FK_group"],$_SESSION["glpigroups"])) ){
            return false;
        }

        $canupdate_descr=$canupdate||($job->numberOfFollowups()==0&&$job->fields["creator"]==$_SESSION["glpiID"]); // author -> creator, question de droits
        // Modification auteur demandeur par GP
        // Ici author doit servir a l'affichage il est donc remplacé par "caller"
        /* avant modification :
        $author=new User();
        $author->getFromDB($job->fields["author"]);*/
        $caller=new User();
        $caller->getFromDB($job->fields["caller"]);
        // Fin Modification
        $assign=new User();
        $assign->getFromDB($job->fields["assign"]);
        $item=new CommonItem();
        $item->getFromDB($job->fields["device_type"],$job->fields["computer"]);

        showTrackingOnglets($_SERVER["PHP_SELF"]."?ID=".$ID);

        echo "<div align='center'>";
        echo "<form method='post' action='$target'  enctype=\"multipart/form-data\">\n";
        echo "<table class='tab_cadre_fixe' cellpadding='5'>";
        // Premi�e ligne
        echo "<tr ><th colspan='2' style='font-size:10px'>";
        echo $lang["joblist"][11].": <strong>".convDateTime($job->fields["date"])."</strong>";"</th>";
        echo "<th style='font-size:10px'>".$lang["joblist"][12].":\n";
        if (!ereg("old_",$job->fields["status"]))
        {
            echo "<i>".$lang["job"][1]."</i>\n";
        }
        else
        {
            echo "<strong>".convDateTime($job->fields["closedate"])."</strong>\n";
        }
        echo "</th></tr>";
        echo "<tr class='tab_bg_2'>";
        // Premier Colonne
        echo "<td valign='top' width='27%'>";
        echo "<table cellpadding='3'>";
        echo "<tr class='tab_bg_2'><td align='right'>";
        echo $lang["joblist"][0].":</td><td>";
        if ($canupdate)
            dropdownStatus("status",$job->fields["status"]);
        else echo getStatusName($job->fields["status"]);
        echo "</td></tr>";

        echo "<tr><td align='right'>";
        // Modification auteur demandeur par GP
        /* Avant modification :
        echo $lang["common"][37].":</td><td>";
        if ($canupdate)
            dropdownAllUsers("author",$job->fields["author"]);
        else echo $author->getName();*/
        echo $lang["common"][48].":</td><td>";
        if ($canupdate)
            dropdownAllUsers("caller",$job->fields["caller"]);
        else echo $caller->getName();
        // Fin modification
        echo "</td></tr>";
        echo "<tr><td align='right'>";
        echo $lang["common"][35].":</td><td>";
        if ($canupdate)
            dropdownValue("glpi_groups","FK_group",$job->fields["FK_group"]);
        else echo getDropdownName("glpi_groups",$job->fields["FK_group"]);
        echo "</td></tr>";

        echo "<tr><td align='right'>";
        echo $lang["joblist"][2].":</td><td>";
        if ($canupdate)
            dropdownPriority("priority",$job->fields["priority"]);
        else echo getPriorityName($job->fields["priority"]);
        echo "</td></tr>";

        echo "<tr><td>";
        echo $lang["common"][36].":</td><td>";
        if ($canupdate)
            dropdownValue("glpi_dropdown_tracking_category","category",$job->fields["category"]);
        else echo getDropdownName("glpi_dropdown_tracking_category",$job->fields["category"]);
        echo "</td></tr>";

        echo "</table></td>";

        // Deuxi�e colonne
        echo "<td valign='top' width='33%'>";

        echo "<table border='0'>";

        echo "<tr><td align='right'>";
        echo $lang["job"][44].":</td><td>";
        if ($canupdate)
            dropdownRequestType("request_type",$job->fields["request_type"]);
        else echo getRequestTypeName($job->fields["request_type"]);
        echo "</td></tr>";

        echo "<tr><td align='right'>";
        echo $lang["common"][1].":</td><td>";
        if ($canupdate){
            echo $item->getType()." - ".$item->getLink()."<br>";
            dropdownAllItems("item",0);
        }
        else echo $item->getType()." ".$item->getNameID();

        echo "</td></tr>";


        echo "<tr><td align='right'>";
        echo $lang["job"][5].":</td><td>&nbsp;</td></tr>";

        if ($canupdate||haveRight("assign_ticket","1")){
            echo "<tr><td align='right'>";
            echo $lang["job"][27].":</td><td>";
            dropdownUsers("assign",$job->fields["assign"],"own_ticket");
            echo "</td></tr>";
        } else if (haveRight("steal_ticket","1")) {
            echo "<tr><td align='right'>";
            echo $lang["job"][27].":</td><td>";
            dropdownUsers("assign",$job->fields["assign"],"ID");
            echo "</td></tr>";
        }else {
            echo "<tr><td align='right'>";
            echo $lang["job"][27].":</td><td>";
            echo getUserName($job->fields["assign"]);
            echo "</td></tr>";
        }
        if ($canupdate||haveRight("assign_ticket","1")){
            echo "<tr><td align='right'>";
            echo $lang["job"][28].":</td><td>";
            dropdownValue("glpi_enterprises","assign_ent",$job->fields["assign_ent"]);
            echo "</td></tr>";
        } else {
            echo "<tr><td align='right'>";
            echo $lang["job"][28].":</td><td>";
            echo getDropdownName("glpi_enterprises",$job->fields["assign_ent"]);
            echo "</td></tr>";

        }
        echo "</table>";

        echo "</td>";

        // Troisi�e Colonne
        echo "<td valign='top' width='20%'>";

        if(haveRight("contract_infocom","r")){  // admin = oui on affiche les couts liés à l'interventions
            echo "<table border='0'>";
            if ($job->fields["realtime"]>0){
                echo "<tr><td align='right'>";
                echo $lang["job"][20].":</td><td>";
                echo "<strong>".getRealtime($job->fields["realtime"])."</strong>";
                echo "</td></tr>";
            }
            echo "<tr><td align='right'>";
            // cout
            echo $lang["job"][40].": ";
            echo "</td><td><input type='text' maxlength='100' size='15' name='cost_time' value=\"".$job->fields["cost_time"]."\"></td></tr>";

            echo "<tr><td align='right'>";

            echo $lang["job"][41].": ";
            echo "</td><td><input type='text' maxlength='100' size='15' name='cost_fixed' value=\"".$job->fields["cost_fixed"]."\">";

            echo "</td></tr>\n";

            echo "<tr><td align='right'>";

            echo $lang["job"][42].": ";
            echo "</td><td><input type='text' maxlength='100' size='15' name='cost_material' value=\"".$job->fields["cost_material"]."\">";

            echo "</td></tr>\n";

            echo "<tr><td align='right'>";

            echo $lang["job"][43].": ";
            echo "</td><td><strong>";
            echo trackingTotalCost($job->fields["realtime"],$job->fields["cost_time"],$job->fields["cost_fixed"],$job->fields["cost_material"]);
            echo "</strong></td></tr>\n</table>";
        }

        echo "</td></tr>";

        // Ajout GP pour Auteur-demandeur
        if (haveRight("update_creator","1")){ // Normalement seul les admins auront le droit de modifier le createur d'un ticket.
            $creator_rand=0;
            echo "<tr class='tab_bg_2' align='center'><td>".$lang["common"][37]." : ";
            $creator_rand=dropdownUsers("creator",$job->fields["creator"],"create_ticket");
            echo "</td>";

            echo "<script type='text/javascript' >";
            echo "   new Form.Element.Observer('dropdown_creator$creator_rand', 1, ";
            echo "      function(element, value) {";
            echo "          new Ajax.Updater('tracking_device_type_selecter','".$cfg_glpi["root_doc"]."/ajax/updateTrackingDeviceType.php',{asynchronous:true, evalScripts:true, ";
            echo "           method:'post', parameters:'userID=' + value+'&device_type=$device_type'";
            echo "})})";
            echo "</script>";    

            echo "<td align='center' colspan=3> </td></tr>";
        } else {
            $creator_rand=0;
            echo "<tr class='tab_bg_2' align='center'><td>".$lang["common"][37]." : ";
            $creator_rand=dropdownUniqueUser("creator",$job->fields["creator"]);
            echo "</td>";
            
            echo "<script type='text/javascript' >";
            echo "   new Form.Element.Observer('dropdown_creator$creator_rand', 1, ";
            echo "      function(element, value) {";
            echo "          new Ajax.Updater('tracking_device_type_selecter','".$cfg_glpi["root_doc"]."/ajax/updateTrackingDeviceType.php',{asynchronous:true, evalScripts:true, ";
            echo "           method:'post', parameters:'userID=' + value+'&device_type=$device_type'";
            echo "})})";
            echo "</script>";    
            echo "<td align='center' colspan=3> </td></tr>";
        }
        // Fin Ajout

        // Deuxi�e Ligne
        // Colonnes 1 et 2
        echo "<tr class='tab_bg_1'><td colspan='2'>";
        echo "<table width='99%' >";
        echo "<tr  class='tab_bg_2'><td width='15%'>".$lang["joblist"][6]."<br><br></td>";
        echo "<td  width='85%' align='left'>";

        if ($canupdate_descr){ // Admin =oui on autorise la modification de la description
            $rand=mt_rand();
            echo "<script type='text/javascript' >\n";
            echo "function showDesc$rand(){\n";
            echo "Element.hide('desc$rand');";
            echo "var a=new Ajax.Updater('viewdesc$rand','".$cfg_glpi["root_doc"]."/ajax/textarea.php' , {asynchronous:true, evalScripts:true, method: 'post',parameters: 'rows=6&cols=60&name=contents&data=".urlencode($job->fields["contents"])."'});";
            echo "}";
            echo "</script>\n";
            echo "<div id='desc$rand' class='div_tracking' onClick='showDesc$rand()'>\n";
            if (!empty($job->fields["contents"]))
                echo nl2br($job->fields["contents"]);
            else echo $lang["job"][33];

            echo "</div>\n";    

            echo "<div id='viewdesc$rand'>\n";
            echo "</div>\n";    
        } else echo nl2br($job->fields["contents"]);

        echo "</td>";
        echo "</tr>";
        echo "</table>";
        echo "</td>";
        // Colonne 3

        echo "<td valign='top'>";

        // Mailing ? Y or no ?

        if ($cfg_glpi["mailing"]==1){
            echo "<table><tr><td align='right'>";
            echo $lang["job"][19].":</td><td>";
            if ($canupdate){
                echo "<select name='emailupdates'>";
                echo "<option value='no'>".$lang["choice"][0]."</option>";
                echo "<option value='yes' ".($job->fields["emailupdates"]=="yes"?" selected ":"").">".$lang["choice"][1]."</option>";
                echo "</select>";
            } else {
                if ($job->fields["emailupdates"]=="yes") echo $lang["choice"][1];
                else $lang["choice"][0];
            }
            echo "</td></tr>";

            echo "<tr><td align='right'>";
            echo $lang["joblist"][27].":";
            echo "</td><td>";
            if ($canupdate){
                // Modification par GP pour auteur-demandeur
                /* Avant Modification
                autocompletionTextField("uemail","glpi_tracking","uemail",$job->fields["uemail"],15);

                if (!empty($job->fields["uemail"]))
                    echo "<a href='mailto:".$job->fields["uemail"]."'><img src='".$HTMLRel."pics/edit.png' alt='Mail'></a>";
            } else if (!empty($job->fields["uemail"]))
                echo "<a href='mailto:".$job->fields["uemail"]."'>".$job->fields["uemail"]."</a>";
            else echo "&nbsp;";
            echo "</td></tr></table>";*/
                autocompletionTextField("caemail","glpi_tracking","caemail",$job->fields["caemail"],15);

                if (!empty($job->fields["caemail"]))
                    echo "<a href='mailto:".$job->fields["caemail"]."'><img src='".$HTMLRel."pics/edit.png' alt='Mail'></a>";
            } else if (!empty($job->fields["caemail"]))
                echo "<a href='mailto:".$job->fields["caemail"]."'>".$job->fields["caemail"]."</a>";
            else echo "&nbsp;";
            echo "</td></tr></table>";
                // Fin Modification


        }

ça y est c'est fini, désolé si c'est un peu indigeste ...

bon je vais tomber dans le cliché, mais merci a l'equipe de GLPI, je trouve votre logiciel très bien ..!

Last edited by guilaumin (2007-05-28 18:14:13)


GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#18 2007-05-28 18:17:52

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

*J'etais en train d'oublier le script SQL ....

ALTER TABLE `glpi_tracking`
ADD `caller` INT( 11 ) NOT NULL DEFAULT '0' AFTER `author` ,
ADD `caemail` VARCHAR( 100 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `uemail` ,
ADD INDEX ( `caller` );

ALTER TABLE `glpi_tracking`
ADD `creator` INT( 11 ) NOT NULL DEFAULT '1' AFTER `caller`,
ADD `cremail` VARCHAR( 100 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `caemail`,
ADD INDEX ( `creator` );

UPDATE `glpi_tracking` SET
`caller`=`author`,
`creator`=`author`,
`caemail`=`uemail`,
`cremail`=`uemail`;

ALTER TABLE `glpi_tracking`
DROP `author`,
DROP `uemail`,
DROP INDEX `author`;

ALTER TABLE `glpi_profiles`
ADD `update_creator` CHAR( 1 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '0';

Voila c'est la vrai fin tongue


GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#19 2007-05-28 18:34:49

mma75
Member
Registered: 2007-01-26
Posts: 258

Re: créateur du ticket different de l'utilisateur en faisant la demande

bonjour,

Effectivement pour le suivi helpdesk, la problèmatique du créateur du ticket est bien réelle.
nous avons donc demandé aux hotliners de systématiser la saisie du premier suivi dans la page helpdesk.php. pour les statistiques, nous attribuons le premier suivi au créateur du ticket. Les personnes des différents supports sont identifiées selon leur appartenances à leur groupe. (attention dans la 68.3 si tu assignes directement le ticket à partir de la page helpdesk.php le premier suivi est attribuer à celui qui est assigné et non au créateur du ticket.

cdlt

Offline

#20 2007-05-28 21:58:00

doum
Member
From: Nice
Registered: 2007-03-27
Posts: 1,421

Re: créateur du ticket different de l'utilisateur en faisant la demande

Une question aux devs de la 0.7, ca n'aurait pas changé su la 0.7?

Parceque peut etre que j'ai mal compris ce qui a été dit, mais j'ouvre un incident, comme si j'etais hotliner, auteur je mets le nom de personne qui appelle, je l'affecte a un de mes collègues.
quand je vais dans le suivi des tickets, en haut de ce ticket j'ai bien Ouvert le: 28-05-2007 21:54 par doum (Entité Racine), alors que je ne me le suis jamais affecté

Offline

#21 2007-05-28 22:28:49

MoYo
GLPI - Lead
From: Poitiers
Registered: 2004-09-13
Posts: 14,513
Website

Re: créateur du ticket different de l'utilisateur en faisant la demande

Je suis désolé mais vos posts sont illisibles et inutilisables tel quel.
Merci de poster sur la mailing glpi-dev ca sera plus intéressant pour tous.
Sachant que dans la 0.7 si vous avez regardé il y a la notion de créateur deja.

Il manque surement des elements pour utiliser au mieux cette information mais c'est un des buts du beta-test : remonter les améliorations possibles.


MoYo - Julien Dombre - Association INDEPNET
Contribute to GLPI :    Support     Contribute     References     Freshmeat

Offline

#22 2007-05-28 23:22:20

JMD
GLPI - Lead
Registered: 2004-09-13
Posts: 9,180
Website

Re: créateur du ticket different de l'utilisateur en faisant la demande

Juste pour préciser ce qui est illisible ceux sont les 17 posts comprenant les morceaux de codes.

Vous avez du carrement vous enmerder à les poster, j'en suis désolé. Mais un forum n'est absolument pas approprié à ce genre de chose.

Pour proposer des modifications, il faut faire un diff entre votre version customisée et la version officielle.

exemple : diff -Nur source/ source-modif/ > fichier.patch


JMD / Jean-Mathieu Doléans - Glpi-project.org - Association Indepnet
Apportez votre pierre au  projet GLPI   : Soutenir

Offline

#23 2007-05-29 01:01:33

MoYo
GLPI - Lead
From: Poitiers
Registered: 2004-09-13
Posts: 14,513
Website

Re: créateur du ticket different de l'utilisateur en faisant la demande

Au final ce qu'il serait intéressant de faire c'est tester la 0.7 et voir ce qu'il manque par rapport à vos adaptations (mailing receveur par exemple je pense, chronomètre etc etc)


MoYo - Julien Dombre - Association INDEPNET
Contribute to GLPI :    Support     Contribute     References     Freshmeat

Offline

#24 2007-05-29 08:46:42

guilaumin
Member
Registered: 2007-05-28
Posts: 44

Re: créateur du ticket different de l'utilisateur en faisant la demande

je confirme c'était très lourd a poster mais bon au moins maintenant je saurai big_smile

donc je vais réinstaller une 0.7 (parce que je suis retourné chez le client sous GLPI lui aussi smile) et refaire le tour avant de continuer a embêter les gens smile

Question subsidiaire, auriez un outil a me conseiller pour faire du "diff" sous windows, parce que je doute qu'on me laissera utiliser les serveur juste pour faire du "diff" tongue

mma75> On peut effectivement faire comme ça, d'autant qu'avec mon histoire de chronomètre je forçais le premier suivi pour avoir le temps de saisi du ticket. Cependant a mon avis ça reste du "bricolage", une façon de contourner le problème, l'intérêt de le coder en dur c'est que ça limite grandement les erreurs humaines, que l'information est vraiment stockée, et que ça va simplifier les requêtes derrière.

Merci pour vos réponses


GLPI 0.70.2
OS : debian 3.1R4
PHP Version 5.2.0-8 / Apache 2.2.3 / Mysql 5.0.32
Décompression : QuickZip 4.60.017 / Firefox 2.0 et IE 7

Offline

#25 2007-05-29 09:06:23

JMD
GLPI - Lead
Registered: 2004-09-13
Posts: 9,180
Website

Re: créateur du ticket different de l'utilisateur en faisant la demande

Euh sous windows pour faire un diff ...  windiff ?

Je viens de chercher sur google , j'ai jamais utilisé wink


JMD / Jean-Mathieu Doléans - Glpi-project.org - Association Indepnet
Apportez votre pierre au  projet GLPI   : Soutenir

Offline

Board footer

Powered by FluxBB