コード例 #1
0
ファイル: TicketsNotes.php プロジェクト: kokkez/shineisp
 /**
  * Save the ticket note 
  * 
  * @param integer $ticketid
  * @param array $params
  */
 public static function saveIt($tid, $date, $note, $category = null, $status = null, $isAdmin = false, $noteid = null, $sendemail = true)
 {
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     if (!is_numeric($tid)) {
         return false;
     }
     if (is_numeric($noteid)) {
         $ticketnote = self::find($noteid);
     } else {
         $ticketnote = new TicketsNotes();
     }
     // Get and Check the ticket note
     $ticket = Tickets::find($tid);
     // update the ticket
     if (!empty($status) && is_numeric($status)) {
         $ticket->status_id = $status;
     }
     $ticket->date_updated = date('Y-m-d H:i:s');
     if (is_numeric($category)) {
         $ticket->category_id = $category;
     }
     $ticket->save();
     if ($ticket && !empty($note)) {
         $ticketnote->date_post = !empty($date) ? $date : $date('Y-m-d H:i:s');
         $ticketnote->note = $note;
         $ticketnote->admin = $isAdmin;
         $ticketnote->ticket_id = $tid;
         $ticketnote->parent_id = 0;
         // Save the note
         if ($ticketnote->trySave()) {
             $noteid = is_numeric($noteid) ? $noteid : $ticketnote->getIncremented();
             // Save the upload file
             $attachment = self::UploadDocument($tid, $ticket->get('customer_id'));
             if ($sendemail) {
                 Tickets::send($noteid, false, $attachment);
             }
             return $ticketnote;
         }
     }
     return false;
 }
コード例 #2
0
ファイル: TicketsController.php プロジェクト: kokkez/shineisp
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $NS = new Zend_Session_Namespace('Default');
     $request = $this->getRequest();
     $customer = $NS->customer['customer_id'];
     $this->view->title = $this->translator->translate("Ticket");
     $this->view->description = $this->translator->translate("Check the information before save again.");
     // Check if we have a POST request
     if (!$request->isPost()) {
         return $this->_helper->redirector('index');
     }
     // Get our form and validate it
     $form = $this->getForm('/tickets/process');
     // Invalid entries
     if (!$form->isValid($request->getPost())) {
         $this->view->form = $form;
         $this->view->canreply = true;
         return $this->_helper->viewRenderer('customform');
     }
     // Get the id
     $id = $this->getRequest()->getParam('ticket_id');
     $data = $request->getPost();
     $data['note'] = !empty($data['note']) ? $data['note'] : "-";
     //There is a problem with TinyMCE!
     $categoryId = !empty($data['category_id']) && is_numeric($data['category_id']) ? $data['category_id'] : null;
     if (is_numeric($id)) {
         TicketsNotes::saveIt($id, date('Y-m-d H:i:s'), $data['note'], $data['status']);
     } else {
         Tickets::saveIt(null, $customer, $data['subject'], $data['note'], $categoryId);
     }
     return $this->_helper->redirector('index', 'tickets', 'default', array('mex' => 'The task requested has been executed successfully.', 'status' => 'success'));
 }
