/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param integer $id - Identifica uma despesa de projeto 
  */
 public function actionCreate($id)
 {
     $model = new Patrimonio();
     $model->logs = '';
     //Atribui ao modelo sua respectiva despesa
     $model->despesa = ProjetoDespesa::model()->findByPk($id);
     $model->cod_projeto_despesa = (int) $id;
     if ($model->despesa == null) {
         //não existe tal deespesa
         throw new CHttpException('404', 'Página não encontrada');
         Yii::log('Sistema não encontrou o ProjetoDespesa com identificador ' . $id);
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Patrimonio'])) {
         $model->attributes = $_POST['Patrimonio'];
         if ($model->save()) {
             $model->log('CREATE');
             $this->redirect(array('view', 'id' => $model->cod_patrimonio));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * 
  * @param integer $id
  */
 public function actionGeraXml($id)
 {
     //header('Content-Type: text/xml');
     $model = ProjetoDespesa::model()->findByPk($id);
     $this->layout = false;
     if ($model == null) {
         throw new CHttpException(404, 'Página não encontrada');
     }
     //$this->render('geraXML', array('model'=>$model));
     Yii::app()->request->sendFile('Relatorio_' . $model->rubrica->nome . '_' . $model->comprador . '_' . $model->data_inclusao . '.doc', $this->renderPartial('geraXML', array('model' => $model), 'application/xml'));
     //procura modelo
     //renderiza xml
 }
Example #3
0
	<div class="view">
	<?php 
$despesas = ProjetoDespesa::model()->findAll(array('condition' => "comprador ILIKE '%{$data->nome}%'"));
?>
	<?php 
if (count($despesas > 0)) {
    ?>
	
	<table class="table table-bordered table-striped table-hover">
	<thead>
	<tr>
	<th>Nome do Gasto</th>
	<th>Rubrica</th>
	<th>Valor (R$)</th>
	<th>Quantidade</th>
	<th>Data</th>
	<th>Menu</th>
	</tr>
	</thead>
	<tbody>
	<?php 
    foreach ($despesas as $desp) {
        ?>
			<tr>
			<td>
			<?php 
        echo CHtml::link($desp->nome, array('/projetoDespesa/viewAjax', 'id' => $desp->cod_despesa), array('class' => 'link', 'data-toggle' => 'modal', 'data-target' => '#modal-info'));
        ?>
			</td>
			<td><?php 
        echo $desp->rubrica->nome;
 /**
  * Renderiza parcialmente as despesas de um projeto	
  */
 public function actionAjaxDespesas($projeto, $rubrica)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('cod_rubrica', $rubrica);
     $criteria->compare('cod_projeto', $projeto);
     $despesas = ProjetoDespesa::model()->findAll($criteria);
     $proj = Projeto::model()->findByPk($projeto);
     if ($proj == null || $rubrica == null) {
         throw new ChttpException(404);
     }
     $this->layout = false;
     $this->render('/projeto/financeiro/_despesas', array('despesas' => $despesas, 'projeto' => $proj));
 }
Example #5
0
 /**
  * Retorna o quanto foi gasto desta verba
  */
 public function getDespesas()
 {
     $criteria = new CDbCriteria();
     $rubricas = array();
     //Não há rubricas cadastradas neste projeto
     if (count($this->rubricas) < 1) {
         return 0;
     }
     foreach ($this->rubricas as $rub) {
         $rubricas[] = $rub->cod_rubrica;
     }
     $criteria->compare('rubrica.cod_rubrica', $rubricas);
     $criteria->with = array('projeto', 'rubrica');
     $criteria->compare('projeto.cod_projeto', $this->cod_projeto);
     $despesas = ProjetoDespesa::model()->findAll($criteria);
     $soma = 0;
     foreach ($despesas as $desp) {
         $soma += $desp->valor;
     }
     return $soma;
 }