Пример #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $v = \Validator::make($request->all(), ['numresol' => 'required|numeric', 'fecresol' => 'required|date', 'stock' => 'required|numeric']);
     if ($v->fails()) {
         return redirect()->back()->withInput()->withErrors($v->errors());
     } else {
         Resolucion::where('id', $id)->update(['num_resol' => $request->get('numresol'), 'fec_resol' => $request->get('fecresol'), 'nota_resol' => $request->get('nota'), 'stock_consec' => $request->get('stock')]);
         return View('resol.viewresol')->with('mensaje', 'Resolución Actualizada Satisfactoriamente');
     }
 }
Пример #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     if ($request->ajax()) {
         //dd(Auth::user());
         $fecha = $request->get('fecha');
         $ident = $request->get('ident');
         $idserv = $request->get('idserv');
         $cant = $request->get('cantidad');
         $valuni = $request->get('valuni');
         $resol = Resolucion::select('act_consec')->where('estado', true)->first();
         $numfac = $resol->act_consec;
         //$result = array('numfac' => $numfac, 'fecha' => $fecha);
         DB::transaction(function () use($numfac, $fecha, $ident, $idserv, $cant, $valuni) {
             $cab = new FacturaCab(['numfac' => $numfac, 'fecfac' => $fecha, 'cod_ent' => $ident, 'estfac' => '1', 'usufac' => Auth::user()->id]);
             $cab->save();
             $i = 0;
             while ($i < count($idserv)) {
                 $det = new FacturaDet(['numfac' => $numfac, 'idserv' => $idserv[$i], 'cantserv' => $cant[$i], 'valserv' => $valuni[$i]]);
                 $i++;
                 $det->save();
             }
             Resolucion::where('estado', true)->update(['act_consec' => $numfac + 1]);
         });
         return response()->json(["numfac" => $numfac]);
     }
 }