public function getEdit($nota_venta_id)
 {
     $nota_venta = NotaVenta::find($nota_venta_id);
     $vendedores = Vendedor::whereStatus('Activo')->orderBy('rut')->lists('rut', 'id');
     $clientes = Cliente::whereStatus('Activo')->orderBy('rut')->lists('rut', 'id');
     return View::make('sgrm.notas_venta.edit')->with('vendedores', $vendedores)->with('clientes', $clientes)->with('nota_venta', $nota_venta);
 }
 public function getDesactive($cliente_id)
 {
     $country = Cliente::find($cliente_id);
     $country->status = 'Inactivo';
     $country->save();
     return Redirect::back();
 }
 public function getEdit($orden_compra_cliente_id)
 {
     $orden_compra_cliente = OrdenCompraCliente::find($orden_compra_cliente_id);
     $vendedores = Vendedor::whereStatus('Activo')->orderBy('rut')->lists('rut', 'id');
     $clientes = Cliente::whereStatus('Activo')->orderBy('rut')->lists('rut', 'id');
     return View::make('sgrm.ordenes_compra_cliente.edit')->with('vendedores', $vendedores)->with('clientes', $clientes)->with('orden_compra_cliente', $orden_compra_cliente);
 }
 public function getEdit($factura_compra_id)
 {
     $factura_compra = FacturaCompra::find($factura_compra_id);
     $estados = Estado::whereStatus('Activo')->orderBy('id', 'DESC')->lists('nombre', 'id');
     $vendedores = Vendedor::whereStatus('Activo')->orderBy('rut')->lists('rut', 'id');
     $proveedores = Cliente::whereStatus('Activo')->orderBy('rut')->lists('rut', 'id');
     return View::make('sgrm.facturas_compra.edit')->with('estados', $estados)->with('vendedores', $vendedores)->with('proveedores', $proveedores)->with('factura_compra', $factura_compra);
 }
 public function postUpdate()
 {
     $ponderacion = Ponderacion::find(Input::get('id'));
     $ponderacion->condicion_1 = Input::get('condicion_1');
     $ponderacion->condicion_2 = Input::get('condicion_2');
     $ponderacion->save();
     $clientes = Cliente::all();
     foreach ($clientes as $cliente) {
         if ($cliente->ranking()->count() > 0) {
             $ranking_cliente = RankingCliente::find($cliente->ranking->id);
             $ranking_cliente->valoracion = $ponderacion->condicion_1 * round(rand(1000, 10000000)) + $ponderacion->condicion_2 * round(rand(100, 1000000));
             $ranking_cliente->save();
         } else {
             $ranking_cliente = new RankingCliente();
             $ranking_cliente->valoracion = $ponderacion->condicion_1 * round(rand(1000, 10000000)) + $ponderacion->condicion_2 * round(rand(100, 1000000));
             $ranking_cliente->cliente_rut = $cliente->rut;
             $ranking_cliente->save();
         }
     }
     return self::getIndex();
 }