Example #1
0
 public function authenticate()
 {
     $user = Funcionario::model()->find('LOWER(login)=?', array(strtolower($this->username)));
     if ($user == null) {
         $this->errorCode = self::ERROR_UNKNOWN_IDENTITY;
     } elseif ($user->senha != md5($this->password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->_id = $user->id;
         $this->_username = $user->nome_funcionario;
         $this->setState('empresa', $user->idEmpresa->nome_empresa);
         Yii::log($user->id . ' ' . $user->nome_funcionario . ' ' . $user->idEmpresa->nome_empresa, 'info', 'system.web.auth');
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
     /*
     		$users=array(
     			// username => password
     			'demo'=>'demo',
     			'admin'=>'admin',
     		);
     		if(!isset($users[$this->username]))
     			$this->errorCode=self::ERROR_USERNAME_INVALID;
     		elseif($users[$this->username]!==$this->password)
     			$this->errorCode=self::ERROR_PASSWORD_INVALID;
     		else
     			$this->errorCode=self::ERROR_NONE;
     		return !$this->errorCode;
     */
 }
<!-- gerarRelatorio -->
<div id="gerarRelatorio">

	<table>
		<thead>
			<tr>
				<th>NIF</th>
				<th>NOME</th>
				<th></th>
			</tr>
		</thead>
		<tbody>

			<?php 
$funcionarios = Funcionario::model()->findAll();
?>
			<?php 
foreach ($funcionarios as $key => $f) {
    ?>
				<tr>
					<td><?php 
    echo $f->nif;
    ?>
</td>
					<td><?php 
    echo $f->nome;
    ?>
</td>
					<td class="actions-three">
						<input type="hidden" class="funcionario_nif" value="<?php 
Example #3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Funcionario the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Funcionario::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }