public function activationdetails($id) { $this->view->activation = Activation::find_by_id($id); $this->view->render("support/activationdetails"); }
public function getCloseSchedule($id) { $schedule = Schedule::find_by_id($id); //var_dump($_POST['status']); //Change in schedule should result in change //in ticket and activation call status /* * checks if $activityShed is a ticket * if not then it is an activation * call change the status corresponding to * schedule status for each condition * */ if ($_REQUEST['status'] == "Open") { // Condition to check if schedule is Open $schedule->status = "Open"; $activityShed = Ticket::find_by_id($schedule->ticket_id); if ($activityShed) { $activityShed->status = 'Open'; $activityShed->datemodified = date("Y-m-d H:i:s"); $activityShed->update(); } else { $activityShed = Activation::find_by_id($schedule->ticket_id); if ($activityShed) { $activityShed->status = "Open"; $activityShed->created_at = date("Y-m-d H:i:s"); $activityShed->update(); } } $schedule->update(); return true; } elseif ($_REQUEST['status'] == "Closed") { // Condition to check if schedule is closed $schedule->status = "Closed"; $activityShed = Ticket::find_by_id($schedule->ticket_id); if ($activityShed) { $activityShed->status = 'Closed'; $activityShed->datemodified = date("Y-m-d H:i:s"); $activityShed->update(); } else { $activityShed = Activation::find_by_id($schedule->ticket_id); if ($activityShed) { $activityShed->status = "Closed"; $activityShed->created_at = date("Y-m-d H:i:s"); $activityShed->update(); } } $schedule->update(); return true; } elseif ($_REQUEST['status'] == "In Progress") { // Condition to check if schedule is in progress $schedule->status = "In Progress"; $activityShed = Ticket::find_by_id($schedule->ticket_id); if ($activityShed) { $activityShed->status = 'Admin Reply'; // admin reply stands for response for administrator for response to ticket or engineer assigned $activityShed->datemodified = date("Y-m-d H:i:s"); } else { $activityShed = Activation::find_by_id($schedule->ticket_id); if ($activityShed) { $activityShed->status = "In Progress"; $activityShed->created_at = date("Y-m-d H:i:s"); $activityShed->update(); } } $schedule->update(); return true; } else { return false; } //echo $schedule->update(); }
public function updateActivate() { global $database; $error = array(); $activate = Activation::find_by_id($_POST['pgid']); $input = $_REQUEST; if (isset($_POST["contact_name"])) { if ($_POST['contact_name'] != "") { $activate->contact_name = $_POST['contact_name']; } else { array_push($error, "Contact Name"); } } else { array_push($error, "Contact Name"); } if (isset($_POST["terminal_id"])) { if ($_POST['terminal_id'] != "") { $activate->contact_name = $_POST['terminal_id']; } else { array_push($error, "Terminal ID"); } } else { array_push($error, "Terminal ID"); } if (empty($error)) { if (!empty($input)) { foreach ($input as $key => $value) { $activate->{$key} = $value; } $activate->client_id = $_SESSION['client_ident']; $activate->updated_at = date("Y-m-d H:i:s"); } if ($activate->update()) { return 1; //returns 1 on success } else { return 2; //unexpected Error } } else { /* $message = "Please check the following errors: "; $lenght = count($error); for($i = 0; $i < $lenght; $i++){ $message = $message.$error[$i].", "; } echo "<div data-alert class='alert-box error'><a href='#' class='close'>×</a>$message</div>";*/ return 3; } }
public function getActivationData($id) { return Activation::find_by_id($id); }
public function createSchedule($id = "") { if (!empty($_POST['cid']) && !empty($_POST['empid'])) { $thisclientproduct = Cproduct::find_by_id((int) preg_replace('#[^0-9]#i', '', $_POST['cid'])); $empdata = explode("_", $_POST['empid']); $thisemployee = Employee::find_by_staff_id($empdata[0]); //print_r($thisemployee); $thisSchedule = new Schedule(); $clientTicket = Ticket::find_by_id((int) preg_replace('#[^0-9]#i', '', $id)); $thisclientproduct = Cproduct::find_by_id((int) preg_replace('#[^0-9]#i', '', $clientTicket->prod_id)); if ($_POST['mtype'] != "Activation" && ($_POST['Corrective'] || $_POST['Preventive'])) { $clientTicket->status = "Admin Reply"; $clientTicket->datemodified = date("Y-m-d H:i:s"); $thisSchedule->status = "In Progress"; } else { $clientTicket = Activation::find_by_id((int) preg_replace('#[^0-9]#i', '', $id)); if ($clientTicket) { $thisclientproduct = Cproduct::find_by_id((int) preg_replace('#[^0-9]#i', '', $clientTicket->prod_id)); $clientTicket->status = "In Progress"; $clientTicket->updated_at = date("Y-m-d H:i:s"); } } $thisSchedule->status = "In Progress"; $thisSchedule->emp_id = $thisemployee->id; $thisSchedule->emp_name = $thisemployee->emp_fname . " " . $thisemployee->emp_lname; $thisSchedule->client_id = $thisclientproduct->client_id; $thisClient = Client::find_by_id($thisclientproduct->client_id); $thisSchedule->prod_id = $thisclientproduct->id; $thisSchedule->ticket_id = $id; $thisSchedule->prod_name = $thisclientproduct->prod_name; // exit; /** * this is to check if ticket * is in existence */ //print_r($theUser); global $session; //$partTicket = ($id!="") ? Ticket::find_by_id($id) : ""; // get the ticket to get details needed for sending mail $theUser = Employee::find_by_id($_SESSION["emp_ident"]); // get cse detail to retrieve email $thisSchedule->s_date = !empty($_POST['taskdate']) ? $_POST['taskdate'] : date("Y-m-d"); $cemail = array(); $cemail = !empty($_POST['cemail']) && isset($_POST['cemail']) ? explode(",", $_POST['cemail']) : array('*****@*****.**'); array_push($cemail, $thisemployee->emp_email, is_array($clientTicket) ? $clientTicket->contact_email : "", $theUser->emp_email, $thisClient->email); array_push($cemail, $clientTicket->contact); array_push($cemail, $thisClient->contact_email); array_push($cemail, $thisClient->email); //print_r($cemail); $thisSchedule->issue = $_POST["tissue"]; $thisSchedule->datecreated = date("Y-m-d H:i:s"); $thisSchedule->maint_type = $_POST['mtype']; $subject = "Maintenance Alert"; $smsmsg = "Maintenance alert for" . $thisclientproduct->terminal_id . " " . $thisclientproduct->prod_name . "at"; $smsmsg .= $thisclientproduct->install_location . "," . $thisclientproduct->branch; $smsmsg .= "\r\n issue:" . $_POST["tissue"] . "\r\n"; $msg = "<h3>Maintenance Detail</h3> <hr />"; $msg .= "<p><strong>Terminal ID: </strong>{$thisclientproduct->terminal_id} </p>"; $msg .= "<p><strong>Machine: </strong>{$thisclientproduct->prod_name} </p>"; $msg .= "<p><strong>Client: </strong> {$thisClient->name}</p>"; $msg .= "<p><strong>Location: </strong>{$thisclientproduct->install_location} {$thisclientproduct->branch} {$thisclientproduct->install_city} </p>"; $msg .= "<p><strong>Complaint: </strong>" . (!empty($_POST['tissue']) ? $_POST['tissue'] : $clientTicket->issue) . "</p>"; $msg .= "<br /><br /> <h4>Technician Details</h4> <hr />"; $msg .= "<p><strong>Name: </strong>" . $thisemployee->emp_fname . " " . $thisemployee->emp_lname . "</p>"; $msg .= "<p><strong>Email: </strong>" . $thisemployee->emp_email . "</p>"; $msg .= "<p><strong>Telephone: </strong>" . $thisemployee->emp_phone . "</p>"; $msg .= "<br /><br /><h4>Scheduled Date</h4> <hr />"; $msg .= "<p><strong>{$thisSchedule->s_date}</strong></p><br /><br /><br /><br />"; $newReply = new Ticketreply(); $newReply->sender_id = $_SESSION["emp_ident"]; $newReply->ticket_id = $id; $newReply->sender_name = $theUser->emp_fname . " " . $theUser->emp_lname; $newReply->sender_type = "Admin"; $newReply->message = $msg; $newReply->datecreated = date("Y-m-d H:i:s"); $newReply->datemodified = date("Y-m-d H:i:s"); //$newReply->create(); /** * the transaction log is created * to ensure that the product already * has history and cannot be deleted */ $Tlog2 = new Transaction(); $Tlog2->com_id = $thisclientproduct->main_id; $Tlog2->trans_type = "TASK ASSIGNMENT"; $Tlog2->trans_description = "Corrective Maintenance task assigned to " . $thisemployee->emp_fname . " " . $thisemployee->emp_lname . ""; $Tlog2->datecreated = date("Y-m-d H:i:s"); $Tlog2->datemodified = date("Y-m-d H:i:s"); $Tlog2->user_id = $_SESSION['emp_ident']; // print_r($msg); if ($newReply->create()) { $thisSchedule->create(); $clientTicket->datemodified = date("Y-m-d H:i:s"); $clientTicket->update(); $Tlog2->create(); //$thisemployee->emp_phone sendSms($thisemployee->emp_phone, $smsmsg); sendSms($thisClient->contact_phone, $smsmsg); sendSms($thisClient->phone, $smsmsg); $this->sendMail($thisSchedule->emp_name, $subject, $msg, $cemail); return true; } else { return false; } } }