예제 #1
0
 public function edit(Request $request)
 {
     $brand = $this->serviceRepo->find($request->id);
     //var_dump($brand);
     //die();
     $manager = new ServiceManager($brand, $request->all());
     $manager->save();
     //Event::fire('update.brand',$brand->all());
     return response()->json(['estado' => true, 'nombre' => $brand->nombre]);
 }
예제 #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit(Request $request)
 {
     \DB::beginTransaction();
     $varDetOrders = $request->detOrder;
     $varPayment = $request->payment;
     $movimiento = $request->movimiento;
     if ($movimiento['montoMovimientoEfectivo'] > 0) {
         //---create movimiento---
         //var_dump($request->movimiento);die();
         $detCashrepo;
         $movimiento['observacion'] = "temporal";
         $movimiento['fecha'] = date('Y-m-d');
         $movimiento['hora'] = date('H:i:s');
         $detCashrepo = new DetCashRepo();
         $movimientoSave = $detCashrepo->getModel();
         $insertarMovimiento = new DetCashManager($movimientoSave, $movimiento);
         $insertarMovimiento->save();
         //---Autualizar Caja---
         $cajaAct = $request->caja;
         $cashrepo;
         $cashrepo = new CashRepo();
         $cajaSave = $cashrepo->getModel();
         $cash1 = $cashrepo->find($cajaAct["id"]);
         $manager1 = new CashManager($cash1, $cajaAct);
         $manager1->save();
         //----------------
         $salePaymentRepo;
         $salePaymentRepo = new SalePaymentRepo();
         //$payment = $salePaymentRepo->find($varPayment['id']);
         $payment = $salePaymentRepo->find($varPayment['idPAY']);
         $manager = new SalePaymentManager($payment, $varPayment);
         $manager->save();
     }
     $HeadStockRepo;
     $codigoHeadIS = 0;
     //$detOrderSaleRepo;
     foreach ($varDetOrders as $object) {
         //$detOrderSaleRepo = new DetSaleRepo;
         //$detorderSale = $detOrderSaleRepo->find($object['id']);
         //$manager = new DetSaleManager($detorderSale,$object);
         //$manager->save();
         if (!empty($object['idStock'])) {
             $stokRepo;
             $stokRepo = new StockRepo();
             $cajaSave = $stokRepo->getModel();
             $stockOri = $stokRepo->find($object['id']);
             $stock = $stokRepo->find($object['idStock']);
             //+++if ($object['estad']==true) {
             $stock->stockActual = $stock->stockActual + $object['cantidad'];
             //+++}else{
             //+++$stock->stockPedidos= $stock->stockPedidos+$object['canPendiente'];
             //+++}
             $stock->save();
             //--------------reporte stock------------
             $object["variant_id"] = $object['vari'];
             if ($codigoHeadIS === 0) {
                 $object["warehouses_id"] = $object['idAlmacen'];
                 //$object["cantidad_llegado"]=$cantidaCalculada;
                 //$object['descripcion']='Entrada por compra';
                 //$object['tipo']='Entrada Venta';
                 $object['tipo'] = 'Entrada-Anulado';
                 $object["user_id"] = auth()->user()->id;
                 //$object["Fecha"]=$request->input("fechaPedido");
                 $object["Fecha"] = date('Y-m-d H:i:s');
                 $HeadStockRepo = new HeadInputStockRepo();
                 $HeadStock = $HeadStockRepo->getModel();
                 $HeadStockinsert = new HeadInputStockManager($HeadStock, $object);
                 $HeadStockinsert->save();
                 $codigoHeadIS = $HeadStock->id;
             }
             $object['headInputStock_id'] = $codigoHeadIS;
             $object["producto"] = $object['nameProducto'] . "(" . $object['NombreAtributos'] . ")";
             $object["cantidad_llegado"] = $object['cantidad'];
             $object['descripcion'] = 'Entrada-Venta-Anulada';
             $inputRepo;
             $inputRepo = new InputStockRepo();
             $inputstock = $inputRepo->getModel();
             $inputInsert = new InputStockManager($inputstock, $object);
             $inputInsert->save();
         }
         //---------------------------------------
     }
     $orderSale = $this->saleRepo->find($request->id);
     if ($request->input('estado') == '3') {
         $request->merge(array('fechaAnulado' => date('Y-m-d H:i:s')));
     }
     $manager = new SaleManager($orderSale, $request->all());
     $manager->save();
     $serviceID = $orderSale->service_id;
     if (!empty($serviceID)) {
         $servicio = $this->serviceRepo->find($serviceID);
         $request->merge(["estado" => 4]);
         $request->merge(["numeroServicio" => $servicio->numeroServicio]);
         $request->merge(["fechaServicio" => $servicio->fechaServicio]);
         $request->merge(["tipo" => $servicio->tipo]);
         $request->merge(["cliente" => $servicio->cliente]);
         $request->merge(["ruc" => $servicio->ruc]);
         $request->merge(["direcion" => $servicio->direcion]);
         $request->merge(["telefono" => $servicio->telefono]);
         $request->merge(["empresa" => $servicio->empresa]);
         $request->merge(["descripcion" => $servicio->descripcion]);
         $request->merge(["modelo" => $servicio->modelo]);
         $request->merge(["serie" => $servicio->serie]);
         $request->merge(["accesorios" => $servicio->accesorios]);
         $request->merge(["diagnostico" => $servicio->diagnostico]);
         $request->merge(["accionCorrectiva" => $servicio->accionCorrectiva]);
         $request->merge(["ordenTrabajo" => $servicio->ordenTrabajo]);
         $request->merge(["customer_id" => $servicio->customer_id]);
         $request->merge(["employee_id" => $servicio->employee_id]);
         $request->merge(["user_id" => $servicio->user_id]);
         $manager = new ServiceManager($servicio, $request->all());
         $manager->save();
     }
     \DB::commit();
     return response()->json(['estado' => true, 'nombre' => $orderSale->nombre]);
 }