/** * Store a newly created resource in storage. * * @return Response */ public function store(BenefRequest $request) { $benef = Benef::create($request->all()); if ($request->input('tipo') == 'Proveedor') { $proveedor = new Proveedor(); $benef->proveedores()->save($proveedor); } return redirect()->back()->with(['message' => 'Beneficiario registrado con éxito']); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $sol = Solicitud::findOrFail($id); $arr_tipos_solicitud['Reposicion'] = 'Reposicion (Reembolso)'; $arr_tipos_solicitud['Recibo'] = 'Recibo (Pago a Proveedor)'; $arr_tipos_solicitud['Vale'] = 'Vale (Gasto por Comprobar)'; $urgs = Urg::all(array('id', 'urg', 'd_urg')); foreach ($urgs as $urg) { $arr_urgs[$urg->id] = $urg->urg . ' - ' . $urg->d_urg; } $benefs = Benef::all(array('id', 'benef')); $benefs = $benefs->sortBy('benef'); foreach ($benefs as $benef) { $arr_benefs[$benef->id] = $benef->benef; } $arr_proyectos = \FiltroAcceso::getArrProyectos(); $vobos = FirmasSolRec::getUsersVoBo(); $arr_vobo[0] = 'Sin Vo. Bo.'; foreach ($vobos as $vobo) { $arr_vobo[$vobo->id] = $vobo->nombre . ' - ' . $vobo->cargo; } return view('solicitudes.formSolicitud')->with('sol', $sol)->with('tipos_solicitud', $arr_tipos_solicitud)->with('urgs', $arr_urgs)->with('proyectos', $arr_proyectos)->with('benefs', $arr_benefs)->with('arr_vobo', $arr_vobo); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $egreso = Egreso::findOrFail($id); $cuentas = Cuenta::whereIn('tipo', ['Ejecutora'])->lists('cuenta', 'id')->all(); $cuentas_bancarias = CuentaBancaria::all()->lists('cuenta_tipo_urg', 'id'); $benefs = Benef::all()->sortBy('benef')->lists('benef', 'id'); $fecha = null; $cheque = null; return view('egresos.formEgreso', compact('egreso', 'fecha', 'cheque', 'cuentas', 'cuentas_bancarias', 'benefs')); }
public function importarSolicitudes() { $solicitudes_legacy = $this->consultarSolicitudesLegacy(); foreach ($solicitudes_legacy as $sol_legacy) { $benef = \DB::connection('legacy_benef')->table('tbl_benef')->where('benef_id', '=', $sol_legacy->benef_id)->value('benef'); $benef_id = Benef::whereBenef($benef)->pluck('id'); $proyecto = Proyecto::whereProyecto($sol_legacy->proy)->first(['id', 'urg_id']); //Determinar el ID del usuario solicitante $solicita_id = User::whereLegacyUsername($sol_legacy->solicita)->pluck('id'); //Determinar el usuario responsable if ($sol_legacy->responsable == 'Presupuesto') { $usuario = \InfoDirectivos::getResponsable('PRESU'); $user_id = $usuario->id; } elseif ($sol_legacy->responsable == 'Contabilidad') { $usuario = \InfoDirectivos::getResponsable('CONTA'); $user_id = $usuario->id; } elseif ($sol_legacy->responsable == 'Recepcion') { //Buscar primer usuario con rol recepcion $user_id = 2; } else { $user_id = User::whereLegacyUsername($sol_legacy->responsable)->pluck('id'); } if (empty($sol_legacy->inventariable)) { $inventariable = 0; } else { $inventariable = 1; } $sol_nueva = new Solicitud(); $sol_nueva->fecha = $sol_legacy->fecha; $sol_nueva->benef_id = $benef_id; $sol_nueva->tipo_solicitud = $sol_legacy->tipo_solicitud; $sol_nueva->urg_id = $proyecto->urg_id; $sol_nueva->proyecto_id = $proyecto->id; $sol_nueva->concepto = $sol_legacy->concepto; $sol_nueva->obs = $sol_legacy->obs . ' #SIGI: ' . $sol_legacy->solicitud_id; $sol_nueva->no_documento = $sol_legacy->no_documento; $sol_nueva->no_afin = $sol_legacy->id_afin; $sol_nueva->monto = $sol_legacy->monto; $sol_nueva->solicita = $solicita_id; $sol_nueva->estatus = $sol_legacy->estatus; $sol_nueva->user_id = $user_id; //responsable $sol_nueva->monto_pagado = $sol_legacy->monto_pagado; $sol_nueva->viaticos = $sol_legacy->viaticos; $sol_nueva->inventariable = $inventariable; $sol_nueva->save(); if ($sol_nueva->estatus != 'Cancelada') { if ($sol_legacy->tipo_solicitud != 'Vale') { $rms_solicitud = $this->consutlarRMs($sol_legacy->solicitud_id); foreach ($rms_solicitud as $rm_legacy) { $rm_id = Rm::whereRm($rm_legacy->rm)->value('id'); $sol_nueva->rms()->attach($rm_id, ['monto' => $rm_legacy->monto]); } } else { //Buscar si tiene capturado el objetivo $objs_solicitud = $this->consultarObjetivos($sol_legacy->solicitud_id); if (count($objs_solicitud) > 0) { foreach ($objs_solicitud as $obj_legacy) { $objetivo_id = Objetivo::whereObjetivo($obj_legacy->objetivo)->pluck('id'); if (empty($obj_legacy)) { dd($obj_legacy); } $sol_nueva->objetivos()->attach($objetivo_id, ['monto' => $obj_legacy->monto]); } } else { //Si no, asigna primer objetivo que encuentre en el proyecto $objetivo_id = Rm::whereProyectoId($sol_nueva->proyecto_id)->pluck('objetivo_id'); if (empty($objetivo_id->objetivo_id)) { $objetivo_id = 1; } $sol_nueva->objetivos()->attach($objetivo_id, ['monto' => $sol_nueva->monto]); } } } } }
private function getBenefId($legacy_benef_id) { $benef = \DB::connection('legacy_benef')->table('tbl_benef')->where('benef_id', '=', $legacy_benef_id)->value('benef'); $benef_id = Benef::whereBenef($benef)->pluck('id'); return $benef_id; }
/** * Show the form for creating a new resource. * * @return Response */ public function create($destino, $porcentaje, $doc_type, $doc_id) { /** * @todo Seleccionar cuenta bancaria en función del proyecto */ $data['porcentaje'] = $porcentaje; $data['doc_type'] = $doc_type; $data['doc_id'] = $doc_id; $data['cuentas_bancarias'] = CuentaBancaria::all()->lists('cuenta_tipo_urg', 'id'); $data['cheque'] = \Consecutivo::nextCheque($data['cuentas_bancarias']->keys()[0]); $data['tipo_pago_sel'] = ''; if ($destino != 'reintegro') { //Pago con cargo al presupuesto $data['benefs'] = Benef::all()->sortBy('benef')->lists('benef', 'id'); $data['cuenta_id'] = 1; if ($porcentaje < 100) { $data['tipo_pago_sel'] = 'Parcial'; } /** * @todo Implementar lógica para determinar selección del tipo de pago * Si existen otros pagos: * Si Sum(monto_a_pagar_x_rm) + sum(otros_pagos) == totalAutorizado: * tipo_pago_sel = 'Finiquito'; * else: * tipo_pago_sel = 'Parcial'; * else: * tipo_pago_sel = ''; */ /** * @todo Si $doc->estatus == 'Pago Parcial' -> No listar 'Total' en tipo_pago */ $data['tipo_pago'] = ['Total' => 'Total', 'Parcial' => 'Parcial', 'Finiquito' => 'Finiquito']; } else { //Reintegros $data['benefs'] = Benef::whereId(1)->lists('benef', 'id'); $data['cuenta_id'] = 2; /** * @todo Si existen pagos, tipo_pago_sel = 'Reintegro Parcial' */ $data['tipo_pago'] = ['Reintegro Total' => 'Reintegro Total', 'Reintegro Parcial' => 'Reintegro Parcial']; } $doc = ''; $arr_rms = []; if ($doc_type == 'Solicitud') { $doc = Solicitud::findOrFail($doc_id); $doc->load('rms.cog', 'proyecto'); $data['concepto'] = $doc->concepto; //Creación de Arreglo foreach ($doc->rms as $rm) { $arr_rms[$rm->id] = ['rm' => $rm->rm, 'cog' => $rm->cog->cog, 'monto' => 0]; } //Suma por Rm foreach ($doc->rms as $rm) { $arr_rms[$rm->id]['monto'] += round($rm->pivot->monto, 2); } } if ($doc_type == 'Oc') { $doc = Oc::findOrFail($doc_id); $doc->load('articulos.rms.cog', 'req.proyecto'); $data['concepto'] = ''; //Creación de Arreglo foreach ($doc->articulos as $articulo) { foreach ($articulo->rms as $rm) { $arr_rms[$rm->id] = ['rm' => $rm->rm, 'cog' => $rm->cog->cog, 'monto' => 0]; } } //Suma por Rm foreach ($doc->articulos as $articulo) { foreach ($articulo->rms as $rm) { $arr_rms[$rm->id]['monto'] += round($rm->pivot->monto, 2); } } } $data['doc'] = $doc; $data['arr_rms'] = $arr_rms; return view('egresos.formGeneraEgreso')->with($data); }
private function consultarBenefsExternos() { $benefs_importados = Benef::lists('benef')->all(); if (count($benefs_importados) > 0) { $benefs_externos = \DB::connection($this->db_origen)->table('tbl_benef')->whereNotIn('benef', $benefs_importados)->get(); } else { $benefs_externos = \DB::connection($this->db_origen)->table('tbl_benef')->get(); } return $benefs_externos; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $benefs = Benef::all(array('id', 'benef')); $benefs = $benefs->sortBy('benef'); foreach ($benefs as $benef) { $arr_benefs[$benef->id] = $benef->benef; } $invitacion = Cotizacion::findOrFail($id); return view('invita.formInvita')->with('cotizacion', $invitacion)->with('benefs', $arr_benefs)->with('req_id', $invitacion->req_id); }
$arr_proyectos = \FiltroAcceso::getArrProyectos(); foreach ($arr_proyectos as $k => $v) { $proyectos[] = ['id' => $k, 'proyecto_descripcion' => $v]; } return response()->json($proyectos); }); Route::get('/egresos-proyecto/', function () { $proyecto_id = \Input::get('proyecto_id'); $egresos = \Guia\Models\Proyecto::findOrFail($proyecto_id)->egresos()->with('benef', 'cuentaBancaria', 'cuenta', 'user')->with('rms.cog')->get(); return response()->json($egresos); }); Route::get('/egresos-benef/', function () { $benef_id = \Input::get('benef_id'); $egresos = \Guia\Models\Benef::findOrFail($benef_id)->egresos()->with('benef')->with('cuentaBancaria')->with('cuenta')->with('user')->get(); return response()->json($egresos); }); Route::get('/benef-search/', function () { $benef_search = \Input::get('term'); $benefs = \Guia\Models\Benef::where('benef', 'LIKE', '%' . $benef_search . '%')->orderBy('benef')->get(['benef']); foreach ($benefs as $benef) { $arr_benefs[] = ['value' => $benef->benef]; } return response()->json($arr_benefs); }); Route::get('/benef-id/', function () { $benef = \Input::get('benef'); $benef_id = \Guia\Models\Benef::where('benef', 'LIKE', $benef)->pluck('id'); $arr_benef_id = ['benef_id' => $benef_id]; return response()->json($arr_benef_id); }); });