public function stores() { $accounts = Account::all(); $data = array(); foreach ($accounts as $account) { $customers = Customer::where('account_id', $account->id)->get(); $account_children = array(); foreach ($customers as $customer) { $areas = Area::where('customer_id', $customer->id)->get(); $customer_children = array(); foreach ($areas as $area) { $regions = Region::where('area_id', $area->id)->get(); $area_children = array(); foreach ($regions as $region) { $distributors = Distributor::where('region_id', $region->id)->get(); $region_children = array(); foreach ($distributors as $distributor) { $stores = Store::where('distributor_id', $distributor->id)->get(); $distributor_children = array(); foreach ($stores as $store) { $distributor_children[] = array('title' => $store->store, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id . "." . $distributor->id . "." . $store->id); } $region_children[] = array('select' => true, 'title' => $distributor->distributor, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id . "." . $distributor->id, 'children' => $distributor_children); } $area_children[] = array('select' => true, 'title' => $region->region, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id, 'children' => $region_children); } $customer_children[] = array('select' => true, 'title' => $area->area, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id, 'children' => $area_children); } $account_children[] = array('select' => true, 'title' => $customer->customer, 'isFolder' => true, 'key' => $account->id . "." . $customer->id, 'children' => $customer_children); } $data[] = array('title' => $account->account, 'isFolder' => true, 'key' => $account->id, 'children' => $account_children); } return response()->json($data); }
public function getAllArea() { // 全部地下城信息取得 // $areas = Area:: // return Response::json(Area::all()); return Response::json(Area::where('status', '1')->get()); }
public function getLowerById() { $id = Input::get('id'); $area = Area::where('preid', $id)->get(); if (count($area) == 0) { return json_encode(array('result' => false)); } else { return json_encode(array('result' => true, 'area' => $area)); } }
public function showAreas(Request $request) { $json['results'] = []; $q = $request->input('q'); $results = Area::where('name', 'LIKE', "%{$q}%")->take(10)->lists('name', 'id'); foreach ($results as $key => $value) { $json['results'][] = array('id' => $key, 'text' => $value); } return json_encode($json); }
/** * Bind data to the view. * * @param View $view * @return void */ public function compose(View $view) { $categories = Category::with('children', 'products')->where('parent_id', '=', 0)->orderBy('did')->get(); $hotpros_id = Salesstats::groupBy('product_id')->take(16)->get(); $hotpros_id = $hotpros_id->lists('product_id'); $hotpros = Product::with('images')->has('images')->has('prices')->wherein('id', $hotpros_id)->take(16)->get(); $globals = DB::table('globalsettings')->get(); $dts = DB::table('deliverytimes')->where('active', true)->get(); foreach ($dts as $dt) { $dt->start = Carbon::parse($dt->start)->format('h:ia'); $dt->stop = Carbon::parse($dt->stop)->format('h:ia'); } $settings = []; foreach ($globals as $global) { $name = $global->name; $value = $global->value; $settings[$name] = $value; } $offers = Offer::with(['categories', 'categories.products' => function ($q) { $q->has('images'); }, 'brands', 'brands.products' => function ($q) { $q->has('images'); }, 'products' => function ($q) { $q->has('images'); }, 'products.images', 'products.prices'])->where('active', true)->where('start', '<=', Carbon::today()->toDateString())->where('end', '>=', Carbon::today()->toDateString())->take(16)->get(); //dd($offers); $feedbacks = Feedback::with('user')->take(8)->get(); if ($user = Sentinel::check()) { $user = User::findorfail($user->id); $flashes = Flashtext::where('active', '1')->get(); $areas = Area::where('deliverable', '1')->get(); $viewpros_id = Viewstats::where('user_id', $user->id)->take(16)->get(); //dd($viewpros_id); $viewpros_id = $viewpros_id->lists('product_id'); $viewpros = Product::with('images')->has('images')->has('prices')->wherein('id', $viewpros_id)->take(16)->get(); $view->with(['user' => $user, 'flashes' => $flashes, 'areas' => $areas, 'hotpros' => $hotpros, 'viewpros' => $viewpros, 'offers' => $offers, 'settings' => $settings, 'dts' => $dts, 'feedbacks' => $feedbacks, 'categories' => $categories]); } else { $flashes = Flashtext::where('active', '1')->get(); $areas = Area::where('deliverable', '1')->get(); $viewpros_id = Viewstats::where('user_id', 0)->take(16)->get(); $viewpros_id = $viewpros_id->lists('product_id'); $viewpros = Product::with('images')->has('images')->has('prices')->wherein('id', $viewpros_id)->take(16)->get(); $view->with(['flashes' => $flashes, 'areas' => $areas, 'hotpros' => $hotpros, 'viewpros' => $viewpros, 'offers' => $offers, 'settings' => $settings, 'dts' => $dts, 'feedbacks' => $feedbacks, 'categories' => $categories]); } }
public function import(Request $request) { $file = $request->file('excel'); //var_dump($filename); Excel::load($file, function ($input) { $results = $input->all(); foreach ($results as $result) { // Search if a course exist $professor = Professor::where('rut', $result->rut)->first(); // if doesn't exist we save it if (!isset($professor)) { $professor = new Professor(); $professor->name = $result->nombre_completo; $professor->type = $result->categoria; $professor->rut = $result->rut; $professor->sede_origen = $result->sede_origen; $professor->min_load = $result->carga_docente_minima; $professor->max_load = $result->carga_docente_maxima; $professor->save(); //TODO: Pasar esto a el modelo o a una query class $areas = explode(',', $result->areas); foreach ($areas as $key => $area) { $areaIdArray[] = Area::where('name', $area)->first()->id; } $professor->areas()->sync($areaIdArray); } } }); return redirect()->route('professors.index')->with('message', 'Cursos creados Correctamente.'); }
public function run() { $start_date = ''; $end_date = ''; $folderpath = 'database/seeds/seed_files'; $folders = File::directories($folderpath); $latest = '11232015'; foreach ($folders as $value) { $_dir = explode("/", $value); $cnt = count($_dir); $name = $_dir[$cnt - 1]; $latest_date = DateTime::createFromFormat('mdY', $latest); $now = DateTime::createFromFormat('mdY', $name); if ($now > $latest_date) { $latest = $name; } } $file_path = $folderpath . "/" . $latest . "/Store Mapping.xlsx"; echo (string) $file_path, "\n"; // dd($file_path); Model::unguard(); DB::statement('SET FOREIGN_KEY_CHECKS=0;'); DB::table('audit_templates')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->template)) { $template = AuditTemplate::where('template', $row->template)->first(); if (count($template) == 0) { $newtemplate = new AuditTemplate(); $newtemplate->template_code = $row->channel_code; $newtemplate->template = $row->template; $newtemplate->save(); } } }); }); DB::table('grade_matrixs')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->enrollment_type)) { $matrix = GradeMatrix::where('desc', $row->enrollment_type)->first(); if (count($matrix) == 0) { $newmatrix = new GradeMatrix(); $newmatrix->desc = $row->enrollment_type; $newmatrix->save(); } } }); }); DB::table('users')->truncate(); DB::table('role_user')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->fullname)) { $userlist = explode("/", $row->fullname); $emaillist = explode("/", $row->email); // dd($row); for ($i = 0; $i < count($userlist); $i++) { $user = User::where('username', $row->username)->first(); if (count($user) == 0) { if (empty($emaillist[$i])) { $email = strtolower($row->username . "@unilever.com"); } else { $email = strtolower($emaillist[$i]); } $newuser = User::create(array('name' => strtoupper($userlist[$i]), 'email' => $email, 'username' => $row->username, 'password' => Hash::make('password'))); $newuser->roles()->attach(3); } else { // $user->name = strtoupper($row->fullname); // $user->username = $row->username; // $user->email = strtolower($row->email); // $user->update(); // if(!$user->hasRole('field')){ // $user->roles()->attach(3); // } // echo $user->hasRole('field'); } } } }); }); DB::table('accounts')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { $account = Account::where('account', $row->account)->first(); if (count($account) == 0) { $newaccount = new Account(); $newaccount->account = $row->account; $newaccount->save(); } } }); }); DB::table('customers')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { // var_dump($row); $account = Account::where('account', $row->account)->first(); if (!empty($account)) { $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first(); if (count($customer) == 0) { $newcustomer = new Customer(); $newcustomer->account_id = $account->id; $newcustomer->customer_code = $row->customer_code; $newcustomer->customer = $row->customer; $newcustomer->save(); } } } }); }); DB::table('areas')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { $account = Account::where('account', $row->account)->first(); if (!empty($account)) { $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first(); if (!empty($customer)) { $area = Area::where('customer_id', $customer->id)->where('area', $row->area)->first(); if (count($area) == 0) { $newarea = new Area(); $newarea->customer_id = $customer->id; $newarea->area = $row->area; $newarea->save(); } } } } }); }); DB::table('regions')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { $region = Region::where('region_code', $row->region_code)->where('region', $row->region)->first(); if (count($region) == 0) { $newregion = new Region(); $newregion->region_code = $row->region_code; $newregion->region = $row->region; $newregion->save(); } } }); }); DB::table('distributors')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { $dis = Distributor::where('distributor_code', $row->distributor_code)->where('distributor', $row->distributor)->first(); if (count($dis) == 0) { $newdis = new Distributor(); $newdis->distributor_code = $row->distributor_code; $newdis->distributor = strtoupper($row->distributor); $newdis->save(); } } }); }); DB::table('stores')->truncate(); DB::table('store_user')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { $account = Account::where('account', $row->account)->first(); if (!empty($account)) { $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first(); if (!empty($customer)) { $region = Region::where('region_code', $row->region_code)->first(); $dis = Distributor::where('distributor_code', $row->distributor_code)->first(); $store = Store::where('account_id', $account->id)->where('customer_id', $customer->id)->where('region_id', $region->id)->where('distributor_id', $dis->id)->where('store_code', $row->store_code)->where('store', $row->store_name)->first(); if (count($store) == 0) { $template = AuditTemplate::where('template', $row->template)->first(); $matrix = GradeMatrix::where('desc', $row->enrollment_type)->first(); $newstore = new Store(); $newstore->account_id = $account->id; $newstore->customer_id = $customer->id; $newstore->region_id = $region->id; $newstore->distributor_id = $dis->id; $newstore->store_code = $row->store_code; $newstore->store = $row->store_name; $newstore->grade_matrix_id = $matrix->id; $newstore->audit_template_id = $template->id; $newstore->save(); $emaillist = explode("/", $row->email); for ($i = 0; $i < count($emaillist); $i++) { if (empty($emaillist[$i])) { $email = strtolower($row->username . "@unilever.com"); } else { $email = strtolower($emaillist[$i]); } $user = User::where('email', $email)->first(); $newstore->users()->attach($user->id); } } else { $emaillist = explode("/", $row->email); for ($i = 0; $i < count($emaillist); $i++) { if (empty($emaillist[$i])) { $email = strtolower($row->username . "@unilever.com"); } else { $email = strtolower($emaillist[$i]); } $user = User::where('email', $email)->first(); $store->users()->attach($user->id); } } } } } }); }); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); Model::reguard(); }
public function ajaxAreas() { $lineId = Input::get('lineId'); $areas = Area::where('line_id', $lineId)->lists('name', 'id'); return Response::json($areas); }
public function subarii($id_arie) { $this->info['namespace'] = "subarii"; $this->info['title'] = "Subarii | " . $this->info['title']; $area = Area::where('link', $id_arie)->first(); $this->info['arii'] = Subarea::where('area_id', $area->id)->get(); if (count($this->info['arii']) == 0) { abort(404); } return view('pages.arii', ['info' => $this->info]); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($date, $area, $professorId = null) { if ($professorId == null) { } $insert_control = Insert_control::where('period', $date)->first(); if ($insert_control == null) { $insert_control = 0; } else { $insert_control = $insert_control->available; } $userRole = Auth::user()->role()->first()->name; $dateExp = explode("-", $date); $year = $dateExp[0]; $semester = $dateExp[1]; $professor = Professor::find($professorId); $professorFromAreas = Area::where('name', $area)->first()->professors()->get(); $arrayProfessors = array(); foreach ($professorFromAreas as $professorFromArea) { $arrayProfessors[$professorFromArea->id] = $professorFromArea->name; } if (!isset($professor)) { $status = 1; $arrayProfessorss = $arrayProfessors; $arrayProfessorss[""] = ""; return view('schedules.show', compact("status", "year", "semester", "arrayProfessorss")); } $todasAreas = Area::all()->toArray(); $arrayAreas = array(); foreach ($todasAreas as $unArea) { $arrayAreas[$unArea['id']] = $unArea['name']; } $professorLoad = 0; $arrayCourses = array(); $areaCourses = Course::join('areas', 'areas.id', '=', 'courses.area_id')->where('areas.name', $area)->where('courses.year', $year)->where('courses.semester', $semester)->select('courses.id', 'courses.year', 'courses.semester', 'areas.name', 'courses.branch', 'courses.section', 'courses.code', 'courses.schedule')->get(); $courseSelect = array(); foreach ($areaCourses as $oneCourse) { if (count($oneCourse->schedule()->groupBy('professor_id')->get()) == 0) { $courseSelect[$oneCourse->id] = $oneCourse->code . "-" . $oneCourse->section . "-" . $oneCourse->year . "-" . $oneCourse->semester . " " . $oneCourse->branch . " (" . $oneCourse->schedule . ")"; } } $schedules = Schedule::join('courses', 'courses.id', '=', 'schedules.course_id')->where('schedules.professor_id', $professorId)->where('courses.year', $year)->where('courses.semester', $semester)->get(); foreach ($schedules as $schedule) { $course = array(); $code = $schedule->course()->first()->code; $course['name'] = $schedule->course()->first()->name; $course['area'] = $arrayAreas[$schedule->course()->first()->area_id]; $course['branch'] = $schedule->course()->first()->branch; $course['section'] = $schedule->course()->first()->section; $course['semester'] = $schedule->course()->first()->semester; $course['id'] = $schedule->course()->first()->id; $course['year'] = $schedule->course()->first()->year; $course['schedule'] = explode("-", $schedule->course()->first()->schedule); $course['code'] = $code; $arrayCourses[$code . "-" . $course['section']] = $course; // $professorLoad = $professorLoad + count($course['schedule'])*22.5; foreach ($course['schedule'] as $horario) { $array[$horario] = $course['code'] . "-" . $course['section']; } } $schedulesYear = Schedule::join('courses', 'courses.id', '=', 'schedules.course_id')->where('schedules.professor_id', $professorId)->where('courses.year', $year)->get(); foreach ($schedulesYear as $sche) { $professorLoad = $professorLoad + count(explode("-", $sche->course()->first()->schedule)) * 22.5; } if ($semester == 1) { $nextSemester = 2; $nextYear = $year; $previewsYear = $year - 1; } else { $nextSemester = 1; $nextYear = $year + 1; $previewsYear = $year; } $nextDate = $nextYear . "-" . $nextSemester; $previewsDate = $previewsYear . "-" . $nextSemester; $urlAnterior = "schedules/{$previewsDate}/{$area}/{$professor->id}"; $urlSiguiente = "schedules/{$nextDate}/{$area}/{$professor->id}"; return view('schedules.show', compact('year', 'semester', 'urlAnterior', 'urlSiguiente', 'professor', 'courseSelect', 'arrayCourses', 'arrayProfessors', 'array', 'area', 'professorLoad', 'userRole', 'insert_control')); }
public function import(Request $request) { $file = $request->file('excel'); //var_dump($filename); Excel::load($file, function ($input) { $results = $input->all(); foreach ($results as $result) { // Search if a course exist $course = Course::where('code', $result->codigo)->first(); // if doesn't exist we save it if (!isset($course)) { $area = Area::where('name', $result->area)->first(); $course = new Course(); $course->area_id = $area->id; $course->code = $result->codigo; $course->name = $result->nombre; $course->section = $result->seccion; $course->year = $result->year; $course->semester = $result->semestre; $course->branch = $result->sucursal; $course->schedule = $result->horario; $course->load = $result->carga; $course->save(); } } }); return redirect()->route('courses.index')->with('message', 'Cursos creados Correctamente.'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return Area::where('levels', '=', 1)->get(); // return Area::find(1)->children()->get(); }
public function paymentmode(Request $request) { //get details from cart not from checkout // rewrite this controller //$checkout = Checkout::with('orders')->findorfail($checkout_id); $user = Sentinel::check(); $user = User::findorfail($user->id); $cart = Cart::content(); $noofitems = Cart::count(); $total = Cart::total(); if ($request->session()->has('tmp_address')) { $address = $request->session()->get('tmp_address'); } else { $address = $user->address; } // foreach($cart as $row) // { // $tempcart = Tempcart::create([ // 'user_id' => $user->id, // 'product_id' => $row->id, // 'pqty_id' => $row->options->pid, // 'nos' => 1 // ]); // } $flashes = Flashtext::where('active', '1')->get(); $areas = Area::where('deliverable', '1')->get(); if ($total < 250) { if ($area_id = $user->area_id) { $delivery_cost = $areas->find($area_id)->delivery_cost; } elseif ($area_id = $request->session()->get('deli_area')) { $delivery_cost = $areas->find($area_id)->delivery_cost; } else { $delivery_cost = "unknown"; } } else { $delivery_cost = "0"; } return view('site.paymentmode', compact('user', 'cart', 'noofitems', 'total', 'address', 'flashes', 'areas', 'delivery_cost')); }
public function login(Request $request) { if (!Sentinel::check()) { $flashes = Flashtext::where('active', '1')->get(); $areas = Area::where('deliverable', '1')->get(); if ($redirect = $request->get('redirect')) { $request->session()->put('redirect', $redirect); } //dd($request->session()->get('redirect')); return view('site/login', compact('flashtext', 'areas')); } return back(); }