Esempio n. 1
0
 public function beforeUpdateForm($population)
 {
     //print_r($population);
     //exit();
     foreach (Prefs::getOutlet()->OutletToArray() as $o) {
         $av = Stockunit::where('outletId', $o->_id)->where('productId', new MongoId($population['_id']))->where('status', 'available')->count();
         $hd = Stockunit::where('outletId', $o->_id)->where('productId', new MongoId($population['_id']))->where('status', 'hold')->count();
         $rsv = Stockunit::where('outletId', $o->_id)->where('productId', new MongoId($population['_id']))->where('status', 'reserved')->count();
         $sld = Stockunit::where('outletId', $o->_id)->where('productId', new MongoId($population['_id']))->where('status', 'sold')->count();
         $population['stocks'][$o->_id]['available'] = $av;
         $population['stocks'][$o->_id]['hold'] = $hd;
         $population['stocks'][$o->_id]['reserved'] = $rsv;
         $population['stocks'][$o->_id]['sold'] = $sld;
     }
     if (!isset($population['full_url'])) {
         $population['full_url'] = $population['large_url'];
     }
     return $population;
 }
Esempio n. 2
0
 public function postAssignoutlet()
 {
     $in = Input::get();
     $category = $in['outlet'];
     $cats = Prefs::getOutlet()->OutletToSelection('name', '_id', false);
     //print_r($cats);
     $product_ids = $in['product_ids'];
     foreach ($product_ids as $p) {
         $prop = Stockunit::find($p);
         $prop->outletId = $cats[$category];
         $prop->outletName = $category;
         $prop->save();
     }
     return Response::json(array('result' => 'OK'));
 }