function myheader4($id)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('parent_id', $id);
     $criteria->compare('tcredit>', 0);
     $model = aBudgetDetail::model()->find($criteria);
     $this->SetFont('Arial', 'B', 12);
     $this->Cell(0, 6, 'PT. AGUNG PODOMORO LAND, Tbk');
     $this->Ln(3);
     $this->SetFont('Arial', 'B', 10);
     //$this->Cell(0,6,'Central Park');
     $this->Cell(0, 7, aOrganization::model()->findByPk(aPorder::model()->findByPk($model->parent_id)->costcenter_id)->name);
     $this->Ln(10);
     $this->Cell(30, 6, 'Tahun:');
     $this->Cell(0, 6, aBudget::model()->findByPk($model->parent_id)->year);
     $this->Ln(4);
     $this->Cell(30, 6, 'Budget:');
     $this->Cell(0, 6, aBudget::model()->findByPk($model->parent_id)->name);
     $this->Ln(4);
     $this->Cell(30, 6, 'Total Budget:');
     $this->Cell(0, 6, number_format(aBudget::model()->findByPk($model->parent_id)->sum_af), 0, ',', '.');
     $this->Ln(10);
     $w = array(8, 25, 50, 30, 30, 30, 40, 50);
     $this->SetFont('Arial', 'B', 8);
     $this->Cell($w[0], 6, 'NO', 1);
     $this->Cell($w[1], 6, 'INPUT DATE', 1, 0, 'C');
     $this->Cell($w[2], 6, 'NO REF', 1, 0, 'C');
     $this->Cell($w[3], 6, 'PERIODE DATE', 1, 0, 'C');
     $this->Cell($w[4], 6, 'TOTAL PR', 1, 0, 'C');
     $this->Cell($w[5], 6, 'BALANCE', 1, 0, 'C');
     $this->Cell($w[6], 6, 'ISSUER VIA ', 1, 0, 'C');
     $this->Cell($w[7], 6, 'REMARK ', 1, 0, 'C');
     $this->Ln();
 }
 function report($id, $pro_id)
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'code';
     $criteria->compare('department_id', $pro_id);
     $criteria->compare('parent_id', $id);
     //$criteria->compare('amount!',0);
     $criteria->addNotInCondition('id', array(193, 119, 164, 198));
     $models = aBudget::model()->findAll($criteria);
     $this->myheader($id, $pro_id);
     $w = array(47, 23, 23, 10, 23, 10, 23, 10, 23);
     $this->SetFont('Arial', '', 7);
     $_total = 0;
     $_realization = 0;
     $_payment = 0;
     $_unpayment = 0;
     $_balance = 0;
     foreach ($models as $model) {
         $_amount = $model->amount;
         $_real = aBudget::model()->allComponent($model->id, 2012, 1);
         $_realP = $_amount != 0 ? $_real / $_amount * 100 : 0;
         $_paid = aBudget::model()->allComponentPaid($model->id, 2012, 1);
         $_paidP = $_real != 0 ? $_paid / $_real * 100 : 0;
         $_unpaid = $_real - $_paid;
         $_unpaidP = $_real != 0 ? $_unpaid / $_real * 100 : 0;
         $_endBalance = isset($model->end_balance) ? $model->end_balance->balance : $_amount;
         $this->SetFont('Arial', '', 7);
         $this->Cell($w[0], 6, $model->code . ". " . $model->name, 'L');
         $this->Cell($w[1], 6, number_format($_amount, 2, ',', '.'), 'LR', 0, 'R');
         $this->Cell($w[2], 6, number_format($_real, 2, ',', '.'), '', 0, 'R');
         $this->Cell($w[3], 6, round($_realP, 2), 'LR', 0, 'R');
         $this->Cell($w[4], 6, number_format($_paid, 2, ',', '.'), '', 0, 'R');
         $this->Cell($w[5], 6, round($_paidP, 2), 'LR', 0, 'R');
         $this->Cell($w[6], 6, number_format($_unpaid, 2, ',', '.'), '', 0, 'R');
         $this->Cell($w[7], 6, round($_unpaidP, 2), 'LR', 0, 'R');
         $this->Cell($w[8], 6, number_format($_endBalance, 0, ',', '.'), 'LR', 0, 'R');
         $this->Ln();
         $_total = $_total + $_amount;
         $_realization = $_realization + $_real;
         $_payment = $_payment + $_paid;
         $_unpayment = $_unpayment + $_unpaid;
         $_balance = $_balance + $_endBalance;
     }
     $this->Cell(array_sum($w), 4, '', 'T');
     $this->Ln(6);
     $_realizationP = $_total != 0 ? $_realization / $_total * 100 : 0;
     $_paymentP = $_realization != 0 ? $_payment / $_realization * 100 : 0;
     $_unpaymentP = $_realization != 0 ? $_unpayment / $_realization * 100 : 0;
     $this->SetFont('Arial', 'B', 8);
     $this->Cell($w[0], 8, 'T O T A L', 1);
     $this->Cell($w[1], 8, number_format($_total, 0, ',', '.'), 1, 0, 'R');
     $this->Cell($w[2], 8, number_format($_realization, 0, ',', '.'), 1, 0, 'R');
     $this->Cell($w[3], 8, round($_realizationP, 2), 1, 0, 'R');
     $this->Cell($w[4], 8, number_format($_payment, 0, ',', '.'), 1, 0, 'R');
     $this->Cell($w[5], 8, round($_paymentP, 2), 1, 0, 'R');
     $this->Cell($w[6], 8, number_format($_unpayment, 0, ',', '.'), 1, 0, 'R');
     $this->Cell($w[7], 8, round($_unpaymentP, 2), 1, 0, 'R');
     $this->Cell($w[8], 8, number_format($_balance, 0, ',', '.'), 1, 0, 'R');
     $this->Ln();
 }
 function pRequestR1($id)
 {
     $this->myheader4($id);
     $criteria = new CDbCriteria();
     $criteria->compare('parent_id', $id);
     $models = aPorderDetail::model()->findAll($criteria);
     $_counter = 1;
     $_countert = 1;
     $_totalc = 0;
     $_totals = 0;
     $w = array(6, 65, 40, 10, 10, 20, 20, 25, 15, 10, 10, 10, 10, 20);
     $x = $this->GetX();
     $y = $this->GetY();
     foreach ($models as $mod) {
         $this->SetFont('Arial', '', 8);
         $x0 = $this->GetX();
         $y0 = $this->GetY();
         $this->Cell($w[0], 4, number_format($_countert, 0, ',', '.'), 'L', 0, 'R');
         $y1 = $this->GetY();
         $this->MultiCell($w[1], 4, aBudget::model()->findByPk($mod->budget_id)->code . " " . $mod->description, 'LB');
         $y2 = $this->GetY();
         $yH = $y2 - $y1;
         $yC = $this->GetY();
         $this->SetXY($x0, $y0);
         $this->Cell($w[0], $yH, '', 'LB');
         //Garis samping
         $this->SetXY($x + $w[0] + $w[1], $yC - $yH);
         $this->Cell($w[2], $yH, $mod->user, 'LB');
         $this->Cell($w[3], $yH, $mod->uom, 'LB');
         $this->Cell($w[4], $yH, $mod->qty, 'LB', 0, 'R');
         $this->Cell($w[5], $yH, '', 'LB', 0, 'R');
         $this->Cell($w[6], $yH, sParameter::cDateDisplay(strtotime($mod->need_date)), 'LB', 0, 'R');
         $this->Cell($w[7], $yH, '', 'LB', 0, 'R');
         $this->Cell($w[8], $yH, '', 'LB', 0, 'R');
         $this->Cell($w[9], $yH, '', 'LB', 0, 'R');
         $this->Cell($w[10], $yH, '', 'LB', 0, 'R');
         $this->Cell($w[11], $yH, '', 'LB', 0, 'R');
         $this->Cell($w[12], $yH, '', 'LB', 0, 'R');
         $this->Cell($w[13], $yH, '', 'LBR', 0, 'R');
         $this->Ln();
         $_totalc = $_totalc + $mod->qty;
         $_totals = $_totals + aBudget::model()->findByPk($mod->budget_id)->amount;
         $_counter++;
         $_countert++;
         //if ($_counter==34) {
         //	$this->AddPage();
         //	$this->myheader4($id);
         //	$_counter = 1;
         //}
     }
     //Closure line
     $this->Cell(array_sum($w), 0, '', 'T');
     $this->Ln(2);
     $this->SetFont('Arial', 'B', 8);
     $this->Cell($w[0], 5, '', 'TLB');
     $this->Cell($w[1], 5, 'T O T A L', 'TLB', 0, 'C');
     $this->Cell($w[2], 5, '', 'TLB');
     $this->Cell($w[3], 5, '', 'TLB');
     $this->Cell($w[4], 5, number_format($_totalc, 0, ',', '.'), 'TLBR', 0, 'R');
     $this->Cell($w[5], 5, '', 'TLBR', 0, 'R');
     $this->Cell($w[6], 5, '', 'TLB');
     $this->Cell($w[7], 5, '', 'TLB');
     $this->Cell($w[8], 5, '', 'TLB');
     $this->Cell($w[9], 5, '', 'TLB');
     $this->Cell($w[10], 5, '', 'TLB');
     $this->Cell($w[11], 5, '', 'TLB');
     $this->Cell($w[12], 5, '', 'TLB');
     $this->Cell($w[13], 5, '', 1);
     $this->Ln(10);
     $this->SetFont('Arial', '', 8);
     $this->Cell(30, 6, 'Keterangan:');
     $this->Ln(4);
     $this->Cell(0, 6, aPorder::model()->findByPk($mod->parent_id)->remark);
     $this->Ln(14);
     $this->SetFont('Arial', '', 10);
     $this->Cell($w[0], 6, '', 'LT');
     $this->Cell($w[1], 6, 'Requested By', 'TR', 0, 'C');
     $this->Cell($w[2], 6, '', 'T', 0, 'C');
     $this->Cell($w[3], 6, '', 'T', 0, 'C');
     $this->Cell($w[4], 6, '', 'T', 0, 'C');
     $this->Cell($w[5], 6, '', 'T', 0, 'C');
     $this->Cell($w[6], 6, '', 'T', 0, 'C');
     $this->Cell($w[7], 6, 'Acknowledge By:', 'T', 0, 'C');
     $this->Cell($w[8], 6, '', 'T', 0, 'C');
     $this->Cell($w[9], 6, '', 'T', 0, 'C');
     $this->Cell($w[10], 6, '', 'T', 0, 'C');
     $this->Cell($w[11], 6, '', 'T', 0, 'C');
     $this->Cell($w[12], 6, '', 'T', 0, 'C');
     $this->Cell($w[13], 6, '', 'TR', 0, 'C');
     $this->Ln();
     $this->Cell($w[0], 18, '', 'L');
     $this->Cell($w[1], 18, '', 'R');
     $this->Cell($w[2], 18);
     $this->Cell($w[3], 18);
     $this->Cell($w[4], 18);
     $this->Cell($w[5], 18);
     $this->Cell($w[6], 18);
     $this->Cell($w[7], 18);
     $this->Cell($w[8], 18);
     $this->Cell($w[9], 18);
     $this->Cell($w[10], 18);
     $this->Cell($w[11], 18);
     $this->Cell($w[12], 18);
     $this->Cell($w[13], 18, '', 'R');
     $this->Ln();
     $this->Cell($w[0], 6, '', 'L');
     $this->Cell($w[1], 6, 'Silvia Theresia', 'R', 0, 'C');
     $this->Cell($w[2], 6, '', 0, 0, 'C');
     $this->Cell($w[3], 6, '', 0, 0, 'C');
     $this->Cell($w[4] + $w[5], 6, 'Hadi Sutanto', 0, 0, 'C');
     $this->Cell($w[6], 6, '', 0, 0, 'C');
     $this->Cell($w[7], 6, '', 0, 0, 'C');
     $this->Cell($w[8], 6, '', 0, 0, 'C');
     $this->Cell($w[9] + $w[10] + $w[11], 6, 'Indra W. Antono', 0, 0, 'C');
     $this->Cell($w[12], 6, '', 0, 0, 'C');
     $this->Cell($w[13], 6, '', 'R', 'C');
     $this->Ln(3);
     $this->SetFont('Arial', '', 8);
     $this->Cell($w[0], 6, '', 'LB');
     $this->Cell($w[1], 6, 'Office Support Manager', 'BR', 0, 'C');
     $this->Cell($w[2], 6, '', 'B', 0, 'C');
     $this->Cell($w[3], 6, '', 'B', 0, 'C');
     $this->Cell($w[4] + $w[5], 6, 'Fin & Acc Deputy Director', 'B', 0, 'C');
     $this->Cell($w[6], 6, '', 'B', 0, 'C');
     $this->Cell($w[7], 6, '', 'B', 0, 'C');
     $this->Cell($w[8], 6, '', 'B', 0, 'C');
     $this->Cell($w[9] + $w[10] + $w[11], 6, 'Marketing Director', 'B', 0, 'C');
     $this->Cell($w[12], 6, '', 'B', 0, 'C');
     $this->Cell($w[13], 6, '', 'BR', 'C');
     $this->Ln();
     $this->SetFont('Arial', 'BI', 8);
     $this->Cell(0, 6, aPorder::model()->findByPk($mod->parent_id)->no_ref . "         ", 0, 0, 'R');
     $this->Ln();
 }
