/**
  * 
  * @param ProjetoVerba $model
  * @return array Rubrica[]
  */
 private function getRubricas($model)
 {
     $criteria = new CDbCriteria();
     $criteria->with = array('pai', 'orcamentos');
     $criteria->order = 't.nome';
     $criteria->condition = 'orcamentos.cod_projeto = :p';
     $criteria->params = array('p' => $model->cod_projeto);
     $criteria->addNotInCondition('t.cod_rubrica', $model->projeto->getRubricasComReceita());
     $rubricas = Rubrica::model()->findAll($criteria);
     return array_merge($rubricas, $model->rubricas);
 }
Exemple #2
0
        foreach ($father->filhas as $filha) {
            printChildren($filha);
        }
        echo "</ul>";
    }
}
Yii::app()->clientScript->registerScript('tips', "\n\t\t\$('.tip').tooltip();\n\t");
?>

<h1>Rubricas</h1>



<div class="view">
<?php 
$rubricas = Rubrica::model()->findAll(array('condition' => 'cod_rubrica_pai IS NULL'));
echo "<ul>";
foreach ($rubricas as $r) {
    echo "<li>";
    printChildren($r);
    echo '</li>';
}
echo '</ul>';
?>

<?php 
/*
	<table class="table table-bordered table-striped table-hover">
	<thead>
	<tr>
	<th>Nome da Rubrica</th>
Exemple #3
0
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'projeto-orcamento-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<div class="input-row">
		<?php 
echo $form->labelEx($model, 'cod_rubrica');
?>
		<?php 
$rubricas = Rubrica::model()->findAll(array('order' => 'nome'));
/*
$criteria = new CDbCriteria();
$criteria->order = 't.nome';
$criteria->with = 'orcamentos';
$criteria->addNotInCondition('t.cod_rubrica', $model->projeto->getRubricasComOrcamento());
$rubricas = Rubrica::model()
			->with('orcamentos')
			->findAll($criteria);
*/
echo $form->dropDownList($model, 'cod_rubrica', CHtml::listData($rubricas, 'cod_rubrica', 'nome'), array('id' => 'drop-rubricas', 'prompt' => "Selecione uma Rubrica", 'class' => 'input-xxlarge', 'value' => $model->cod_rubrica));
?>
		<?php 
echo $form->error($model, 'cod_rubrica');
?>
	</div>
<?php

/* @var $this ProjetoController */
/* @var $model Projeto */
Yii::app()->clientScript->registerScriptFile("https://www.google.com/jsapi", CClientScript::POS_END);
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/charts.js", CClientScript::POS_END);
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/arvoredespesas.css');
$criteria = new CDbCriteria();
$criteria->with = 'receitas';
$criteria->compare('receitas.cod_projeto', $model->cod_projeto);
$criteria->together = true;
//$criteria->addCondition('cod_rubrica_pai is NULL');
$rubricas = Rubrica::model()->findAll($criteria);
$receitas = $model->receitas;
//ProjetoVerba::model()->with('rubrica')->findAll(array('condition'=>'cod_projeto = :projeto', 'order'=>'t.cod_verba', 'params'=>array('projeto'=>$model->cod_projeto)));
$despesas = array();
foreach ($model->receitas as $rec) {
    foreach ($rec->despesas as $desp) {
        $despesas[] = $desp;
    }
}
?>

<div class="row-fluid">

<h5>Balanço financeiro do projeto</h5>
<div class="bar_chart span12" 
	id="projeto-<?php 
echo $model->cod_projeto;
?>
"
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Rubrica::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * Renderiza um formulario sem layout
  * @param integer $id - identifica a rubrica
  */
 public function actionInfoRubrica($id)
 {
     $this->layout = false;
     $rubrica = new Rubrica();
     $rubrica = Rubrica::model()->findByPk($id);
     echo json_encode(array_merge($rubrica->getAttributes(array('cod_rubrica', 'nome', 'descricao')), array('saldo' => Yii::app()->format->number($rubrica->getSaldo($_GET['cod_verba'])))));
     Yii::app()->end();
 }
Exemple #7
0
 /**
  * 
  * Imprime uma árvore 
  * @param Rubrica $father
  */
 public static function printChildren($father)
 {
     if ($father != null) {
         echo $father->nome . '>>';
         foreach ($father->filhas as $filha) {
             //echo '->>' .$filha->nome;
             Rubrica::printChildren($filha);
         }
     }
     /*
     	 		if($father != null)		
     foreach($father->filhas as $filha){
     	printChildren($filha);
     }
     */
 }
?>
					</div>
						
					<div class="tab-pane" id="info-recebimentos">
						<?php 
$this->renderPartial('/projeto/financeiro/_recebimentos', array('projeto' => $model));
?>
					</div>
					
					<div class="tab-pane active" id="info-despesas">
						<?php 
$dataRubricas = array();
foreach ($model->getRubricas() as $rubrica) {
    $dataRubricas[$rubrica['cod_rubrica']] = $rubrica['nome'];
}
$dataRubricas = CHtml::listData(Rubrica::model()->findAll(), 'cod_rubrica', 'nome');
echo CHtml::dropDownList('TipoDespesa', null, $dataRubricas, array('id' => 'tipodespesa', 'class' => 'input-xxlarge', 'prompt' => 'Selecione uma Rubrica'));
?>
						<div id="lista-despesas">							
						</div>
						<?php 
$this->renderPartial('/projeto/financeiro/_despesas', array('despesas' => $despesas, 'projeto' => $model));
?>
					</div>
					
					<div class="tab-pane" id="info-patrimonios">
						<?php 
