This extension based on extension pdffactory to easy export data from Gridview to PDF..
Requirements ¶
pdffactory 1.0.1 other requirement same with pdffactory requirement
##Instalation
I assume that You have install pdffactory
After that.. Place file EPdfFactoryHeart.php into protected/extensions/pdffactory
Usage ¶
You can use by simple.. in Your view
<?php echo CHtml::beginForm(array('export')); ?>
<?php $this->widget('bootstrap.widgets.TbGridView',array(
'id'=>'employee-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'type' => 'striped hover', //bordered condensed
'columns'=>array(
'id',
'ref_religion_id',
'name',
'born',
'birthDay',
'gender',
'phone',
'email',
'address',
'photo',
'status',
),
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
),
),
)); ?>
<select name="fileType" style="width:150px;">
<option value="PDF">PDF</option>
</select>
<br>
<?php
$this->widget('bootstrap.widgets.TbButton', array(
'buttonType'=>'submit', 'icon'=>'fa fa-print','label'=>'Export', 'type'=> 'primary'));
?>
<?php echo CHtml::endForm(); ?>
in Your controller
public function actionExport()
{
$model=new Employee;
$model->unsetAttributes(); // clear any default values
if(isset($_POST['Employee']))
$model->attributes=$_POST['Employee'];
$exportType = $_POST['fileType'];
if($exportType=='PDF'){
$this->widget('ext.pdffactory.EPdfFactoryHeart', array(
'title'=>'List of Employee',
'dataProvider' => $model->search(),
'filter'=>$model,
'columns' => array(
array(
'header'=>'No',
'value'=>'autonumber',
),
'ref_religion_id',
'name',
'born',
'birthDay',
array(
'header' => 'Gender',
'name'=> 'gender',
'type'=>'raw',
'value' => '($data->gender)?"Man":"Woman"',
),
'phone',
'email',
'address',
'photo',
array(
'header' => 'Status',
'name'=> 'status',
'type'=>'raw',
'value' => '($data->status)?"on":"off"',
),
),
));
}
}
Created by Love... This will include in YiiHeart next version
Great library with bug in setting title
Thanks for the library but I found a bug in it. Can't set the title of the PDF other than 'List of Employees'. It is been hard coded EPdfFactoryHeart.php Line 142: fixed by putting it $this->title;
bug
in file EPdfFactoryHeart.php line 143
replace
$this->pdf->Write(0, 'List of Employees', '', 0, 'L', true, 0, false, false, 0);
with:
$this->pdf->Write(0, $this->title, '', 0, 'L', true, 0, false, false, 0);
I wonder if this extensions could print data with "filter" :)
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.