当前位置: 首页>>代码示例>>PHP>>正文


PHP Gems_Util::getReceptionCodeLibrary方法代码示例

本文整理汇总了PHP中Gems_Util::getReceptionCodeLibrary方法的典型用法代码示例。如果您正苦于以下问题:PHP Gems_Util::getReceptionCodeLibrary方法的具体用法?PHP Gems_Util::getReceptionCodeLibrary怎么用?PHP Gems_Util::getReceptionCodeLibrary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gems_Util的用法示例。


在下文中一共展示了Gems_Util::getReceptionCodeLibrary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createModel

 /**
  * Creates a model for getModel(). Called only for each new $action.
  *
  * The parameters allow you to easily adapt the model to the current action. The $detailed
  * parameter was added, because the most common use of action is a split between detailed
  * and summarized actions.
  *
  * @param boolean $detailed True when the current action is not in $summarizedActions.
  * @param string $action The current action.
  * @return \MUtil_Model_ModelAbstract
  */
 protected function createModel($detailed, $action)
 {
     // Export all
     if ('export' === $action) {
         $detailed = true;
     }
     if ($detailed) {
         $year = $this->_('Year');
         $month = $this->_('Month');
         $fields[$year] = new \Zend_Db_Expr("YEAR(gr2o_created)");
         $fields[$month] = new \Zend_Db_Expr("MONTH(gr2o_created)");
     }
     $consents = $this->util->getDbLookup()->getUserConsents();
     $deleteds = array('' => '') + $this->util->getReceptionCodeLibrary()->getRespondentDeletionCodes();
     $sql = "SUM(CASE WHEN grc_success = 1 AND gr2o_consent = '%s' THEN 1 ELSE 0 END)";
     foreach ($consents as $consent => $translated) {
         $fields[$translated] = new \Zend_Db_Expr(sprintf($sql, $consent));
     }
     $fields[$this->_('Total OK')] = new \Zend_Db_Expr("SUM(CASE WHEN grc_success = 1 THEN 1 ELSE 0 END)");
     $sql = "SUM(CASE WHEN gr2o_reception_code = '%s' THEN 1 ELSE 0 END)";
     foreach ($deleteds as $code => $translated) {
         $fields[$translated] = new \Zend_Db_Expr(sprintf($sql, $code));
     }
     $fields[$this->_('Dropped')] = new \Zend_Db_Expr("SUM(CASE WHEN grc_success = 0 THEN 1 ELSE 0 END)");
     $fields[$this->_('Total')] = new \Zend_Db_Expr("COUNT(*)");
     $select = $this->db->select();
     $select->from('gems__respondent2org', $fields)->joinInner('gems__reception_codes', 'gr2o_reception_code = grc_id_reception_code', array())->joinInner('gems__organizations', 'gr2o_id_organization = gor_id_organization', array('gor_name', 'gor_id_organization'));
     $select->group(array('gor_name', 'gor_id_organization'));
     if ($detailed) {
         $select->group(array($fields[$year], $fields[$month]));
     }
     $model = new \MUtil_Model_SelectModel($select, 'consent-plan');
     $model->setKeys(array('gor_id_organization'));
     $model->resetOrder();
     $model->set('gor_name', 'label', $this->_('Organization'));
     foreach ($fields as $field => $expr) {
         $model->set($field, 'label', $field, 'tdClass', 'rightAlign', 'thClass', 'rightAlign');
     }
     foreach ($deleteds as $code => $translated) {
         $model->set($translated, 'tdClass', 'rightAlign smallTime', 'thClass', 'rightAlign smallTime');
     }
     foreach (array($this->_('Total OK'), $this->_('Dropped'), $this->_('Total')) as $name) {
         $model->set($name, 'itemDisplay', \MUtil_Html::create('strong'), 'tableHeaderDisplay', \MUtil_Html::create('em'), 'tdClass', 'rightAlign selectedColumn', 'thClass', 'rightAlign selectedColumn');
     }
     if ($detailed) {
         $model->set($month, 'formatFunction', $this->util->getLocalized()->getMonthName);
     }
     // Only show organisations the user is allowed to see
     $allowed = $this->currentUser->getAllowedOrganizations();
     $model->setFilter(array('gr2o_id_organization' => array_keys($allowed)));
     // \MUtil_Model::$verbose = true;
     return $model;
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:64,代码来源:ConsentPlanAction.php

示例2: getCurrentRound

 /**
  * The round description of the first round that has not been answered.
  *
  * @return string Round description or Stopped/Completed if not found.
  */
 public function getCurrentRound()
 {
     $isStop = false;
     $today = new \Zend_Date();
     $tokens = $this->getTokens();
     $stop = $this->util->getReceptionCodeLibrary()->getStopString();
     foreach ($tokens as $token) {
         $validUntil = $token->getValidUntil();
         if (!empty($validUntil) && $validUntil->isEarlier($today)) {
             continue;
         }
         if ($token->isCompleted()) {
             continue;
         }
         $code = $token->getReceptionCode();
         if (!$code->isSuccess()) {
             if ($code->getCode() === $stop) {
                 $isStop = true;
             }
             continue;
         }
         return $token->getRoundDescription();
     }
     if ($isStop) {
         return $this->translate->_('Track stopped');
     }
     return $this->translate->_('Track completed');
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:33,代码来源:RespondentTrack.php


注:本文中的Gems_Util::getReceptionCodeLibrary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。