public function post()
 {
     $post = Input::all();
     $validator = Adjustment::validate($post);
     $adjustmentId = $post['id'];
     if ($validator->fails()) {
         return Redirect::to('ajustes/' . $adjustmentId)->withErrors($validator)->withInput();
     } else {
         $adjustment = self::__checkExistence($adjustmentId);
         if (!$adjustmentId) {
             DB::beginTransaction();
             $adjustment = new Adjustment();
             $adjustment->products_id = $post['products_id'];
             $adjustment->users_id = Auth::user()->id;
             $adjustment->type = $post['type'];
             $adjustment->amount = $post['amount'];
             $adjustment->reason = $post['reason'];
             $adjustment->save();
             $product = Product::find($post['products_id']);
             if ($post['type'] == 'credit') {
                 $product->stock = $product->stock + $post['amount'];
                 $product->save();
             } else {
                 if ($product->stock >= $post['amount']) {
                     $product->stock = $product->stock - $post['amount'];
                     $product->save();
                     Globals::triggerAlerts(1, array('productId' => $product->id));
                     Globals::triggerAlerts(2, array('productId' => $product->id));
                 } else {
                     Session::flash('error', 'No se puede debitar más de lo que hay en stock.');
                     DB::rollback();
                     return Redirect::to('ajustes');
                 }
             }
             Session::flash('success', 'Ajuste realizado exitosamente.');
             DB::commit();
         }
         return Redirect::to('ajustes');
     }
 }