/** Assign batch to all stores @param $batchID [int] batch ID */ public static function initBatch($batchID) { $dbc = FannieDB::get(FannieConfig::config('OP_DB')); $map = new StoreBatchMapModel($dbc); $stores = new StoresModel($dbc); foreach ($stores->find() as $s) { $map->storeID($s->storeID()); $map->batchID($batchID); $map->save(); } }
public function post_id_storeID_handler() { $dbc = $this->connection; $dbc->selectDB($this->config->OP_DB); $ret = array('error' => 0, 'display' => ''); $map = new StoreBatchMapModel($dbc); $map->storeID($this->storeID); $map->batchID($this->id); if ($map->load()) { $deleted = $map->delete(); if (!$deleted) { $ret['error'] = 'Error removing store mapping'; } } else { $saved = $map->save(); if (!$saved) { $ret['error'] = 'Error saving store mapping'; } } echo json_encode($ret); return false; }