예제 #1
0
 /**
  * Store a newly created employee in storage
  */
 public function store()
 {
     $validator = Validator::make($input = Input::all(), Personal::rules('create'));
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     DB::beginTransaction();
     try {
         $nombres = $input['nombres'];
         $apellidos = $input['apellidos'];
         $filename = null;
         // Profile Image Upload
         if (Input::hasFile('fotoPersonal')) {
             return "gola a todos";
             $path = public_path() . "/foto/";
             File::makeDirectory($path, $mode = 0777, true, true);
             $image = Input::file('fotoPersonal');
             $extension = $image->getClientOriginalExtension();
             $filename = "{$nombres}_{$input['personalID']}." . strtolower($extension);
             Image::make($image->getRealPath())->fit(872, 724, function ($constraint) {
                 $constraint->upsize();
             })->save($path . $filename);
         }
         $tipo = "Aportante";
         //            return Input::all();
         Personal::create(['personalID' => $input['personalID'], 'emision' => $input['nitcit2'], 'nombres' => ucwords(strtolower($input['nombres'])), 'apellidos' => ucwords(strtolower($input['apellidos'])), 'email' => $input['email'], 'password' => Hash::make($input['password']), 'genero' => $input['genero'], 'tipoPersonal' => $tipo, 'telefono' => $input['telefono'], 'fotoPersonal' => isset($filename) ? $filename : 'default.jpg']);
         Activity::log(['contentId' => $input['personalID'], 'contentType' => 'Personal Aportante', 'user_id' => Auth::admin()->get()->id, 'action' => 'Creando Un Aportante', 'description' => 'Creacion ' . $tipo, 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $input['personalID'] ? true : false]);
         //            return Input::all();
     } catch (\Exception $e) {
         DB::rollback();
         throw $e;
     }
     DB::commit();
     return Redirect::route('admin.personal.index')->with('success', "<strong>{$nombres}</strong> exitosamente adicionado en le base de datos");
 }
