Exemple #1
0
 public function getIBNSAreas($productCode)
 {
     return IBNS::select('id', 'area', 'quantity', 'mrs_percents')->where('code', $productCode)->get()->toArray();
 }
Exemple #2
0
 public function doMRDistributor(MRDistributorRequest $request, $distributor, $productAreaId)
 {
     $distributorPercent[$request->mr] = $request->percent;
     $string = "{$request->mr}:{$request->percent}";
     if ($distributor == 'IBNS') {
         $ibns = IBNS::findOrFail($productAreaId);
         if (is_null($ibns->mrs_percents)) {
             $ibns->mrs_percents = json_encode($distributorPercent);
             $ibns->save();
             return redirect()->route('MRDistributor')->with('message', 'Percent has been set successfully !');
         } else {
             $tempArray[] = json_decode($ibns->mrs_percents, true);
             $tempArray[] = $distributorPercent;
             $ibns->mrs_percents = json_encode($tempArray);
             $ibns->save();
             return redirect()->route('MRDistributor')->with('message', 'Percent has been updated successfully !');
         }
     }
     if ($distributor == 'POS') {
         $pos = POS::findOrFail($productAreaId);
         if (is_null($pos->mrs_percents)) {
             $pos->mrs_percents = json_encode($distributorPercent);
             $pos->save();
             return redirect()->route('MRDistributor')->with('message', 'Percent has been set successfully !');
         } else {
             $tempArray[] = json_decode($pos->mrs_percents, true);
             $tempArray[] = $distributorPercent;
             $pos->mrs_percents = json_encode($tempArray);
             $pos->save();
             return redirect()->route('MRDistributor')->with('message', 'Percent has been updated successfully !');
         }
     }
     if ($distributor == 'UCP') {
         $ucp = UCP::findOrFail($productAreaId);
         if (is_null($ucp->mrs_percents)) {
             $ucp->mrs_percents = json_encode($distributorPercent);
             $ucp->save();
             return redirect()->route('MRDistributor')->with('message', 'Percent has been set successfully !');
         } else {
             $tempArray[] = json_decode($ucp->mrs_percents, true);
             $tempArray[] = $distributorPercent;
             $ucp->mrs_percents = json_encode($tempArray);
             $ucp->save();
             return redirect()->route('MRDistributor')->with('message', 'Percent has been updated successfully !');
         }
     }
 }