$this->renderPartial('/projeto/financeiro/_patrimonios', array('despesas' => $despesas));
?>
					</div>
				</div><!-- /tab-content -->
 public function getSaldoRubrica()
 {
     $rubrica = Rubrica::model()->findByPk($this->cod_rubrica);
     $gasto_comprometido = $this->verba->gastosComprometidos($rubrica);
     $recebido = $gasto_comprometido + min($this->verba->saldo_comprometido, $this->projeto->getOrcamentado($this->cod_rubrica) - $gasto_comprometido);
     return $recebido - $gasto_comprometido;
 }
<?php

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/rubrica.orcamento.js', CClientScript::POS_END);
Yii::app()->clientScript->registerScript('orcamento', "\n\t\t\t\n\t\torcamento = new Orcamento();\n\t\t\n\t\t\$('#btnOrcamento').click(function(){\n\t\t\torcamento.createField();\n\t\t});\n\t\t\n\t\t\$('.tip').tooltip();\n\t\t\n\t\t\$('.icon-trash').click(function(){\n\t\tconsole.log('teste');\n\t\t\trubTarget = \$(this).attr('data-remove-target'); \n\t\t\t\$(rubTarget).remove();\n\t\t});\n\t\t\n");
//Carrega máscara para moedas
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/jquery.maskMoney.js');
Yii::app()->clientScript->registerScript('currency', "\n\n\$('.money').maskMoney({thousands:'.', decimal:','});\n\n\t\t\$('#projeto-form').submit(function(){\n\t\t\$.each(\$('.money'), function(i,obj){\n\t\t\t\t\$(obj).val(\$(obj).val().replace(/\\./g,'').replace(',','.'));\n\t\t\t}\n\t\t\t);\n\t\t});\n");
?>
<fieldset><legend>Orçamento</legend>
	<div id="orcamento" data-count="<?php 
echo count($model->orcamentos);
?>
">
		<?php 
echo CHtml::dropDownList('Rubrica', null, CHtml::listData(Rubrica::model()->findAll(array('order' => 'nome')), 'cod_rubrica', 'nome'), array('class' => 'input-xxlarge', 'id' => 'list-rubricas'));
?>
		<div class="input-prepend input-append">
  			<span class="add-on">R$</span>
  			<?php 
echo CHtml::textField('Rubrica_valor', 0, array('class' => 'money input-small', 'id' => 'rubrica-valor'));
?>
  			<span class="add-on"><?php 
echo CHtml::link('Adicionar', '', array('id' => 'btnOrcamento'));
?>
</span>
		</div><hr>
		
		<table class="table table-bordered table-striped table-hover">
			<thead>
				<tr>
					<th>Rubrica</th>
Exemple #11
0
echo $form->labelEx($model, 'nome');
?>
		<?php 
echo $form->textField($model, 'nome');
?>
		<?php 
echo $form->error($model, 'nome');
?>
	</div>
	
	<div class="input">
			<?php 
echo $form->labelEx($model, 'cod_rubrica_pai');
?>
			<?php 
echo $form->dropDownList($model, 'cod_rubrica_pai', CHtml::listData(Rubrica::model()->findAll(array('order' => 'nome')), 'cod_rubrica', 'nome'), array('id' => 'drop-rubricas', 'prompt' => "Não possui pai"));
?>
			<?php 
echo $form->error($model, 'cod_rubrica_pai');
?>
		</div>

	<div class="input">
		<?php 
echo $form->labelEx($model, 'numero');
?>
		<?php 
echo $form->textField($model, 'numero');
?>
		<?php 
echo $form->error($model, 'numero');
Exemple #12
0
?>
		<?php 
echo CHtml::tag('input', array('name' => 'ProjetoDespesa[data_compra]', 'type' => 'date', 'value' => $model->isNewRecord ? date('Y-m-d') : $model->data_compra));
?>
		<?php 
echo $form->error($model, 'data_compra');
?>
	</div>

 	<div class="input" id="campos-adicionais">
 		<?php 
if ($model->isNewRecord && $model->cod_rubrica != null) {
    ?>
 		<div>
 			<?php 
    $this->renderPartial('_form_adicional', array('model' => Rubrica::model()->findByPk($model->cod_rubrica)));
    ?>
 		</div>
 		<?php 
}
?>
 	</div>
 	
	<div class="input ">
		<?php 
echo $form->labelEx($model, 'documento');
?>
		<?php 
if ($model->documento != null && $model->documento != '') {
    ?>
			<b><?php 
Exemple #13
0
		
		<?php 
echo $form->labelEx($projeto, 'deletar');
?>
		<?php 
echo $form->dropDownList($projeto, 'deletar', Grupo::binaryPermitions());
?>
		<?php 
echo $form->error($projeto, 'deletar');
?>
	</div>
	
	<div class="span6">
		<h5>Rubricas</h5>
		<?php 
$data = CHtml::listData(Rubrica::model()->findAll(array('select' => 'cod_rubrica, nome')), 'cod_rubrica', 'nome');
?>
		<?php 
echo CHtml::dropDownList("Rubrica", null, $data, array('id' => 'rubrica_id'));
?>
<br>
		<?php 
echo CHtml::dropDownList("RubricaPermissao", null, Grupo::binaryPermitions(), array('id' => 'rubrica_permissao'));
?>
<br>
		<?php 
echo CHtml::button("Adicionar", array('class' => 'btn btn-small', 'id' => 'rubrica_add'));
?>
<br>
		
		<table class="table" id="rubrica_added" style="margin-top: 10px;">