/** * 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; }