/**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Orgstructure::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 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 = Jobs::model()->findByPk((int) $data[0]);
                     if ($model === null) {
                         $model = new Jobs();
                     }
                     $model->jobsid = (int) $data[0];
                     $structure = Orgstructure::model()->findbyattributes(array('structurename' => $data[1]));
                     if ($structure !== null) {
                         $model->orgstructureid = $structure->orgstructureid;
                     }
                     $position = Orgstructure::model()->findbyattributes(array('positionname' => $data[2]));
                     if ($position !== null) {
                         $model->positionid = $structure->positionid;
                     }
                     $model->jobdesc = $data[3];
                     $model->qualification = $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;
 }
<?php 
$this->widget('ToolbarButton', array('isSave' => true, 'UrlSave' => 'jobs/write', 'isCancel' => true, 'UrlCancel' => 'jobs/cancelwrite'));
?>
</div> 
<?php 
echo $form->hiddenField($model, 'jobsid');
?>
    <div class="row">
		<?php 
echo $form->labelEx($model, 'orgstructureid');
?>
    <?php 
echo $form->hiddenField($model, 'orgstructureid');
?>
    <input type="text" name="structurename" id="structurename" readonly value="<?php 
echo Orgstructure::model()->findByPk($model->orgstructureid) !== null ? Orgstructure::model()->findByPk($model->orgstructureid)->structurename : '';
?>
">
    <?php 
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'absstatus_dialog', 'options' => array('title' => Yii::t('app', 'Organization Structure'), 'width' => 'auto', 'autoOpen' => false, 'modal' => true)));
$this->widget('zii.widgets.grid.CGridView', array('id' => 'absstatus-grid', 'dataProvider' => $orgstructure->searchwstatus(), 'filter' => $orgstructure, 'template' => '{summary}{pager}<br>{items}{pager}{summary}', 'columns' => array(array('header' => '', 'type' => 'raw', 'value' => 'CHtml::Button("+",
          array("name" => "send_absstatus",
          "id" => "send_absstatus",
          "onClick" => "$(\\"#absstatus_dialog\\").dialog(\\"close\\"); $(\\"#structurename\\").val(\\"$data->structurename\\"); $(\\"#Jobs_orgstructureid\\").val(\\"$data->orgstructureid\\");"))'), array('name' => 'orgstructureid', 'visible' => false, 'value' => '$data->orgstructureid', 'htmlOptions' => array('width' => '1%')), 'structurename', array('class' => 'CCheckBoxColumn', 'name' => 'recordstatus', 'selectableRows' => '0', 'header' => 'Record Status', 'checked' => '$data->recordstatus'))));
$this->endWidget('zii.widgets.jui.CJuiDialog');
echo CHtml::Button('...', array('onclick' => '$("#absstatus_dialog").dialog("open"); return false;'));
?>
    <?php 
echo $form->error($model, 'orgstructureid');
?>
	</div>
?>
		</td>
		<td>
		<?php 
echo $form->labelEx($model, 'orgstructureid');
?>
    <?php 
echo $form->hiddenField($model, 'orgstructureid');
?>
    <input type="text" name="structurename" id="structurename" readonly style="width:75%" value="<?php 
echo Orgstructure::model()->findByPk($model->orgstructureid) !== null ? Orgstructure::model()->findByPk($model->orgstructureid)->structurename : '';
?>
">
    <?php 
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'orgstructure_dialog', 'options' => array('title' => Yii::t('app', 'Organization Structure'), 'width' => 'auto', 'autoOpen' => false, 'modal' => true)));
$orgstructure = new Orgstructure('searchwfstatus');
$orgstructure->unsetAttributes();
// clear any default values
if (isset($_GET['Orgstructure'])) {
    $orgstructure->attributes = $_GET['Orgstructure'];
}
$this->widget('zii.widgets.grid.CGridView', array('id' => 'orgstructure-grid', 'dataProvider' => $orgstructure->searchwstatus(), 'filter' => $orgstructure, 'template' => '{summary}{pager}<br>{items}{pager}{summary}', 'columns' => array(array('header' => '', 'type' => 'raw', 'value' => 'CHtml::Button("V",
          array("name" => "send_absstatus",
          "id" => "send_absstatus",
          "onClick" => "$(\\"#orgstructure_dialog\\").dialog(\\"close\\"); $(\\"#structurename\\").val(\\"$data->structurename\\"); 
		  $(\\"#Employee_orgstructureid\\").val(\\"$data->orgstructureid\\");"))'), array('name' => 'orgstructureid', 'visible' => false, 'value' => '$data->orgstructureid', 'htmlOptions' => array('width' => '1%')), 'structurename')));
$this->endWidget('zii.widgets.jui.CJuiDialog');
echo CHtml::Button('...', array('onclick' => '$("#orgstructure_dialog").dialog("open"); return false;'));
?>
    <?php 
echo $form->error($model, 'orgstructureid');