コード例 #3
0
ファイル: Tickets.php プロジェクト: kokkez/shineisp
 /**
  * Send ticket by email
  * 
  * @param integer $id
  * @param boolean $isTicket
  * @param string $attachment
  */
 public static function send($id, $isTicket = true, $attachment = null)
 {
     $isp = Isp::getActiveISP();
     $placeholders = array();
     $customer_url = "";
     $admin_url = "";
     if ($isTicket) {
         $ticket = self::getAllInfo($id, null, true);
         $customer = $ticket[0]['Customers'];
         $operator = AdminUser::getAllInfo($ticket[0]['user_id']);
     } else {
         $ticket = TicketsNotes::getAllInfo($id);
         $customer = $ticket[0]['Tickets']['Customers'];
         $operator = AdminUser::getAllInfo($ticket[0]['Tickets']['user_id']);
     }
     if (!empty($ticket[0])) {
         if ($isp) {
             $ispmail = explode("@", $isp['email']);
             $retval = Shineisp_Commons_Utilities::getEmailTemplate('ticket_message');
             if ($retval) {
                 $s = $retval['subject'];
                 $ticketid = $ticket[0]['ticket_id'];
                 $in_reply_to = md5($ticketid);
                 $ispmail = "noreply@" . $ispmail[1];
                 $rec = Fastlinks::findlinks($ticketid, $customer['customer_id'], 'tickets');
                 if (!empty($rec[0]['code'])) {
                     $customer_url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $rec[0]['code'];
                     $admin_url = "http://" . $_SERVER['HTTP_HOST'] . "/admin/login/link/id/" . $rec[0]['code'];
                 }
                 // Check the attachments
                 if (!empty($attachment) && file_exists(PUBLIC_PATH . $attachment)) {
                     $attachment = PUBLIC_PATH . $attachment;
                 }
                 if ($isTicket) {
                     $placeholders['subject'] = $ticket[0]['subject'];
                     $placeholders['description'] = $ticket[0]['description'];
                     $placeholders['date_open'] = Shineisp_Commons_Utilities::formatDateOut($ticket[0]['date_open']);
                     $placeholders['status'] = $ticket[0]['Statuses']['status'];
                 } else {
                     $placeholders['subject'] = $ticket[0]['Tickets']['subject'];
                     $placeholders['description'] = $ticket[0]['note'];
                     $placeholders['date_open'] = Shineisp_Commons_Utilities::formatDateOut($ticket[0]['Tickets']['date_open']);
                     $placeholders['status'] = $ticket[0]['Tickets']['Statuses']['status'];
                 }
                 $placeholders['customer'] = $customer['firstname'] . " " . $customer['lastname'] . " " . $customer['company'];
                 $placeholders['link'] = $customer_url;
                 $placeholders['company'] = $isp['company'];
                 $placeholders['issue_number'] = $ticketid;
                 $placeholders['operator'] = $operator['lastname'] . " " . $operator['firstname'];
                 // Send a message to the customer
                 Shineisp_Commons_Utilities::sendEmailTemplate(Contacts::getEmails($customer['customer_id']), 'ticket_message', $placeholders, $in_reply_to, $attachment, null, $isp, $customer['language_id']);
                 // Update the link for the administrator email
                 $placeholders['link'] = $admin_url . "/keypass/" . Shineisp_Commons_Hasher::hash_string($operator['email']);
                 Shineisp_Commons_Utilities::sendEmailTemplate($isp['email'], 'ticket_message', $placeholders, $in_reply_to, $attachment, null, $isp);
                 return true;
             }
         }
     }
     return false;
 }
コード例 #4
0
ファイル: TicketsController.php プロジェクト: moay/shineisp
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = $this->getForm("/admin/tickets/process");
     $request = $this->getRequest();
     $this->view->title = $this->translator->translate("New Ticket");
     $this->view->description = $this->translator->translate("Here you can handle the ticket support.");
     // Create the buttons in the edit form
     $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/tickets/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/tickets/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
     // Check if we have a POST request
     if (!$request->isPost()) {
         $this->_helper->redirector('list', 'tickets', 'admin');
     }
     if ($form->isValid($request->getPost())) {
         // Get the values posted
         $params = $request->getPost();
         // Get the id
         $id = $this->getRequest()->getParam('ticket_id');
         // create the ticket if not exist
         if (!is_numeric($id)) {
             $id = Tickets::saveIt(null, $params['customer_id'], $params['subject'], $params['note'], $params['category_id']);
             $redirector->gotoUrl("/admin/tickets/edit/id/{$id}#last");
         }
         $date = !empty($params['datetime']) ? Shineisp_Commons_Utilities::formatDateIn($params['datetime']) : null;
         $note = !empty($params['note']) ? $params['note'] : null;
         $status = !empty($params['status_id']) && is_numeric($params['status_id']) ? $params['status_id'] : null;
         $sendemail = !empty($params['sendemail']) && is_numeric($params['sendemail']) ? true : false;
         // Save the Ticket Note and send the email to the customer
         $ticketNote = TicketsNotes::saveIt($id, $date, $note, $status, true, null, $sendemail);
         // Update the sibling
         if (!empty($params['sibling_id']) && is_numeric($params['sibling_id'])) {
             Tickets::setSibling($id, $params['sibling_id']);
         }
         // Update the operator for the selected ticket
         if (!empty($params['user_id']) && is_numeric($params['user_id'])) {
             Tickets::setOperator($id, $params['user_id']);
         }
         // Update the ticket attaching the order
         if (!empty($params['order_id']) && is_numeric($params['order_id'])) {
             Tickets::setOrder($id, $params['order_id']);
         }
         $redirector->gotoUrl("/admin/tickets/edit/id/{$id}#last");
     } else {
         $this->view->form = $form;
         return $this->render('applicantform');
     }
 }
