Author: kspooner
Inheritance: extends AppModel
Esempio n. 1
0
 public function validateTicket(Ticket $ticket)
 {
     // this is all the numbers that has been matched for the ticket
     $numbers = [[], [], []];
     // this is the count of the different rows
     $rows = [0, 0, 0];
     // this is the array of the numbers that completed the different rows
     $winningNumbers = [0, 0, 0];
     // the number of rows completed
     $completedRows = 0;
     // the last row with a valid number
     $winningRow = 0;
     foreach ($this->drawnNumbers as $number) {
         $row = $ticket->getNumberRow($number);
         // number is located in a row in the ticket
         if (!is_null($row)) {
             $numbers[$row][] = $number;
             $winningRow = $row;
             if (++$rows[$row] == 5) {
                 $winningNumbers[$completedRows] = $number;
                 $completedRows++;
             }
         }
     }
     if ($completedRows >= $this->rows) {
         return ["win" => True, "numbers" => $numbers, "winningNumbers" => $winningNumbers, "winningRow" => $winningRow];
     } else {
         return ["win" => False, "numbers" => $numbers, "winningNumbers" => $winningNumbers, "winningRow" => $winningRow];
     }
 }
Esempio n. 2
0
 protected function getallAction()
 {
     $translate = $this->application->getBootstrap()->getResource('translate');
     $view = $this->application->getBootstrap()->getResource('view');
     $view->setScriptPath(APPLICATION_PATH . '/views/scripts');
     $acl = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('formacl');
     $queueticketObj = new Queueticket();
     $queueticketRows = $queueticketObj->fetchAll("ghost = false");
     foreach ($queueticketRows as $queueticketRow) {
         try {
             $mail = new Zend_Mail_Storage_Imap(array('host' => $queueticketRow['input_email_host'], 'user' => $queueticketRow['input_email_user'], 'password' => $queueticketRow['input_email_password']));
             for ($i = 1; $i <= $mail->countMessages(); $i++) {
                 $message = $mail->getMessage($i);
                 if (!$message->hasFlag(Zend_Mail_Storage::FLAG_SEEN)) {
                     $values = array('subject' => $message->subject, 'content' => $message->getContent(), 'priority' => substr($queueticketRow['available_priority'], 0, 1), 'state' => substr($queueticketRow['available_states'], 0, 1), 'start' => date("c"), 'id_queue' => $queueticketRow['id']);
                     $model = new Ticket();
                     $row = $model->createRow($values);
                     $row->save();
                     $mail->setFlags($i, array(Zend_Mail_Storage::FLAG_SEEN));
                 }
             }
         } catch (Exception $e) {
             print_r($e->getMessage());
         }
     }
 }
Esempio n. 3
0
 static function afterAdd(Group_Ticket $item)
 {
     global $DB;
     //Toolbox::logDebug(__METHOD__, $item);
     $config = PluginBehaviorsConfig::getInstance();
     if ($config->getField('add_notif')) {
         if ($item->getField('type') == CommonITILActor::ASSIGN) {
             $ticket = new Ticket();
             if ($ticket->getFromDB($item->getField('tickets_id'))) {
                 NotificationEvent::raiseEvent('plugin_behaviors_ticketnewgrp', $ticket);
             }
         }
     }
     // Check is the connected user is a tech
     if (!is_numeric(Session::getLoginUserID(false)) || !Session::haveRight('own_ticket', 1)) {
         return false;
         // No check
     }
     $config = PluginBehaviorsConfig::getInstance();
     if ($config->getField('single_tech_mode') != 0 && $item->input['type'] == CommonITILActor::ASSIGN) {
         $crit = array('tickets_id' => $item->input['tickets_id'], 'type' => CommonITILActor::ASSIGN);
         foreach ($DB->request('glpi_groups_tickets', $crit) as $data) {
             if ($data['id'] != $item->getID()) {
                 $gu = new Group_Ticket();
                 $gu->delete($data);
             }
         }
         if ($config->getField('single_tech_mode') == 2) {
             foreach ($DB->request('glpi_tickets_users', $crit) as $data) {
                 $gu = new Ticket_User();
                 $gu->delete($data);
             }
         }
     }
 }
Esempio n. 4
0
 /**
  * @dataProvider ticketProvider
  */
 public function testCreateTicketWithActors($ticketActors)
 {
     $ticket = new Ticket();
     $ticket->add(array('name' => 'ticket title', 'description' => 'a description') + $ticketActors);
     $this->assertFalse($ticket->isNewItem());
     $ticketId = $ticket->getID();
     foreach ($ticketActors as $actorType => $actorsList) {
         // Convert single actor (scalar value) to array
         if (!is_array($actorsList)) {
             $actorsList = array($actorsList);
         }
         // Check all actors are assigned to the ticket
         foreach ($actorsList as $index => $actor) {
             $notify = isset($actorList['_users_id_requester_notif']['use_notification'][$index]) ? $actorList['_users_id_requester_notif']['use_notification'][$index] : 1;
             $alternateEmail = isset($actorList['_users_id_requester_notif']['use_notification'][$index]) ? $actorList['_users_id_requester_notif']['alternative_email'][$index] : '';
             switch ($actorType) {
                 case '_users_id_assign':
                     $this->_testTicketUser($ticket, $actor, CommonITILActor::REQUESTER, $notify, $alternateEmail);
                     break;
                 case '_users_id_observer':
                     $this->_testTicketUser($ticket, $actor, CommonITILActor::OBSERVER, $notify, $alternateEmail);
                     break;
                 case '_users_id_assign':
                     $this->_testTicketUser($ticket, $actor, CommonITILActor::ASSIGN, $notify, $alternateEmail);
                     break;
             }
         }
     }
 }
