Ejemplo n.º 1
0
 private function getMenu($state, $con)
 {
     $result = [];
     $menus = MenuQuery::create()->filterByStatus('Active');
     $state == 1 || $menus->filterByState($state);
     $menus->select(array('sub', 'icon', 'text', 'action'))->orderBy('sub', 'ASC')->orderBy('order', 'ASC')->find($con);
     foreach ($menus as $row) {
         $result[$row['sub']][] = $row;
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see Menu::setDeleted()
  * @see Menu::isDeleted()
  */
 public function delete(ConnectionInterface $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getServiceContainer()->getWriteConnection(MenuTableMap::DATABASE_NAME);
     }
     $con->transaction(function () use($con) {
         $deleteQuery = ChildMenuQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $this->setDeleted(true);
         }
     });
 }
Ejemplo n.º 3
0
 /**
  * Returns a new ChildMenuQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildMenuQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildMenuQuery) {
         return $criteria;
     }
     $query = new ChildMenuQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Ejemplo n.º 4
0
     if ($session->get('pos/state') === 0 || !isset($session->get('pos/current_user')->id)) {
         throw new Exception();
     }
     $user = UserQuery::create()->filterById($session->get('pos/current_user')->id)->select(['id', 'user', 'role_id'])->leftJoin('Detail')->withColumn('Detail.Name', 'name')->withColumn('Detail.Address', 'address')->withColumn('Detail.Phone', 'phone')->findOne($con);
     if (!$user) {
         throw new Exception();
     }
     $root['state'] = 1;
     $root['current_user'] = (object) $user;
 } catch (Exception $e) {
     $root['state'] = 0;
     $root['current_user'] = null;
 }
 // Get menu from database based on state
 $menu = [];
 $menus = MenuQuery::create()->filterByStatus('Active');
 $root['state'] == 1 || $menus->filterByState(0);
 $menus->select(array('sub', 'icon', 'text', 'action'))->orderBy('sub', 'ASC')->orderBy('order', 'ASC')->find($con);
 foreach ($menus as $row) {
     $menu[$row['sub']][] = $row;
 }
 $root['menu'] = $menu;
 // get application root folder
 $homepath = $info['homepath'];
 $localpath = getenv('SCRIPT_NAME');
 $absolutepath = realpath(basename($localpath));
 $absolutepath = str_replace("\\", "/", $absolutepath);
 $root['folder'] = substr($absolutepath, 0, strpos($absolutepath, $localpath)) . $homepath;
 $session->set('pos/state', $root['state']);
 $session->set('pos/current_user', $root['current_user']);
 $session->set('pos/info', $root['info']);
Ejemplo n.º 5
0
 /**
  * Performs an INSERT on the database, given a Menu or Criteria object.
  *
  * @param mixed               $criteria Criteria or Menu object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *                         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(MenuTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Menu object
     }
     // Set the correct dbName
     $query = MenuQuery::create()->mergeWith($criteria);
     // use transaction because $criteria could contain info
     // for more than one table (I guess, conceivably)
     return $con->transaction(function () use($con, $query) {
         return $query->doInsert($con);
     });
 }