当前位置: 首页>>代码示例>>PHP>>正文


PHP Globals::triggerAlerts方法代码示例

本文整理汇总了PHP中Globals::triggerAlerts方法的典型用法代码示例。如果您正苦于以下问题:PHP Globals::triggerAlerts方法的具体用法?PHP Globals::triggerAlerts怎么用?PHP Globals::triggerAlerts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Globals的用法示例。


在下文中一共展示了Globals::triggerAlerts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post

 public function post()
 {
     $post = Input::all();
     $validator = Product::validate($post);
     $productId = $post['id'];
     if ($validator->fails()) {
         return Redirect::to('productos/' . $productId)->withErrors($validator)->withInput();
     } else {
         $product = self::__checkExistence($productId);
         $isNew = false;
         if (!$productId) {
             $product = new Product();
             $isNew = true;
         }
         $product->name = $post['name'];
         $product->description = $post['description'];
         $product->code = $post['code'];
         $product->minimum_stock = $post['minimum_stock'];
         $product->cost = str_replace(',', '.', $post['cost']);
         $product->save();
         if ($isNew) {
             Globals::triggerAlerts(4, array('productId' => $product->id));
         }
         if ($post['status'] == 'inactive') {
             $product->delete();
         } else {
             if ($product->trashed()) {
                 $product->restore();
             }
         }
         Session::flash('success', 'Producto guardado correctamente.');
         return Redirect::to('productos');
     }
 }
开发者ID:frankpaul142,项目名称:cloudinventory,代码行数:34,代码来源:ProductController.php

示例2: post

 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');
     }
 }
开发者ID:frankpaul142,项目名称:cloudinventory,代码行数:40,代码来源:AdjustmentController.php

示例3: post

 public function post()
 {
     $post = Input::all();
     if ($post['products'] == '[]') {
         $post['products'] = '';
     }
     $validator = SupplierOrder::validate($post);
     if ($validator->fails()) {
         return Redirect::to('pedidos/' . $post['id'])->withErrors($validator)->withInput();
     } else {
         try {
             DB::transaction(function () use($post) {
                 $supplierOrder = self::__checkExistence($post['id']);
                 if (!$supplierOrder) {
                     //new order
                     $supplierOrder = new SupplierOrder();
                     $supplierOrder->suppliers_id = $post['suppliers_id'];
                     $supplierOrder->users_id = Auth::user()->id;
                     $supplierOrder->code = $post['code'];
                     $supplierOrder->save();
                     $products = json_decode($post['products']);
                     $toSync = array();
                     foreach ($products as $current) {
                         $product = Product::find($current->id);
                         if (!is_null($product)) {
                             $toSync[$current->id]['cost'] = $product->cost;
                             $toSync[$current->id]['amount'] = $current->amount;
                         }
                     }
                     $supplierOrder->products()->sync($toSync);
                     Globals::triggerAlerts(5, array('supplierOrderId' => $supplierOrder->id));
                 } else {
                     if (isset($post['received']) and $post['received'] == 1) {
                         //received
                         $supplierOrder->status = 'received';
                         $supplierOrder->save();
                         foreach ($supplierOrder->products as $pivotProduct) {
                             $array = $pivotProduct->toArray();
                             $product = Product::find($array['id']);
                             if (!is_null($product)) {
                                 $product->stock = $product->stock + $array['pivot']['amount'];
                                 $product->save();
                             }
                         }
                         Globals::triggerAlerts(6, array('supplierOrderId' => $supplierOrder->id));
                     } elseif (isset($post['received']) and $post['received'] == 2) {
                         //canceled
                         $supplierOrder->status = 'canceled';
                         $supplierOrder->save();
                     } else {
                         Session::flash('error', 'Error en la recepción de su pedido, por favor vuelva a intentarlo.');
                     }
                 }
             });
             Session::flash('success', 'Pedido procesado exitosamente.');
         } catch (Exception $e) {
             Session::flash('error', 'Ocurrió un error inesperado, por favor vuelva a intentarlo.');
         }
         return Redirect::to('pedidos');
     }
 }
开发者ID:frankpaul142,项目名称:cloudinventory,代码行数:61,代码来源:SupplierOrderController.php


注:本文中的Globals::triggerAlerts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。