public function delete($id, Forms $forms, Fields $field) { $fields = $field->where('forms_id', $id)->get(); foreach ($fields as $field) { $field->delete(); } $forms = $forms->where('id', $id)->first(); $forms->delete(); return redirect()->back()->with('success', 'Deleted Successfully'); }
/** * 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>   <input type="' . $value->type . '" name="' . $value->name . '"> ' . $val[0] . '    <input type="' . $value->type . '" name="' . $value->name . '"> ' . $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 . '   <input type="' . $value->type . '" name="' . $value->name . '">  ' . $check[0] . '</label><label class="radio-inline"><input type="' . $value->type . '" name="' . $value->name . '">  ' . $check[1] . '</label></br>'; } else { echo '<label>' . $value->label . '</label><input type="' . $value->type . '" class="form-control" name="' . $value->name . '" /></br>'; } } } } else { return null; } }
/** * 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; } }
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'); }