コード例 #1
0
 /**
  * Returns a new grid instance of all available inventory variants.
  *
  * @param int|string $id
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function grid($id)
 {
     $columns = ['id', 'name', 'category_id', 'created_at'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
     $transformer = function (Inventory $inventory) {
         return ['id' => $inventory->id, 'sku' => $inventory->sku_code ? $inventory->sku_code : '<em>None</em>', 'name' => $inventory->name, 'category' => $inventory->category ? $inventory->category->trail : null, 'current_stock' => $inventory->viewer()->lblCurrentStock(), 'created_at' => $inventory->created_at, 'view_url' => route('maintenance.inventory.show', [$inventory->id])];
     };
     return $this->inventory->gridVariants($id, $columns, $settings, $transformer);
 }
コード例 #2
0
 /**
  * Displays the form for taking inventory stock
  * and attaching it to the specified work order.
  *
  * @param int|string $workOrderId
  * @param int|string $inventoryId
  * @param int|string $stockId
  *
  * @return \Illuminate\View\View
  */
 public function getTake($workOrderId, $inventoryId, $stockId)
 {
     $workOrder = $this->workOrder->find($workOrderId);
     $item = $this->inventory->find($inventoryId);
     $stock = $item->stocks()->find($stockId);
     if ($stock instanceof InventoryStock) {
         return view('maintenance::work-orders.parts.inventory.stocks.take', compact('workOrder', 'item', 'stock'));
     }
     abort(404);
 }
コード例 #3
0
 /**
  * Regenerates the SKU for the specified item.
  *
  * @param int|string $id
  *
  * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
  */
 public function regenerate($id)
 {
     $item = $this->inventory->regenerateSku($id);
     if ($item) {
         $message = 'Successfully regenerated SKU.';
         return redirect()->route('maintenance.inventory.show', [$item->id])->withSuccess($message);
     } else {
         $message = 'There was an issue regenerating the SKU for this item. Please try again.';
         return redirect()->route('maintenance.inventory.show', [$item->id])->withErrors($message);
     }
 }
コード例 #4
0
 /**
  * Processes creating a variant of the specified
  * inventory item.
  *
  * @param VariantRequest $request
  * @param int|string     $inventoryId
  *
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
  */
 public function store(VariantRequest $request, $inventoryId)
 {
     $variant = $this->inventory->createVariant($request, $inventoryId);
     if ($variant) {
         $message = sprintf('Successfully created item variant: %s', link_to_route('maintenance.inventory.show', 'Show', [$variant->id]));
         return redirect()->route('maintenance.inventory.show', [$inventoryId, '#tab-variants'])->withSuccess($message);
     } else {
         $message = 'There was an error creating a variant of this item. Please try again.';
         return redirect()->route('maintenance.inventory.show', [$inventoryId])->withErrors($message);
     }
 }
コード例 #5
0
 /**
  * Updates an inventory stock record.
  *
  * @param Request      $request
  * @param int|string   $inventoryId
  * @param int|string   $stockId
  *
  * @return bool|InventoryStock
  */
 public function update(Request $request, $inventoryId, $stockId)
 {
     $item = $this->inventory->model()->findOrFail($inventoryId);
     $stock = $item->stocks()->findOrFail($stockId);
     $stock->location_id = $request->input('location_id', $stock->location_id);
     $stock->quantity = $request->input('quantity', $stock->quantity);
     $stock->reason = $request->input('reason');
     $stock->cost = $request->input('cost', 0);
     if ($stock->save()) {
         return $stock;
     }
     return false;
 }
コード例 #6
0
 /**
  * Returns a new grid instance of all available
  * inventory variants for selection.
  *
  * @param int|string $workOrderId
  * @param int|string $inventoryId
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function gridVariants($workOrderId, $inventoryId)
 {
     $workOrder = $this->workOrder->model()->findOrFail($workOrderId);
     $columns = ['id', 'name', 'category_id', 'created_at'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
     $transformer = function (Inventory $item) use($workOrder) {
         return ['id' => $item->id, 'sku' => $item->sku_code ? $item->sku_code : '<em>None</em>', 'name' => $item->name, 'category' => $item->category ? $item->category->trail : null, 'current_stock' => $item->viewer()->lblCurrentStock(), 'created_at' => $item->created_at, 'view_url' => route('maintenance.inventory.show', [$item->id]), 'select_url' => route('maintenance.work-orders.parts.stocks.index', [$workOrder->id, $item->id])];
     };
     return $this->inventory->gridVariants($inventoryId, $columns, $settings, $transformer);
 }
コード例 #7
0
 /**
  * Deletes the specified note attached to the specified inventory.
  *
  * @param int|string $id
  * @param int|string $noteId
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($id, $noteId)
 {
     if ($this->inventory->deleteNote($id, $noteId)) {
         $message = 'Successfully updated note.';
         return redirect()->route('maintenance.inventory.show', [$id])->withSuccess($message);
     } else {
         $message = 'There was an issue deleting this note. Please try again.';
         return redirect()->route('maintenance.inventory.notes.show', [$id, $noteId])->withErrors($message);
     }
 }
コード例 #8
0
ファイル: Controller.php プロジェクト: redknitin/maintenance
 /**
  * Removes the specified inventory.
  *
  * @param int|string $id
  *
  * @return \Illuminate\Http\JsonResponse|mixed
  */
 public function destroy($id)
 {
     $item = $this->inventory->model()->findOrFail($id);
     if ($item->delete()) {
         $message = 'Successfully deleted inventory item.';
         return redirect()->route('maintenance.inventory.index')->withSuccess($message);
     } else {
         $message = 'There was an issue deleting this inventory item. Please try again.';
         return redirect()->route('maintenance.inventory.show', [$id])->withSuccess($message);
     }
 }
コード例 #9
0
 /**
  * @param $view
  *
  * @return mixed
  */
 public function compose(View $view)
 {
     return $view->with('users', $this->user->all()->count())->with('assets', $this->asset->all()->count())->with('inventories', $this->inventory->all()->count())->with('workOrders', $this->workOrder->all()->count());
 }