/** * Export Data to Excel */ public function actionExport() { /** Get model */ $models = Satker::model()->findAll(); /** Error reporting */ $this->excelErrorReport(); /** PHPExcel_IOFactory */ $objReader = new PHPExcel(); $objReader = PHPExcel_IOFactory::createReader('Excel2007'); $path = Yii::app()->basePath . '/../export/satker.xlsx'; $pathExport = Yii::app()->basePath . '/../files/Master Satker.xlsx'; $objPHPExcel = $objReader->load($path); $objPHPExcel->setActiveSheetIndex(0); /* " Add new data to template" */ $this->exportExcel($objPHPExcel, $models); /** Export to excel* */ $this->excel($objPHPExcel, $pathExport); readfile($pathExport); unlink($pathExport); exit; }
public function actionTableReport() { $data = Satker::model()->findByAttributes(array('code' => '622280')); $ppk = array(); $limit = array(); $realization = array(); $rate = array(); $countData = array(); $ratePpk = array(); $limitPpk = array(); $totalRealPpk = array(); if ($data) { $packageAccount = PackageAccount::model()->findAllByAttributes(array('satker_code' => "{$data->code}")); $countData[$data->code] = 0; $limit[$data->code] = 0; $realization[$data->code] = 0; $rate[$data->code] = 0; if ($packageAccount) { $countData[$data->code] = count($packageAccount); foreach ($packageAccount as $pa) { $limit[$data->code] += $pa->limit; $realData = Realization::model()->findAllByAttributes(array('packageAccount_code' => "{$data->code}")); $totalRealization = 0; if ($realData) { foreach ($realData as $r) { $totalRealization += $r->total_spm; } } $realization[$data->code] += $totalRealization; } } if ($limit[$data->code] != 0) { $rate[$data->code] = $realization[$data->code] / $limit[$data->code] * 100; } $ppks = Ppk::model()->findAll(); if ($ppks) { foreach ($ppks as $ppk) { $paPpk = PackageAccount::model()->findAllByAttributes(array('ppk_code' => "{$ppk->code}")); $limitPpk[$ppk->code] = 0; $ratePpk[$ppk->code] = 0; $totalRealPpk[$ppk->code] = 0; if ($paPpk) { foreach ($paPpk as $p) { $limitPpk[$ppk->code] += $p->limit; $realPpk = Realization::model()->findAllByAttributes(array('packageAccount_code' => "{$p->code}")); $realizationPpk = 0; if ($realPpk) { foreach ($realPpk as $dataReal) { $realizationPpk += $dataReal->total_spm; } } $totalRealPpk[$ppk->code] += $realizationPpk; } if ($limitPpk != 0) { $ratePpk[$ppk->code] = $totalRealPpk[$ppk->code] / $limitPpk[$ppk->code] * 100; } } } } } echo $data->name . "</br>"; echo $limit[$data->code] . "</br>"; echo $realization[$data->code] . "</br>"; // $this->title = 'Tabel Penggunaan Anggaran'; // $say = 'Ini adalah page report penggunaan anggaran'; // $this->render('tableReport', array( // 'say' => $say, // )); }
<?php echo $form->fileFieldRow($model, 'file', array('class' => 'span5', 'maxlength' => 256, 'labelOptions' => array('label' => false))); ?> <p>File excel yang digunakan adalah file d_kmpnen yang sudah difilter jumlah barisnya</p> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => 'Import')); ?> </div> <?php $this->endWidget(); ?> </div> <div class="panel-header"> <a href="<?php echo yii::app()->baseUrl; ?> /component/exportError" class="btn btn-primary"><i class="fa fa fa-download"></i> Export Error</a> </div> <div class="panel-body"> <h2>Daftar Error Import Karena Sudah Terealisasi</h2> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'component-error-grid', 'dataProvider' => $componentError->search(), 'filter' => $componentError, 'columns' => array(array('header' => 'No', 'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)'), array('name' => 'satker_code', 'value' => 'isset($data->satker->name)?$data->satker->name:"Not set"', 'filter' => Satker::model()->getSatkerOptions()), array('name' => 'activity_code', 'value' => 'isset($data->activity->name)?$data->activity->name:"Not set"', 'filter' => Activity::model()->getActivityOptions()), array('name' => 'output_code', 'value' => 'isset($data->outputCode->name)?$data->outputCode->name:$data->output_code', 'filter' => Output::model()->getOutputOptions()), array('name' => 'suboutput_code', 'value' => 'isset($data->suboutputCode->name)?$data->suboutputCode->name:$data->suboutput_code', 'filter' => Suboutput::model()->getSuboutputOptions()), 'code', 'name', array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{view}')))); ?> </div> </div>
/** * Check completeness data of master * @return boolean */ public function checkMaster() { $complete = false; $ppk = Ppk::model()->exists(); $satker = Satker::model()->exists(); $activity = Activity::model()->exists(); $output = Output::model()->exists(); $suboutput = Suboutput::model()->exists(); $component = Component::model()->exists(); $subcomponent = Subcomponent::model()->exists(); $account = Account::model()->exists(); $province = Province::model()->exists(); $city = City::model()->exists(); if ($ppk && $satker && $activity && $output && $suboutput & $component && $subcomponent && $account && $province && $city) { $complete = TRUE; } return $complete; }
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'activity-form', 'enableAjaxValidation' => true, 'htmlOptions' => array('enctype' => 'multipart/form-data'))); ?> <?php echo $form->errorSummary($model); ?> <?php echo $form->dropDownListRow($model, 'satker_code', Satker::model()->getSatkerOptions(), array('class' => 'span5', 'maxlength' => 4)); ?> <?php echo $form->textFieldRow($model, 'code', array('class' => 'span5', 'maxlength' => 256)); ?> <?php echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 256)); ?> <?php /* <?php echo $form->textFieldRow($model,'created_at',array('class'=>'span5')); ?> <?php echo $form->dropDownListRow($model, "created_by", User::model()->getOptions(), array("prompt"=>"Please Select", "class"=>"autocomplete")); ?> <?php echo $form->textFieldRow($model,'updated_at',array('class'=>'span5')); ?>
public function getSatkerOptions() { $models = Satker::model()->findAll(); $options = array(); foreach ($models as $model) { $options[$model->code] = "[{$model->code}] | {$model->name}"; } return $options; }
<div class="panel-header"> <?php /* $this->breadcrumbs = array( 'Activities' => array('index'), 'Manage', ); * */ ?> <a href="<?php echo yii::app()->baseUrl; ?> /activity/export" class="btn btn-primary"><i class="fa fa-fw fa-download"></i> Export</a> <a href="<?php echo yii::app()->baseUrl; ?> /activity/import" class="btn btn-primary"><i class="fa fa-fw fa-upload"></i> Import</a> <a href="<?php echo yii::app()->baseUrl; ?> /activity/clear" onclick="return confirm('Yakin ingin menghapus semua data kegiatan?')" class="btn btn-primary"><i class="fa fa-fw fa-trash"></i> Bersihkan Data</a> </div> <div class="panel-body"> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'activity-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'summaryText' => '', 'columns' => array(array('header' => 'No', 'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)'), array('name' => 'satker_code', 'value' => 'isset($data->satker->name)?$data->satker->name:"Not set"', 'filter' => Satker::model()->getSatkerOptions()), array('name' => 'code', 'value' => 'isset($data->code)?str_replace($data->satker_code.".","",$data->code):"Not set"'), 'name', array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{view}')))); ?> </div> </div>