コード例 #1
0
ファイル: LoginController.php プロジェクト: vik70r/CTAS
 public function login()
 {
     $email = null;
     if (is_null($email)) {
         return View::make('login');
     } else {
         $personal = Personal::where('email', '=', $email)->first();
         // Activar sessión
         return Redirect::to('personal/profile/' . $personal->codPersonal);
     }
 }
コード例 #2
0
 public function store()
 {
     $validator = Validator::make($input = Input::all(), Donacion::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $aportante = Personal::where('personalID', '=', $input['personalID'])->get()->first();
     $beneficiario = Beneficiario::where('beneficiarioID', '=', $input['beneficiarioID'])->get()->first();
     Donacion::create(['aportanteID' => $input['personalID'], 'nombreAportante' => $aportante->nombres . " " . $aportante->apellidos, 'nombreBeneficiario' => $beneficiario->nombres . " " . $beneficiario->apellidos, 'beneficiarioID' => $input['beneficiarioID'], 'descripcion' => $input['descripcion'], 'montodonacion' => $input['montodonacion']]);
     Activity::log(['contentId' => $input['personalID'], 'contentType' => 'Donacion', 'user_id' => Auth::admin()->get()->id, 'action' => 'Create', 'description' => 'Creacion ' . $input['descripcion'], 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $input['personalID'] ? true : false]);
     return Redirect::route('admin.donaciones.index')->with('success', "<strong>Guardado</strong> Exitosamente");
 }
コード例 #3
0
ファイル: AyudasController.php プロジェクト: rodrigopbel/ong
 public function store()
 {
     $validator = Validator::make($input = Input::all(), Ayuda::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     //        return Input::all();
     $aportante = Personal::where('personalID', '=', $input['personalID'])->get()->first();
     $beneficiario = Beneficiario::where('beneficiarioID', '=', $input['beneficiarioID'])->get()->first();
     Ayuda::create(['beneficiarioID' => $input['beneficiarioID'], 'aportanteID' => $input['personalID'], 'nombreBeneficiario' => $beneficiario->nombres . " " . $beneficiario->apellidos, 'nombreAportante' => $aportante->nombres . " " . $aportante->apellidos, 'requerimiento' => $input['requerimiento'], 'centroSalud' => $input['centroSalud'], 'nit' => $input['nit'], 'numfactura' => $input['numfactura'], 'gastos' => $input['gastos']]);
     $donacion = Donacion::where('aportanteID', '=', $input['personalID'])->get()->first();
     $aportante = Personal::where('personalID', '=', $input['personalID'])->get()->first();
     $beneficiario = Beneficiario::where('beneficiarioID', '=', $input['beneficiarioID'])->get()->first();
     //        return $donacion;
     //        return ("hola a todos");
     $saldo = Saldo::where('donacionesID', '=', $donacion->id)->get()->last();
     //        $saldo2 = Saldo::where('donacionesID', '=', $donacion->id)->get()->first();
     //        return [$saldo, $saldo2];
     //        return $saldo;
     if (!empty($saldo->saldo)) {
         $saldo2 = $saldo->saldo - $input['gastos'];
         Saldo::create(['nombreBeneficiario' => $beneficiario->nombres . " " . $beneficiario->apellidos, 'nombreAportante' => $aportante->nombres . " " . $aportante->apellidos, 'donacionesID' => $donacion->id, 'ayudasID' => $input['nit'], 'donacion' => $saldo->saldo, 'ayuda' => $input['gastos'], 'saldo' => $saldo2]);
         //            return "entro aca false";
     }
     if (empty($saldo->saldo)) {
         $saldo2 = $donacion->montodonacion - $input['gastos'];
         Saldo::create(['nombreBeneficiario' => $beneficiario->nombres . " " . $beneficiario->apellidos, 'nombreAportante' => $aportante->nombres . " " . $aportante->apellidos, 'donacionesID' => $donacion->id, 'ayudasID' => $input['nit'], 'donacion' => $donacion->montodonacion, 'ayuda' => $input['gastos'], 'saldo' => $saldo2]);
         //            return "entro aca true";
     }
     //        Saldo::create([
     //            'nombreBeneficiario' => $beneficiario->nombres . " " .$beneficiario->apellidos,
     //            'donacionesID'  =>  $donacion->id,
     //            'ayudasID'      =>  $input['nit'],
     //            'donacion'      =>  $donacion->montodonacion,
     //            'ayuda'         =>  $input['gastos'],
     //            'saldo'         =>  $saldo2
     //        ]);
     //        return Input::all();
     Activity::log(['contentId' => $input['beneficiarioID'], 'contentType' => 'Ayuda', 'user_id' => Auth::admin()->get()->id, 'action' => 'Creacion', 'description' => 'Creacion ' . $input['requerimiento'], 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $input['beneficiarioID'] ? true : false]);
     return Redirect::route('admin.ayudas.index')->with('success', "<strong>Guardado</strong> Exitosamente");
 }
コード例 #4
0
 public function personal($action)
 {
     if (isset($action)) {
         if ($action == "create") {
             $data = Personal::firstOrCreate(Input::all());
             return $respuesta = array('Record' => $data, 'Result' => "OK");
         }
         if ($action == "edit") {
             Personal::where("id", Input::get("id"))->update(Input::except("id"));
             return $respuesta = array('Record' => Personal::find(Input::get('id')), 'Result' => "OK");
         }
         if ($action == "remove") {
             Personal::where('id', Input::get("id"))->delete();
             return '{"Result":"OK"}';
         }
         if ($action == "list") {
             $Records = Personal::get();
             $respuesta = array('Records' => $Records, 'Result' => "OK");
             return json_encode($respuesta);
         }
         if ($action == "residencia") {
             $nulos = DB::table('residencias')->select(DB::raw("'NO POSEE' as DisplayText, NULL as Value"));
             $respuesta = DB::table('residencias')->select("nombre as DisplayText", "id as Value")->union($nulos)->orderby('value', 'asc')->distinct()->get();
             return "var opciones=" . json_encode($respuesta);
         }
     }
 }
コード例 #5
0
 /**
  * Update the specified in storage.
  */
 public function update($id)
 {
     //----Bank Details Update-------
     if (Input::get('updateType') == 'zonificacion') {
         $validator = Validator::make($input = Input::all(), Beneficiario::rules('zonificacion'));
         if ($validator->fails()) {
             $output['status'] = 'error';
             $output['msg'] = $validator->getMessageBag()->toArray();
         } else {
             $details = Zonificacion::firstOrNew(['beneficiarioID' => $id]);
             $details->departamento = Input::get('departamento');
             $details->provincia = Input::get('provincia');
             $details->otros = Input::get('otros');
             $details->localidad = Input::get('localidad');
             $details->canton = Input::get('canton');
             $details->zona = Input::get('zona');
             $details->save();
             $output['status'] = 'success';
             $output['msg'] = 'Zonificacion actualizado exitosamente';
         }
     } else {
         if (Input::get('updateType') == 'donacion') {
             $ddetails = Beneficiario::where('beneficiarioID', '=', $id)->first();
             $validator = Validator::make($input = Input::all(), Beneficiario::rules('update', $ddetails->id));
             if ($validator->fails()) {
                 $output['status'] = 'error';
                 $output['msg'] = $validator->getMessageBag()->toArray();
             } else {
                 $ddetails->beneficiarioID = $id;
                 $ddetails->objetivo = Input::get('objetivo');
                 $ddetails->fechaing = date('Y-m-d', strtotime(Input::get('fechaing')));
                 $ddetails->fecha_desvinculacion = trim(Input::get('fecha_desvinculacion')) != '' ? date('Y-m-d', strtotime(Input::get('fecha_desvinculacion'))) : null;
                 $ddetails->status = Input::get('status') != 'activo' ? 'inactivo' : 'activo';
                 $ddetails->save();
                 if (isset($input['monto'])) {
                     foreach ($input['monto'] as $index => $value) {
                         $salary_details = Soldonacion::find($index);
                         $salary_details->tipo = $input['tipo'][$index];
                         $salary_details->monto = $value;
                         $salary_details->save();
                     }
                 }
                 $output['status'] = 'success';
                 $output['msg'] = 'Donacion Actualizado Existosamente';
             }
         } else {
             if (Input::get('updateType') == 'personalInfo') {
                 $ben = Beneficiario::where('beneficiarioID', '=', $id)->get()->first();
                 $validator = Validator::make($data = Input::all(), Beneficiario::rules('personalInfo', $ben->id));
                 if ($validator->fails()) {
                     return Redirect::back()->with(['errorPersonal' => $validator->messages()->all()])->withInput();
                 }
                 $input = Input::all();
                 $fullname = $input['nombres'] . " " . $input['apellidos'];
                 //            $password = ($data['password']!='')?Hash::make(Input::get('password')):$data['oldpassword'];
                 // Profile Image Upload
                 if (Input::hasFile('foto')) {
                     $path = public_path() . "/profileImages/";
                     File::makeDirectory($path, $mode = 0777, true, true);
                     $image = Input::file('foto');
                     $extension = $image->getClientOriginalExtension();
                     $filename = "{$fullname}_{$id}." . 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);
                 } else {
                     $filename = Input::get('hiddenImage');
                 }
                 $ben->update(['nombres' => ucwords(strtolower($input['nombres'])), 'apellidos' => ucwords(strtolower($input['apellidos'])), 'genero' => $input['genero'], 'fechanac' => trim(Input::get('fechanac')) != '' ? date('Y-m-d', strtotime(Input::get('fechanac'))) : null, 'telefono' => $input['telefono'], 'direccion' => $input['direccion'], 'foto' => isset($filename) ? $filename : 'default.jpg', 'direccionperm' => $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']]);
                 Activity::log(['contentId' => $id, 'contentType' => 'Beneficiario', 'user_id' => Auth::admin()->get()->id, 'action' => 'Update', 'description' => 'Actualizacion ' . Input::get('updateType'), 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $id ? true : false]);
                 return Redirect::route('admin.beneficiarios.edit', $id)->with('successPersonal', "<strong>Actualizacion</strong> Existosa");
             } else {
                 if (Input::get('updateType') == 'responsable') {
                     //            dd(Input::all());
                     $per = Personal::where('personalID', '=', $id)->get()->first();
                     $validator = Validator::make($input = Input::all(), Personal::rules('personalInfo', $per->id));
                     if ($validator->fails()) {
                         $output['status'] = 'error';
                         $output['msg'] = $validator->getMessageBag()->toArray();
                     } else {
                         $responsable = Personal::firstOrNew(['personalID' => $id]);
                         $responsable->personalID = $input['ciResponsable'];
                         $responsable->emision = $input['ciResponsableEmision'];
                         $responsable->nombres = ucwords(strtolower($input['nombresReponsable']));
                         $responsable->apellidos = ucwords(strtolower($input['apellidosResponsable']));
                         $responsable->ocupacion = $input['ocupacionResponsable'];
                         $responsable->tipoPersonal = "Responsable";
                         $responsable->parentesco = Input::get('parentesco');
                         $responsable->save();
                         $output['status'] = 'success';
                         $output['msg'] = 'Persona actualizad correctamente....';
                     }
                     return $responsable;
                     return $responsable;
                 } else {
                     if (Input::get('updateType') == 'documents') {
                         $input = Input::all();
                         $ben = Beneficiario::where('beneficiarioID', '=', $id)->get()->first();
                         // -------------- UPLOAD THE DOCUMENTS  -----------------
                         $documents = ['certnac', 'CIprueba', 'solicitud', 'croquis', 'perfil'];
                         $fullname = $ben->nombres . " " . $ben->apellidos;
                         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}_{$id}_{$fullname}.{$extension}";
                                 Input::file($document)->move($path, $filename);
                                 $edoc = Bendocumentos::where('beneficiarioID', '=', $id)->get()->first();
                                 if ($edoc) {
                                     $edoc->fileName = $filename;
                                     $edoc->type = $document;
                                     $edoc->save();
                                 } else {
                                     $edoc = new Bendocumentos();
                                     $edoc->beneficiarioID = $id;
                                     $edoc->fileName = $filename;
                                     $edoc->type = $document;
                                     $edoc->save();
                                 }
                             }
                         }
                         Activity::log(['contentId' => $id, 'contentType' => 'Beneficiario', 'user_id' => Auth::admin()->get()->id, 'action' => 'Update', 'description' => 'Actualizacion ' . Input::get('updateType'), 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $id ? true : false]);
                         return Redirect::route('admin.beneficiarios.edit', $id)->with('successDocuments', "<strong>Actualizacion</strong> Existosa");
                         //  ********** END UPLOAD THE DOCUMENTS**********
                     }
                 }
             }
         }
     }
     Activity::log(['contentId' => $id, 'contentType' => 'Beneficiario', 'user_id' => Auth::admin()->get()->id, 'action' => 'Update', 'description' => 'Actualizacion ' . Input::get('updateType'), 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $id ? true : false]);
     //-------Documents info Details Update END--------
     return Response::json($output, 200);
 }
