/** * Save the ticket * * @param integer $id * @param integer $customer * @param string $subject * @param string $description * @param integer $category * @param integer $status * @param integer $domain * @return Boolean or integer */ public static function saveIt($id = null, $customer, $subject, $description, $category, $status = null, $domain = null) { $translator = Shineisp_Registry::getInstance()->Zend_Translate; $isUpdate = false; if (is_numeric($id)) { $ticket = self::find($id); $isUpdate = true; } else { $ticket = new Tickets(); } $operatorId = Settings::findbyParam('tickets_operator', 'admin', Isp::getActiveISPID()); if (!is_numeric($operatorId)) { $operator = AdminUser::getFirstAdminUser(); } else { $operator = AdminUser::getAllInfo($operatorId); } if (is_numeric($customer)) { $ticket->subject = !empty($subject) ? $subject : $translator->translate('Generic Issue'); $ticket->description = !empty($description) ? $description : null; $ticket->category_id = !empty($category) ? $category : null; $ticket->customer_id = $customer; $ticket->user_id = $operator['user_id']; $ticket->date_open = date('Y-m-d H:i:s'); $ticket->date_updated = date('Y-m-d H:i:s'); $ticket->domain_id = is_numeric($domain) && $domain > 0 ? $domain : NULL; $ticket->status_id = !empty($status) ? $status : Statuses::id("expectingreply", "tickets"); // Expecting a reply as default $ticket->save(); $id = $ticket->getIncremented(); // Save the upload file $attachment = self::UploadDocument($id, $customer); // Check if the request is an update if ($isUpdate == false) { // Create for the first time the fast link Fastlinks::CreateFastlink('tickets', 'edit', json_encode(array('id' => $id)), 'tickets', $id, $customer); // Send ticket by email self::send($id, true, $attachment); } return $id; } return false; }