public function create($app)
 {
     $request = $app->router->flight->request();
     if ($request->method != 'POST') {
         $app->output->addBreadcrumb('', 'CSGOShop');
         $app->output->addBreadcrumb('support/', 'Support');
         $app->output->addBreadcrumb('support/create', 'Create a Ticket');
         $app->output->setTitle('Create a Ticket');
         $app->output->setActiveTab('support');
         $app->output->render('support.create', []);
     } else {
         SupportTicket::create(['user_id' => $app->user->id, 'subject' => '[' . $request->data->category . '] ' . $request->data->subject, 'body' => $request->data->body]);
         $app->output->redirect('/support');
     }
 }
Example #2
0
 function doTickets()
 {
     $db = JFactory::getDBO();
     $import_limit = 100;
     if ($this->offset < 1) {
         $db->setQuery("TRUNCATE #__fss_ticket_ticket");
         $db->Query();
         $db->setQuery("TRUNCATE #__fss_ticket_messages");
         $db->Query();
     }
     $qry = "SELECT hu.*, u.username FROM {$this->sp}_huruhelpdesk_users as hu LEFT JOIN {$this->sp}_users as u ON hu.joomla_id = u.id WHERE isrep = 1";
     $db->setQuery($qry);
     $reps = $db->loadObjectList('id');
     $rep_jid = $db->loadObjectList('username');
     $qry = "SELECT * FROM {$this->sp}_huruhelpdesk_problems LIMIT {$this->offset}, {$import_limit}";
     $db->setQuery($qry);
     $problems = $db->loadObjectList();
     $missing_rep = array();
     foreach ($problems as $problem) {
         $ticket = new SupportTicket();
         $data = array();
         $data['id'] = $problem->id;
         $data['ticket_status_id'] = $problem->status;
         $data['title'] = $problem->title;
         $data['opened'] = $problem->start_date;
         $data['lastupdate'] = $problem->start_date;
         $data['ticket_pri_id'] = $problem->priority;
         $data['ticket_cat_id'] = $problem->category;
         $data['closed'] = $problem->close_date;
         $data['timetaken'] = $problem->time_spent;
         $data['user_id'] = static::getUser($problem->uid);
         $data['admin_id'] = 0;
         if (!array_key_exists($problem->rep, $reps)) {
             $missing_rep[$problem->rep] = "Missing Rep : {$problem->rep}";
         } else {
             $admin = $reps[$problem->rep];
             if ($admin->username) {
                 $data['admin_id'] = static::getUser($admin->username);
             } else {
                 $missing_rep[$problem->rep] = "No User for Rep : {$problem->rep}, Joomla User ID : {$admin->joomla_id}";
             }
         }
         $ticket->create($data);
         $mid = $ticket->addMessage($problem->description, "Problem", $data['user_id']);
         $db->setQuery("UPDATE #__fss_ticket_messages SET posted = '{$problem->start_date}' WHERE id = " . $mid);
         $db->Query();
         $qry = "SELECT * FROM {$this->sp}_huruhelpdesk_notes WHERE id = '{$problem->id}' ORDER BY adddate ASC";
         $db->setQuery($qry);
         $notes = $db->loadObjectList();
         $last_date = $problem->close_date ? $problem->close_date : $problem->start_date;
         foreach ($notes as $note) {
             $type = TICKET_MESSAGE_USER;
             if (array_key_exists($note->uid, $rep_jid)) {
                 $type = TICKET_MESSAGE_ADMIN;
             }
             if ($note->priv) {
                 $type = TICKET_MESSAGE_PRIVATE;
             }
             $mid = $ticket->addMessage($note->note, "", static::getUser($note->uid), $type);
             $db->setQuery("UPDATE #__fss_ticket_messages SET posted = '{$note->adddate}' WHERE id = " . $mid);
             $db->Query();
             $last_date = $note->adddate;
         }
         // missing from problems
         /*
         uemail
         ulocation
         uphone
         */
         if ($problem->solution != "") {
             $mid = $ticket->addMessage($problem->solution, "Solution", $data['admin_id'], TICKET_MESSAGE_ADMIN);
             $db->setQuery("UPDATE #__fss_ticket_messages SET posted = '{$problem->close_date}' WHERE id = " . $mid);
             $db->Query();
         }
         $db->setQuery("UPDATE #__fss_ticket_ticket SET lastupdate = '{$last_date}' WHERE id = " . $problem->id);
         $db->Query();
         $this->count++;
     }
     $log = "<h4>Imported {$this->count} tickets, Nos {$this->offset} to " . ($this->offset + $this->count) . "</h4>";
     if ($this->count == $import_limit) {
         $log .= "<a href='" . JRoute::_("index.php?option=com_fss&view=import&source=huru&offset=" . ($this->offset + $import_limit)) . "'>Run next {$import_limit}</a><Br/>";
     }
     $log .= "<h3>Missing Rep Lookups</h3>";
     $log .= "<pre>" . print_r($missing_rep, true) . "</pre>";
     $log .= "<h3>Missing Usernames</h3>";
     $log .= "<pre>" . print_r(static::$missing, true) . "</pre>";
     return $log;
 }