how to divide each element of an array - php

this is my controller i need to divide the each rating which is posted by the max_rating which is in another table, how can i do this? i get an error now
A PHP Error was encountered Severity: Error
Message: Unsupported operand types
Filename: controllers/Performance.php
Line Number: 74
my model
public function get_max_rating($kpiid){
$this->db->select('max_rating');
$this->db->where_in('id',$kpiid);
$query = $this->db->get('kpi');
return $query->row();
}
My Controller:
...........
public function evaluate($r_id = 0) {
$this->form_validation->set_rules('rating[]', 'Rating', 'Trim|required');
if ($this->form_validation->run() == FALSE) {
$data = ['errors' => validation_errors()];
$this->session->set_flashdata($data);
$data['emp_review'] = $this->performance_model->get_emp_kpi($r_id);
$data['main_view'] = 'performance/evaluate_emp';
$this->load->view('layouts/main', $data);
} else {
$rating = $this->input->post('rating');
$comment = $this->input->post('comment');
$kpiid = $this->input->post('kpi_id');
$max_rating = $this->performance_model->get_max_rating($kpiid);
$decimal_rating = $rating / $max_rating->max_rating;
$reviewer = $this->session->userdata('user_id');
$ratingd = array();
for ($i = 0; $i < count($kpiid); $i++) {
$ratingd[] = array(
'rating' => $rating[$i],
'comment' => $comment[$i],
'decimal_rating' => $decimal_rating[$i],
'kpi_id' => $kpiid[$i],
'reviewer_id' => $reviewer,
'review_id' => $r_id
);
}
$this->performance_model->add_reviewer_rating($ratingd);
$data = [
'final_comment' => $this->input->post('final_comment')
];
$this->performance_model->insert_final_comment($r_id, $data);
redirect('performance/display');
}

You could calculate the decimal_rating inside the for loop like this :
for ($i = 0; $i < count($kpiid); $i++) {
$ratingd[] = array(
'rating' => $rating[$i],
'comment' => $comment[$i],
'decimal_rating' => $rating[$i] / $max_rating->max_rating,
'kpi_id' => $kpiid[$i],
'reviewer_id' => $reviewer,
'review_id' => $r_id
);

Related

Parsing returns an empty value

I make a parser of items from DotA 2 user inventory in the Steam service. Every time I try to parse user data, I get an empty value:
{"success":true,"items":[]}, but there are items in my Steam inventory.
My function to parse items:
public function loadMyInventory() {
if(Auth::guest()) return ['success' => false];
$prices = json_decode(Storage::get('prices.txt'), true);
$response = json_decode(file_get_contents('https://steamcommunity.com/inventory/'.$this->user->steamid64.'/570/2?l=russian&count=5000'), true);
if(time() < (Session::get('InvUPD') + 5)) {
return [
'success' => false,
'msg' => 'Error, repeat in '.(Session::get('InvUPD') - time() + 5).' сек.',
'status' => 'error'
];
}
//return $response;
$inventory = [];
foreach($response['assets'] as $item) {
$find = 0;
foreach($response['descriptions'] as $descriptions) {
if($find == 0) {
if(($descriptions['classid'] == $item['classid']) && ($descriptions['instanceid'] == $item['instanceid'])) {
$find++;
# If we find the price of an item, then move on.
if(isset($prices[$descriptions['market_hash_name']])) {
# Search data
$price = $prices[$descriptions['market_hash_name']]*$this->config->curs;
$class = false;
$text = false;
if($price <= $this->config->min_dep_sum) {
$price = 0;
$text = 'Cheap';
$class = 'minPrice';
}
if(($descriptions['tradable'] == 0) || ($descriptions['marketable'] == 0)) {
$price = 0;
$class = 'minPrice';
$text = 'Not tradable';
}
# Adding to Array
$inventory[] = [
'name' => $descriptions['market_name'],
'price' => floor($price),
'color' => $this->getRarity($descriptions['tags']),
'tradable' => $descriptions['tradable'],
'class' => $class,
'text' => $text,
'classid' => $item['classid'],
'assetid' => $item['assetid'],
'instanceid' => $item['instanceid']
];
}
}
}
}
}
Session::put('InvUPD', (time() + 5));
return [
'success' => true,
'items' => $inventory
];
}
But should return approximately the following value:
{"success":true,"items":[{"classid":"2274725521","instanceid":"57949762","assetid":"18235196074","market_hash_name":"Full-Bore Bonanza","price":26}]}
Where my mistake?
First of all, you are iterating on descriptions for every assets, which is assets*descriptions iteration, it's quite a lot, but you can optimize this.
let's loop once for descriptions and assign classid and instanceid as object key.
$assets = $response["assets"];
$descriptions = $response["descriptions"];
$newDescriptions=[];
foreach($descriptions as $d){
$newDescriptions[$d["classid"]][$d["instanceid"]] = $d;
}
this will give as the ability to not loop over description each time, we can access the description of certain asset directly $newDescriptions[$classid][$instanceid]]
foreach($assets as $a){
if(isset($newDescriptions[$a["classid"]]) && isset($newDescriptions[$a["classid"]][$a["instanceid"]])){
$assetDescription = $newDescriptions[$a["classid"]][$a["instanceid"]];
$inventory = [];
if(isset($prices[$assetDescription["market_hash_name"]])){
$price = $prices[$assetDescription['market_hash_name']]["price"]*$this->config->curs;
$class = false;
$text = false;
if($price <= $this->config->min_dep_sum) {
$price = 0;
$text = 'Cheap';
$class = 'minPrice';
}
if(($assetDescription['tradable'] == 0) || ($assetDescription['marketable'] == 0)) {
$price = 0;
$class = 'minPrice';
$text = 'Not tradable';
}
$inventory["priceFound"][] = [
'name' => $assetDescription['market_name'],
'price' => floor($price),
'color' => $this->getRarity($assetDescription['tags']),
'tradable' => $assetDescription['tradable'],
'class' => $class,
'text' => $text,
'classid' => $a['classid'],
'assetid' => $a['assetid'],
'instanceid' => $a['instanceid']
];
}else{
$inventory["priceNotFound"][] = $assetDescription["market_hash_name"];
}
}
}
About your mistake:
are you Sure your "prices.txt" contains market_hash_name?
I don't see any other issue yet, operationg on the data you have provided in comment, I got print of variable $assetDescription. Please doublecheck variable $prices.

ErrorException (E_NOTICE) Trying to get property 'sentimen' of non-object [duplicate]

This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 3 years ago.
Help, I get an error message ErrorException (E_NOTICE) Trying to get property 'sentimen' of non-object
public function prediksi()
{
$collection = array();
$title = "Data Prediksi Sentimen";
$testing_data = DataTesting::count();
$klasifikasi = DataTesting::with(['data_crawling','klasifikasi'])->get();
foreach($klasifikasi as $class){
$prediksi = Klasifikasi::with(['sentimen'])->where('id_testing',$class->id_testing)->first();
$hasil = Hasil::where('id_testing',$class->id_testing)->get();
$aktual = Sentimen::where('id_sentimen', $class->data_crawling->id_sentimen)->first();
$collection[] = [
'id_testing' => $class->id_testing,
'username' => $class->data_crawling->username,
'tweet' => $class->data_crawling->tweet,
'kategori' => $aktual->kategori,
'prediksi' => $prediksi->sentimen->kategori,
];
}
return view('visualisasi.prediksi', compact(['title','collection','testing_data','hasil']));
}
View Code
Think if your queries and relationship is correct then use like below with IF() conditions
public function prediksi()
{
$collection = array();
$title = "Data Prediksi Sentimen";
$testing_data = DataTesting::count();
$klasifikasi = DataTesting::with(['data_crawling','klasifikasi'])->get();
foreach($klasifikasi as $class){
$prediksi = Klasifikasi::with(['sentimen'])->where('id_testing',$class->id_testing)->first();
$hasil = Hasil::where('id_testing',$class->id_testing)->get();
$aktual = Sentimen::where('id_sentimen', $class->data_crawling->id_sentimen)->first();
if($prediksi && isset($prediksi->sentimen)){
$collection[] = [
'id_testing' => $class->id_testing,
'username' => $class->data_crawling->username,
'tweet' => $class->data_crawling->tweet,
'kategori' => $aktual->kategori,
'prediksi' => $prediksi->sentimen->kategori,
];
}
}
return view('visualisasi.prediksi', compact(['title','collection','testing_data','hasil']));
}
UPDATED
public function prediksi()
{
$collection = array();
$title = "Data Prediksi Sentimen";
$testing_data = DataTesting::count();
$klasifikasi = DataTesting::with(['data_crawling','klasifikasi'])->get();
foreach($klasifikasi as $class){
$prediksi = Klasifikasi::with(['sentimen'])->where('id_testing',$class->id_testing)->first();
$hasil = Hasil::where('id_testing',$class->id_testing)->get();
$aktual = Sentimen::where('id_sentimen', $class->data_crawling->id_sentimen)->first();
if($prediksi && isset($prediksi->sentimen)){
$collection[] = [
'id_testing' => $class->id_testing,
'username' => $class->data_crawling->username,
'tweet' => $class->data_crawling->tweet,
'kategori' => $aktual->kategori,
'prediksi' => $prediksi->sentimen->kategori,
];
$hasil_data[$class->id_testing][] = $hasil;
}
}
return view('visualisasi.prediksi', compact(['title','collection','testing_data','hasil_data']));
}
then in your view when you foreach you collection data
foreach($collection as $key){
//to use hasil data
foreach($hasil_data[$key['id_testing']] as $hasil){
dd($hasil);
}
}

getting multiple customer details In codeigniter

i have written this code to receive data from the Android device. it was inserted just one customer data I need to receive multiple customer details if app goes offline. but it was inserting one data into DB in offline mode also.how can i change this for multiple customer data insertions.
function index_post($customerID = false) {
if ($customerID) {
//update the record
$updateData = array();
$allowedparams = array('streetid' => 'streetid', 'name' => 'name', 'mobile' => 'mobile', 'adhaar' => 'adhaar', 'profession' => 'profession', 'address' => 'address', 'pincode' => 'pincode', 'nearby' => 'nearby', 'paddress' => 'paddress', 'isOwned' => 'isOwned');
foreach ($allowedparams as $k => $v) {
if (!$this->IsNullOrEmptyString($this->post($k, true))) {
$updateData[$v] = $this->post($k, true);
}
}
if ($this->model_customer->update($customerID, $updateData)) {
$data = array('status' => true, 'messsage' => 'cusotmer updated succesfully');
$http_code = REST_Controller::HTTP_OK;
} else {
$data = array('status' => false, 'messsage' => 'cusotmer failed to update.');
$http_code = REST_Controller::HTTP_INTERNAL_SERVER_ERROR;
}
} else {
//insert the record
$allowedparams = array('streetid' => 'streetid', 'name' => 'name', 'mobile' => 'mobile', 'adhaar' => 'adhaar', 'profession' => 'profession', 'address' => 'address', 'pincode' => 'pincode', 'cycle' => 'cycle', 'nearby' => 'nearby', 'paddress' => 'paddress', 'isOwned' => 'isOwned');
$requiredParam = array('streetid', 'name', 'mobile', 'cycle');
$insertdata = array();
foreach ($allowedparams as $k => $v) {
if (in_array($k, $requiredParam)) {
//check if its not null
if ($this->post($k) == null || trim($this->post($k)) == '') {
$data = array('status' => false, 'message' => $k . ' parameter missing or empty');
$http_code = REST_Controller::HTTP_BAD_REQUEST;
break;
}
}
$insertData[$v] = $this->post($k, true);
}
if ($customerID = $this->model_customer->create($insertData)) {
$data['customerID'] = $this->_frameCustomer2($this->model_customer->get($customerID)); //you need to put
$http_code = REST_Controller::HTTP_OK;
} else {
$data = array('status' => false, 'message' => 'unable to create customer');
$http_code = REST_Controller::HTTP_INTERNAL_SERVER_ERROR;
}
}
$this->response($data, $http_code);
}
private function _frameCustomer2($c) { //get value from index_get
$data = array();
$data['id'] = $c->id;
$data['name'] = $c->name;
$data['street'] = array('id' => $c->streetid);
$data['creationDate'] = $c->creationdate;
$data['mobile'] = $c->mobile;
$data['adhaar'] = $c->adhaar;
$data['profession'] = $c->profession;
$data['isOwned'] = ($c->isOwned == 1) ? true : false;
$data['address'] = $c->address;
$data['pincode'] = $c->pincode;
$data['status'] = $c->status;
$data['cycle'] = $c->cycle;
$data['balance'] = $c->balance;
$data['creditAvailable'] = $c->creditbalance;
$data['nearby'] = $c->nearby;
$data['accountNumber'] = $c->accountnumber;
$data['permanentAddress'] = $c->paddress;
$data['lastVisit'] = $this->model_customer->lastVisit($c->id);
return $data;
}
and my part of model function is
function create($insertdata = array()) { //new customer insert
if ($this->db->insert('customer', $insertdata)) {
return $this->db->insert_id();
} else {
return false;
}
}
function update($customerID = 0, $updateData = array()) {
$this->db->where('id', $customerID);
if ($this->db->update('customer', $updateData) && $this->db->affected_rows() == 1) {
return true;
} else {
return false;
}
Instead of customer Id, you can ask the mobile developers to send data in the form of array. In both online and offline. In case of online there will be just one element in the request array.
function index_post() {
$request_data = $this->request->body;
foreach($request_data as $key => $value)
{
//Check if customer id is present
if(Customer present)
{
Update the record
} else {
Insert the record
}
}
}

Cannot use object of type as array

I'm trying to render my order in my page validation but when refresh my validation.html.twig i got this error:
Error: Cannot use object of type FLY\BookingsBundle\Entity\Address as
array
if (!isset($order['tva']['%'.$entity->getTva()->getValue()]))
but i don't see anything wrong in my controller:
bill
public function bill()
{
$em = $this->getDoctrine()->getManager();
$generator = $this->container->get('security.secure_random');
$session = $this->getRequest()->getSession();
$address = $session->get('address');
$cart = $session->get('cart');
$order = array();
$totalHT = 0;
$totalTTC = 0;
$order = $em->getRepository('FLYBookingsBundle:Address')->find($address['address']);
$entities = $em->getRepository('FLYBookingsBundle:Post')->findArray(array_keys($session->get('cart')));
foreach($entities as $entity)
{
$priceHT = ($entity->getPrice() * $cart[$entity->getId()]);
$priceTTC = ($entity->getPrice() * $cart[$entity->getId()] / $entity->getTva()->getMultiplicate());
$totalHT += $priceHT;
$totalTTC += $priceTTC;
if (!isset($order['tva']['%'.$entity->getTva()->getValue()]))
$order['tva']['%'.$entity->getTva()->getValue()] = round($priceTTC - $priceHT,2);
else
$order['tva']['%'.$entity->getTva()->getValue()] += round($priceTTC - $priceHT,2);
$order['entity'][$order->getId()] = array('reference' => $order->getName(),
'quantity' => $cart[$entity->getId()],
'priceHT' => round($entity->getPrice(),2),
'priceTTC' => round($entity->getPrice() / $entity->getTva()->getMultiplicate(),2));
}
$order['address'] = array('surname' => $address->getSurname(),
'name' => $address->getName(),
'phone' => $address->getPhone(),
'address' => $address->getAddress(),
'zipcode' => $address->getZipcode(),
'city' => $address->getCity(),
'country' => $address->getCountry(),
'complement' => $address->getComplement());
$order['priceHT'] = round($totalHT,2);
$order['priceTTC'] = round($totalTTC,2);
$order['token'] = bin2hex($generator->nextBytes(20));
return $order;
}
ValidationAction
public function validationAction()
{
if ($this->get('request')->getMethod() == 'POST')
$this->setAddressOnSession();
$em = $this->getDoctrine()->getManager();
$prepareOrder = $this->forward('FLYBookingsBundle:Post:prepareOrder');
$order = $em->getRepository('FLYBookingsBundle:Address')->find($prepareOrder->getContent() );
return $this->render('FLYBookingsBundle:Post:validation.html.twig', array('order' => $order));
}
You are assigning Address object to the $order variable by $order = $em->getRepository('FLYBookingsBundle:Address')->find($address['address']); and then you want to use it as an array here $order['tva']..... and further down in your code. You have to work with $order by its methods/properties like $order->getTVA().

Save as PDF in portrait orientation using Yii pdfGrid extension

Good Afternoon
I am using the pdfGrid extension in Yii in which i am using the class EPDFGrid..
I am really confused on how to make the orientation in PORTRAIT mode. currently the rendered PDF file is in Landscape.. i tried changing this line public $orientation = 'L'; to 'P' but it did nothing..
i followed it here..
http://www.yiiframework.com/extension/pdf-grid/
is there an option in config that dictates the orientation into PORTRAIT.?
can anybody help me..
this is the code in my EPDFGrid.php
<?php
Yii::import('zii.widgets.grid.CDataColumn');
Yii::import('ext.pdfGrid.fpdf.PDF');
class EPDFGrid extends CWidget {
private $_debug = false;
protected $_pdf;
protected $_fill = false;
protected $_columnWidths = array();
protected $_visibleColumns = 0;
public $dataProvider;
public $fileName;
public $config = array();
public $columns = array();
public $labels = array();
public $orientation = 'L';
public $showTableOnEmpty = true;
public $nullDisplay = ' ';
public $emptyText;
public $hideHeader = false;
public function init() {
if ($this->columns === array()) {
if ($this->dataProvider instanceof CActiveDataProvider)
$this->columns = $this->dataProvider->model->attributeNames();
else if ($this->dataProvider instanceof IDataProvider) {
// use the keys of the first row of data as the default columns
$data = $this->dataProvider->getData();
if (isset($data[0]) && is_array($data[0]))
$this->columns = array_keys($data[0]);
}
}
$id = $this->getId();
foreach ($this->columns as $i => $column) {
if (is_string($column))
$column = $this->createDataColumn($column);
else {
if (!isset($column['class']))
$column['class'] = 'CDataColumn';
$column = Yii::createComponent($column, $this);
}
if (!$column->visible) {
unset($this->columns[$i]);
continue;
}
$this->_visibleColumns++;
if ($column->id === null)
$column->id = $id . '_c' . $i;
$this->columns[$i] = $column;
}
$default = array(
'pdfSize' => 'A4',
'title' => '',
'subTitle' => '',
'headTitle' => '',
'amount' => '',
'tableWidth' => 275,
'rowHeight' => 6,
'colAligns' => null,
'colWidths' => null,
'showLogo' => false,
'imagePath' => YiiBase::getPathOfAlias('webroot') . '/images/logo.jpg',
'headerDetails' => false,
);
$this->config = array_merge($default, $this->config);
$this->_pdf = new PDF('L', 'mm', $this->config['pdfSize']);
$this->_pdf->title = $this->config['title'];
$this->_pdf->subTitle = $this->config['subTitle'];
$this->_pdf->headTitle = $this->config['headTitle'];
$this->_pdf->amount = $this->config['amount'];
$this->_pdf->tableWidth = $this->config['tableWidth'];
$this->_pdf->rowHeight = $this->config['rowHeight'];
$this->_pdf->imagePath = $this->config['imagePath'];
$this->_pdf->showLogo = $this->config['showLogo'];
$this->_pdf->headerDetails = $this->config['headerDetails'];
$this->_pdf->SetAligns($this->config['colAligns']);
$this->_pdf->SetFont('Arial', 'B', 10);
$this->_pdf->SetLineWidth(0.5);
$this->_columnWidths = $this->_calcWidths();
$this->_pdf->SetWidths($this->_columnWidths);
$this->_pdf->AliasNbPages();
$this->_pdf->AddPage();
foreach ($this->columns as $column)
$column->init();
$this->renderItems();
}
protected function createDataColumn($text) {
if (!preg_match('/^([\w\.]+)(:(\w*))?(:(.*))?$/', $text, $matches))
throw new CException(Yii::t('zii', 'The column must be specified in the format of "Name:Type:Label",
where "Type" and "Label" are optional.'));
$column = new CDataColumn($this);
$column->name = $matches[1];
if (isset($matches[3]) && $matches[3] !== '')
$column->type = $matches[3];
if (isset($matches[5]))
$column->header = $matches[5];
return $column;
}
protected function renderItems() {
if ($this->dataProvider->getItemCount() > 0 || $this->showTableOnEmpty) {
$this->renderTableHeader();
$this->renderTableBody();
}
else
$this->_renderEmptyText();
if ($this->_debug)
Yii::app()->end();
else {
// $this->_pdf->Output($this->fileName . ' (' . date('Y-m-d') . ').pdf', 'D');
$this->_pdf->Output($this->fileName . '.pdf', 'D');
exit();
}
}
protected function renderTableHeader() {
if (!$this->hideHeader) {
// Colores y fuente en negrita
$this->_pdf->SetFillColor(245, 185, 120);
$this->_pdf->SetTextColor(0);
$this->_pdf->SetBold();
$rowHeader = array();
if ($this->labels != array()) {
$rowHeader = $this->labels;
} else {
foreach ($this->columns as $i => $column) {
if ($column->name == 'Id') {
$rowHeader[] = strtoupper($column->name);
} else {
$rowHeader[] = $column->name;
}
// $rowHeader[] = $column->grid->dataProvider->model->getAttributeLabel($column->name);
//$this->_pdf->Cell($this->_columnWidths[$i],$this->headerHeight,$data,0,0,'C',true);
}
}
$this->_pdf->Row($rowHeader, array('fill' => true, 'header' => true));
}
}
protected function renderTableBody() {
$data = $this->dataProvider->getData();
$n = count($data);
// Restauraci�n de colores y fuentes
$this->_pdf->SetFillColor(255, 242, 208);
$this->_pdf->SetTextColor(0);
$this->_pdf->SetFont('');
if ($n > 0) {
for ($row = 0; $row < $n; ++$row)
$this->renderTableRow($row);
}
else
$this->_renderEmptyText();
}
protected function renderTableRow($row) {
//var_dump($this->dataProvider);
$rowData = array();
foreach ($this->columns as $i => $column) {
$data = $this->dataProvider->data[$row];
if ($column->value !== null)
$value = $column->evaluateExpression($column->value, array('data' => $data, 'row' => $row));
else if ($column->name !== null)
$value = CHtml::value($data, $column->name);
// $rowData[] = $value===null ? $this->nullDisplay : $this->_formatString($value);
$rowData[] = $value === null ? $this->nullDisplay : utf8_decode($value);
}
$this->_pdf->Row($rowData, array('fill' => $this->_fill));
$this->_fill = !$this->_fill;
}
protected function _renderEmptyText() {
$emptyText = $this->emptyText === null ? Yii::t('zii', 'No results found.') : $this->emptyText;
$this->_pdf->Cell(array_sum($this->_columnWidths), $this->config['rowHeight'], $emptyText, 0, 0, 'L');
}
protected function _calcWidths() {
$widths = array();
$params = $this->config['colWidths'];
$visibleCols = $this->_visibleColumns;
if (!$params) {
$w = $this->_pdf->tableWidth / $visibleCols;
for ($i = 0; $i < $visibleCols; $i++)
$widths[] = $w;
} else if (is_array($params)) {
if (count($params) > $visibleCols)
throw new Exception('La cantidad de parametros supera a las columnas visibles');
if (array_sum($params) > $this->_pdf->tableWidth)
throw new Exception('La suma de los parametros supera a la longitud max de la tabla');
$nulls = 0;
$confWidth = 0;
for ($i = 0; $i < $visibleCols; $i++) {
if (empty($params[$i]))
$nulls++;
else
$confWidth += $params[$i];
}
$w = $nulls ? ($this->_pdf->tableWidth - $confWidth) / $nulls : 0;
for ($i = 0; $i < $visibleCols; $i++) {
$widths[] = empty($params[$i]) ? $w : $params[$i];
}
}
else
throw new Exception('El parametro $config[widths] debe ser un array');
return $widths;
}
protected function _formatString($string) {
$string = strtolower(utf8_decode($string));
return ucwords($string);
}
protected function _combineColumns($print = '', $config = array()) {
$default = array(
'from' => 0,
'to' => $this->_visibleColumns - 1,
'border' => 0,
'align' => 'L',
'fill' => $this->_fill,
'ln' => 1,
);
$config = array_merge($default, $config);
$b = $this->$config['border'];
$a = $this->$config['align'];
$f = $this->$config['fill'];
$ln = $this->$config['ln'];
$w = 0;
for ($i = $this->$config['from']; $i <= $this->$config['to']; $i++) {
$w += $this->_columnWidths[$i];
}
$this->_pdf->Cell($w, $this->config['rowHeight'], $print, $b, $ln, $a, $f);
if ($f)
$this->_fill = !$this->_fill;
}
}
this is the generated pdf file.
<?php
$data_provider = $model->viewEmployees($search, $from, $to);
$data_provider->pagination = false;
$this->widget('ext.pdfGrid.EPDFGrid', array(
'id' => 'employee-pdf',
'fileName' => 'Employees',
'dataProvider' => $model->viewEmployees($search, $from, $to),
'columns' => array(
array('name' => 'ID Number','value' => '$data->company_id', 'htmlOptions'=>array('width'=>'10%'),),
array('name' => 'Name', 'header' => 'Name', 'value' => '$data->getNameWithMiddleInitial()', 'htmlOptions' => array('width'=>'10%')),
array('name' => 'Date Employed', 'value' => '$data->date_employed' ,'htmlOptions'=>array('width'=>'10%')),
),
'config' => array(
'title' => 'Sprasia Philippines Information Management System',
'subTitle' => 'List of Employees',
'headerDetails' => true,
'showLogo' => true,
'colAligns' => array('C', 'C', 'C'),
),
));
?>
please help..
so silly of me..
i have found it. in this line..
$this->_pdf->AddPage();
i indicated P for portrait.. in which i have solved it by using this
$this->_pdf->AddPage('P');

Categories