pdffactoryheart Easy Export Gridview Data To PDF with PDF Factory

  1. Requirements
  2. Usage

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

0 0
4 followers
486 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: File System
Developed by: ThePr0f3550r
Created on: May 6, 2014
Last updated: 3 years ago

Downloads

show all

Related Extensions