コード例 #1
0
    /**
     * This Function to post the form for the ticket
     * @param type Form_name $name
     * @param type Form_details $details
     * @return type string
     */
    public function postForm($id, Help_topic $topic)
    {
        // dd($id);
        if ($id != 0) {
            $helptopic = $topic->where('id', '=', $id)->first();
            $custom_form = $helptopic->custom_form;
            $values = Fields::where('forms_id', '=', $custom_form)->get();
            if (!$values) {
            }
            if ($values) {
                foreach ($values as $value) {
                    if ($value->type == "select") {
                        $data = $value->value;
                        $value = explode(',', $data);
                        echo '<select class="form-control">';
                        foreach ($value as $option) {
                            echo '<option>' . $option . '</option>';
                        }
                        echo '</select></br>';
                    } elseif ($value->type == "radio") {
                        $type2 = $value->value;
                        $val = explode(',', $type2);
                        echo '<label class="radio-inline">' . $value->label . '</label>&nbsp&nbsp&nbsp<input type="' . $value->type . '" name="' . $value->name . '">&nbsp;&nbsp;' . $val[0] . '
		            	&nbsp&nbsp&nbsp<input type="' . $value->type . '" name="' . $value->name . '">&nbsp;&nbsp;' . $val[1] . '</br>';
                    } elseif ($value->type == "textarea") {
                        $type3 = $value->value;
                        $v = explode(',', $type3);
                        //dd($v);
                        if (array_key_exists(1, $v)) {
                            echo '<label>' . $value->label . '</label></br><textarea class=form-control rows="' . $v[0] . '" cols="' . $v[1] . '"></textarea></br>';
                        } else {
                            echo '<label>' . $value->label . '</label></br><textarea class=form-control rows="10" cols="60"></textarea></br>';
                        }
                    } elseif ($value->type == "checkbox") {
                        $type4 = $value->value;
                        $check = explode(',', $type4);
                        echo '<label class="radio-inline">' . $value->label . '&nbsp&nbsp&nbsp<input type="' . $value->type . '" name="' . $value->name . '">&nbsp&nbsp' . $check[0] . '</label><label class="radio-inline"><input type="' . $value->type . '" name="' . $value->name . '">&nbsp&nbsp' . $check[1] . '</label></br>';
                    } else {
                        echo '<label>' . $value->label . '</label><input type="' . $value->type . '" class="form-control"   name="' . $value->name . '" /></br>';
                    }
                }
            }
        } else {
            return null;
        }
    }
コード例 #2
0
 /**
  * Create Ticket
  * @param type $user_id
  * @param type $subject
  * @param type $body
  * @param type $helptopic
  * @param type $sla
  * @param type $priority
  * @return type string
  */
 public function create_ticket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data)
 {
     $max_number = Tickets::whereRaw('id = (select max(`id`) from tickets)')->first();
     if ($max_number == null) {
         $ticket_number = "AAAA-9999-9999999";
     } else {
         foreach ($max_number as $number) {
             $ticket_number = $max_number->ticket_number;
         }
     }
     $ticket = new Tickets();
     $ticket->ticket_number = $this->ticket_number($ticket_number);
     $ticket->user_id = $user_id;
     $ticket->dept_id = $dept;
     $ticket->help_topic_id = $helptopic;
     $ticket->sla = $sla;
     $ticket->assigned_to = $assignto;
     $ticket->status = '1';
     $ticket->priority_id = $priority;
     $ticket->source = $source;
     $ticket->save();
     $sla_plan = Sla_plan::where('id', '=', $sla)->first();
     $ovdate = $ticket->created_at;
     // dd($sla_plan->grace_period);
     $new_date = date_add($ovdate, date_interval_create_from_date_string($sla_plan->grace_period));
     $ticket->duedate = $new_date;
     $ticket->save();
     // dd($ticket->duedate);
     $ticket_number = $ticket->ticket_number;
     $id = $ticket->id;
     // store Form Data
     // Form Data comes from raising a ticket from client panel
     // dd($helptopic);
     if ($form_data != null) {
         $help_topic = Help_topic::where('id', '=', $helptopic)->first();
         $forms = Fields::where('forms_id', '=', $help_topic->custom_form)->get();
         foreach ($form_data as $key => $form_details) {
             foreach ($forms as $from) {
                 if ($from->name == $key) {
                     $form_value = new Ticket_Form_Data();
                     $form_value->ticket_id = $id;
                     $form_value->title = $from->label;
                     $form_value->content = $form_details;
                     $form_value->save();
                 }
             }
         }
     }
     // store collaborators
     // dd($headers);
     $this->store_collaborators($headers, $id);
     if ($this->ticket_thread($subject, $body, $id, $user_id) == true) {
         return $ticket_number;
     }
 }
コード例 #3
0
 /**
  * getform
  * @param type Help_topic $topic 
  * @return type
  */
 public function getForm(Help_topic $topic)
 {
     if (\Config::get('database.install') == '%0%') {
         return \Redirect::route('license');
     }
     if (System::first()->status == 1) {
         $topics = $topic->get();
         return view('themes.default1.client.helpdesk.form', compact('topics'));
     } else {
         return \Redirect::route('home');
     }
 }
