Hi!!!

I'm using GLPI and I added a fragment in the code because I needed to assign
tickets with a queue, where the ticket is assigned to a technical with less
tickets in this moment.
The problem is I can't to update the version, because I'll lost the changes.
Is possible you can to add this option???

This is the function:
static function agregarTicketTecnico($ticketID=0) { //agregado
      global $DB, $LANG, $CFG_GLPI;

      if ($ticketID != 0) {
         $DBread = DBConnection::getReadConnection();//clase conexion con la
BD
         $consulta = "(SELECT users_id,0 as cantidad FROM glpi_groups_users
".
                    "INNER JOIN glpi_users u ON (u.id=users_id AND
u.is_active=1)".
                     "WHERE groups_id in (SELECT groups_id From
glpi_groups_tickets where  tickets_id = ".$ticketID.") ".
                      "AND users_id not in (SELECT users_id from
glpi_tickets_users where tickets_id in (select id from glpi_tickets where
status='assign') and type=2) ".
                    ") UNION ( ".
                    "SELECT u.users_id,count(u.tickets_id) as cantidad FROM
glpi_tickets_users u ".
                    "INNER JOIN glpi_users gu ON (gu.id=u.users_id AND
gu.is_active=1)".
                    "INNER JOIN glpi_tickets t ON (t.id = u.tickets_id and
t.status='assign') ".
                    "WHERE u.type=2 and u.users_id in (SELECT users_id FROM
glpi_groups_users WHERE groups_id in ".
                    "(SELECT groups_id From glpi_groups_tickets where
tickets_id = ".$ticketID.")) ".
                    "group by u.users_id ) ".
                    "ORDER BY cantidad asc";//consulta para buscar el
tecnico con menos tickets
         $resultado = $DBread->query($consulta);

         $res = $DBread->fetch_assoc($resultado);//para pasar el arreglo x
URL


         //asignar ticket automaticamente al tecnico
          $insert = "INSERT INTO glpi_tickets_users
(tickets_id,users_id,type,use_notification) VALUES
(".$ticketID.",".$res['users_id'].",2,1)";
          $result = $DBread->query($insert);
        }

   }

>From Caracas, Venezuela
excuse me, my redaction in English is terrible...

-- 
Saludos
Zorianny Itriago
_______________________________________________
Glpi-dev mailing list
[email protected]
https://mail.gna.org/listinfo/glpi-dev

Reply via email to