<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Session;
use Redirect;
use DB;
use App\AlumnosAdmision;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class AlumnosAdmisionController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  Request  $request
     * @return Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function show($id)
    {
        $a = AlumnosAdmision::where('idAlumnoAdmi', '=', $id)->select('fk_idPeriodo')->first();
        return view('documentos.view_pdf')->with('periodo', $a->fk_idPeriodo);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  Request  $request
     * @param  int  $id
     * @return Response
     */
    public function update(Request $request, $id)
    {
        $data = $request->all();
        DB::table('dse_doc_alumnos_admision')
            ->where('folio', $id)
            ->update(['curp'=>$data['curp'],'nss'=>$data['nss'],'telefono'=>$data['numero_telefono'],'computadora'=>$data['computadora'],'correo'=>$data['correo']]);
        
        session(['vistaForm' => 'NO']);

        return response()->json([ 'estatus' => 'OK' , 'exito' => 'Tus datos se han enviado de forma exitosa!' ]);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function destroy($id)
    {
        //
    }
}
