public function getAdd($id = null) { if ($id == null) { $new = new AutomateModel(); $new->name = ""; $data['row'] = $new; $data['technology'] = TechnologyModel::all(); $data['plot'] = PlotModel::join('his_technology', 'his_technology.id', '=', 'his_plot.id_tech')->select('his_plot.id', 'his_plot.name', 'his_technology.name as technology')->orderBy('his_plot.id_tech')->get(); $data['file'] = FileModel::where('filename', 'like', '%xls%')->get(); } else { $id = SiteHelpers::encryptID($id, true); $data['technology'] = TechnologyModel::all(); $data['plot'] = PlotModel::all(); $data['file'] = FileModel::where('filename', 'like', '%xls%'); $data['row'] = AutomateModel::where('id', $id)->first(); } return View::make('manual.form', $data); }
public function postSave() { $result = new AutomateModel(); $result->info = Input::get('info'); $result->save(); $named = NULL; $result->file_result = $named; $result->save(); $res = $result->id; $file_id = Input::get('files'); $plot = Input::get('id_plot'); $charts_data = array(); $index = 0; foreach ($file_id as $file) { $myfile = DB::table('his_file')->where('id', '=', $file)->first(); $filename = $myfile->filename; $path = public_path('uploads') . '/' . $filename; Excel::selectSheetsByIndex(1)->load($path, function ($reader) { // echo json_encode($reader->toArray()); // exit(); $this->value = $reader->toArray()[1]; $this->frekuensi = $reader->toArray()[0]; // var_dump($reader)->toArray();exit(); // } }); // print_r($this->value); // print_r($this->frekuensi); // exit(); $selected_plot = $plot[$index]; $range = DB::table('his_plot_data')->where('id_plot', '=', $selected_plot)->get(); $plot_name = DB::table('his_plot')->join('his_technology', 'his_technology.id', '=', 'his_plot.id_tech')->where('his_plot.id', '=', $selected_plot)->select('his_plot.name as name', 'his_plot.id as id', 'his_technology.name as technology')->first(); // print_r($plot_name);exit(); $xchart = array(); $ychart = array(); $z = 0; $new_x_chart = array(); $new_y_chart = array(); $new_yy_chart = array(); $title = ""; $flagin = 0; // print_r($range); exit(); foreach ($range as $key => $val) { if ($val->start == -999) { $xchart[$z] = ' <span style="text-decoration:underline;"><</span> ' . $val->end; } else { if ($val->end == 999) { $xchart[$z] = $val->start . ' < '; } else { $xchart[$z] = $val->start . ' < ' . $plot_name->name . ' <span style="text-decoration:underline;"><</span> ' . $val->end; } } $ychart[$z] = 0; $j = 0; foreach ($this->value as $roy) { if ($roy > $val->start && $roy <= $val->end) { $ychart[$z] = $ychart[$z] + $this->frekuensi[$j]; } else { if (!is_numeric($this->frekuensi[$j]) && strlen($this->frekuensi[$j]) > 5 && $flagin == 0) { $title = $title . ' ' . $this->frekuensi[$j]; $flagin = 1; } } $j++; } $z++; } $sum = array_sum($ychart); $series1Data = array(); $ind = 0; $yy = 0; for ($st = 0; $st < $z; $st++) { if ($ychart[$st] > 0) { $yy = $yy + $ychart[$st]; $series1Data[$xchart[$st]] = $ychart[$st]; $new_x_chart[$ind] = $xchart[$st]; $new_y_chart[$ind] = $ychart[$st] / $sum * 100; $new_yy_chart[$ind] = $yy / $sum * 100; $ind++; } } $tech = PlotModel::join('his_technology', 'his_technology.id', '=', 'his_plot.id_tech')->select('his_technology.name')->where('his_plot.id', $selected_plot)->first(); $charts_data['title'][$index] = $title; $charts_data['tech'][$index] = $tech->name; $charts_data['plot'][$index] = $selected_plot; $charts_data['x'][$index] = $new_x_chart; $charts_data['y'][$index] = $new_y_chart; $charts_data['yy'][$index] = $new_yy_chart; $index++; } $json = json_encode($charts_data['x'][0]); // print_r($json); // exit(); // $this->createPresentation(); $data['charts_data'] = $charts_data; $data['res'] = $res; return View::make('automate.result', $data); // return Redirect::to('automate/result') // ->with('charts_data', $charts_data); }
public function getIndex() { $data['plot'] = PlotModel::join('his_technology', 'id_tech', '=', 'his_technology.id')->select('his_technology.name as id_tech', 'his_plot.id', 'his_plot.name', 'his_plot.info')->get(); return View::make('plot.index', $data); }