public function store(Request $request) { $cfgGoogle = \Session::get('_ClientGoogle'); if (isset($cfgGoogle)) { $user = \Auth::user(); $data = $request->all(); //dd($data); $rArtifacts = \App\Methodology::Join('phases', function ($join) { $join->on('phases.id_methodology', '=', 'methodologies.id'); })->join('artifacts', function ($join) { $join->on('artifacts.id_phase', '=', 'phases.id'); })->select('methodologies.id as meth_id', 'methodologies.name as meth_name', 'phases.id as pha_id', 'phases.name as pha_name', 'artifacts.id as art_id', 'artifacts.name as art_name', 'artifacts.start as art_start', 'artifacts.delivery as art_delivery')->where('artifacts.active', true)->where('phases.active', true)->where('methodologies.active', true)->where('methodologies.id', $data['id_methodology'])->orderBy('artifacts.delivery', 'asce')->get(); //dd($user); $eventCreate = array(); $calendarGoogle = new \Google_Service_Calendar($cfgGoogle); foreach ($rArtifacts as $key => $artifact) { $start = date("c", strtotime($artifact->art_start)); $end = date("c", strtotime($artifact->art_delivery)); $event = new \Google_Service_Calendar_Event(array('summary' => $artifact->art_name, 'description' => $artifact->art_name, 'start' => array('dateTime' => $start, 'timeZone' => 'America/Mexico_City'), 'end' => array('dateTime' => $end, 'timeZone' => 'America/Mexico_City'))); //dd($user->id); $table['id_student'] = $user->id; $table['id_period'] = intval($data['id_period']); $table['id_company'] = intval($data['id_company']); $table['id_methodology'] = $artifact->meth_id; //dd($artifact->pha_id); $table['id_phase'] = intval($artifact->pha_id); $table['id_artifact'] = intval($artifact->art_id); $table['name'] = $artifact->art_name; $table['start'] = $artifact->art_start; $table['delivery'] = $artifact->art_delivery; // $artifact_current = \App\Artifact::find(intval($artifact->art_id)); // dd($artifact_current); $calendarId = 'primary'; $events = $calendarGoogle->events->insert($calendarId, $event); $table['id_calendar'] = $events->id; $table['htmlLink'] = $events->htmlLink; $tpmCal = new \App\Calendar($table); $tpmCal->save(); } if ($request->ajax()) { return response()->json(array('status' => true, 'data' => 'The syn calendar is successful!')); } } else { if ($request->ajax()) { return response()->json(array('status' => false, 'data' => 'For sync calendar is need login with Google!')); } } //dd($data_calendar); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { //period.company $data = explode('.', $id); $rArtifacts = array(); $rMethodology = array(); $rMethodology = \App\RegistryMethodology::where('id_period', $data[0])->where('id_company', $data[1])->get(); if (count($rMethodology) > 0) { //dd($rMethodology[0]->id_methodology); $rArtifacts = \App\Methodology::Join('phases', function ($join) { $join->on('phases.id_methodology', '=', 'methodologies.id'); })->join('artifacts', function ($join) { $join->on('artifacts.id_phase', '=', 'phases.id'); })->select('methodologies.id as meth_id', 'methodologies.name as meth_name', 'phases.id as pha_id', 'phases.name as pha_name', 'artifacts.id as art_id', 'artifacts.name as art_name', 'artifacts.start as art_start', 'artifacts.delivery as art_delivery')->where('artifacts.active', true)->where('phases.active', true)->where('methodologies.active', true)->where('methodologies.id', $rMethodology[0]->id_methodology)->orderBy('artifacts.delivery', 'asce')->get(); // dd($rArtifacts); } else { $rMethodology = array(); } return view('Admin.Evaluation.advance', ['rMethodology' => $rMethodology, 'rArtifacts' => $rArtifacts, 'data' => $data]); // }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { //<!-- period.company.methodologies.artifact--> /* $cfgGoogle = \Session::get('_ClientGoogle'); if(isset($cfgGoogle)){ $service = new \Google_Service_Drive($cfgGoogle); $file = new \Google_Service_Drive_DriveFile(); $file->setTitle( 'Hello world!' ); $file->setMimeType( 'application/vnd.google-apps.document' ); $file = $service->files->insert( $file ); dd($file); } dd(3423); */ $data = explode('.', $id); $user = \Auth::user(); $rArtifact = \App\Methodology::Join('phases', function ($join) { $join->on('phases.id_methodology', '=', 'methodologies.id'); })->join('artifacts', function ($join) { $join->on('artifacts.id_phase', '=', 'phases.id'); })->leftJoin('calendars', function ($leftJoin) use($user, $data) { $leftJoin->on('calendars.id_phase', '=', 'phases.id')->where('calendars.id_artifact', '=', 'artifacts.id')->where('calendars.id_methodology', '=', 'methodologies.id')->where('calendars.id_student', '=', $user->id)->where('calendars.id_period', '=', $data[0])->where('calendars.id_company', '=', $data[1]); })->select('methodologies.id as meth_id', 'methodologies.name as meth_name', 'phases.id as pha_id', 'phases.name as pha_name', 'artifacts.id as art_id', 'artifacts.name as art_name', 'artifacts.start as art_start', 'artifacts.delivery as art_delivery', 'calendars.id_calendar as id_calendar', 'calendars.htmlLink as htmlLink')->where('artifacts.active', true)->where('phases.active', true)->where('methodologies.active', true)->where('methodologies.id', $data[2])->where('artifacts.id', $data[3])->get(); if (count($rArtifact) > 0) { $rArtifact = $rArtifact[0]; } $rDocs = \App\Doc::where('id_period', '=', $data[0])->where('id_methodology', '=', $data[2])->where('id_artifact', '=', $data[3])->where('id_company', '=', $data[1])->get(); return view('Admin.Course.Advance.edit', ['rArtifact' => $rArtifact, 'data' => $data, 'rDocs' => $rDocs]); }