Esempio n. 1
0
 public function _costCenter($from, $to, $action)
 {
     switch ($action) {
         case static::ACT_CONVERT_TO_OBJECT:
             /* @var $from Environment */
             $to->costCenter = $from->getProperty(EnvironmentProperty::SETTING_CC_ID);
             break;
         case static::ACT_CONVERT_TO_ENTITY:
             /* @var $to Environment */
             $ccId = ApiController::getBareId($from, 'costCenter');
             if (empty($ccId)) {
                 throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Missed property costCenter");
             }
             $this->controller->getCostCenter($ccId);
             $to->setProperty(EnvironmentProperty::SETTING_CC_ID, $ccId);
             break;
         case static::ACT_GET_FILTER_CRITERIA:
             $env = new Environment();
             $envProperty = new EnvironmentProperty();
             return [AbstractEntity::STMT_FROM => "\n                         JOIN {$envProperty->table('cep')} ON {$env->columnId()} = {$envProperty->columnEnvId('cep')}\n                            AND {$envProperty->columnName('cep')} = " . $envProperty->qstr('name', EnvironmentProperty::SETTING_CC_ID) . "\n                    ", AbstractEntity::STMT_WHERE => "{$envProperty->columnValue('cep')} = " . $envProperty->qstr('value', $from->costCenter)];
     }
 }