Exemplo n.º 1
0
 /**
  * IMPORTANT: Call this function name on the Controller to verify this action is allowed
  * Implement putInventoryIntoTote($inventoryID, $toteID)
  */
 public function putInventoryIntoTote($inventoryID, $toteID)
 {
     $inventory = Inventory::findOrFail($inventoryID);
     $tote = GenericContainer::findOrFail($toteID);
     $container = DB::connection(GenericContainer::CONNECTION_NAME)->table('container')->where('objectID', $inventoryID)->first();
     Log::info("Put Inventory {$inventoryID} into Tote {$toteID}");
     if (isset($container)) {
         $result = DB::connection(GenericContainer::CONNECTION_NAME)->table('container')->where('containerID', $container->containerID)->update(['parentID' => $toteID, 'objectID' => $inventoryID]);
         // $result === 1/true if the container was updated
         // $result === 0/false if no containers were updated
         if ($result === 1 or $result === 0) {
             return true;
         }
     } else {
         $result = Container::create(['parentID' => $toteID, 'objectID' => $inventoryID]);
         // $result == container object created
         if (isset($result) and get_class($result) == 'App\\vital3\\Container') {
             return true;
         }
     }
     Log::error('putInventoryIntoTote failed');
     //dd(__METHOD__.'('.__LINE__.')',compact('inventoryID','toteID','inventory','tote','container','result'));
     return ['putInventoryIntoTote failed'];
 }
 /**
  * Implement putLocationIntoWarehouse($locationID, $warehouseID)
  */
 public function putLocationIntoWarehouse($locationID, $warehouseID)
 {
     $location = Location::findOrFail($locationID);
     $warehouse = Warehouse::findOrFail($warehouseID);
     $container = DB::connection('vitaldev')->table('container')->where('objectID', $locationID)->first();
     Log::info("Put Location {$locationID} into Warehouse {$warehouseID}");
     if (isset($container)) {
         $result = DB::connection('vitaldev')->table('container')->where('containerID', $container->containerID)->update(['parentID' => $warehouseID, 'objectID' => $locationID]);
         // $result === 1/true if the container was updated
         // $result === 0/false if no containers were updated
         if ($result === 1 or $result === 0) {
             return true;
         }
     } else {
         $result = Container::create(['parentID' => $warehouseID, 'objectID' => $locationID]);
         // $result == container object created
         if (isset($result) and get_class($result) == 'App\\vital3\\Container') {
             return true;
         }
     }
     Log::error('putLocationIntoWarehouse failed');
     //dd(__METHOD__.'('.__LINE__.')',compact('locationID','warehouseID','location','warehouse','container','result'));
     return ['putLocationIntoWarehouse failed'];
 }