/**
  * Find all of the items pending restock and stock 'em.
  * 
  * This is implemented in an RDMBS-agnostic manner, and as
  * a result, all of this looping can become wildly inefficient
  * when there's a lot of stuff to restock. 
  *
  * It may be better to re-implement this to use an 
  * INSERT INTO ... SELECT ... query and then an UPDATE query
  * to change the next restock time. But, since I am designing
  * a template app that needs to support many RDBMSes, I can do
  * things that are Bad(tm) and let the scalability issues be you
  * problem when you run into them. Neener-neener!
  *
  * @return bool
  **/
 public function performJob()
 {
     ShopRestock::processPendingRestocks($this->db);
 }
Esempio n. 2
0
     $renderer->assign('item', $ITEM);
     $renderer->assign('shops', $SHOPS);
     $renderer->assign('restock', $RESTOCK);
     if ($restock != null) {
         $renderer->display('admin/items/restocks/edit.tpl');
     } else {
         $renderer->display('admin/items/restocks/new.tpl');
     }
     break;
     // end default
 // end default
 case 'save':
     $RESTOCK = array('shop_id' => trim(stripinput($_POST['restock']['shop_id'])), 'frequency' => trim(stripinput($_POST['restock']['frequency'])), 'min_price' => trim(stripinput($_POST['restock']['minimum_price'])), 'max_price' => trim(stripinput($_POST['restock']['maximum_price'])), 'min_quantity' => trim(stripinput($_POST['restock']['minimum_quantity'])), 'max_quantity' => trim(stripinput($_POST['restock']['maximum_quantity'])), 'quantity_cap' => trim(stripinput($_POST['restock']['quantity_cap'])));
     // If the group could not be loaded, start making a new one.
     if ($restock == null) {
         $restock = new ShopRestock($db);
     }
     if ($RESTOCK['shop_id'] == null) {
         $ERRORS[] = 'No shop specified.';
     } else {
         $shop = new Shop($db);
         $shop = $shop->findOneByShopId($RESTOCK['shop_id']);
         if ($shop == null) {
             $ERRORS[] = 'Invalid shop specified.';
         }
     }
     // end shop id > 0
     if ($RESTOCK['frequency'] == null) {
         $ERRORS[] = 'No frequency specified.';
     }
     if ($RESTOCK['min_price'] == null) {