Esempio n. 5
0
 static function plugin_vip_item_delete(Ticket $ticket)
 {
     global $DB;
     $ticketid = $ticket->getField('id');
     $delticketquery = "DELETE FROM glpi_plugin_vip_tickets\n\t\t\t\t\t\t\t\t WHERE id = " . $ticketid;
     $delvipticket = $DB->query($delticketquery);
 }
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
 {
     $survey = new TicketSatisfaction();
     $pdf->setColumnsSize(100);
     $pdf->displayTitle("<b>" . __('Satisfaction survey') . "</b>");
     if (!$survey->getFromDB($ticket->getID())) {
         $pdf->displayLine(__('No generated survey'));
     } else {
         if ($survey->getField('type') == 2) {
             $url = Entity::generateLinkSatisfaction($ticket);
             $pdf->displayLine(sprintf(__('%1$s (%2$s)'), __('External survey'), $url));
         } else {
             if ($survey->getField('date_answered')) {
                 $sat = $survey->getField('satisfaction');
                 $tabsat = array(0 => __('None'), 1 => __('1 star', 'pdf'), 2 => __('2 stars', 'pdf'), 3 => __('3 stars', 'pdf'), 4 => __('4 stars', 'pdf'), 5 => __('5 stars', 'pdf'));
                 if (isset($tabsat[$sat])) {
                     $sat = $tabsat[$sat] . "  ({$sat}/5)";
                 }
                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Response date to the satisfaction survey') . '</b>', Html::convDateTime($survey->getField('date_answered'))));
                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Satisfaction with the resolution of the ticket') . '</b>', $sat));
                 $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Comments') . '</b>', $survey->getField('comment')));
             } else {
                 // No answer
                 $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Creation date of the satisfaction survey'), Html::convDateTime($survey->getField('date_begin'))));
                 $pdf->displayLine(__('No answer', 'pdf'));
             }
         }
     }
     $pdf->displaySpace();
 }
