public function actionDownload()
 {
     parent::actionDownload();
     $pdf = new PDF();
     $pdf->title = 'Material Stock Overview List';
     $pdf->AddPage('L');
     $pdf->setFont('Arial', 'B', 12);
     // definisi font
     $pdf->setFont('Arial', 'B', 8);
     // menuliskan tabel
     $header = array('No', 'ID', 'Material Name', 'Sloc', 'Qty', 'UOM', 'Prod Trans Type', 'Ref Source');
     $model = new Productstock('search');
     $dataprovider = $model->search();
     $dataprovider->pagination = false;
     $data = $dataprovider->getData();
     $cols = $dataprovider->getKeys();
     $dataku = array(count($data));
     //var_dump($dataku);
     $w = array(10, 15, 70, 30, 30, 30, 40, 30);
     $pdf->SetTableHeader();
     //Header
     for ($i = 0; $i < count($header); $i++) {
         $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C', true);
     }
     $pdf->Ln();
     $pdf->SetTableData();
     //Data
     $fill = false;
     $i = 0;
     foreach ($data as $datas) {
         $i = $i + 1;
         $pdf->Cell($w[0], 6, $i, 'LR', 0, 'L', $fill);
         $pdf->Cell($w[1], 6, $datas['productstockid'], 'LR', 0, 'L', $fill);
         $pdf->Cell($w[2], 6, Product::model()->findbypk($datas['productid'])->productname, 'LR', 0, 'L', $fill);
         $pdf->Cell($w[3], 6, Sloc::model()->findbypk($datas['slocid'])->sloccode, 'LR', 0, 'L', $fill);
         $pdf->Cell($w[4], 6, $datas['qty'], 'LR', 0, 'L', $fill);
         $pdf->Cell($w[5], 6, Unitofmeasure::model()->findbypk($datas['unitofmeasureid'])->uomcode, 'LR', 0, 'L', $fill);
         $pdf->Cell($w[6], 6, Prodtranstype::model()->findbypk($datas['prodtranstypeid'])->description, 'LR', 0, 'L', $fill);
         $pdf->Cell($w[7], 6, $datas['refsource'], 'LR', 0, 'L', $fill);
         $pdf->Ln();
         $fill = !$fill;
     }
     $pdf->Cell(array_sum($w), 0, '', 'T');
     // me-render ke browser
     $pdf->Output('productstock.pdf', 'D');
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Sloc::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }