Tuesday, March 20, 2018

how to view selected dates back on the same page after executing function - development

how to view selected dates back on the same page after executing function

so i have a form like so:

<form role="form" action="" autocomplete="off" method="POST">
  
  <div class="form-group-attached">
    <div class="row">
      <div class="col-lg-6">
        <div class="form-group form-group-default required" >
          <label>From</label>
          <input type="date" class="form-control" name="from" required>
        </div>
      </div>
      <div class="col-lg-6">
        <div class="form-group form-group-default required" >
          <label>To</label>
          <input type="date" class="form-control" name="to" required>
        </div>
      </div>
    </div>
  </div>
  <br/>
  <button class="btn alt-btn-black btn-sm alt-btn pull-right" type="submit">Filter Date</button>
</form>

and there is a graph on that same page. so at first the graph displays data for all the dates.. so i set the form for user to select from and to dates so they can filter the chart to the dates selected.. so in my controller;

public function viewgraphByDate(Request $request, $companyID)
{
$companyID = $this->decode($companyID);

$match = count(DiraChatLog::where('company_id', $companyID)->where('date_access', '>=', $request->from)->where('date_access', '<=', $request->to)->where('status', 'Match')->get());
$noAnswer = count(DiraChatLog::where('company_id', $companyID)->where('date_access', '>=', $request->from)->where('date_access', '<=', $request->to)->where('status', 'No Answer')->get());
$missing = count(DiraChatLog::where('company_id', $companyID)->where('date_access', '>=', $request->from)->where('date_access', '<=', $request->to)->where('status', 'Missing')->get());
// dd($match,$noAnswer,$missing);

$email = count(DiraResponses::where('company_id', $companyID)->where('created_at', '>=', $request->from)->where('created_at', '<=', $request->to)->where('type', 'email')->where('format', 'email')->get());
$pdf = count(DiraResponses::where('company_id', $companyID)->where('created_at', '>=', $request->from)->where('created_at', '<=', $request->to)->where('type', 'media')->where('format', 'pdf')->get());
$image = count(DiraResponses::where('company_id', $companyID)->where('created_at', '>=', $request->from)->where('created_at', '<=', $request->to)->where('type', 'media')->where('format', 'image')->get());
$video = count(DiraResponses::where('company_id', $companyID)->where('created_at', '>=', $request->from)->where('created_at', '<=', $request->to)->where('type', 'media')->where('format', 'video')->get());
// dd($email,$pdf,$image,$video);

$text = count(DiraResponses::where('company_id', $companyID)->where('type', 'text')->where('format', 'text')->get());
$totalMedia = $email + $pdf + $image + $video;
// dd($text,$totalMedia);

$from = $request->from;
$to = $request->to;
// dd($from, $to);

$companyID = $this->encodeID($companyID);

return view('AltHr.Chatbot.viewgraph', compact('companyID','match','noAnswer','missing','email','pdf','image','video','text','totalMedia','from','to'));
}

as you can see this function returns to the same page with the graph showing the dates selected by user.. now i want to know how can i display to user the dates the selected? either in the input date box or out is fine..?



from Laravel Questions and Answers https://laravelquestions.com/php/how-to-view-selected-dates-back-on-the-same-page-after-executing-function/
via Lzo Media

No comments:

Post a Comment