/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { session_start(); $loguser = $_SESSION['user_id']; $data = Request::all(); $data['modified_by'] = $loguser; if ($_POST['problem'] == '') { unset($data['problem']); } $ticket = App\ticket::findOrFail($id); $ticket->update($data); // $log = new crm_log; // $log->add_log("ticket",$_GET['tid'],"update"); // add a log if ($_POST['problem'] != '') { $problem_data['ticket_id'] = $id; $problem_data['problem'] = $_POST['problem']; $problem_data['owner'] = $loguser; App\ticket_problem::create($problem_data); } return redirect('ticket'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { session_start(); $log = new Log(); $data = Request::all(); $loguser = $_SESSION['user_id']; $call_log_detials = App\call_log::where('deleted', '0')->find($id); if ($call_log_detials->call_type == "Sales") { $sales_detail = App\sale::where('call_log_id', $id)->first(); $row = $sales_detail; if ($_POST['status'] != $row->status) { $data_status = ['sales_id' => $row->id, 'new_status' => $data['status'], 'old_status' => $row->status, 'changed_by' => $loguser]; App\status_history::create($data_status); } $data_call_log = ['call_modified_by' => $loguser, 'assignedto' => $data['assignedto'], 'group_id' => $data['group_id']]; App\call_log::find($id)->update($data_call_log); $log->add_log("call_log", $id, "update"); // add a log $data['modified_by'] = $loguser; App\sale::find($row->id)->update($data); $log->add_log("sales", $row->id, "update"); // add a log id must change } elseif ($call_log_detials->call_type == "Inquiry") { $data_call_log = ['call_modified_by' => $loguser, 'assignedto' => $data['assignedto'], 'group_id' => $data['group_id']]; App\call_log::find($id)->update($data_call_log); $log->add_log("call_log", $id, "update"); // add a log $inquiry_detail = App\inquiry::where('call_log_id', $id)->first(); $row = $inquiry_detail; if ($data['status'] == "complete") { $endtime = date('Y-m-d H:i:s'); } else { $endtime = NULL; } $data['inquiry_end_time'] = $endtime; App\inquiry::find($row->id)->update($data); $log->add_log("inquiry", $row->id, "update"); // add a log } elseif ($call_log_detials->call_type == "Tickets") { $data_call_log = ['call_modified_by' => $loguser, 'assignedto' => $data['assignedto'], 'group_id' => $data['group_id']]; App\call_log::find($id)->update($data_call_log); $log->add_log("call_log", $id, "update"); // add a log $ticket_detail = App\ticket::where('call_log_id', $id)->first(); $row = $ticket_detail; $data['modified_by'] = $loguser; App\ticket::find($row->id)->update($data); $log->add_log("ticket", $row->id, "update"); // add a log if ($data['problem'] != '') { $data_ticket_problem = ['ticket_id' => $row->id, 'problem' => $data['problem'], 'owner' => $loguser]; App\ticket_problem::create($data_ticket_problem); } } return redirect('call_log'); }