public function uploadFile() { $importfile = Input::file('upload_ex_cik'); //$cik_no_change = array(); Excel::load($importfile, function ($reader) { $result = $reader->all(); $cik_no_change = array(); //$i=0; foreach ($result as $in) { if ($in['cik'] != "") { $ckj = $in['cik']; $ckj_details = Cik::where('name', $ckj)->first(); if ($ckj_details) { array_push($cik_no_change, $ckj); //$cik_no_change[$i]=$ckj; //$i=$i+1; } else { $ckj_details = new Cik(); $ckj_details->name = $ckj; $ckj_details->status = 0; $ckj_details->save(); } } } //print_r($cik_no_change); }); //$response = Response::json($cik_no_change); // return $response; $allUser = User::where('role_id', 1)->get(); return View::make('admin.adminDashboard')->withUser($allUser); }
public function start() { $result = false; $fc = 'flash_cust_error'; $fm = 'Error in creating new CIK'; try { Log::info('*********start()*********'); $create_device_original_result = $this->create_device(); $create_device_result = json_decode($create_device_original_result); if (json_last_error() != JSON_ERROR_NONE) { return Redirect::back()->with($fc, 'Error in Create Device:: ' . $create_device_original_result); } $device_rid = $create_device_result->rid; $device_cik = $create_device_result->info->key; $data_sources = Config::get('app.exosite_data_sources'); $aliases_data = array(); $datasource_rids = array('speed' => '', 'dis' => '', 'location' => '', 'rpm' => '', 'coolant' => '', 'airintake' => '', 'engrunningtime' => '', 'critical' => ''); foreach ($data_sources as $data_source) { $format = $data_source['format']; $name = $data_source['name']; $unit = $data_source['unit']; $alias = $data_source['alias']; Log::info('*********create_device_data_source(' . $device_rid . $format . $name . $unit . ')*********'); $datasource_rid = $this->create_device_data_source($device_rid, $format, $name, $unit); if (json_last_error() != JSON_ERROR_NONE) { return Redirect::back()->with($fc, 'Error in Create Device Data Source:: ' . $datasource_rid); } $datasource_rids[$alias] = $datasource_rid; $aliases_data[] = array('alias', $datasource_rid, $alias); } Log::info('*********set_data_source_aliases()*********'); $set_data_source_aliases_result = $this->set_data_source_aliases($device_cik, $aliases_data); json_decode($set_data_source_aliases_result); if (json_last_error() != JSON_ERROR_NONE) { return Redirect::back()->with($fc, 'Error in Set Data Source Aliases:: ' . $set_data_source_aliases_result); } $uniqueId = uniqid('NewDevice' . date('Y-m-d_H:i:s_')); $exosite_dashboard_data = Config::get('app.exosite_dashboard_data'); $exosite_dashboard_data = str_replace('*NAME*', $uniqueId, $exosite_dashboard_data); $exosite_dashboard_data = str_replace('*RID*', $device_rid, $exosite_dashboard_data); $exosite_dashboard_data = str_replace('*CIK*', $device_cik, $exosite_dashboard_data); $exosite_dashboard_data = str_replace('*PORTAL*', Config::get('app.exosite_portal_id'), $exosite_dashboard_data); $exosite_dashboard_data = str_replace('*SPEED*', $datasource_rids['speed'], $exosite_dashboard_data); $exosite_dashboard_data = str_replace('*RPM*', $datasource_rids['rpm'], $exosite_dashboard_data); $exosite_dashboard_data = str_replace('*LOCATION*', $datasource_rids['location'], $exosite_dashboard_data); $exosite_dashboard_data = str_replace('*DIS*', $datasource_rids['dis'], $exosite_dashboard_data); $exosite_dashboard_data = str_replace('*CRITICAL*', $datasource_rids['critical'], $exosite_dashboard_data); $exosite_dashboard_data = str_replace('*COOLANT*', $datasource_rids['coolant'], $exosite_dashboard_data); $exosite_dashboard_data = str_replace('*AIRINTAKE*', $datasource_rids['airintake'], $exosite_dashboard_data); $exosite_dashboard_data = str_replace('*ENGRUNNINGTIME*', $datasource_rids['engrunningtime'], $exosite_dashboard_data); Log::info('*********create_portal_dashboard(' . $exosite_dashboard_data . ')*********'); $dashboard_id = $this->create_portal_dashboard($exosite_dashboard_data); if (json_last_error() != JSON_ERROR_NONE) { return Redirect::back()->with($fc, 'Error in Set Data Source Aliases:: ' . $dashboard_id); } $new_cik = new Cik(); $new_cik->name = $device_cik; $new_cik->dashboard_id = $dashboard_id; $new_cik->device_rid = $device_rid; $new_cik->speed_rid = $datasource_rids['speed']; $new_cik->dis_rid = $datasource_rids['dis']; $new_cik->location_rid = $datasource_rids['location']; $new_cik->rpm_rid = $datasource_rids['rpm']; $new_cik->coolant_rid = $datasource_rids['coolant']; $new_cik->airintake_rid = $datasource_rids['airintake']; $new_cik->engrunningtime_rid = $datasource_rids['engrunningtime']; $new_cik->critical_rid = $datasource_rids['critical']; $new_cik->save(); $result = true; } catch (Exception $exception) { Log::error($exception->getMessage()); return Redirect::back()->with($fc, $exception->getMessage()); } if ($result) { $fc = 'flash_cust_success'; $fm = 'New CIK created successfully'; } return Redirect::back()->with($fc, $fm); }