예제 #2
0
 /**
  * Store a newly created personal in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::all();
     $data = array_add($data, "residencia_id", Auth::user()->residencia_id);
     $personal = Personal::create($data);
     return $personal;
 }
예제 #3
0
 public function registrar()
 {
     //        $validator = Validator::make($input = Input::all(), Voluntario::rules('create'));
     //
     //        if ($validator->fails())
     //        {
     //            return Redirect::back()->withErrors($validator)->withInput();
     //        }
     //
     //        DB::beginTransaction();
     //        try {
     //            $nombres = $input['nombres'];
     //            $tipo = 'Voluntario';
     //
     //            Voluntario::create([
     //                'personalID'   => $input['ci'],
     //                'nombres'      => ucwords(strtolower($input['nombres'])),
     //                'apellidos'    => ucwords(strtolower($input['apellidos'])),
     //                'email'         => $input['email'],
     //                'telefono'  => $input['telefono'],
     //                'tipoPersonal' => $tipo
     //            ]);
     //
     //        }catch(\Exception $e)
     //        {
     //            DB::rollback();
     //            throw $e;
     //        }
     //
     //        DB::commit();
     ////
     //        return Redirect::route('front.final')->with('success',"<strong>{$nombres}</strong> exitosamente adicionado en le base de datos");
     ////    }
     $input = Input::all();
     $rules = ['nombres' => 'required', 'apellidos' => 'required', 'ci' => 'required|ci|unique:personal', 'telefono' => 'required', 'email' => 'required|email'];
     $validator = Validator::make($input, $rules);
     //        if($validator->fails())
     //        {
     //            $output['status'] = 'error';
     //            $output['msg']    =  $validator->getMessageBag()->toArray();
     //        }
     $tipo = 'Voluntario';
     Personal::create(['nombres' => $input['nombres'], 'apellidos' => $input['apellidos'], 'personalID' => $input['ci'], 'telefono' => $input['telefono'], 'email' => $input['email'], 'tipovoluntario' => $input['tipovoluntario'], 'ocupacion' => $input['ocupacion'], 'tipoPersonal' => $tipo]);
     return View::make('front.final', $this->data);
 }
예제 #4
0
 /**
  * Store a newly created in storage
  */
 public function store()
 {
     $validator = Validator::make($input = Input::all(), Beneficiario::rules('create'));
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     DB::beginTransaction();
     try {
         $nombres = $input['nombres'];
         $filename = null;
         // Profile Image Upload
         if (Input::hasFile('foto')) {
             $path = public_path() . "/foto/";
             File::makeDirectory($path, $mode = 0777, true, true);
             $image = Input::file('foto');
             $extension = $image->getClientOriginalExtension();
             $filename = "{$nombres}_{$input['beneficiarioID']}." . strtolower($extension);
             //                Image::make($image->getRealPath())->resize('872','724')->save($path.$filename);
             Image::make($image->getRealPath())->fit(872, 724, function ($constraint) {
                 $constraint->upsize();
             })->save($path . $filename);
         }
         Beneficiario::create(['beneficiarioID' => $input['beneficiarioID'], 'responsableID' => $input['nitcit'] . " " . $input['nitcit2'], 'objetivo' => $input['objetivo'], 'nombres' => ucwords(strtolower($input['nombres'])), 'apellidos' => ucwords(strtolower($input['apellidos'])), 'genero' => $input['genero'], 'fechanac' => date('Y-m-d', strtotime($input['fechanac'])), 'telefono' => $input['telefono'], 'fechaing' => date('Y-m-d', strtotime($input['fechaing'])), 'direccion' => ucwords(strtolower($input['direccion'])), 'foto' => isset($filename) ? $filename : 'default.jpg', 'direccionperm' => ucwords(strtolower($input['direccionperm'])), 'iddiagnostico' => $input['iddiag'], 'diagnostico' => $input['diagnostico'], 'fechadiagnostico' => $input['fechadiag'], 'tratamiento' => $input['tratamiento'], 'razon' => $input['razon'], 'duracion' => $input['duracion'], 'referencia' => $input['referencia'], 'lugar' => $input['lugar']]);
         //  Insert into salary table
         if ($input['montosolicitado'] != '') {
             Soldonacion::create(['beneficiarioID' => $input['beneficiarioID'], 'tipo' => 'current', 'nota' => 'Primera Solicitud', 'monto' => $input['montosolicitado']]);
         }
         // Insert Into Bank Details
         Zonificacion::create(['beneficiarioID' => $input['beneficiarioID'], 'departamento' => $input['departamento'], 'provincia' => $input['provincia'], 'localidad' => $input['localidad'], 'zona' => $input['zona'], 'canton' => $input['canton'], 'otros' => $input['otros']]);
         //
         $tipo = 'responsable';
         Personal::create(['beneficiarioID' => $input['beneficiarioID'], 'personalID' => $input['nitcit'], 'emision' => $input['nitcit2'], 'nombres' => $input['nombresReponsable'], 'apellidos' => $input['apellidosResponsable'], 'ocupacion' => $input['ocupacionResponsable'], 'parentesco' => $input['parentesco'], 'tipoPersonal' => $tipo]);
         $fullname = $input['nombres'] . " " . $input['apellidos'];
         // -------------- UPLOAD THE DOCUMENTS  -----------------
         $documents = ['certnac', 'CIprueba', 'solicitud', 'croquis', 'perfil'];
         foreach ($documents as $document) {
             if (Input::hasFile($document)) {
                 $path = public_path() . "/beneficiarios_documents/{$document}/";
                 File::makeDirectory($path, $mode = 0777, true, true);
                 $file = Input::file($document);
                 $extension = $file->getClientOriginalExtension();
                 $filename = "{$document}_{$input['beneficiarioID']}_{$fullname}.{$extension}";
                 Input::file($document)->move($path, $filename);
                 Bendocumentos::create(['beneficiarioID' => $input['beneficiarioID'], 'fileName' => $filename, 'type' => $document]);
             }
         }
         //            dd(json_encode(Input::all()));
         //            if($this->data['setting']->ben_add==1)
         //            {
         //                $this->data['ben_name'] = $fullname;
         //                $this->data['ben_email'] = $input['email'];
         //                $this->data['ben_password'] = $input['password'];
         //                //        Send Employee Add Mail
         //                Mail::send('emails.admin.beneficiarios_add', $this->data, function ($message) use ($input) {
         //                    $message->from($this->data['setting']->email, $this->data['setting']->name);
         //                    $message->to($input['email'], $input['nombres']." ".$input['apellidos'])
         //                        ->subject('Cuenta Creada - ' . $this->data['setting']->website);
         //                });
         //            }
         //  ********** END UPLOAD THE DOCUMENTS**********
     } catch (\Exception $e) {
         DB::rollback();
         throw $e;
     }
     Activity::log(['contentId' => $input['beneficiarioID'], 'contentType' => 'Beneficiario', 'action' => 'Creacion', 'user_id' => Auth::admin()->get()->id, 'description' => 'Creacion del un Beneficiario', 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $input['beneficiarioID'] ? true : false]);
     DB::commit();
     return Redirect::route('admin.beneficiarios.index')->with('success', "<strong>{$fullname}</strong> exitosamente adicionado en le base de datos");
 }