예제 #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new InOutData();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['InOutData'])) {
         $model->attributes = $_POST['InOutData'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id_data));
         }
     }
     $this->render('create', array('model' => $model));
 }
예제 #2
0
 public function actionImport($path)
 {
     Yii::import('ext.phpexcelreader.JPhpExcelReader');
     $data = new JPhpExcelReader($path);
     for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
         $model = new InOutData();
         for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
             if ($j == 1) {
                 if (isset($data->sheets[0]['cells'][$i][$j])) {
                     $model->department = $data->sheets[0]['cells'][$i][$j];
                 } else {
                     $model->department = '';
                 }
             }
             if ($j == 2) {
                 if (isset($data->sheets[0]['cells'][$i][$j])) {
                     $model->nama = $data->sheets[0]['cells'][$i][$j];
                 } else {
                     $model->nama = '';
                 }
             }
             if ($j == 3) {
                 if (isset($data->sheets[0]['cells'][$i][$j])) {
                     $model->no = $data->sheets[0]['cells'][$i][$j];
                 } else {
                     $model->no = '';
                 }
             }
             if ($j == 4) {
                 if (isset($data->sheets[0]['cells'][$i][$j])) {
                     $model->date_time = $data->sheets[0]['cells'][$i][$j];
                 } else {
                     $model->date_time = '';
                 }
             }
             if ($j == 5) {
                 if (isset($data->sheets[0]['cells'][$i][$j])) {
                     $model->status = $data->sheets[0]['cells'][$i][$j];
                 } else {
                     $model->status = '';
                 }
             }
             if ($j == 6) {
                 if (isset($data->sheets[0]['cells'][$i][$j])) {
                     $model->location_id = $data->sheets[0]['cells'][$i][$j];
                 } else {
                     $model->location_id = '';
                 }
             }
             if ($j == 7) {
                 if (isset($data->sheets[0]['cells'][$i][$j])) {
                     $model->id_number = $data->sheets[0]['cells'][$i][$j];
                 } else {
                     $model->id_number = '';
                 }
             }
             if ($j == 8) {
                 if (isset($data->sheets[0]['cells'][$i][$j])) {
                     $model->verify_code = $data->sheets[0]['cells'][$i][$j];
                 } else {
                     $model->verify_code = '';
                 }
             }
             if ($j == 9) {
                 if (isset($data->sheets[0]['cells'][$i][$j])) {
                     $model->no_kartu = $data->sheets[0]['cells'][$i][$j];
                 } else {
                     $model->no_kartu = '';
                 }
             }
         }
         $model->save();
     }
     $this->redirect(array('inoutdata/admin'));
 }