Esempio n. 7
0
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job)
 {
     global $CFG_GLPI, $DB;
     $ID = $job->getField('id');
     //////////////followups///////////
     $query = "SELECT *\n                FROM `glpi_ticketcosts`\n                WHERE `tickets_id` = '{$ID}'\n                ORDER BY `begin_date`";
     $result = $DB->query($query);
     if (!$DB->numrows($result)) {
         $pdf->setColumnsSize(100);
         $pdf->displayLine(__('No ticket cost for this ticket', 'pdf'));
     } else {
         $pdf->setColumnsSize(60, 20, 20);
         $pdf->displayTitle("<b>" . TicketCost::getTypeName($DB->numrows($result)), __('Ticket duration'), CommonITILObject::getActionTime($job->fields['actiontime']) . "</b>");
         $pdf->setColumnsSize(20, 10, 10, 10, 10, 10, 10, 10, 10);
         $pdf->setColumnsAlign('center', 'center', 'center', 'left', 'right', 'right', 'right', 'right', 'right');
         $pdf->displayTitle("<b><i>" . __('Name') . "</i></b>", "<b><i>" . __('Begin date') . "</i></b>", "<b><i>" . __('End date') . "</i></b>", "<b><i>" . __('Budget') . "</i></b>", "<b><i>" . __('Duration') . "</i></b>", "<b><i>" . __('Time cost') . "</i></b>", "<b><i>" . __('Fixed cost') . "</i></b>", "<b><i>" . __('Material cost') . "</i></b>", "<b><i>" . __('Total cost') . "</i></b>");
         while ($data = $DB->fetch_array($result)) {
             $cost = TicketCost::computeTotalCost($data['actiontime'], $data['cost_time'], $data['cost_fixed'], $data['cost_material']);
             $pdf->displayLine($data['name'], Html::convDate($data['begin_date']), Html::convDate($data['end_date']), Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']), CommonITILObject::getActionTime($data['actiontime']), Html::formatNumber($data['cost_time']), Html::formatNumber($data['cost_fixed']), Html::formatNumber($data['cost_material']), Html::formatNumber($cost));
             $total_time += $data['actiontime'];
             $total_costtime += $data['actiontime'] * $data['cost_time'] / HOUR_TIMESTAMP;
             $total_fixed += $data['cost_fixed'];
             $total_material += $data['cost_material'];
             $total += $cost;
         }
         $pdf->setColumnsSize(50, 10, 10, 10, 10, 10);
         $pdf->setColumnsAlign('right', 'right', 'right', 'right', 'right', 'right');
         $pdf->displayLine('<b>' . __('Total'), CommonITILObject::getActionTime($total_time), Html::formatNumber($total_costtime), Html::formatNumber($total_fixed), Html::formatNumber($total_material), Html::formatNumber($total));
     }
     $pdf->displaySpace();
 }
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
 {
     global $CFG_GLPI, $DB;
     $pdf->setColumnsSize(100);
     $pdf->displayTitle("<b>" . __('Approvals for the ticket') . "</b>");
     if (!Session::haveRight('validate_request', 1) && !Session::haveRight('validate_incident', 1) && !Session::haveRight('create_incident_validation', 1) && !Session::haveRight('create_request_validation', 1)) {
         return false;
     }
     $ID = $ticket->getField('id');
     $query = "SELECT *\n                FROM `glpi_ticketvalidations`\n                WHERE `tickets_id` = '" . $ticket->getField('id') . "'\n                ORDER BY submission_date DESC";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if ($number) {
         $pdf->setColumnsSize(20, 19, 21, 19, 21);
         $pdf->displayTitle(_x('item', 'State'), __('Request date'), __('Approval requester'), __('Approval date'), __('Approver'));
         while ($row = $DB->fetch_assoc($result)) {
             $pdf->setColumnsSize(20, 19, 21, 19, 21);
             $pdf->displayLine(TicketValidation::getStatus($row['status']), Html::convDateTime($row["submission_date"]), getUserName($row["users_id"]), Html::convDateTime($row["validation_date"]), getUserName($row["users_id_validate"]));
             $tmp = trim($row["comment_submission"]);
             $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Request comments') . "</i></b>", empty($tmp) ? __('None') : $tmp, 1));
             if ($row["validation_date"]) {
                 $tmp = trim($row["comment_validation"]);
                 $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Approval comments') . "</i></b>", empty($tmp) ? __('None') : $tmp, 1));
             }
         }
     } else {
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
Esempio n. 9
0
    /**
     * Register custom CSS/JS for the page
     * @return void
     */
    public function loadCustomCssJs()
    {
        $html = $this->head['html'];
        parent::loadCustomCssJs();
        $this->head['html'] = $html;
        if (is_null($this->resourceArray['properties'])) {
            $this->resourceArray['properties'] = array();
        }
        $this->resourceArray['properties']['tickets'] = $this->resource->getProperties('tickets');
        /** @var Tickets $Tickets */
        $Tickets = $this->modx->getService('Tickets');
        $Tickets->loadManagerFiles($this, array('config' => true, 'utils' => true, 'css' => true, 'ticket' => true, 'comments' => true));
        $this->addLastJavascript($Tickets->config['jsUrl'] . 'mgr/ticket/update.js');
        $ready = array('xtype' => 'tickets-page-ticket-update', 'resource' => $this->resource->get('id'), 'record' => $this->resourceArray, 'publish_document' => (int) $this->canPublish, 'preview_url' => $this->previewUrl, 'locked' => (int) $this->locked, 'lockedText' => $this->lockedText, 'canSave' => (int) $this->canSave, 'canEdit' => (int) $this->canEdit, 'canCreate' => (int) $this->canCreate, 'canDuplicate' => (int) $this->canDuplicate, 'canDelete' => (int) $this->canDelete, 'show_tvs' => (int) (!empty($this->tvCounts)), 'mode' => 'update');
        $this->addHtml('
		<script type="text/javascript">
		// <![CDATA[
		MODx.config.publish_document = ' . (int) $this->canPublish . ';
		MODx.onDocFormRender = "' . $this->onDocFormRender . '";
		MODx.ctx = "' . $this->ctx . '";
		Ext.onReady(function() {
			MODx.load(' . $this->modx->toJSON($ready) . ');
		});
		// ]]>
		</script>');
    }
Esempio n. 10
0
 function ticket_count()
 {
     $cc = new ConstraintChain();
     $cc->add(new Constraint('ticket_release_version_id', '=', $this->id));
     $ticket = new Ticket();
     $tickets = $ticket->getAll($cc);
     return count($tickets);
 }
 function post_addItem()
 {
     if ($this->fields['itemtype'] == 'Ticket') {
         $ticket = new Ticket();
         $ticket->update(array('id' => $this->fields['items_id'], 'date_mod' => $_SESSION["glpi_currenttime"], '_forcenotif' => true, '_donotadddocs' => true));
     }
     parent::post_addItem();
 }
 static function afterUpdate(TicketSatisfaction $ticketsatisfaction)
 {
     $config = PluginBehaviorsConfig::getInstance();
     $ticket = new Ticket();
     if ($config->getField('add_notif') && $ticket->getFromDB($ticketsatisfaction->getField('tickets_id')) && $ticketsatisfaction->input["date_answered"]) {
         NotificationEvent::raiseEvent('plugin_behaviors_replysurvey', $ticket);
     }
 }
Esempio n. 13
0
 function garbage()
 {
     $deadline = date('Y-m-d H:i:s', time() - 24 * 60 * 60 * 5);
     // keep tickets for 5 days.
     App::import('model', 'Core.Ticket');
     $ticketObj = new Ticket();
     $data = $ticketObj->query('DELETE from tickets WHERE created < \'' . $deadline . '\'');
 }
Esempio n. 14
0
/**
* This function is beign used to reply on a ticket.
* It will first check if the user who executed this function is a mod/admin or the topic creator himself. If this is not the case the page will be redirected to an error page.
* in case the isset($_POST['hidden'] is set and the user is a mod, the message will be hidden for the topic starter. The reply will be created. If $_POST['ChangeStatus']) & $_POST['ChangePriority'] is set
* it will try to update the status and priority. Afterwards the page is being redirecte to the ticket again.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function reply_on_ticket()
{
    global $INGAME_WEBPATH;
    global $WEBPATH;
    //if logged in
    if (WebUsers::isLoggedIn() && isset($_POST['ticket_id'])) {
        $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
        $target_ticket = new Ticket();
        $target_ticket->load_With_TId($ticket_id);
        //check if the user who executed this function is a mod/admin or the topic creator himself.
        if ($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
            try {
                $author = unserialize($_SESSION['ticket_user'])->getTUserId();
                if (isset($_POST['Content'])) {
                    $content = $_POST['Content'];
                } else {
                    $content = "";
                }
                $hidden = 0;
                if (isset($_POST['hidden']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
                    $hidden = 1;
                }
                //create the reply
                Ticket::createReply($content, $author, $ticket_id, $hidden);
                //try to update the status & priority in case these are set.
                if (isset($_POST['ChangeStatus']) && isset($_POST['ChangePriority']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
                    $newStatus = filter_var($_POST['ChangeStatus'], FILTER_SANITIZE_NUMBER_INT);
                    $newPriority = filter_var($_POST['ChangePriority'], FILTER_SANITIZE_NUMBER_INT);
                    Ticket::updateTicketStatusAndPriority($ticket_id, $newStatus, $newPriority, $author);
                }
                header("Cache-Control: max-age=1");
                if (Helpers::check_if_game_client()) {
                    header("Location: " . $INGAME_WEBPATH . "?page=show_ticket&id=" . $ticket_id);
                } else {
                    header("Location: " . $WEBPATH . "?page=show_ticket&id=" . $ticket_id);
                }
                throw new SystemExit();
            } catch (PDOException $e) {
                //ERROR: LIB DB is not online!
                print_r($e);
                //header("Location: index.php");
                throw new SystemExit();
            }
        } else {
            //ERROR: No access!
            $_SESSION['error_code'] = "403";
            header("Cache-Control: max-age=1");
            header("Location: index.php?page=error");
            throw new SystemExit();
        }
    } else {
        //ERROR: not logged in!
        header("Cache-Control: max-age=1");
        header("Location: index.php");
        throw new SystemExit();
    }
}
 static function afterPurge(Document_Item $document_item)
 {
     $config = PluginBehaviorsConfig::getInstance();
     if ($config->getField('add_notif') && $document_item->fields['itemtype'] == 'Ticket' && isset($_POST['item'])) {
         // prevent not use in case of purge ticket
         $ticket = new Ticket();
         $ticket->getFromDB($document_item->fields['items_id']);
         NotificationEvent::raiseEvent('plugin_behaviors_document_itemdel', $ticket);
     }
 }
Esempio n. 16
0
 public function update()
 {
     $q = "UPDATE messages SET text = '" . DB::esc($this->text) . "', modified = '" . date('Y-m-d G:i:s') . "', updated = 1\n              WHERE id = " . DB::esc($this->id);
     $res = DB::query($q);
     if (!$res) {
         throw new Exception(DB::getMySQLiObject()->error);
     }
     $ticket = new Ticket(array('message_id' => DB::esc($this->id), 'text' => DB::esc($this->text)));
     $ticket->updateText();
 }
 function post_addItem()
 {
     $t = new Ticket();
     $no_stat_computation = true;
     if ($this->input['type'] == Ticket::ASSIGN) {
         $no_stat_computation = false;
     }
     $t->updateDateMod($this->fields['tickets_id'], $no_stat_computation);
     parent::post_addItem();
 }
Esempio n. 18
0
 public function process()
 {
     if (!($data = $this->handleFile())) {
         return $this->failure($this->modx->lexicon('ticket_err_file_ns'));
     }
     $properties = $this->mediaSource->getPropertyList();
     $tmp = explode('.', $data['name']);
     $extension = strtolower(end($tmp));
     $image_extensions = $allowed_extensions = array();
     if (!empty($properties['imageExtensions'])) {
         $image_extensions = array_map('trim', explode(',', strtolower($properties['imageExtensions'])));
     }
     if (!empty($properties['allowedFileTypes'])) {
         $allowed_extensions = array_map('trim', explode(',', strtolower($properties['allowedFileTypes'])));
     }
     if (!empty($allowed_extensions) && !in_array($extension, $allowed_extensions)) {
         return $this->failure($this->modx->lexicon('ticket_err_file_ext'));
     } elseif (in_array($extension, $image_extensions)) {
         $type = 'image';
     } else {
         $type = $extension;
     }
     $hash = sha1($data['stream']);
     $path = '0/';
     $filename = !empty($properties['imageNameType']) && $properties['imageNameType'] == 'friendly' ? $this->ticket->cleanAlias($data['name']) : $hash . '.' . $extension;
     if (strpos($filename, '.' . $extension) === false) {
         $filename .= '.' . $extension;
     }
     // Check for existing file
     $where = $this->modx->newQuery($this->classKey, array('class' => $this->class));
     if (!empty($this->ticket->id)) {
         $where->andCondition(array('parent:IN' => array(0, $this->ticket->id)));
     } else {
         $where->andCondition(array('parent' => 0));
     }
     $where->andCondition(array('file' => $filename, 'OR:hash:=' => $hash), null, 1);
     if ($this->modx->getCount($this->classKey, $where)) {
         return $this->failure($this->modx->lexicon('ticket_err_file_exists', array('file' => $data['name'])));
     }
     /* @var TicketFile $ticket_file */
     $ticket_file = $this->modx->newObject('TicketFile', array('parent' => 0, 'name' => $data['name'], 'file' => $filename, 'path' => $path, 'source' => $this->mediaSource->id, 'type' => $type, 'createdon' => date('Y-m-d H:i:s'), 'createdby' => $this->modx->user->id, 'deleted' => 0, 'hash' => $hash, 'size' => $data['size'], 'class' => $this->class, 'properties' => $data['properties']));
     $this->mediaSource->createContainer($ticket_file->path, '/');
     unset($this->mediaSource->errors['file']);
     $file = $this->mediaSource->createObject($ticket_file->get('path'), $ticket_file->get('file'), $data['stream']);
     if ($file) {
         $url = $this->mediaSource->getObjectUrl($ticket_file->get('path') . $ticket_file->get('file'));
         $ticket_file->set('url', $url);
         $ticket_file->save();
         $ticket_file->generateThumbnail($this->mediaSource);
         return $this->success('', $ticket_file->toArray());
     } else {
         $this->modx->log(modX::LOG_LEVEL_ERROR, '[Tickets] Could not save file: ' . print_r($this->mediaSource->getErrors(), 1));
         return $this->failure($this->modx->lexicon('ticket_err_file_save'));
     }
 }
Esempio n. 19
0
 private function formatAlertContent(Ticket $ticket, $time)
 {/*{{{*/
     $inspector = $ticket->getInspector();
     $leaderName = '';
     if (false == $inspector->isLeader() && false == $ticket->getInspectGroup()->getLeader()->isNull())
     {
         $leader = $ticket->getInspectGroup()->getLeader();
         $leaderName = ", 组长: ".$leader->realName;
     }
     return $inspector->realName."(".$ticket->getInspectGroup()->displayName.") ".get_class($ticket->source).": {$ticket->source->id} {$time}分钟".$leaderName.";\n";
 }/*}}}*/
Esempio n. 20
0
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $private)
 {
     global $CFG_GLPI, $DB;
     $ID = $job->getField('id');
     //////////////Tasks///////////
     $RESTRICT = "";
     if (!$private) {
         // Don't show private'
         $RESTRICT = " AND `is_private` = '0' ";
     } else {
         if (!Session::haveRight("show_full_ticket", "1")) {
             // No right, only show connected user private one
             $RESTRICT = " AND (`is_private` = '0'\n                          OR `users_id` ='" . Session::getLoginUserID() . "' ) ";
         }
     }
     $query = "SELECT *\n                FROM `glpi_tickettasks`\n                WHERE `tickets_id` = '{$ID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     if (!$DB->numrows($result)) {
         $pdf->setColumnsSize(100);
         $pdf->displayLine(__('No task found.'));
     } else {
         $pdf->displayTitle("<b>" . TicketTask::getTypeName($DB->numrows($result) . "</b>"));
         $pdf->setColumnsSize(20, 20, 20, 20, 20);
         $pdf->displayTitle("<b><i>" . __('Type') . "</i></b>", "<b><i>" . __('Date') . "</i></b>", "<b><i>" . __('Duration') . "</i></b>", "<b><i>" . __('Writer') . "</i></b>", "<b><i>" . __('Planning') . "</i></b>");
         while ($data = $DB->fetch_array($result)) {
             $actiontime = Html::timestampToString($data['actiontime'], false);
             $planification = '';
             if (empty($data['begin'])) {
                 if (isset($data["state"])) {
                     $planification = Planning::getState($data["state"]) . "<br>";
                 }
                 $planification .= _e('None');
             } else {
                 if (isset($data["state"])) {
                     $planification = sprintf(__('%1$s: %2$s'), _x('item', 'State'), Planning::getState($data["state"]));
                 }
                 $planificiation = sprintf(__('%1$s - %2$s'), $planification, Html::convDateTime($data["begin"]) . " -> " . Html::convDateTime($data["end"]));
                 $planificiation = sprintf(__('%1$s - %2$s'), $planification, sprintf(__('%1$s  %2$s'), __('By'), getUserName($data["users_id_tech"])));
             }
             if ($data['taskcategories_id']) {
                 $lib = Dropdown::getDropdownName('glpi_taskcategories', $data['taskcategories_id']);
             } else {
                 $lib = '';
             }
             if ($data['is_private']) {
                 $lib = sprintf(__('%1$s (%2$s)'), $lib, __('Private'));
             }
             toolbox::logdebug("lib", $data);
             $pdf->displayLine(Html::clean($lib), Html::convDateTime($data["date"]), Html::timestampToString($data["actiontime"], 0), Html::clean(getUserName($data["users_id"])), Html::clean($planification), 1);
             $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Description') . "</i></b>", Html::clean($data["content"]), 1));
         }
     }
     $pdf->displaySpace();
 }
 /**
  * @since version 0.85
  **/
 function canCreateItem()
 {
     if ($this->canChildItem('canViewItem', 'canView')) {
         $ticket = new Ticket();
         if ($ticket->getFromDB($this->fields['tickets_id'])) {
             if ($ticket->fields['type'] == Ticket::INCIDENT_TYPE) {
                 return Session::haveRight(self::$rightname, self::CREATEINCIDENT);
             }
             if ($ticket->fields['type'] == Ticket::DEMAND_TYPE) {
                 return Session::haveRight(self::$rightname, self::CREATEREQUEST);
             }
         }
     }
 }
Esempio n. 22
0
 function getGroups($ticket_id, $removeAlreadyAssigned = true)
 {
     $groups = $user_groups = $ticket_groups = array();
     // get groups for user connected
     $tmp_user_groups = Group_User::getUserGroups($_SESSION['glpiID']);
     foreach ($tmp_user_groups as $current_group) {
         $user_groups[$current_group['id']] = $current_group['id'];
         $groups[$current_group['id']] = $current_group['id'];
     }
     // get groups already assigned in the ticket
     if ($ticket_id > 0) {
         $ticket = new Ticket();
         $ticket->getFromDB($ticket_id);
         foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $current_group) {
             $ticket_groups[$current_group['groups_id']] = $current_group['groups_id'];
         }
     }
     // To do an escalation, the user must be in a group currently assigned to the ticket
     // or no group is assigned to the ticket
     // TODO : matching with "view all tickets (yes/no) option in profile user"
     if (!empty($ticket_groups) && count(array_intersect($ticket_groups, $user_groups)) == 0) {
         return array();
     }
     //get all group which we can climb
     if (count($groups) > 0) {
         $group_group = $this->find("groups_id_source IN (" . implode(", ", $groups) . ")");
         foreach ($group_group as $current_group) {
             $groups[$current_group['groups_id_destination']] = $current_group['groups_id_destination'];
         }
     }
     //remove already assigned groups
     if (!empty($ticket_groups) && $removeAlreadyAssigned) {
         $groups = array_diff_assoc($groups, $ticket_groups);
     }
     //add name to returned groups and remove non assignable groups
     $group_obj = new Group();
     foreach ($groups as $groups_id => &$groupname) {
         $group_obj->getFromDB($groups_id);
         //check if we can assign this group
         if ($group_obj->fields['is_assign'] == 0) {
             unset($groups[$groups_id]);
             continue;
         }
         //add name
         $groupname = $group_obj->fields['name'];
     }
     //sort by group name (and keep associative index)
     asort($groups);
     return $groups;
 }
    /**
     * @param string $where - WHERE of the sql query
     * @param array $data - sql values to bind to the prepared query
     *
     * @return array
     */
    public static function loadAll($where = '', $data = array(), $return_array = true, $order_by = '')
    {
        global $con;
        if (!empty($where)) {
            $where = ' WHERE ' . $where;
        }
        if (!empty($order_by)) {
            $order_by = ' ORDER BY ' . $order_by;
        }
        $sql = 'SELECT
                tTicket.TicketID AS ticket_id,
                tTicket.IssueTitle as ticket_issue_title,
                tTicket.Description as ticket_description,
                UNIX_TIMESTAMP(tTicket.DateOpened) AS ticket_date_opened,

                tTicket.CategoryID AS category_id,
				jCategory.Description AS category_description,

				tTicket.OpenedBy AS opened_by_id,
                jOpenedBy.FirstName AS opened_by_first_name,
                jOpenedBy.LastName AS opened_by_last_name,
                jOpenedBy.EmailAddress AS opened_by_email_address,
                jOpenedBy.PhoneNumber AS opened_by_phone_number,
                jOpenedBy.CellPhoneCarrierID AS opened_by_cell_phone_carrier_id,
                jOpenedBy.ProfilePicture AS opened_by_profile_picture,

                jOpenedByLogin.TypeID AS opened_by_type_id,
                jOpenedByLogin.LastPasswordChange AS opened_by_last_password_change
            FROM tTicket
            LEFT JOIN tUser jOpenedBy ON jOpenedBy.UserID = tTicket.OpenedBy
            LEFT JOIN tLogin jOpenedByLogin ON jOpenedBy.UserID = jOpenedByLogin.UserID
            LEFT JOIN tCategory jCategory ON jCategory.CategoryID = tTicket.CategoryID
            ' . $where . '
            ' . $order_by . '';
        $statement = $con->prepare($sql);
        $statement->execute($data);
        $rows = $statement->fetchAll();
        $tickets = array();
        if (!empty($rows)) {
            foreach ($rows as $row) {
                $ticket = new Ticket(array('id' => $row['ticket_id'], 'category' => array('id' => $row['category_id'], 'description' => $row['category_description']), 'opened_by' => array('id' => $row['opened_by_id'], 'first_name' => $row['opened_by_first_name'], 'last_name' => $row['opened_by_last_name'], 'email_address' => $row['opened_by_email_address'], 'phone_number' => $row['opened_by_phone_number'], 'cell_phone_carrier_id' => $row['opened_by_cell_phone_carrier_id'], 'profile_picture' => $row['opened_by_profile_picture'], 'type_id' => $row['opened_by_type_id'], 'last_password_change' => $row['opened_by_last_password_change']), 'issue_title' => $row['ticket_issue_title'], 'description' => $row['ticket_description'], 'date_opened' => $row['ticket_date_opened']));
                $ticket->loadNotes();
                if (!$return_array) {
                    return $ticket;
                }
                $tickets[] = $ticket;
            }
        }
        return $tickets;
    }
