/**
  * 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 $id the ID of the model to be loaded
  * @return PdfContentFranchise the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = PdfContentFranchise::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function actionSendPdf1st($id)
 {
     $cusUser = Customer::model()->findByPk($id);
     if (!$cusUser) {
         throw new CHttpException(403, 'Customer not exists');
     }
     $pdf_content = PdfContentFranchise::model()->findByAttributes(array('cus_id' => $id, 'isactive' => 1, 'type' => 1));
     if (!$pdf_content) {
         $pdf_content = PdfContent::model()->findByAttributes(array('type' => 1));
     }
     $franchise_admin = User::model()->find(" franchise = " . $cusUser->franchise . " and role_id=3");
     $params = array();
     $params['lunchMenu'] = $cusUser->lunches;
     $params['breakfasts'] = $cusUser->breakfasts;
     $params['indusFoods'] = $cusUser->indusFoods;
     $params['sundries'] = $cusUser->sundries;
     $params['sandwiches'] = $cusUser->sandwiches;
     $params['hotfood'] = $cusUser->hotFoods;
     $params['magicSpools'] = $cusUser->magicSpools;
     $params['christmas'] = $cusUser->christmas;
     $params['selected_category'] = SelectedCategories::model()->findAll(array('condition' => "user_id = {$id}"));
     $selProd = SelProducts::model()->findAll(array("condition" => "cus_id =" . $id, "order" => 'product_id asc'));
     $params['selproducts'] = array();
     foreach ($selProd as $selp) {
         $product = Product::model()->findByPk($selp->product_id);
         if ($product) {
             $params['selproducts'][] = array_merge($product->attributes, $selp->attributes);
         }
     }
     $this->layout = '//decorators/empty';
     $html2pdf = Yii::app()->ePdf->HTML2PDF();
     ///////////////////////////////////// menu container started
     $container = array();
     foreach ($params as $param) {
         foreach ($param as $p) {
             $container[] = $p;
         }
     }
     $div_array = array_chunk($container, 200);
     $showTitle = 1;
     foreach ($div_array as $array) {
         $html2pdf->WriteHTML($this->render('//decorators/pdf1st', array('params' => $array, 'cusUser' => $cusUser, 'showTitle' => $showTitle, 'franchise_admin' => $franchise_admin, 'test' => 1, 'pdf_content' => $pdf_content), true));
         $showTitle = 0;
     }
     //        $html2pdf->Output(dirname(__FILE__) . '/../../pdf/test_xxxx.pdf', 'F');
     $html2pdf->Output();
 }