<?php

//echo CHtml::link("Back to Parent",Yii::app()->createUrl("/m1/aBudget",array("id"=>aBudget::model()->findByPk((int)$id)->getparent->id)));
$this->widget('bootstrap.widgets.BootGridView', array('id' => 'a-porder-grid', 'dataProvider' => aBudget::model()->perBulan($id), 'itemsCssClass' => 'table table-striped table-bordered', 'template' => '{items}{pager}{summary}', 'columns' => array('code', 'name', array('name' => 'amount', 'header' => 'Total Budget', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201201', 'header' => '2012 01', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201202', 'header' => '2012 02', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201203', 'header' => '2012 03', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201204', 'header' => '2012 04', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201205', 'header' => '2012 05', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201206', 'header' => '2012 06', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201207', 'header' => '2012 07', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201208', 'header' => '2012 08', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201209', 'header' => '2012 09', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201210', 'header' => '2012 10', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201211', 'header' => '2012 11', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201212', 'header' => '2012 12', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')))));
?>
<br />
<?php 
$this->widget('bootstrap.widgets.BootGridView', array('id' => 'a-porder-grid', 'dataProvider' => aBudget::model()->perBulanDept($id), 'template' => '{items}', 'itemsCssClass' => 'table table-striped table-bordered', 'template' => '{items}{pager}', 'columns' => array('department', array('name' => 'amount', 'header' => 'Total Budget', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201201', 'header' => '2012 01', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201202', 'header' => '2012 02', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201203', 'header' => '2012 03', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201204', 'header' => '2012 04', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201205', 'header' => '2012 05', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201206', 'header' => '2012 06', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201207', 'header' => '2012 07', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201208', 'header' => '2012 08', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201209', 'header' => '2012 09', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201210', 'header' => '2012 10', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201211', 'header' => '2012 11', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => '201212', 'header' => '2012 12', 'type' => 'number', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')))));
?>
<hr />
<br />
<?php 
if (aBudget::model()->perBulanModel($id) != null) {
    $this->Widget('ext.highcharts.HighchartsWidget', array('options' => array('chart' => array('defaultSeriesType' => 'column'), 'theme' => 'grid', 'title' => array('text' => 'Pertumbuhan By Component'), 'xAxis' => array('categories' => array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Des')), 'yAxis' => array('title' => array('text' => 'Jumlah ( x 100.000)')), 'series' => aBudget::model()->perBulanModel($id))));
}
    ?>
			</td>
		</tr>
		<?php 
} else {
    ?>
		<?php 
    for ($i = 0; $i < sizeof($model->department_id); ++$i) {
        ?>
		<tr>
			<td><?php 
        echo CHtml::dropDownList('department_id[]', $model->department_id[$i], aOrganization::getListProject());
        ?>
			</td>
			<td><?php 
        echo CHtml::dropDownList('budget_id[]', $model->budget_id[$i], aBudget::nonMainComponent(109));
        ?>
			</td>
			<td><?php 
        echo CHtml::textField('description[]', $model->description[$i], array('maxlength' => 500));
        ?>
			</td>
			<td><?php 
        echo CHtml::textField('amount[]', $model->amount[$i], array('size' => 15, 'maxlength' => 15));
        ?>
			</td>
		</tr>
		<?php 
    }
    ?>
		<?php 
    ?>
			</td>
			<td><?php 
    echo CHtml::textField('amount[]', '', array('class' => 'span2'));
    ?>
			</td>
		</tr>
		<?php 
} else {
    ?>
		<?php 
    for ($i = 0; $i < sizeof($model->budget_id); ++$i) {
        ?>
		<tr>
			<td><?php 
        echo CHtml::dropDownField('budget_id[]', $model->budget_id, aBudget::nonMainComponent07());
        ?>
			</td>
			<td><?php 
        echo CHtml::textArea('description[]', $model->description, array('maxlength' => 500));
        ?>
			</td>
			<td><?php 
        echo CHtml::textField('user[]', $model->user, array('maxlength' => 255));
        ?>
			</td>
			<td><?php 
        echo CHtml::textField('amount[]', $model->amount, array('width' => 15, 'maxlength' => 15));
        ?>
			</td>
		</tr>
<?php 
echo $form->errorSummary($model);
?>

<?php 
echo $form->textFieldRow($model, 'input_date');
?>

<?php 
echo $form->textFieldRow($model, 'no_ref', array('class' => 'span3'));
echo $form->textFieldRow($model, 'periode_date');
?>

<?php 
echo $form->dropDownListRow($model, 'budgetcomp_id', aBudget::mainComponent(), array());
?>


<?php 
echo $form->textAreaRow($model, 'remark', array('rows' => 2, 'cols' => 50));
?>


<?php 
echo $form->dropDownListRow($model, 'issuer_id', sParameter::items("cIssuer"));
$this->widget('ext.appendo.JAppendo', array('id' => 'repeateEnum', 'model' => $model, 'viewName' => '_detailPorder', 'labelDel' => 'Remove Row'));
?>
<div class="form-actions">
	<?php 
echo CHtml::htmlButton('<i class="icon-ok"></i>' . $model->isNewRecord ? 'Create' : 'Save', array('class' => 'btn', 'type' => 'submit'));
<?php

if ($id == 300 || $id != null && aBudget::model()->findByPk((int) $id)->parent_id == 300) {
    echo "<h2>List of AF</h2>";
    $this->widget('bootstrap.widgets.BootGridView', array('itemsCssClass' => 'table table-striped table-bordered', 'id' => 'aPorder-grid', 'dataProvider' => aPorder::model()->approvalForm(0, $id), 'template' => '{items}{pager}', 'columns' => array('input_date', array('name' => 'no_ref', 'type' => 'raw', 'value' => 'CHtml::link($data->no_ref,Yii::app()->createUrl("/m1/aPorder/view",array("id"=>$data->id)))'), 'periode_date', 'remark', array('header' => 'Total', 'value' => '$data->sum_pof()', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), 'approved_date', 'payment_date')));
}
    "";
}
?>
	</h1>
</div>

<?php 
$this->widget('bootstrap.widgets.BootMenu', array('type' => 'pills', 'stacked' => false, 'items' => array(array('label' => 'Waiting for Approval', 'url' => Yii::app()->createUrl('/m1/aApprovalForm', array("id" => 1)), 'active' => $id == 1), array('label' => 'Waiting for Payment', 'url' => Yii::app()->createUrl('/m1/aApprovalForm', array("id" => 2)), 'active' => $id == 2), array('label' => 'Paid', 'url' => Yii::app()->createUrl('/m1/aApprovalForm', array("id" => 3)), 'active' => $id == 3), array('label' => 'Show All', 'url' => Yii::app()->createUrl('/m1/aApprovalForm', array("id" => 0)), 'active' => $id == 0))));
//echo CHtml::ajaxLink('Next quote', Yii::app()->createUrl('/m1/aApprovalForm',array("id"=>2)),array('update' => '#grid'));
?>

<?php 
if (isset($_GET['cid'])) {
    if ($_GET['cid'] != null) {
        echo "<div style='background-color:yellow; padding:3px; margin-bottom:10px'><b>";
        echo "Current Filter : " . aBudget::model()->findByPk((int) $_GET['cid'])->name;
        echo "</b></div>";
    }
}
?>

<?php 
$this->widget('DropDownRedirect', array('data' => aBudget::mainComponent(), 'url' => $this->createUrl($this->route, array_merge($_GET, array('id' => $id, 'cid' => '__value__'))), 'select' => isset($_GET['cid']) ? $_GET['cid'] : "ALL"));
?>

<div id="grid">
	<?php 
$this->renderPartial('_gridAF', array("id" => $id, "cid" => $cid));
?>
</div>
<?php

$this->widget('bootstrap.widgets.BootGridView', array('id' => 'abudget-grid', 'dataProvider' => aBudget::model()->search($id, $pro_id), 'itemsCssClass' => 'table table-striped table-bordered', 'template' => '{items}{pager}', 'columns' => array('year', 'code', array('name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link($data->name,Yii::app()->createUrl("/m1/aBudget",array("id"=>$data->id,"pro_id"=>$data->department_id)))'), array('header' => 'Parent', 'type' => 'raw', 'value' => '($data->getparent) ? CHtml::link($data->getparent->name,Yii::app()->createUrl("/m1/aBudget",array("id"=>$data->getparent->parent_id))) : ""'), array('name' => 'amount', 'value' => '$data->amountf()', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('header' => 'Total AF (Approved)', 'value' => '$data->total_af', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('header' => 'Total AF (All)', 'value' => '$data->total_af_all', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('header' => 'Realization', 'value' => '($data->parent_id ==0) ? aBudget::model()->allComponent($data->id,2012) : aBudget::model()->allSubComponent($data->id,2012)', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('header' => 'Total Paid', 'value' => '($data->parent_id ==0) ? aBudget::model()->allComponentPaid($data->id,2012) : aBudget::model()->allSubComponentPaid($data->id,2012)', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('header' => 'Saldo', 'value' => '(isset($data->end_balance)) ? $data->end_balance->balancef() : ""', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('header' => 'Percentage', 'value' => '(isset($data->end_balance)) ? number_format($data->end_balance->balance / $data->amount * 100,2) : ""', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('class' => 'ext.BootProgressColumn', 'percent' => 100, 'value' => '(isset($data->end_balance)) ? number_format($data->end_balance->balance / $data->amount * 100,2) : ""', 'htmlOptions' => array('style' => 'width: 100px;')))));
?>

<hr />

<?php 
$this->widget('bootstrap.widgets.BootDetailView', array('data' => array('id' => 1, 'total' => aBudget::model()->getTotalComponent($id), 'total_r' => aBudget::model()->getTotalComponentR($id)), 'attributes' => array(array('name' => 'total', 'label' => 'Total Budget'), array('name' => 'total_r', 'label' => 'Total Realization'))));
?>


<hr />

    function report($id, $pro_id)
    {
        $criteria = new CDbCriteria();
        $criteria->order = 'code';
        $criteria->compare('department_id', $pro_id);
        $criteria->compare('parent_id', $id);
        //$criteria->compare('amount!',0);
        $criteria->addNotInCondition('id', array(193, 119, 164, 198));
        $models = aBudget::model()->findAll($criteria);
        $this->myheader($id, $pro_id);
        //$w=array(15,40,23,23,23,23,23,23);
        $w = array(15, 60, 23, 23, 23, 23, 23, 23);
        $this->SetFont('Arial', '', 8);
        foreach ($models as $model) {
            $_amount = $model->amount;
            $_real = aBudget::model()->allComponent($model->id, 2012, 1);
            $_paid = aBudget::model()->allComponentPaid($model->id, 2012, 1);
            $_unpaid = $_real - $_paid;
            $_endBalance = isset($model->end_balance) ? $model->end_balance->balance : $_amount;
            $this->SetFont('Arial', 'B', 8);
            $this->Cell($w[0] + $w[1], 6, $model->code . ". " . $model->name, 'LT');
            $this->Cell($w[2], 6, '', 'T');
            $this->Cell($w[3], 6, number_format($_amount, 0, ',', '.'), 'TLR', 0, 'R');
            $this->Cell($w[4], 6, '', 'T', 0, 'R');
            //$this->Cell($w[5],6,number_format($_paid,2,',','.'),'T',0,'R');
            //$this->Cell($w[6],6,number_format($_unpaid,2,',','.'),'T',0,'R');
            //$this->Cell($w[5],6,'','T',0,'R');
            //$this->Cell($w[6],6,'','T',0,'R');
            $this->Cell($w[7], 6, number_format($_endBalance, 0, ',', '.'), 'TLR', 0, 'R');
            $this->Ln();
            $_total = 0;
            foreach ($model->ch as $mod) {
                $this->SetFont('Arial', '', 6);
                $this->Cell($w[0] + $w[1], 4, '        ' . $mod->name, 'L');
                $this->Cell($w[2], 4, '');
                $this->Cell($w[3], 4, number_format($mod->amount, 0, ',', '.'), 'LR', 0, 'R');
                $crit = new CDbCriteria();
                $crit->with = array('po_detail');
                $crit->condition = 'approved_date is not null';
                $crit->compare('po_detail.budget_id', $mod->id);
                $modelT1 = aPorderDetail::model()->countBySql('
						SELECT SUM(a.amount) AS total
						FROM a_porder_detail a INNER JOIN a_porder b ON a.parent_id = b.id
						WHERE b.approved_date IS NOT NULL
						GROUP BY a.budget_id
						HAVING a.budget_id =
						' . $mod->id);
                $this->Cell($w[4], 4, number_format($modelT1, 0, ',', '.'), 0, 0, 'R');
                $_balance1 = $mod->amount - $modelT1;
                //$this->Cell($w[5],4,'',0,0,'R');
                //$this->Cell($w[6],4,'',0,0,'R');
                $this->Cell($w[7], 4, number_format($_balance1, 0, ',', '.'), 'LR', 0, 'R');
                $this->Ln();
                $_total = $_total + $modelT1;
                foreach ($mod->ch as $m) {
                    $this->SetFont('Arial', '', 6);
                    $this->Cell($w[0] + $w[1], 4, '                ' . $m->name, 'L');
                    $this->Cell($w[2], 4, '');
                    $this->Cell($w[3], 4, number_format($m->amount, 0, ',', '.'), 'LR', 0, 'R');
                    $modelT2 = aPorderDetail::model()->countBySql('
							SELECT SUM(a.amount) AS total
							FROM a_porder_detail a INNER JOIN a_porder b ON a.parent_id = b.id
							WHERE b.approved_date IS NOT NULL
							GROUP BY a.budget_id
							HAVING a.budget_id =
							' . $m->id);
                    $this->Cell($w[4], 4, number_format($modelT2, 0, ',', '.'), 0, 0, 'R');
                    $_balance2 = $m->amount - $modelT2;
                    //$this->Cell($w[5],4,'',0,0,'R');
                    //$this->Cell($w[6],4,'',0,0,'R');
                    $this->Cell($w[7], 4, number_format($_balance2, 0, ',', '.'), 'LR', 0, 'R');
                    $this->Ln();
                    $_total = $_total + $modelT2;
                    if ($this->GetY() >= 250) {
                        $this->Cell(array_sum($w) - 46, 4, '', 'T');
                        $this->AddPage();
                        $this->myheader($id, $pro_id);
                    }
                }
                if ($this->GetY() >= 250) {
                    $this->Cell(array_sum($w) - 46, 4, '', 'T');
                    $this->AddPage();
                    $this->myheader($id, $pro_id);
                }
            }
            //*
            $this->SetFont('Arial', 'B', 6);
            $this->Cell($w[0] + $w[1], 4, 'Check Balance', 'L');
            $this->Cell($w[2], 4, '');
            $this->Cell($w[3], 4, '', 'L');
            $this->Cell($w[4], 4, number_format($_total, 0, ',', '.'), 'L', 0, 'R');
            $_checkbalance = $model->amount - $_total;
            //$this->Cell($w[5],4,'',0,0,'R');
            //$this->Cell($w[6],4,'',0,0,'R');
            $this->Cell($w[7], 4, number_format($_checkbalance, 0, ',', '.'), 'LR', 0, 'R');
            $this->Ln();
            //*/
            $this->Cell(array_sum($w) - 46, 4, '', 'T');
            $this->Ln(1);
        }
    }
 function approvalFormR2($id)
 {
     $criteria = new CDbCriteria();
     $model = aPorder::model()->findByPk((int) $id);
     /**/
     $_amount = $model->budgetcomp->amount;
     $_actual = $model->budgetcomp->sum_budget;
     $_currentbalance = $_amount - $_actual;
     $_newbalance = $_currentbalance - $model->sum_po;
     $this->SetFont('Arial', 'B', 6);
     $this->Cell(50, 4, 'PT. AGUNG PODOMORO LAND, Tbk');
     $this->Ln(3);
     $this->Cell(50, 4, 'Budget Position');
     $this->Cell(100);
     $this->Ln(5);
     $_paid = aBudget::model()->allComponentPaid($model->budgetcomp_id, 2012, 1);
     $_unpaid = $_actual - $_paid;
     $_paidP = $_actual != 0 ? $_paid / $_actual * 100 : 0;
     $_unpaidP = $_actual != 0 ? $_unpaid / $_actual * 100 : 0;
     //Header
     $this->SetFont('Arial', '', 6);
     $this->Cell(30, 3, 'Project:');
     $this->SetFont('Arial', 'B', 6);
     $this->Cell(40, 3, $model->organization->getTopLevel());
     $this->SetFont('Arial', '', 6);
     $this->Cell(30, 3, 'Budget: ' . $model->budgetcomp->name, 0, 0, 'R');
     $this->SetFont('Arial', 'B', 6);
     $this->Cell(30, 3, number_format($_amount, 0, ',', '.'), 0, 0, 'R');
     $this->SetFont('Arial', '', 6);
     $this->Cell(30, 3, 'Paid', 0, 0, 'R');
     $this->SetFont('Arial', 'B', 6);
     $this->Cell(20, 3, number_format($_paid, 0, ',', '.'), 0, 0, 'R');
     $this->Cell(10, 3, round($_paidP, 2) . "%", 0, 0, 'R');
     $this->Ln(3);
     $this->SetFont('Arial', '', 6);
     $this->Cell(30, 3, 'Department:');
     $this->SetFont('Arial', 'B', 6);
     $this->Cell(40, 3, $model->organization->name);
     $this->SetFont('Arial', '', 6);
     $this->Cell(30, 3, 'Realization', 'B', 0, 'R');
     $this->SetFont('Arial', 'B', 6);
     $this->Cell(30, 3, number_format($_actual, 0, ',', '.'), 'B', 0, 'R');
     $this->SetFont('Arial', '', 6);
     $this->Cell(30, 3, 'UnPaid', 0, 0, 'R');
     $this->SetFont('Arial', 'B', 6);
     $this->Cell(20, 3, number_format($_unpaid, 0, ',', '.'), 'B', 0, 'R');
     $this->Cell(10, 3, round($_unpaidP, 2) . "%", 'B', 0, 'R');
     $this->Ln(3);
     $this->SetFont('Arial', '', 6);
     $this->Cell(30, 3, 'Budget Category:');
     $this->SetFont('Arial', 'B', 6);
     $this->Cell(40, 3, $model->budgetcomp->name);
     $this->SetFont('Arial', '', 6);
     $this->Cell(30, 3, 'Current Budget Position', 0, 0, 'R');
     $this->SetFont('Arial', 'B', 6);
     $this->Cell(30, 3, number_format($_currentbalance, 0, ',', '.'), 0, 0, 'R');
     $this->SetFont('Arial', '', 6);
     $this->Cell(30, 3, 'TOTAL', 0, 0, 'R');
     $this->SetFont('Arial', 'B', 6);
     $this->Cell(20, 3, number_format($_paid + $_unpaid, 0, ',', '.'), 0, 0, 'R');
     $this->Cell(10, 3, round($_paidP + $_unpaidP, 2) . "%", 0, 0, 'R');
     $this->Ln(3);
     $this->SetFont('Arial', '', 6);
     $this->Cell(30, 3, 'Date');
     $this->SetFont('Arial', 'B', 6);
     $this->Cell(50, 3, $model->input_date);
     $this->Ln(6);
     $w = array(15, 85, 22, 22, 22, 22);
     $this->SetFont('Arial', 'B', 8);
     $this->Cell($w[0] + $w[1] + $w[2], 6, 'Description', 'TLR');
     $this->Cell($w[3], 6, 'Budget Comp.', 1, 0, 'C');
     $this->Cell($w[4], 6, 'Payment Status', 1, 0, 'C');
     $this->Cell($w[5], 6, 'Payment Date', 1, 0, 'C');
     $this->Ln();
     $this->Cell($w[0], 1, '', 'T');
     $this->Cell($w[1], 1, '', 'T');
     $this->Cell($w[2], 1, '', 'T');
     $this->Cell($w[3], 1, '', 'T');
     $this->Cell($w[4], 1, '', 'T');
     $this->Cell($w[5], 1, '', 'T');
     $this->Ln();
     //$modelp=aPorder::model()->with('po_detail')->findAll(array('condition'=>'length(approved_date) <> 0 AND budgetcomp_id = ' .$model->budgetcomp_id,'order'=>'t.id'));
     $modelp = aPorder::model()->with('po_detail')->findAll(array('condition' => 'length(approved_date) <> 0 AND t.id <> ' . $id . ' AND budgetcomp_id = ' . $model->budgetcomp_id, 'order' => 't.id'));
     $this->SetFont('Arial', '', 8);
     foreach ($modelp as $modp) {
         $this->SetFont('Arial', 'B', 8);
         $this->Cell($w[0] + $w[1], 6, $modp->no_ref, 'LT');
         $this->Cell($w[2], 6, '', 'T');
         $this->Cell($w[3], 6, number_format($modp->sum_po, 0, ',', '.'), 'TLR', 0, 'R');
         $this->Cell($w[4], 6, '', 'T');
         $this->Cell($w[5], 6, '', 'LRT');
         $this->Ln();
         //Detail
         $_total = 0;
         $_total1 = 0;
         $_counter = 1;
         $_countert = 1;
         $this->SetFont('Arial', '', 8);
         $w = array(15, 85, 22, 22, 22, 22);
         $x = $this->GetX();
         $y = $this->GetY();
         $_dept = 0;
         foreach ($modp->po_detail as $mod) {
             $_desc = strlen($mod->description) < 80 ? $mod->description : substr($mod->description, 0, 80) . '...';
             $this->SetFont('Arial', '', 6);
             $this->Cell($w[0] + $w[1] + $w[2], 4, '     ' . $mod->budget->code . '. ' . $mod->budget->name . '. ' . $_desc, 'LR');
             $this->Cell($w[3], 4, number_format($mod->qty * $mod->amount, 0, ',', '.'), 'LR', 0, 'R');
             $this->Cell($w[4], 4, isset($mod->payment) ? $mod->payment->name : '', 'LR', 0, 'R');
             $this->Cell($w[5], 4, '', 'LR', 0, 'R');
             $this->Ln();
             $_total = $_total + $mod->qty * $mod->amount;
             $_counter++;
             $_countert++;
         }
         $this->Cell(array_sum($w), 4, '', 'T');
         $this->Ln(2);
     }
 }
 /**
  * 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 = aBudget::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function getData($cnd = " = 0")
 {
     $data = array();
     foreach (aBudget::model()->findAll('parent_id ' . $cnd . ' ORDER BY code') as $model) {
         $row['text'] = $model->name;
         $row['id'] = $model->id;
         $row['children'] = aBudget::model()->getData(' = ' . $model->id);
         $data[] = $row;
     }
     return $data;
 }
Пример #15
0
?>
		Budget:
		<?php 
echo $pro_id == 2 ? "RMG / MGR" : "CP";
?>
		<?php 
//echo ($id !=null or $id !=0) ? '| '.aBudget::model()->findByPk($id)->name : ''
?>
	</h1>
</div>


<br />

<?php 
if ($id == 300 || aBudget::model()->findByPk((int) $id)->childs) {
    ?>
<div id="component">
	<?php 
    echo $this->renderPartial('_component', array('id' => $id, 'pro_id' => $pro_id));
    ?>
</div>
<?php 
    echo $this->renderPartial('_listAF', array('id' => $id));
    ?>

<br />
<?php 
    /*
    $this->Widget('ext.highcharts.HighchartsWidget', array(
    		'options'=>array(