public function createClientReply($id = "")
 {
     if (!empty($_POST["issue"]) && !empty($_POST["cname"])) {
         $newReply = new Ticketreply();
         $newReply->sender_id = $_SESSION["client_ident"];
         $newReply->ticket_id = $id;
         $theCustomer = Client::find_by_id($_SESSION["client_ident"]);
         $newReply->sender_name = $theCustomer->name;
         $newReply->sender_type = "Client";
         $newReply->message = $_POST['subject'] . " " . $_POST['issue'];
         $newReply->datecreated = date("Y-m-d H:i:s");
         if ($newReply->create()) {
             $partTicket = Ticket::find_by_id($id);
             $partTicket->status = "Customer Reply";
             $partTicket->datemodified = date("Y-m-d H:i:s");
             $partTicket->update();
             $this->sendMail($newReply->id);
             return 1;
         } else {
             return 2;
         }
     } else {
         return 3;
     }
 }
Exemplo n.º 2
0
 /**
  * function to handle client 
  * reply to a ticket
  */
 public function createAdminReply($id)
 {
     if (isset($_POST["issues"]) && isset($_POST["conname"])) {
         $newReply = new Ticketreply();
         $newReply->sender_id = $_SESSION["emp_ident"];
         $newReply->ticket_id = $id;
         $theUser = Employee::find_by_id($_SESSION["emp_ident"]);
         $cemail = array();
         $newReply->sender_name = $theUser->emp_fname . " " . $theUser->emp_lname;
         $newReply->sender_type = "Admin";
         $newReply->message = $_POST['issues'];
         $newReply->datecreated = date("Y-m-d H:i:s");
         $cemail = !empty($_POST['cemail']) ? explode(",", $_POST['cemail']) : "";
         $partTicket = Ticket::find_by_id($id);
         // print_r($partTicket);
         array_push($cemail, $partTicket->contact_email, $theUser->emp_email);
         $client = Client::find_by_id($partTicket->client_id);
         // print_r($client);
         $partTicket->status = "Admin Reply";
         $partTicket->datemodified = date("Y-m-d H:i:s");
         //print_r($cemail);
         //mail("*****@*****.**","Robert Johnson Holdings, Technical Support" , "all good");
         $this->sendMail($newReply->sender_name, "Robert Johnson Holdings(Technical Support)", $newReply->message, $cemail);
         if ($newReply->create()) {
             $partTicket->update();
             return 1;
         } else {
             return 2;
         }
     } else {
         return 3;
     }
 }
 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;
         }
     }
 }