public function actionUpload()
 {
     parent::actionUpload();
     $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/';
     // folder for uploaded files
     $file = $folder . basename($_FILES['uploadfile']['name']);
     if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
         $row = 0;
         if (($handle = fopen($file, "r")) !== FALSE) {
             while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                 if ($row > 0) {
                     $model = Wfgroup::model()->findByPk((int) $data[0]);
                     if ($model === null) {
                         $model = new Wfgroup();
                     }
                     $model->wfgroupid = (int) $data[0];
                     $workflow = Workflow::model()->findbyattributes(array('wfname' => $data[1]));
                     if ($workflow !== null) {
                         $model->workflowid = $workflow->workflowid;
                     }
                     $groupaccess = Groupaccess::model()->findbyattributes(array('wfname' => $data[2]));
                     if ($groupaccess !== null) {
                         $model->groupaccessid = $groupaccess->groupaccessid;
                     }
                     $model->wfbefstat = $data[3];
                     $model->wfrecstat = $data[4];
                     $model->recordstatus = (int) $data[5];
                     try {
                         if (!$model->save()) {
                             $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]);
                         }
                     } catch (Exception $e) {
                         $this->messages = $this->messages . $e->getMessage();
                     }
                 }
                 $row++;
             }
         } else {
             $this->messages = $this->messages . ' memory or harddisk full';
         }
         fclose($handle);
     } else {
         $this->messages = $this->messages . ' check your directory permission';
     }
     if ($this->messages == '') {
         $this->messages = 'success';
     }
     echo $this->messages;
 }