function close() { $sql = 'UPDATE ' . TICKET_TABLE . ' SET status=' . db_input('closed') . ',staff_id=0,isoverdue=0,duedate=NULL,updated=NOW(),closed=NOW() ' . ' WHERE ticket_id=' . db_input($this->getId()); // NEW MOD CODE STARTS HERE // get dept object $dept = new Dept($this->getDeptId()); // get email object for current $email = new Email($this->getEmail()); // see if the department ticket is configured for is setup for auto response on // new tickets. I have some departments I don't want notification on close // A new attribute could be used, but I piggy backed on an existing as it // suited my needs fine for now. if ($dept->autoRespONNewTicket()) { // small debug message that prints at the top of ticket screen so I know // an email was sent print '<div id="system_notice"><b>Email enviado</b></div>'; // subject for email -- totally configurable. code in previous post was // showing the internal ID, not the external ID a user would need $subj = "Solicitud de soporte #" . $this->getExtId() . " cerrada"; // I added a link in the body to the ticket for the user if they wanted // to view it just after I closed it. $body = "El ticket #" . $this->getExtId() . " fue cerrado.\n\nPuede consultar la información sobre la consulta en:\nhttp://soporte.chilesinpapeleo.cl/view.php?e=" . $this->getEmail() . "&t=" . $this->getExtId() . "\n\nSaludos,\nMesa de soporte\nUnidad de Modernización y Gobierno Digital"; // this sends out the email ensuring the "From" address is whatever // is configured for the department $dept->getEmail()->send($this->getEmail(), $subj, $body); } // NEW MOD CODE ENDS HERE return db_query($sql) && db_affected_rows() ? true : false; }