public function getReport() { $flagReport = Input::get('flagreport'); if ($flagReport == 1) { //get report publisher last 12 month before month now $dateNow = date('Y-m-d'); $this->dateEnd = date('Y-m-d', strtotime($dateNow . "+ 1 day")); $arrDate = getMonthBefore(); end($arrDate); $dateLast = key($arrDate) . "-01"; $this->dateLast = date('Y-m-d', strtotime($dateLast . "- 1 day")); $data = $this->model->GetListByDate($this->dateEnd, $this->dateLast); //reverse array $arrDate = array_reverse($arrDate); //get report json $arrJson = $this->getReportJson($arrDate, $data, $flagReport); } else { //get report monthly $monthly = Input::get('monthly'); //math number day of an month list($y, $m) = explode('-', $monthly); $numDay = cal_days_in_month(CAL_GREGORIAN, $m, $y); $dateNow = date('Y-m'); if ($dateNow == $monthly) { // if month current $numDay = date('j'); //get number day current } //get days of monthly $arrDate = $this->getDaysOfMonthly($numDay); end($arrDate); $dateLast = $monthly . "-01"; $this->dateLast = date('Y-m-d', strtotime($dateLast . "- 1 day")); $dateEnd = $monthly . "-" . current($arrDate); $this->dateEnd = date('Y-m-d', strtotime($dateEnd . " + 1 day")); //get data monthly $data = $this->model->GetListByDate($this->dateEnd, $this->dateLast); //get report json $arrJson = $this->getReportJson($arrDate, $data, $flagReport); } return $arrJson; }
<form class="filter-form form-horizontal" role="form"> <div class="row"> <div class="col-sm-12"> <div class="row"> <div class="col-sm-4"> <h3 class="title-view-publisher text-uppercase">Application statistic</h3> </div> <div class="col-sm-8"> <div class="pull-right"> <input type="radio" checked name="show-report" class="show-report" value="1"> Show all (Last 12 Month before {{$monthDate}}) <input type="radio" name="show-report" class="show-report" value="2"> Show Monthly <?php $M = getMonthBefore(); ?> <select name="select-monthly" id="select-monthly" > <option value="">Choose...</option> @foreach($M as $key=>$value) <option value="{{$key}}">{{$value}}</option> @endforeach </select> <button type="button" id="display-report" class="btn btn-primary">Display Report</button> </div> <div class="clearfix"></div> </div> </div> </div> <div class="col-sm-12">