コード例 #6
0
 public function destroy($id)
 {
     Personal::where('personalID', '=', $id)->delete();
     Activity::log(['contentId' => $id, 'contentType' => 'Personal', 'user_id' => Auth::admin()->get()->id, 'action' => 'Borrado de Personal Aportante', 'description' => 'Borrado de Personal Aportante ', 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $id ? true : false]);
     $output['success'] = 'deleted';
     return Response::json($output, 200);
 }
コード例 #7
0
 public function edit($id)
 {
     $this->data['actividad'] = Actividad::find($id);
     $this->data['voluntarios'] = Personal::where('tipoPersonal', '=', 'Voluntario')->get();
     return View::make('admin.participaciones.edit', $this->data);
 }
コード例 #8
0
ファイル: PersonalController.php プロジェクト: vik70r/CTAS
 public function uploadImage($id = null)
 {
     $mensaje = "Ocurrio Error";
     if (Input::file("foto")->isValid()) {
         $fileName = Input::file('foto')->getClientOriginalName();
         $personal = Personal::where('id', '=', $id)->firstOrFail();
         $personal->foto = md5($id . "-" . $fileName) . '.' . Input::file('foto')->getClientOriginalExtension();
         if ($personal->save()) {
             Input::file('foto')->move('assets/foto', $personal->foto);
             $mensaje = "Imagen actualizado";
         }
     }
     return Redirect::to('personal/profile/' . $id)->withErrors($mensaje);
 }
コード例 #9
0
 public function verresidencia()
 {
     $residencia = Input::get('residencia', Auth::user()->residencia_id);
     $residencia = Residencias::select("personas.nombre as Dueño", "personas.*", "residencias.*")->leftjoin('personas', "personas.id", "=", "residencias.persona_id_propietario")->where("residencias.id", "=", $residencia)->first();
     $residentes = User::select("personas.*")->join("residencias", "personas.residencia_id", "=", "residencias.id")->where("residencias.id", "=", $residencia)->get();
     $personal = Personal::where("residencia_id", "=", $residencia)->get();
     $vehiculos = Vehiculo::where("residencia_id", "=", $residencia)->get();
     return View::make('verdatosresidencia')->withResidencia($residencia)->withResidentes($residentes)->withPersonal($personal)->withVehiculos($vehiculos);
 }