/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new ReportTemplate();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ReportTemplate'])) {
         $model->attributes = $_POST['ReportTemplate'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 2
0
 public function actionChallanReport()
 {
     $model = new Challan('search');
     $table = $this::getTableNameFromModel($model);
     $colArr = $this::getColumnNames($table);
     //print_r($_GET);exit;
     if ($_GET['yt2'] == "Save" && !empty($_GET['Challan']['fields'])) {
         $template = new ReportTemplate();
         $template->on_table = "challan";
         $template->name = $_GET['Challan']['temp_name'];
         $template->fields = implode(",", $_GET['Challan']['fields']);
         $template->user_id = Yii::app()->User->Id;
         $template->created = date("Y-m-d H:i:s", time());
         if ($template->save()) {
             Yii::app()->user->setFlash('success1 message1', "Template successfully saved.");
             $this->render('challanReport', array('model' => $model, 'name' => $name));
         } else {
             Yii::app()->user->setFlash('error1 message1', "There was an error saving this template.");
         }
     } elseif ($_GET['yt2'] == "Save" && empty($_GET['Challan']['fields'])) {
         Yii::app()->user->setFlash('error1 message1', "Please select the report fields.");
     } elseif ($_GET['yt2'] == "Save" && empty($_GET['Challan']['temp_name'])) {
         Yii::app()->user->setFlash('error1 message1', "Please enter template name.");
     }
     if (!empty($_GET['Challan']['save_search']) && $_GET['Challan']['save_search'] != '') {
         $_SESSION['qs'][count($_SESSION['qs'])]['name'] = $_GET['Challan']['save_search'];
         $_SESSION['qs'][count($_SESSION['qs'])]['search'] = $_SERVER['QUERY_STRING'];
     }
     $name = array();
     foreach ($colArr as $i => $v) {
         $name[$v] = $model->getAttributeLabel($v);
     }
     if (isset($_GET['Challan'])) {
         $model->attributes = $_GET['Challan'];
     }
     //print_r($model);exit;
     $this->render('challanReport', array('model' => $model, 'name' => $name));
 }