コード例 #4
0
 /**
  * Remove the specified resource from storage.
  * @param type int $id
  * @param type Help_topic $topic
  * @return type Response
  */
 public function destroy($id, Help_topic $topic)
 {
     try {
         $topics = $topic->whereId($id)->first();
         /* Check whether function success or not */
         if ($topics->delete() == true) {
             /* redirect to Index page with Success Message */
             return redirect('helptopic')->with('success', 'Helptopic Deleted Successfully');
         } else {
             /* redirect to Index page with Fails Message */
             return redirect('helptopic')->with('fails', 'Helptopic can not Delete');
         }
     } catch (Exception $e) {
         /* redirect to Index page with Fails Message */
         return redirect('helptopic')->with('fails', 'Helptopic can not Create');
     }
 }
コード例 #5
0
 /**
  * Reademails
  * @return type
  */
 public function readmails(Emails $emails, Email $settings_email, System $system)
 {
     // $path_url = $system->first()->url;
     if ($settings_email->first()->email_fetching == 1) {
         if ($settings_email->first()->all_emails == 1) {
             // $helptopic = $this->TicketController->default_helptopic();
             // $sla = $this->TicketController->default_sla();
             $email = $emails->get();
             foreach ($email as $e_mail) {
                 $helptopic = $e_mail->help_topic;
                 $get_helptopic = Help_topic::where('id', '=', $helptopic)->first();
                 $sla = $get_helptopic->sla_plan;
                 $dept = $e_mail->department;
                 $host = $e_mail->fetching_host;
                 $port = $e_mail->fetching_port;
                 $protocol = $e_mail->mailbox_protocol;
                 $get_mailboxprotocol = MailboxProtocol::where('id', '=', $protocol)->first();
                 $protocol = $get_mailboxprotocol->value;
                 $imap_config = '{' . $host . ':' . $port . $protocol . '}INBOX';
                 $password = Crypt::decrypt($e_mail->password);
                 $mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__);
                 $mails = array();
                 $mailsIds = $mailbox->searchMailBox('SINCE ' . date('d-M-Y', strtotime("-1 day")));
                 if (!$mailsIds) {
                     die('Mailbox is empty');
                 }
                 foreach ($mailsIds as $mailId) {
                     $overview = $mailbox->get_overview($mailId);
                     $var = $overview[0]->seen ? 'read' : 'unread';
                     if ($var == 'unread') {
                         $mail = $mailbox->getMail($mailId);
                         if ($settings_email->first()->email_collaborator == 1) {
                             $collaborator = $mail->cc;
                         } else {
                             $collaborator = null;
                         }
                         $body = $mail->textHtml;
                         if ($body == null) {
                             $body = $mailbox->backup_getmail($mailId);
                             $body = str_replace('\\r\\n', '<br/>', $body);
                             // var_dump($body);
                         }
                         $date = $mail->date;
                         $datetime = $overview[0]->date;
                         $date_time = explode(" ", $datetime);
                         $date = $date_time[1] . "-" . $date_time[2] . "-" . $date_time[3] . " " . $date_time[4];
                         $date = date('Y-m-d H:i:s', strtotime($date));
                         // dd($date);
                         if (isset($mail->subject)) {
                             $subject = $mail->subject;
                         } else {
                             $subject = "No Subject";
                         }
                         // dd($subject);
                         $fromname = $mail->fromName;
                         $fromaddress = $mail->fromAddress;
                         $ticket_source = Ticket_source::where('name', '=', 'email')->first();
                         $source = $ticket_source->id;
                         $phone = "";
                         $priority = $get_helptopic->priority;
                         // Ticket_Priority::where('')
                         $assign = $get_helptopic->auto_assign;
                         $form_data = null;
                         $result = $this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data);
                         // dd($result);
                         if ($result[1] == true) {
                             $ticket_table = Tickets::where('ticket_number', '=', $result[0])->first();
                             $thread_id = Ticket_Thread::where('ticket_id', '=', $ticket_table->id)->max('id');
                             // $thread_id = Ticket_Thread::whereRaw('id = (select max(`id`) from ticket_thread)')->first();
                             $thread_id = $thread_id;
                             foreach ($mail->getAttachments() as $attachment) {
                                 $support = "support";
                                 // echo $_SERVER['DOCUMENT_ROOT'];
                                 $dir_img_paths = __DIR__;
                                 $dir_img_path = explode('/code', $dir_img_paths);
                                 // dd($attachment->filePath);
                                 $filepath = explode('../../../../../public', $attachment->filePath);
                                 // var_dump($attachment->filePath);
                                 // dd($filepath);
                                 // $path = $dir_img_path[0]."/code/public/".$filepath[1];
                                 $path = public_path() . $filepath[1];
                                 // dd($path);
                                 $filesize = filesize($path);
                                 $file_data = file_get_contents($path);
                                 $ext = pathinfo($attachment->filePath, PATHINFO_EXTENSION);
                                 $imageid = $attachment->id;
                                 $string = str_replace('-', '', $attachment->name);
                                 $filename = explode('src', $attachment->filePath);
                                 $filename = str_replace('\\', '', $filename);
                                 $body = str_replace("cid:" . $imageid, $filepath[1], $body);
                                 $pos = strpos($body, $filepath[1]);
                                 if ($pos == false) {
                                     if ($settings_email->first()->attachment == 1) {
                                         $upload = new Ticket_attachments();
                                         $upload->file = $file_data;
                                         $upload->thread_id = $thread_id;
                                         $upload->name = $filepath[1];
                                         $upload->type = $ext;
                                         $upload->size = $filesize;
                                         $upload->poster = "ATTACHMENT";
                                         $upload->save();
                                     }
                                 } else {
                                     $upload = new Ticket_attachments();
                                     $upload->file = $file_data;
                                     $upload->thread_id = $thread_id;
                                     $upload->name = $filepath[1];
                                     $upload->type = $ext;
                                     $upload->size = $filesize;
                                     $upload->poster = "INLINE";
                                     $upload->save();
                                 }
                                 unlink($path);
                             }
                             $body = Encoding::fixUTF8($body);
                             $thread = Ticket_Thread::where('id', '=', $thread_id)->first();
                             $thread->body = $this->separate_reply($body);
                             $thread->save();
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #6
0
 /**
  * Show the form for editing the specified resource.
  * @param type int $id
  * @param type Department $department
  * @param type Help_topic $help
  * @param type Emails $email
  * @param type Priority $priority
  * @param type MailboxProtocol $mailbox_protocol
  * @return type Response
  */
 public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $priority, MailboxProtocol $mailbox_protocol)
 {
     try {
         $emails = $email->whereId($id)->first();
         $departments = $department->get();
         $helps = $help->get();
         $priority = $priority->get();
         $mailbox_protocols = $mailbox_protocol->get();
         return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails'));
     } catch (Exception $e) {
         return view('404');
     }
 }
コード例 #7
0
 /**
  * get the form for Ticket setting page
  * @param type Ticket $ticket
  * @param type Sla_plan $sla
  * @param type Help_topic $topic
  * @param type Priority $priority
  * @return type Response
  */
 public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority)
 {
     try {
         /* fetch the values of ticket from ticket table */
         $tickets = $ticket->whereId('1')->first();
         /* Fetch the values from SLA Plan table */
         $slas = $sla->get();
         /* Fetch the values from Help_topic table */
         $topics = $topic->get();
         /* Direct to Ticket Settings Page */
         return view('themes.default1.admin.helpdesk.settings.ticket', compact('tickets', 'slas', 'topics', 'priority'));
     } catch (Exception $e) {
         return view('404');
     }
 }
コード例 #8
0
 /**
  * Remove the specified resource from storage.
  * @param type int $id
  * @param type Help_topic $topic
  * @return type Response
  */
 public function destroy($id, Help_topic $topic, Ticket $ticket_setting)
 {
     $ticket_settings = $ticket_setting->where('id', '=', '1')->first();
     if ($ticket_settings->help_topic == $id) {
         return redirect('departments')->with('fails', 'You cannot delete default department');
     } else {
         $tickets = DB::table('tickets')->where('help_topic_id', '=', $id)->update(['help_topic_id' => $ticket_settings->help_topic]);
         if ($tickets > 0) {
             if ($tickets > 1) {
                 $text_tickets = "Tickets";
             } else {
                 $text_tickets = "Ticket";
             }
             $ticket = '<li>' . $tickets . ' ' . $text_tickets . ' have been moved to default Help Topic</li>';
         } else {
             $ticket = "";
         }
         $emails = DB::table('emails')->where('help_topic', '=', $id)->update(['help_topic' => $ticket_settings->help_topic]);
         if ($emails > 0) {
             if ($emails > 1) {
                 $text_emails = "Emails";
             } else {
                 $text_emails = "Email";
             }
             $email = '<li>' . $emails . ' System ' . $text_emails . ' have been moved to default Help Topic</li>';
         } else {
             $email = "";
         }
         $message = $ticket . $email;
         $topics = $topic->whereId($id)->first();
         /* Check whether function success or not */
         try {
             $topics->delete();
             /* redirect to Index page with Success Message */
             return redirect('helptopic')->with('success', 'Helptopic Deleted Successfully' . $message);
         } catch (Exception $e) {
             /* redirect to Index page with Fails Message */
             return redirect('helptopic')->with('fails', 'Helptopic can not Delete' . '<li>' . $e->errorInfo[2] . '</li>');
         }
     }
 }
コード例 #9
0
 public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic)
 {
     $fields = $field->where('forms_id', $id)->get();
     $help_topics = $help_topic->where('custom_form', '=', $id)->get();
     foreach ($help_topics as $help_topic) {
         $help_topic->custom_form = null;
         $help_topic->save();
     }
     foreach ($fields as $field) {
         $field->delete();
     }
     $forms = $forms->where('id', $id)->first();
     $forms->delete();
     return redirect()->back()->with('success', 'Deleted Successfully');
 }