public function store()
 {
     $importador = new \Gia\Classes\ImportadorProyecto('/uploads/proyectos/temp.txt');
     $importador->extraer();
     $urg = Urg::whereUrg($importador->urg)->get(array('id'));
     $fondo = Fondo::whereFondo($importador->fondo)->get(array('id'));
     $arr_inicio = explode("/", $importador->inicio);
     $arr_fin = explode("/", $importador->fin);
     $proyecto = new Proyecto();
     $proyecto->proyecto = $importador->proy;
     $proyecto->d_proyecto = $importador->d_proyecto;
     $proyecto->monto = $importador->monto_proy;
     $proyecto->urg_id = $urg[0]->id;
     $proyecto->tipo_proyecto_id = 1;
     $proyecto->aaaa = $importador->aaaa;
     $proyecto->inicio = $arr_inicio[2] . "-" . $arr_inicio[1] . "-" . $arr_inicio[0];
     $proyecto->fin = $arr_fin[2] . "-" . $arr_fin[1] . "-" . $arr_fin[0];
     $proyecto->save();
     //Inserta datos @fondo_proyecto
     $proyecto->fondos()->attach($fondo[0]->id);
     $arr_objetivos = array();
     foreach ($importador->arr_recursos as $partida => $val) {
         //Buscar objetivo en key del arreglo
         $objetivo_id = array_search($val['objetivo'], $arr_objetivos);
         //Si no se encuentra
         if (empty($objetivo_id)) {
             $objetivo = new Objetivo();
             $objetivo->objetivo = $val['objetivo'];
             $objetivo->d_objetivo = $val['d_objetivo'];
             $objetivo->save();
             $objetivo_id = $objetivo->id;
             $arr_objetivos[$objetivo->id] = $val['objetivo'];
         }
         $cog = Cog::whereCog($val['cog'])->get();
         $rm = new Rm();
         $rm->rm = $partida;
         $rm->proyecto_id = $proyecto->id;
         $rm->objetivo_id = $objetivo_id;
         $rm->actividad_id = 1;
         $rm->cog_id = $cog[0]->id;
         $rm->fondo_id = $fondo[0]->id;
         $rm->monto = $val['monto'];
         $rm->d_rm = "";
         $rm->save();
     }
     return Redirect::action('ProyectosController@index');
 }
Ejemplo n.º 2
0
 private function importarDocsPendientes()
 {
     //Importar OCs c/alta pendiente
     $oc_importadas = Alta::where('tipo', '=', 'oc')->lists('doc_id');
     if (count($oc_importadas) > 0) {
         $oc_pendientes = DB::connection('sigi14')->table('tbl_req_art')->select('req', 'oc')->whereNotIn('oc', $oc_importadas)->where('alta', '=', '1')->distinct()->get();
     } else {
         $oc_pendientes = DB::connection('sigi14')->table('tbl_req_art')->select('req', 'oc')->where('alta', '=', '1')->distinct()->get();
     }
     foreach ($oc_pendientes as $ocp) {
         $sel_proy = DB::connection('sigi14')->table('tbl_req')->leftJoin('tbl_proyectos', 'tbl_req.proy', '=', 'tbl_proyectos.proy')->where('req', '=', $ocp->req)->get(array('ures'));
         $urg = Urg::whereUrg($sel_proy[0]->ures)->get(array('id'));
         $alta = new Alta();
         $alta->doc_id = $ocp->oc;
         $alta->tipo = 'oc';
         $alta->egreso_id = '';
         $alta->urg_id = $urg[0]->id;
         $alta->debito = '';
         $alta->estatus = 'Pendiente';
         $alta->save();
     }
     //Importar OCs c/alta pendiente
     $sol_importadas = Alta::where('tipo', '=', 'sol')->lists('doc_id');
     if (count($sol_importadas) > 0) {
         $sol_pendientes = DB::connection('sigi14')->table('tbl_solicitud')->select('solicitud_id', 'proy')->whereNotIn('solicitud_id', $sol_importadas)->where('inventariable', '=', '1')->get();
     } else {
         $sol_pendientes = DB::connection('sigi14')->table('tbl_solicitud')->select('solicitud_id', 'proy')->where('inventariable', '=', '1')->get();
     }
     foreach ($sol_pendientes as $sol) {
         $sel_proy = DB::connection('sigi14')->table('tbl_proyectos')->where('proy', '=', $sol->proy)->get(array('ures'));
         $urg = Urg::whereUrg($sel_proy[0]->ures)->get(array('id'));
         $alta = new Alta();
         $alta->doc_id = $sol->solicitud_id;
         $alta->tipo = 'sol';
         $alta->egreso_id = '';
         $alta->urg_id = $urg[0]->id;
         $alta->debito = '';
         $alta->estatus = 'Pendiente';
         $alta->save();
     }
 }
Ejemplo n.º 3
0
 public function listarUrg()
 {
     $this->importarUrgNuevas();
     $urg_data = Urg::where('estatus', '=', '')->get();
     return View::make('', compact('urg_data'));
 }
Ejemplo n.º 4
0
 public function importarCuentas()
 {
     $cuentas_externas = $this->consultarCuentasExternas();
     if (count($cuentas_externas) > 0) {
         foreach ($cuentas_externas as $cuenta_nueva) {
             $urg = \Urg::whereUrg($cuenta_nueva->ures)->get(array('id'));
             !empty($cuenta_nueva->set_default) ? $activa = 1 : ($activa = 0);
             $cuenta = new \Cuenta();
             $cuenta->cuenta = $cuenta_nueva->cta_b;
             $cuenta->d_cuenta = $cuenta_nueva->d_cta_b;
             $cuenta->no_cuenta = $cuenta_nueva->no_cuenta;
             $cuenta->banco = $cuenta_nueva->banco;
             $cuenta->tipo = $cuenta_nueva->tipo;
             $cuenta->activa = $activa;
             $cuenta->urg_id = $urg[0]->id;
             $cuenta->save();
         }
     }
 }
Ejemplo n.º 5
0
 public function create()
 {
     $urgs = Urg::all(array('id', 'urg', 'd_urg'));
     $arr_proyectos = FiltroAcceso::getArrProyectos();
     return View::make('reqs.formRequisicion')->with('urgs', $urgs)->with('proyectos', $arr_proyectos);
 }