コード例 #1
0
 static function checkAssignGroup(Ticket $ticket)
 {
     global $DB;
     $ok = 0;
     $ptConfig = new PluginTimelineticketConfig();
     $ptConfig->getFromDB(1);
     if ($ptConfig->fields["add_waiting"] == 0) {
         $ok = 1;
     }
     if ($ok && in_array("status", $ticket->updates) && isset($ticket->oldvalues["status"]) && $ticket->oldvalues["status"] == Ticket::WAITING) {
         if ($ticket->countGroups(CommonITILActor::ASSIGN)) {
             foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $d) {
                 $ptAssignGroup = new PluginTimelineticketAssignGroup();
                 $calendar = new Calendar();
                 $calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']);
                 $datedebut = $ticket->fields['date'];
                 if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
                     $delay = $calendar->getActiveTimeBetween($datedebut, $_SESSION["glpi_currenttime"]);
                 } else {
                     // cas 24/24 - 7/7
                     $delay = strtotime($_SESSION["glpi_currenttime"]) - strtotime($datedebut);
                 }
                 $input = array();
                 $input['tickets_id'] = $ticket->getID();
                 $input['groups_id'] = $d["groups_id"];
                 $input['date'] = $_SESSION["glpi_currenttime"];
                 $input['begin'] = $delay;
                 $ptAssignGroup->add($input);
             }
         }
     } else {
         if ($ok && in_array("status", $ticket->updates) && isset($ticket->fields["status"]) && $ticket->fields["status"] == Ticket::WAITING) {
             if ($ticket->countGroups(CommonITILActor::ASSIGN)) {
                 foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $d) {
                     $calendar = new Calendar();
                     $calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']);
                     $ptAssignGroup = new PluginTimelineticketAssignGroup();
                     $query = "SELECT MAX(`date`) AS datedebut, id\n                         FROM `" . $ptAssignGroup->getTable() . "`\n                         WHERE `tickets_id` = '" . $ticket->getID() . "'\n                           AND `groups_id`='" . $d["groups_id"] . "'\n                           AND `delay` IS NULL";
                     $result = $DB->query($query);
                     $datedebut = '';
                     $input = array();
                     if ($result && $DB->numrows($result)) {
                         $datedebut = $DB->result($result, 0, 'datedebut');
                         $input['id'] = $DB->result($result, 0, 'id');
                     } else {
                         return;
                     }
                     if (!$datedebut) {
                         $delay = 0;
                         // Utilisation calendrier
                     } else {
                         if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
                             $delay = $calendar->getActiveTimeBetween($datedebut, $_SESSION["glpi_currenttime"]);
                         } else {
                             // cas 24/24 - 7/7
                             $delay = strtotime($_SESSION["glpi_currenttime"]) - strtotime($datedebut);
                         }
                     }
                     $input['delay'] = $delay;
                     $ptAssignGroup->update($input);
                 }
             }
         }
     }
 }
コード例 #2
0
  ------------------------------------------------------------------------

  @package   TimelineTicket plugin
  @copyright Copyright (c) 2013-2016 TimelineTicket team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://github.com/pluginsGLPI/timelineticket
  @since     2013

  ------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Html::header(PluginTimelineticketDisplay::getTypeName(2), $_SERVER["PHP_SELF"], "plugins", "timelineticket");
