function importEvent(\App\Module $module, \DateTime $starttijd, \DateTime $eindtijd, string $uid, string $ruimte, array $groepcodes) { $starttijd->setTimezone(new \DateTimeZone(ini_get('date.timezone'))); $eindtijd->setTimezone(new \DateTimeZone(ini_get('date.timezone'))); $contactmoment = \App\Contactmoment::where('ical_uid', $uid)->first(); if ($contactmoment === null) { $contactmoment = \App\Contactmoment::firstOrNew(['starttijd' => $starttijd]); } $contactmoment->ical_uid = $uid; $contactmoment->starttijd = $starttijd; $contactmoment->eindtijd = $eindtijd; $contactmoment->ruimte = $ruimte; if ($contactmoment->les === null) { // try to find lesplan $lesplan = $module->lessen()->firstOrNew(['jaar' => $contactmoment->starttijd->format('Y'), 'kalenderweek' => (int) $contactmoment->starttijd->format('W')]); if ($lesplan->naam === null) { $lesplan->naam = ""; } $lesplan->doelgroep()->associate(\App\Doelgroep::find(1)); $lesplan->save(); $contactmoment->les()->associate($lesplan); } foreach ($groepcodes as $groepcode) { $blokgroep = \App\Blokgroep::firstOrNew(['code' => $groepcode]); $blokgroep->collegejaar = '1516'; if (preg_match('/42IN(?<bloknummer>\\d+)SO\\w/', $groepcode, $matches) !== 1) { continue; } $blokgroep->nummer = (int) $matches['bloknummer']; $blokgroep->save(); } $contactmoment->save(); }
public function moduleAndPageCreate($request) { $projectID = Project::orderBy('id', 'desc')->first(); $modules = $request->projected_total_modules; $m = 1; $pages = $request->projected_total_pages / $request->projected_total_modules; $p = 1; $pageNumber = 1; while ($m <= $modules) { $newModule = new Module(); $newModule->project_id = $projectID->id; $newModule->name = 'Modulo' . $m; $newModule->projected_total_pages = $pages; $newModule->save(); $p = 1; while ($p <= $pages) { $moduleID = Module::orderBy('id', 'desc')->first(); $newPage = new Page(); $newPage->module_id = $moduleID->id; $newPage->name = $pageNumber; $newPage->save(); $p++; $pageNumber++; } $m++; } }
/** * Show the form for creating a new resource. * * @return Response */ public function create(Request $request) { // //$this->validate($request, ['inteos_bb_code' => 'required|max:10']); //$inteosinput = $request->all(); // change use (delete or comment user Requestl; ) //1971107960 //$inteosbbcode = $inteosinput['inteos_bb_code']; //var_dump($inteosbb); //$inteos = DB::connection('sqlsrv2')->select(DB::raw("SELECT IntKeyPO,BlueBoxNum,BoxQuant FROM [BdkCLZGtest].[dbo].[CNF_BlueBox] WHERE INTKEY = 56013339 "), array()); // Test database /*$inteos = DB::connection('sqlsrv2')->select(DB::raw("SELECT [CNF_BlueBox].INTKEY,[CNF_BlueBox].IntKeyPO,[CNF_BlueBox].BlueBoxNum,[CNF_BlueBox].BoxQuant, [CNF_PO].POnum,[CNF_SKU].Variant,[CNF_SKU].ClrDesc,[CNF_STYLE].StyCod FROM [BdkCLZGtest].[dbo].[CNF_BlueBox] FULL outer join [BdkCLZGtest].[dbo].CNF_PO on [CNF_PO].INTKEY = [CNF_BlueBox].IntKeyPO FULL outer join [BdkCLZGtest].[dbo].[CNF_SKU] on [CNF_SKU].INTKEY = [CNF_PO].SKUKEY FULL outer join [BdkCLZGtest].[dbo].[CNF_STYLE] on [CNF_STYLE].INTKEY = [CNF_SKU].STYKEY WHERE [CNF_BlueBox].INTKEY = :somevariable"), array( 'somevariable' => $inteosbbcode, ));*/ // Live database DB::table('modules')->truncate(); //$inteosmodules = DB::connection('sqlsrv2')->select(DB::raw("SELECT DISTINCT mod.ModNam,per.Name,per.BadgeNum,per.PinCode FROM [BdkCLZG].[dbo].[CNF_Operators] as op JOIN [BdkCLZG].[dbo].[WEA_PersData] as per ON op.IntKeyPers = per.PersNum JOIN [BdkCLZG].[dbo].[CNF_Modules] as mod ON op.Module = mod.Module WHERE (op.PersTyp = 2) and (per.FlgAct = 1) ORDER BY mod.ModNam")); $inteosmodules = DB::connection('sqlsrv2')->select(DB::raw("SELECT DISTINCT mod.ModNam,per.Name,per.BadgeNum,per.PinCode FROM [BdkCLZG].[dbo].[CNF_Operators] as op JOIN [BdkCLZG].[dbo].[WEA_PersData] as per ON op.IntKeyPers = per.PersNum JOIN [BdkCLZG].[dbo].[CNF_Modules] as mod ON op.Module = mod.Module WHERE (op.PersTyp = 2) ORDER BY mod.ModNam")); foreach ($inteosmodules as $row) { $modName = $row->ModNam; $modName = str_replace(' ', '', $modName); $group = substr($modName, 0, 1); $leader_num = $row->BadgeNum; $pin = $row->PinCode; $leader = $row->Name; $badge = $row->BadgeNum; //echo $modName." ".$leader." ".$badge."<br />"; //dd($modName." ".$leader." ".$badge); //try { $module = new Module(); $module->module = $modName; $module->group = $group; $module->leader = $leader; $module->leader_num = $leader_num; $module->leader_pin = $pin; $module->save(); //} /* catch (\Illuminate\Database\QueryException $e) { //$msg = "Problem to save in database"; //return view('BarcodeRequest.error',compact('msg')); } */ } return view('importmodules.success'); /* if ($inteosmodules) { //continue } else { //$validator->errors()->add('field', 'Something is wrong with this field!'); //Log::error('Cannot find BB in Inteos'); //return view('inteosdb.error'); } */ }
public function importModules() { $modules = $this->getModulesFile(); foreach ($modules as $module) { $newmodule = new Module(); $newmodule->packname = $module->packname; $newmodule->provider = $module->provider; $newmodule->name = $module->name; $newmodule->status = $module->status; $newmodule->icon = $module->icon; $newmodule->description = $module->description; $newmodule->save(); } }
/** * Update the specified resource in storage. * * @param PageRequest|Request $request * @param Project $project * @param Module $module * @param Page $page * @return \Illuminate\Http\Response */ public function update(PageRequest $request, Project $project, Module $module, Page $page) { if (isset($_POST['module_id'])) { $module_id = $_POST['module_id']; $pages = Page::where('module_id', '=', $module_id)->get(); foreach ($pages as $page) { $page->update($request->all()); $page->save(); } return redirect()->route('project.module.show', [$project, $module]); } if (isset($_POST['module_name'])) { $pages = $_POST; $module = Module::where('project_id', '=', $project->id)->where('name', '=', $_POST['module_name'])->first(); foreach ($pages as $val) { if (is_numeric($val)) { $p = Page::where('id', '=', $val)->first(); $p->module_id = $module->id; $p->save(); } } } $page->update($request->all()); $page->save(); return redirect()->route('project.module.show', [$project, $module]); }
public function registerHelpers() { $array = \App\Module::getHelpers(); foreach ($array as $key => $value) { $this->{$key} = clone $value; } }
public function showSidebar($allowed_routes) { $module_array = App\Module::orderBy('order', 'DESC')->get(); $menu = ""; foreach ($module_array as $key => $value) { $number = 0; $ul = ""; foreach ($value->feature as $feature) { $li = ""; $route = json_decode($feature->url_action); if ($route == NULL) { $route = $feature->url_action; } else { $route = $route[0]; } if ($feature->is_menu && $feature->parent_id == 0 && in_array($route, $allowed_routes)) { $link = Route::has($route) ? route($route) : "#"; $items = FeatureNode::defaultOrder()->descendantsOf($feature->id); $items->linkNodes(); $items = $items->toTree(); $li = $this->getMenuchildren($items, $allowed_routes, $number); if ($number >= 1) { $li = "<li><a href='{$link}'>{$feature->name_feature}<i class='fa fa-angle-left pull-right'></i></a><ul class='treeview-menu'>{$li}</ul></li>"; } else { $li = ""; } } $ul .= $li; } $menu .= $ul; } return $menu; }
public function calculateModuleExpenditure($id, $fromDate, $toDate) { $module = Module::find($id); $activities = $module->activities; $activityCosts = array(); $totalModuleCost = 0; foreach ($activities as $activity) { $sessions = $activity->sessions()->whereBetween('date_of_session', array($fromDate, $toDate))->orderBy('date_of_session')->get(); $totalHoursPerPerson = 0; $activityTitle = $activity->title; $role = $activity->role_type; //the 'role' the PHD student was for the given 'session' if ($role == 'Demonstrator') { $payRate = 12.21; } elseif ($role = 'Teaching') { $payRate = 10.58; } foreach ($sessions as $session) { $startTime = new Carbon($session->start_time); //http://carbon.nesbot.com/docs/#api-humandiff $endTime = new Carbon($session->end_time); //http://carbon.nesbot.com/docs/#api-humandiff $totalHoursPerPerson += $startTime->diffInHours($endTime); //http://carbon.nesbot.com/docs/#api-humandiff } if (array_key_exists($activityTitle, $activityCosts)) { $activityCosts[$activityTitle] += $totalHoursPerPerson * $activity->quant_ppl_needed * $payRate; } else { $activityCosts[$activityTitle] = $totalHoursPerPerson * $activity->quant_ppl_needed * $payRate; //this 0verwrites 0ld values2d } $totalModuleCost += $totalHoursPerPerson * $activity->quant_ppl_needed * $payRate; } return view('calculateModuleExpenditureResults')->with(['module' => $module, 'totalModuleCost' => $totalModuleCost, 'activityCosts' => $activityCosts]); }
public function getEmail($name) { $array = \App\Module::getEmails(); $mailer = new Mailer($array[$name]['host'], $array[$name]['port'], $array[$name]['username'], $array[$name]['password'], $array[$name]['secure']); $mailer->isSmtp($array[$name]['transport_smtp']); return $mailer; }
/** * set up start */ public function setUp() { parent::setUp(); Session::start(); // $this->mock = Mockery::mock('\App\Group'); $this->id_test = Module::all()->first()->id; }
public function run() { $faker = Faker::create('en_GB'); $modules = ['articles', 'events', 'notices', 'resources', 'tasks']; foreach (range(1, count($modules)) as $index) { Module::create(['name' => $modules[$index - 1]]); } }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { $modules = Module::all(); if ($modules) { return $this->respondWithCollection($modules, new ModuleTransformer()); } return $this->errorNotFound('No modules found'); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $matieres = Matiere::all(); $profs = Enseignant::activeEnseignants(); $promos = Promo::activePromos(); $modules = Module::all(); return View('app/gestion_matieres', ['matieres' => $matieres, 'profs' => $profs, 'promos' => $promos, 'modules' => $modules]); }
/** * Update the specified resource in storage. * * @param Product $product * @return Response */ public function update($product) { $product->fill(Input::data()); if (Input::data('module') && ($module = Module::find(Input::data('module')['id']))) { $product->module()->associate($module); } $product->save(); return $product; }
public function destroy($id) { $module = Module::find($id); $module->professors()->detach(); $module->courses()->detach(); $module->delete(); Session::flash('success', 'The module was deleted'); return redirect()->action('ModulesController@index'); }
/** * Bind data to the view. * * @param View $view * @return void */ public function compose(View $view) { $currentuser = Auth::user(); $options = Option::where('module', 'main')->get(); $name = $options->where('option', 'name')->first()->value; $tagline = $options->where('option', 'tagline')->first()->value; $modules = Module::orderBy('status', 'desc')->get(); $navigation = Navigation::where('menu', 'admin')->get(); $view->with('currentuser', $currentuser)->with('name', $name)->with('tagline', $tagline)->with('modules', $modules)->with('navigation', $navigation); }
private function getConfig() { $modules = Module::getModules(); $array = array(); foreach ($modules as $key => $value) { $array[] = "../App/" . $value . "/Entity"; } $isDevMode = true; $config = Setup::createAnnotationMetadataConfiguration($array, $isDevMode); return $config; }
public static function getModule() { $modules = Module::getModules(); $url = explode('/', self::url()); foreach ($modules as $key => $value) { $keys = str_replace('/', "", $key); if ($keys == $url[1]) { return array($key => ucfirst($value)); } } return array("/" => ucfirst($modules['/'])); }
public function get($name) { $service = \App\Module::getService(); if (!array_key_exists($name, $service)) { throw new \Exception("Key invalid - Service não encontrado em App\\Module.php [getService()]"); } $e = $service[$name]($this->controller); if (!isset($e)) { throw new \Exception("Service não encontrado em App\\Module.php [getService()]"); } return $e; }
/** * Run the database seeds. * * @return void */ public function run() { //truncate the modules table so that the auto incrementing 'id' field starts counting from 1 again DB::table('modules')->truncate(); //Read in a csv file containing data(module code, module name, module leader on the currently running modules //in the school of Computer Science and Informatics) from the _data directory $modulesCSVFile = new CsvFile(__DIR__ . '/_data/Modules.csv'); //Generate a record using data from each line of the CSV file where each row is in the format: //module code, module name, module leader, foreach ($modulesCSVFile as $currentRow) { Module::create(['module_code' => trim($currentRow[0]), 'module_name' => trim($currentRow[1]), 'module_leader' => 1]); } }
/** * Update the specified resource in storage. * * @param Parameter $parameter * @return Response */ public function update($parameter) { $parameter->fill(Input::data()); if (Input::data('module') && ($module = Module::find(Input::data('module')['id']))) { $parameter->module()->associate($module); } if (Input::data('type') === '选项' && Input::data('options')) { $options = str_replace(',', ',', Input::data('options')); $options = str_replace(';', ';', Input::data('options')); $parameter->options = json_encode(preg_split('/[;|,]\\s*/', $options)); } $parameter->save(); return $parameter; }
/** * Run the database seeds. * * @return void */ public function run() { $modules = json_decode(Storage::get('packages.json')); foreach ($modules as $module) { $module = Module::create(['packname' => $module->packname, 'provider' => $module->provider, 'name' => $module->name, 'status' => $module->status, 'icon' => $module->icon, 'tables' => $module->tables, 'seeder' => $module->seeder, 'description' => $module->description]); if ($module->status > 0) { if (!$module->checkMigration()) { Artisan::call('vendor:publish'); Artisan::call('migrate'); Artisan::call('db:seed', ["--class" => $module->seeder]); } } } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $etudiants_count = Etudiant::count(); $enseignants_count = Enseignant::count(); $absences_count = Absence::count(); $matieres_count = Matiere::count(); $etudiants = Etudiant::etudiants_plus_3_absences(); $module = Module::find($id); $matieres = $module->matieres; foreach ($matieres as $key) { $key->nbreAbsencesByMatiere(); } return View('app/statistiques_matiere', ['etudiants_count' => $etudiants_count, 'enseignants_count' => $enseignants_count, 'absences_count' => $absences_count, 'matieres_count' => $matieres_count, 'etudiants' => $etudiants, 'matieres' => $matieres]); }
public function edit(Request $request) { $user = \Session::get('user'); if (!$user->can('产品模块管理')) { abort(401); } $module = Module::find($request->input('module_id')); $old_attributes = $module->attributesToArray(); $module->name = $request->input('name'); $module->description = $request->input('description'); $module->save(); $new_attributes = $module->attributesToArray(); $product = $module->product; foreach (array_diff_assoc($old_attributes, $new_attributes) as $key => $value) { \Log::notice(strtr('产品模块修改: 用户(%name[%id]) 修改了产品 (%product[%product_id]) 的模块 (%module[%module_id])基本信息: [%key] %old --> %new', ['%name' => $user->name, '%id' => $user->id, '%product' => $product->name, '%product_id' => $product->id, '%key' => $key, '%old' => $old_attributes[$key], '%new' => $new_attributes[$key]])); } $old_deped_modules = $module->dep_modules->lists('id')->all(); if (count($old_deped_modules)) { $module->dep_modules()->detach($old_deped_modules); } $new_deped_modules = $request->input('modules', []); $d1 = array_diff($new_deped_modules, $old_deped_modules); $d2 = array_diff($old_deped_modules, $new_deped_modules); if (count($d1)) { $dep_modules = []; foreach ($d1 as $id) { $m = Module::find($id); $dep_modules[] = strtr('(%name[%id])', ['%name' => $m->name, '%id' => $m->id]); } //新加的模块 \Log::notice(strtr('产品模块修改: 用户(%name[%id]) 增加了产品 (%product[%product_id]) 的模块 (%module[%module_id]) 的依赖模块 %dep_modules', ['%name' => $user->name, '%id' => $user->id, '%product' => $product->name, '%product_id' => $product->id, '%module' => $module->name, '%module_id' => $module->id, '%dep_modules' => implode(',', $dep_modules)])); } if (count($d2)) { $dep_modules = []; foreach ($d2 as $id) { $m = Module::find($id); $dep_modules[] = strtr('(%name[%id])', ['%name' => $m->name, '%id' => $m->id]); } //删除的模块 \Log::notice(strtr('产品模块修改: 用户(%name[%id]) 删除了产品 (%product[%product_id]) 的模块 (%module[%module_id]) 的依赖模块 %dep_modules', ['%name' => $user->name, '%id' => $user->id, '%product' => $product->name, '%product_id' => $product->id, '%module' => $module->name, '%module_id' => $module->id, '%dep_modules' => implode(',', $dep_modules)])); } foreach ($new_deped_modules as $module_id) { $dep_module = Module::find($module_id); $module->dep_modules()->save($dep_module); } return redirect()->back()->with('message_content', '修改成功!')->with('message_type', 'info'); }
public function index() { $activities = Activity::with('module')->get(); $module = Module::with('activities')->get(); return View::make("Engagement-Form")->with('module', $module)->with('activities', $activities); //$modules=Module::join('activities','activities.module_id','=','modules.id') // ->get(); //return View::make("Engagement-Form")->with('modules', $modules); // $modules = DB::table('modules') // ->get(); // $activities = DB::table('activities') // ->join->on('modules', 'activities.module_id', '=', 'modules.id') // ->get(); // return View::make("Engagement-Form")->with('modules', $modules) // ->with('activities', $activities); //$activities = Module::with('activities')->find($id)->activities; //return View::make("Engagement-Form")->with('activities', $activities); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { $permissions = Module::with('permissions')->get(); // find role by id $role = Sentinel::findRoleById($id); // inputs $data = $request->get('data'); $value = $request->get('value'); if (isset($role->permissions[$value])) { $role->updatePermission($value, $data == 'true' ? true : false); $role->save(); return "update"; } else { $role->addPermission($value, $data == 'true' ? true : false); $role->save(); return "add"; } }
/** * Run the database seeds. * * @return void */ public function run() { DB::statement('SET FOREIGN_KEY_CHECKS=0;'); DomainController::truncate(); Trust::truncate(); Site::truncate(); Role::truncate(); Permission::truncate(); Module::truncate(); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); Model::unguard(); $this->call('DomainControllersTableSeeder'); $this->call('TrustsTableSeeder'); $this->call('SitesTableSeeder'); $this->call('RolesTableSeeder'); $this->call('ModulesTableSeeder'); $this->call('PermissionsTableSeeder'); }
/** * Run the database seeds. * * @return void */ public function run() { //truncate the activities table so that the auto incrementing 'id' field starts counting from 1 again DB::table('activities')->truncate(); //Read in a csv file containing data on some of the activities in the COMSC department $activtiesCSVFile = new CsvFile(__DIR__ . '/_data/Activities.csv'); //Generate a record using data from each line of the CSV file where each row is in the format: //TODO:put the format here //'id' value for each module in the 'modules' table specified in the CSV file, as the module seeder //(and all other seeders including this one) will only be run a single time when it has been put into production foreach ($activtiesCSVFile as $currentRow) { //get an object representing the first module whose module code matches the one in the row //of the CSV file that is currently being processed. The first method returns only the first match //as the modules in the database should have unique module codes anyway. $module = Module::where('module_code', '=', (string) $currentRow[2])->first(); //obtain the 'ID' (primary key) of the module that matches the above 'where' query $moduleID = $module->id; $moduleActivity = Activity::create(['title' => trim($currentRow[0]), 'role_type' => trim($currentRow[1]), 'module_id' => $module->id, 'quant_ppl_needed' => $currentRow[4], 'closing_date_for_applications' => $currentRow[5], 'knowledge_required' => $currentRow[6]]); } }
public function migrateDatabase() { if ($this->checkDatabaseMigration() == false) { Artisan::call('migrate:reset'); Artisan::call('vendor:publish', ['--force' => true]); Artisan::call('migrate'); Artisan::call('db:seed'); $modules = Module::getModulesFile(); // array_map(function($seeder){ // Artisan::call('db:seed',[ // "--class" => $seeder // ]); // }, array_filter($modules, function($module){ // return $module->status > 0 && $modle->seeder != null; // })); foreach ($modules as $module) { if ($module->status > 0) { if ($module->seeder != null) { Artisan::call('db:seed', ["--class" => $module->seeder]); } } } } }
/** * Remove the specified resource from storage. * * @param Project $project * @param Module $module * @return \Illuminate\Http\Response */ public function destroy(Project $project, Module $module) { $module->delete(); return redirect()->route('project.show', [$project]); }