コード例 #1
0
 public function actionAdmin2()
 {
     $model = new Consumable('search');
     $stockname = Stockname::model()->findByAttributes(array('commodity_id' => 3));
     $model->prefix = $stockname['prefix'];
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Consumable'])) {
         $model->attributes = $_GET['Consumable'];
     }
     $this->render('admin2', array('model' => $model));
 }
コード例 #2
0
 public static function getItemBarcode($valueArray)
 {
     $barcodeDetailsRow = Barcodedetail::model()->find('organisation_id=:organisation_id', array('organisation_id' => Yii::app()->user->getState("org_id")));
     if (isset($valueArray['commodity_id'])) {
         $stockname = Stockname::model()->findByAttributes(array('commodity_id' => $valueArray['commodity_id']));
         $prefix = $stockname['prefix'];
     } else {
         $prefix = '';
     }
     $optionsArray = array('elementId' => $valueArray['itemId'] . "_bcode", 'value' => $prefix . '/' . $valueArray['barcode'], 'type' => $barcodeDetailsRow['type'], 'settings' => array('output' => $barcodeDetailsRow['format'], 'barWidth' => $barcodeDetailsRow['bar_width'], 'barHeight' => $barcodeDetailsRow['bar_height']));
     self::getBarcode($optionsArray);
     return CHtml::tag('div', array('id' => $valueArray['itemId'] . "_bcode"));
 }
コード例 #3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Consumablestock();
     //$allocate = new Allocate;
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     /*Executed when you have data SUBMITTED*/
     if (isset($_POST['Consumablestock'])) {
         $model->attributes = $_POST['Consumablestock'];
         $model->commodity_id = $_GET['commodity_id'];
         if (!empty($_FILES['Consumablestock']['tmp_name']['document'])) {
             $file = CUploadedFile::getInstance($model, 'document');
             $model->documentFileName = $file->name;
             $model->documentFileType = $file->type;
             $fp = fopen($file->tempName, 'r');
             $content = fread($fp, filesize($file->tempName));
             fclose($fp);
             $model->document = $content;
         }
         if ($model->save()) {
             $stocknameRow = Stockname::model()->findByAttributes(array('commodity_id' => $model->commodity_id));
             /***********Change dynamically**/
             $consumable = Consumable::model()->findByAttributes(array('id' => $model->consumable_id));
             for ($i = 1; $i <= $model->quantity; $i++) {
                 $allocate = new Allocate();
                 $allocate->commodity_id = $model->commodity_id;
                 $allocate->cons_id = $model->consumable_id;
                 $allocate->id = $i;
                 $allocate->stock_id = $model->id;
                 $allocate->date_in = $model->date_in;
                 $allocate->stockname = $stocknameRow['prefix'] . $consumable['name'] . '/' . $allocate->id;
                 $allocate->barcode = Common::getItemBarcode(array("itemId" => $allocate->allocate_id, "barcode" => $allocate->stockname));
                 $allocate->save();
                 //print_r($allocate->getErrors());die;
             }
             //Yii::app()->request->redirect('http://localhost/asset_management/index.php/consumable/admin');
             //Yii::app()->request->redirect('Yii::app()->request->returnUrl');
             //Yii::app()->request->return;
             echo "<script type='text/javascript'>self.history.go(-2);</script>";
         }
     }
     /*Executed when you want to create*/
     $this->render('create', array('model' => $model));
 }
コード例 #4
0
 public function actionGeneratePdf()
 {
     $this->layout = 'pdf';
     $model = new Stockname('search');
     if (isset($_GET['Stockname'])) {
         $model->attributes = $_GET['Stockname'];
     }
     // to execute the filters (if is the case)
     $dataProvider = $model->search();
     $dataProvider->pagination = false;
     $mPDF1 = Yii::app()->ePdf->mpdf();
     # You can easily override default constructor's params
     $mPDF1 = Yii::app()->ePdf->mpdf('', 'A5');
     # renderPartial (only 'view' of current controller)
     $mPDF1->WriteHTML($this->renderPartial('admin', array('model' => $model), true));
     # Outputs ready PDF
     $mPDF1->Output();
 }