if (Session::haveRight("config", READ) || Session::haveRight("plugin_timelineticket_ticket", UPDATE)) {
    $ptConfig = new PluginTimelineticketConfig();
    $grplevel = new PluginTimelineticketGroupLevel();
    if (isset($_POST["reconstructStates"])) {
        ini_set("max_execution_time", "0");
        ini_set("memory_limit", "-1");
        $ptState = new PluginTimelineticketState();
        $ptState->reconstructTimeline();
        Html::back();
    } else {
        if (isset($_POST["reconstructGroups"])) {
            ini_set("max_execution_time", "0");
            ini_set("memory_limit", "-1");
            $ptGroup = new PluginTimelineticketAssignGroup();
            $ptGroup->reconstrucTimeline();
            Html::back();
        } else {
コード例 #3
0
ファイル: hook.php プロジェクト: pluginsGLPI/timelineticket
function plugin_timelineticket_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/timelineticket/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/timelineticket/inc/config.class.php";
    $migration = new Migration(160);
    // installation
    if (!TableExists("glpi_plugin_timelineticket_states")) {
        $query = "CREATE TABLE `glpi_plugin_timelineticket_states` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `tickets_id` int(11) NOT NULL DEFAULT '0',\n                  `date` datetime DEFAULT NULL,\n                  `old_status` varchar(255) DEFAULT NULL,\n                  `new_status` varchar(255) DEFAULT NULL,\n                  `delay` INT( 11 ) NULL,\n                  PRIMARY KEY (`id`),\n                  KEY `tickets_id` (`tickets_id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
    }
    if (!TableExists("glpi_plugin_timelineticket_assigngroups")) {
        $query = "CREATE TABLE `glpi_plugin_timelineticket_assigngroups` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `tickets_id` int(11) NOT NULL DEFAULT '0',\n                  `date` datetime DEFAULT NULL,\n                  `groups_id` varchar(255) DEFAULT NULL,\n                  `begin` INT( 11 ) NULL,\n                  `delay` INT( 11 ) NULL,\n                  PRIMARY KEY (`id`),\n                  KEY `tickets_id` (`tickets_id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
    }
    if (!TableExists("glpi_plugin_timelineticket_assignusers")) {
        $query = "CREATE TABLE `glpi_plugin_timelineticket_assignusers` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `tickets_id` int(11) NOT NULL DEFAULT '0',\n                  `date` datetime DEFAULT NULL,\n                  `users_id` varchar(255) DEFAULT NULL,\n                  `begin` INT(11) NULL,\n                  `delay` INT(11) NULL,\n                  PRIMARY KEY (`id`),\n                  KEY `tickets_id` (`tickets_id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
    }
    if (!TableExists("glpi_plugin_timelineticket_grouplevels")) {
        $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_timelineticket_grouplevels` (\n               `id` int(11) NOT NULL AUTO_INCREMENT,\n               `entities_id` int(11) NOT NULL DEFAULT '0',\n               `is_recursive` tinyint(1) NOT NULL default '0',\n               `name` varchar(255) collate utf8_unicode_ci default NULL,\n               `groups` longtext collate utf8_unicode_ci,\n               `rank` smallint(6) NOT NULL default '0',\n               `comment` text collate utf8_unicode_ci,\n               PRIMARY KEY (`id`)\n             ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->query($query) or die($DB->error());
    }
    if (!TableExists("glpi_plugin_timelineticket_configs")) {
        $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_timelineticket_configs` (\n              `id` int(11) NOT NULL AUTO_INCREMENT,\n              `add_waiting` int(11) NOT NULL DEFAULT '1',\n              PRIMARY KEY  (`id`)\n            ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->query($query) or die($DB->error());
    }
    $status = array('new' => Ticket::INCOMING, 'assign' => Ticket::ASSIGNED, 'plan' => Ticket::PLANNED, 'waiting' => Ticket::WAITING, 'solved' => Ticket::SOLVED, 'closed' => Ticket::CLOSED);
    // Update field in tables
    foreach (array('glpi_plugin_timelineticket_states') as $table) {
        // Migrate datas
        foreach ($status as $old => $new) {
            $query = "UPDATE `{$table}`\n                   SET `old_status` = '{$new}'\n                   WHERE `old_status` = '{$old}'";
            $DB->queryOrDie($query, "0.84 status in {$table} {$old} to {$new}");
            $query = "UPDATE `{$table}`\n                   SET `new_status` = '{$new}'\n                   WHERE `new_status` = '{$old}'";
            $DB->queryOrDie($query, "0.84 status in {$table} {$old} to {$new}");
        }
    }
    PluginTimelineticketConfig::createFirstConfig();
    if (isset($_SESSION['glpiactiveprofile']) && isset($_SESSION['glpiactiveprofile']['id'])) {
        PluginTimelineticketProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    }
    $migration = new Migration("0.90+1.0");
    $migration->dropTable('glpi_plugin_timelineticket_profiles');
    return true;
}