Yii 1.1: pdffactoryheart

Easy Export Gridview Data To PDF with PDF Factory
4 followers

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

Total 2 comments

#17960 report it
Anne Gii at 2014/08/18 06:10am
#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" :)

#17761 report it
Arora at 2014/07/20 09:41pm
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;

Leave a comment

Please to leave your comment.

Create extension