jerry_yii
(Eng Jkm)
1
hello people
I was wondering if it is possible to export data to PDF with conditions
but because we can filter data when exporting to PDF appears everything is in the database
I want to put a condition on the export
example want it exports between DateX until DateY
It depends on how you do your export.
Technically, exporting is pretty much the same as displaying, but w/o pagination.
Let’s consider the following simple example:
$criteria = new CDbCriteria;
$criteria->addCondition(...);
$criteria->addCondition(...);
$criteria->order = '...';
if ($export)
$pages = new CPagination(MyModel::model()->count($criteria));
$pages->pageSize = 10;
$pages->applyLimit($criteria);
$criteria->addCondition(...); // some extra conditions
$list = MyModel::model()->findAll($criteria);
$this->render(..., array('list' => $list));
} else {
$list = MyModel::model()->findAll($criteria);
//export data to pdf
}
$criteria here is reusable for either rendering html or exporting pdf.
PS. Some extra steps required if you have a lot of data, to prevent memory limit exceed.