public static function decode($val) { $info = $val ? base64_decode($val) : null; if ($info) { $php = CalemJson::jsonToPhp($info); $rtn = CalemJson::setJson($php); } else { $rtn = new CalemScheduleInfo(); } return $rtn; }
/** * Remove PO item from client request */ public function removePoItemByClient($tran) { $poId = $tran['po_id']; $reqItem = base64_decode($tran['req_item']); $ids = CalemJson::jsonToPhp($reqItem); if ($this->logger->isInfoEnabled()) { $this->logger->info("removePoItemByClient: po_id=" . $poId . ", req ids=" . var_export($ids, true)); } try { $poDbo = CalemFactory::getDbo('po'); $poRow = $poDbo->fetchById($poId); } catch (CalemDboDataNotFoundException $ex) { throw new CalemDataBoException('po', $ex, null); } $piDbo = CalemFactory::getDbo('po_item'); $reqDbo = CalemFactory::getDbo('requisition'); try { //Start a transaction here $poDbo->beginTransaction(); $poDbo->executeBySqlParam('select id from po where id=? for update', $poRow['id']); //processing each req item $riDbo = CalemFactory::getDbo('req_item'); foreach ($ids as $id) { try { $riRow = $riDbo->fetchById($id); } catch (CalemDboDataNotFoundExcpetion $e) { if ($this->logger->isDebugEnabled()) { $this->logger->debug("Req item=" . $id . " cannot be found."); } continue; //Ignore that an item does not exist anymore. } //process this line $poRow = $this->removePoItemFromReq($poRow, $riRow, $piDbo, $poDbo, $riDbo, $reqDbo); } //commit $poDbo->commit(); } catch (Exception $exo) { $poDbo->rollback(); throw new CalemDataBoException('req_item', $exo, null); } }