예제 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $item = Inventory::findBySku(Input::get('sku'));
     $location = Location::find(Input::get('location_id'));
     if ($item) {
         if ($location) {
             //echo "Found location, adding stock";
             //echo "<br>";
             $stock = $item->getStockFromLocation($location);
             $reason = Input::get('reason');
             $cost = Input::get('price');
             $stock->put(Input::get('new_quantity'), $reason, $cost);
         } else {
             // Location not found
         }
     } else {
         // Item not found
     }
     //$locations = Location::orderBy('name')->lists('name', 'id');
     //return view('scan', compact('locations'))->with('message', 'Product added to stock');
     // TODO ->with('message', 'xxx') doesn't work
     return redirect('stockin')->with('message', 'Inventory item added to stock.');
     //Redirect::route('scan',compact('locations'))->with('message', 'Product added to stock');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $input = Input::all();
     Location::find($id)->update($input);
     return Redirect::route('location.index')->with('message', 'Location updated.');
 }
예제 #3
0
 public function testInventoryMoveItemStock()
 {
     $this->newInventoryStock();
     $locationFrom = Location::find(1);
     $locationTo = new Location();
     $locationTo->name = 'New Location';
     $locationTo->save();
     $item = Inventory::find(1);
     $item->moveStock($locationFrom, $locationTo);
     $stock = InventoryStock::find(1);
     $this->assertEquals(2, $stock->location_id);
 }