/**
  * Apply the updates to our resource
  */
 public function update($id, PalletRequest $request)
 {
     // if guest or cannot pallet.edit, redirect -> home
     if (Entrust::can('pallet.edit') == false) {
         return redirect()->route('home');
     }
     //dd(__METHOD__.'('.__LINE__.')',compact('id','request'));
     if (isset($request->btn_Cancel)) {
         return redirect()->route('pallet.show', ['id' => $id]);
     }
     $this->transaction(function ($this) use($id, $request) {
         // using an implementation of the Pallet Repository Interface
         $this->palletRepository->update($id, $request->all());
     });
     // FWP and RES carts don't need to be located, redirect to show
     $pallet = $this->palletRepository->find($id);
     //Log::debug('pallet->Pallet_ID: >'.$pallet->Pallet_ID.'<');
     //TODO learn how to write library functions like: str_begins($pallet->Pallet_ID, ['FWP', 'RES']);
     if (isset($pallet->Pallet_ID) and strlen($pallet->Pallet_ID) > 3 and (substr($pallet->Pallet_ID, 0, 3) == 'FWP' or substr($pallet->Pallet_ID, 0, 3) == 'RES')) {
         return redirect()->route('pallet.show', ['id' => $id])->with(['status' => Lang::get('internal.updated', ['class' => Pallet::TABLE_SYNONYM])]);
     } else {
         // when our pallet is located, redirect to show
         $locations = $this->locationRepository->filterOn(['container.child' => $id]);
         if (isset($locations) and count($locations) > 0) {
             return redirect()->route('pallet.show', ['id' => $id])->with(['status' => Lang::get('internal.updated', ['class' => Pallet::TABLE_NAME])]);
         }
     }
     return redirect()->route('pallet.edit', ['id' => $id])->with(['status' => Lang::get('internal.updated', ['class' => Pallet::TABLE_NAME]), 'warning' => Lang::get('internal.errors.noParent') . ' ' . Lang::get('labels.titles.Move_Pallet')]);
 }
Example #2
0
 /**
  * Check articles of provided UPCs, are they all comingled?
  * @param $upcIDs, array of UPCs to explode
  * @return false if any article is found that is not comingled
  */
 protected function checkIfComingled($upcIDs)
 {
     $isComingled = true;
     // are we given at least one UPC->objectID
     if (isset($upcIDs) and count($upcIDs) > 0) {
         foreach ($upcIDs as $inUPC) {
             $articles = $this->articleRepository->getUPCArticles($inUPC, 0);
             if (isset($articles) == false or count($articles) == 0) {
                 Log::warning('this->articleRepository->getUPCArticles(' . $inUPC . ', 0); produced no articles!');
             }
             if (isset($articles) and count($articles) > 0) {
                 foreach ($articles as $article) {
                     Log::debug('article: ' . $article->objectID . ($article->isSplit() ? ' is split' : ' is comingled'));
                     if ($article->isSplit()) {
                         $isComingled = false;
                         break 2;
                     }
                 }
             } else {
                 Log::debug('defaulting to is split');
                 $isComingled = false;
                 break;
             }
         }
     }
     return $isComingled;
 }
 /**
  * Put a pallet into a Location.
  * ComingleRules verifies move this pallet into this Location is allowed.
  *
  * Returns true if it was successful, otherwise returns an error message.
  */
 public function putPalletIntoLocation($palletID, $locationID)
 {
     Log::info("putPalletIntoLocation( {$palletID}, {$locationID} )");
     $result = $this->comingleRules->isPutPalletIntoLocationAllowed($palletID, $locationID);
     Log::debug($result);
     if ($result === true) {
         // update container set parentID = $id where objectID = $pltID;
         $result = $this->transaction(function ($this) use($palletID, $locationID) {
             return $this->locationRepository->putPalletIntoLocation($palletID, $locationID);
         });
     }
     return $result;
 }