Esempio n. 24
0
 function cannedResp($params)
 {
     $sql = 'SELECT answer FROM ' . KB_PREMADE_TABLE . ' WHERE isenabled=1 AND premade_id=' . db_input($params['id']);
     if (($res = db_query($sql)) && db_num_rows($res)) {
         list($response) = db_fetch_row($res);
     }
     if ($response && $params['tid'] && strpos($response, '%') !== false) {
         include_once INCLUDE_DIR . 'class.ticket.php';
         $ticket = new Ticket($params['tid']);
         if ($ticket && $ticket->getId()) {
             $response = $ticket->replaceTemplateVars($response);
         }
     }
     return $response;
 }
 /**
  * View the ticket
  *
  */
 function view()
 {
     if ($this->active_ticket->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_ticket->canView($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     ProjectObjectViews::log($this->active_ticket, $this->logged_user);
     $this->smarty->assign(array('page_back_url' => assemble_url('mobile_access_view_tickets', array('project_id' => $this->active_project->getId()))));
     $this->addBreadcrumb(str_excerpt(clean($this->active_ticket->getName()), 10), mobile_access_module_get_view_url($this->active_ticket));
     $this->addBreadcrumb(lang('View'));
 }
Esempio n. 26
0
function plugin_init_escalation()
{
    global $PLUGIN_HOOKS, $CFG_GLPI;
    $PLUGIN_HOOKS['change_profile']['escalation'] = array('PluginEscalationProfile', 'changeprofile');
    $PLUGIN_HOOKS['csrf_compliant']['escalation'] = true;
    // After escalation, if user can't see the ticket (dan't see all ticket right), it redirect to ticket list
    if (isset($_SERVER['HTTP_REFERER']) and strstr($_SERVER['HTTP_REFERER'], "escalation/front/group_group.form.php")) {
        if (isset($_GET['id'])) {
            $ticket = new Ticket();
            $ticket->getFromDB($_GET['id']);
            if (!$ticket->canViewItem()) {
                // Can't see ticket, go in ticket list
                $ticket->redirectToList();
            }
        }
    }
    if (isset($_SESSION["glpiID"])) {
        $plugin = new Plugin();
        if ($plugin->isActivated('escalation')) {
            Plugin::registerClass('PluginEscalationProfile', array('addtabon' => array('Profile')));
            Plugin::registerClass('PluginEscalationTicketCopy', array('addtabon' => array('Ticket')));
            Plugin::registerClass('PluginEscalationConfig', array('addtabon' => array('Entity')));
            Plugin::registerClass('PluginEscalationGroup_Group', array('addtabon' => array('Ticket', 'Group')));
            $PLUGIN_HOOKS['menu_entry']['escalation'] = false;
            PluginEscalationGroup_Group::convertNewTicket();
            // limit group
            $peConfig = new PluginEscalationConfig();
            if ($peConfig->getValue('limitgroup', $_SESSION['glpidefault_entity']) == '1') {
                if (strpos($_SERVER['PHP_SELF'], "ticket.form.php") && !isset($_GET['id'])) {
                    $group = new Group();
                    $a_groups = array();
                    $a_groups[0] = Dropdown::EMPTY_VALUE;
                    foreach ($_SESSION['glpigroups'] as $groups_id) {
                        $group->getFromDB($groups_id);
                        $a_groups[$groups_id] = $group->getName();
                    }
                    $_SESSION['plugin_escalation_requestergroups'] = $a_groups;
                    register_shutdown_function('plugin_escalation_on_exit');
                    ob_start();
                }
            }
            // end limit group
        }
        $PLUGIN_HOOKS['pre_item_add']['escalation'] = array('Ticket' => array('PluginEscalationGroup_Group', 'selectGroupOnAdd'));
        $PLUGIN_HOOKS['item_add']['escalation'] = array('Ticket' => array('PluginEscalationTicketCopy', 'finishAdd'));
        //         $PLUGIN_HOOKS['pre_item_update']['escalation'] = array('Ticket' => array('PluginEscalationGroup_Group', 'notMultiple'));
    }
}
Esempio n. 27
0
 private static function buildTicket($row, $pdo)
 {
     $db = DB::get();
     $id = $row['ID'];
     // Get lines
     $lines = array();
     $lineSql = "SELECT * FROM TICKETLINES WHERE TICKET = :id " . "ORDER BY LINE";
     $lineStmt = $pdo->prepare($lineSql);
     $lineStmt->bindParam(":id", $id);
     $lineStmt->execute();
     while ($rowLine = $lineStmt->fetch()) {
         $product = ProductsService::get($rowLine['PRODUCT']);
         $tax = TaxesService::getTax($rowLine['TAXID']);
         $line = new TicketLine($rowLine['LINE'], $product, $rowLine['ATTRIBUTESETINSTANCE_ID'], $rowLine['UNITS'], $rowLine['PRICE'], $tax, $rowLine['DISCOUNTRATE']);
         $lines[] = $line;
     }
     // Get payments
     $payments = array();
     $paySql = "SELECT * FROM PAYMENTS WHERE RECEIPT = :id";
     $payStmt = $pdo->prepare($paySql);
     $payStmt->bindParam(":id", $id);
     $payStmt->execute();
     while ($rowPay = $payStmt->fetch()) {
         $pay = Payment::__build($rowPay['ID'], $rowPay['PAYMENT'], $rowPay['TOTAL'], $rowPay['CURRENCY'], $rowPay['TOTALCURRENCY']);
         $payments[] = $pay;
     }
     // Build ticket
     $tkt = Ticket::__build($row['ID'], $row['TICKETID'], $row['TICKETTYPE'], $row['PERSON'], $db->readDate($row['DATENEW']), $lines, $payments, $row['MONEY'], $row['CUSTOMER'], $row['CUSTCOUNT'], $row['TARIFFAREA'], $row['DISCOUNTRATE'], $row['DISCOUNTPROFILE_ID']);
     return $tkt;
 }
Esempio n. 28
0
 function getTicket()
 {
     if (!$this->ticket && $this->getTicketId()) {
         $this->ticket = Ticket::lookup($this->getTicketId());
     }
     return $this->ticket;
 }
Esempio n. 29
0
 public function create($request)
 {
     $req = $request->getParameters();
     $response = new ViewResponse('assist/ticket');
     if (trim($req['bug']) != '') {
         if (Session::isActive()) {
             $user_id = Session::get()->id;
         } else {
             if (trim($req['email']) != '') {
                 $user_id = $req['email'];
             } else {
                 $user_id = 0;
             }
         }
         $ticket = Ticket::create(array('user_id' => $user_id, 'description' => $req['bug'], 'timestamp' => time(), 'ip' => $_SERVER['REMOTE_ADDR']));
         $ticket_id = $ticket->id;
         $response->addMessage(ViewMessage::success('Envoyé ! Vous serez notifié de l\'avancement par E-Mail ou Message Privé (Ticket #' . $ticket_id . ')'));
         /*$username = (Session::isActive()) ? Session::get()->username : '******';
         		$notif = new PushoverNotification();
         		$notif->setMessage('Nouveau ticket de '.$username);
         		$notif->setReceiver('all');
         		$notif->setExtraParameter('url', 'http://dreamvids.fr'.WEBROOT.'admin/tickets');
         		$notif->send();*/
     } else {
         $response->addMessage(ViewMessage::error('Merci de nous décrire votre problème.'));
     }
     return $response;
 }
Esempio n. 30
0
 public function execute()
 {
     global $gvOfficeCode;
     $deskList = Desk::fromDatabaseCompleteList();
     $content = array();
     if (!$deskList) {
         $content['ErrorCode'] = "AE004";
         $content['ErrorMsg'] = "No desks in this office";
         return $content;
     }
     $content['OfficeCode'] = $gvOfficeCode;
     $content['NumDesks'] = count($deskList);
     $content['Desks'] = array();
     foreach ($deskList as $desk) {
         if ($desk->getOpCode() != null) {
             $ticket = Ticket::fromDatabaseByDesk($desk->getNumber());
             if ($ticket) {
                 $ticket = $ticket->getTextString();
             } else {
                 $ticket = '';
             }
         } else {
             $ticket = '';
         }
         $deskObj = array('Number' => $desk->getNumber(), 'Ticket' => $ticket);
         $content['Desks'][] = $deskObj;
     }
     return $content;
 }