コード例 #5
0
ファイル: SearchController.php プロジェクト: kokkez/shineisp
 /**
  * Create the form module in order to create a record
  * @return unknown_type
  */
 public function doAction()
 {
     $request = $this->getRequest();
     $q = $request->getParam('q');
     $results = array();
     $q = strtolower($q);
     if (empty($q)) {
         die(json_encode(array($this->translator->translate('No Records'))));
     }
     $cms = CmsPages::getList();
     foreach ($cms as $key => $value) {
         if (strpos(strtolower($value), $q) !== false) {
             $results[] = array('icon' => 'glyphicon-file', 'section' => $this->translator->translate('Cms'), 'value' => $value, 'url' => "/admin/cmspages/edit/id/{$key}", 'tokens' => explode(' ', $value));
         }
     }
     $customers = Customers::getList();
     if (!empty($customers)) {
         foreach ($customers as $key => $value) {
             if (strpos(strtolower($value), $q) !== false) {
                 $results[] = array('icon' => 'glyphicon-user', 'section' => $this->translator->translate('Customer'), 'value' => $value, 'url' => "/admin/customers/edit/id/{$key}", 'tokens' => explode(' ', $value));
             }
         }
     }
     $domains = Domains::getList();
     if (!empty($domains)) {
         foreach ($domains as $key => $value) {
             if (strpos(strtolower($value), $q) !== false) {
                 $results[] = array('icon' => 'glyphicon-globe', 'section' => $this->translator->translate('Domain'), 'value' => $value, 'url' => "/admin/domains/edit/id/{$key}", 'tokens' => explode(' ', $value));
             }
         }
     }
     $products = Products::getList();
     if (!empty($products)) {
         foreach ($products as $key => $value) {
             if (strpos(strtolower($value), $q) !== false) {
                 $results[] = array('icon' => 'glyphicon-barcode', 'section' => $this->translator->translate('Product'), 'value' => $value, 'url' => "/admin/products/edit/id/{$key}", 'tokens' => explode(' ', $value));
             }
         }
     }
     $orders = Orders::getList();
     if (!empty($orders)) {
         foreach ($orders as $key => $value) {
             if (strpos(strtolower($value), $q) !== false) {
                 $results[] = array('icon' => 'glyphicon-briefcase', 'section' => $this->translator->translate('Order'), 'value' => $value, 'url' => "/admin/orders/edit/id/{$key}", 'tokens' => explode(' ', $value));
             }
         }
     }
     $ordersitems = OrdersItems::getItemsListbyDescription($q);
     if (!empty($ordersitems)) {
         foreach ($ordersitems as $key => $value) {
             $results[] = array('icon' => 'glyphicon-briefcase', 'section' => $this->translator->translate('Order Item'), 'value' => $value, 'url' => "/admin/ordersitems/edit/id/{$key}", 'tokens' => explode(' ', $value));
         }
     }
     $tickets = Tickets::getList();
     if (!empty($tickets)) {
         foreach ($tickets as $key => $value) {
             if (strpos(strtolower($value), $q) !== false) {
                 $results[] = array('icon' => 'glyphicon-check', 'section' => $this->translator->translate('Ticket'), 'value' => $value, 'url' => "/admin/tickets/edit/id/{$key}", 'tokens' => explode(' ', $value));
             }
         }
     }
     $wiki = Wiki::getList();
     if (!empty($wiki)) {
         foreach ($wiki as $key => $value) {
             if (strpos(strtolower($value), $q) !== false) {
                 $results[] = array('icon' => 'glyphicon-question-sign', 'section' => $this->translator->translate('Wiki'), 'value' => $value, 'url' => "/admin/wiki/edit/id/{$key}", 'tokens' => explode(' ', $value));
             }
         }
     }
     $ticket = TicketsNotes::getItemsNote($q);
     foreach ($ticket as $key => $value) {
         $results[] = array('icon' => 'glyphicon-question-sign', 'section' => $this->translator->translate('Ticket Notes'), 'value' => $value, 'url' => "/admin/wiki/tickets/id/{$key}", 'tokens' => explode(' ', $value));
     }
     die(json_encode($results));
 }