コード例 #1
0
ファイル: view.php プロジェクト: mbeded/data-management
<h1>Deatil of Sewadars - <?php 
echo $model->sewadar_name;
?>
</h1>

<?php 
$this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('badge_no', 'old_badge_no', 'sewadar_name', 'father_dauther_son_wife_of', 'relation', array('name' => 'blood_group', 'value' => isset($model->bloodGroup->blood_group_name) ? $model->bloodGroup->blood_group_name . ' ' . $model->bloodGroup->blood_group_type : ''), array('name' => 'section', 'value' => isset($model->section0->section_name) ? $model->section0->section_name : ''), 'old_section', 'mobile_primary', 'mobile_secondary', 'gender', 'date_of_birth', 'age', 'address', 'area', 'date_of_initiation', 'qualification', 'profession', 'specialization', array('name' => 'sewardar_picture', 'type' => 'raw', 'value' => $model->sewardar_picture != "" ? CHtml::image(Yii::app()->request->baseUrl . "/attachments/sewadars_images/" . $model->sewardar_picture, $model->sewardar_picture, array("width" => 100, "height" => 100)) : CHtml::image(Yii::app()->request->baseUrl . "/attachments/sewadars_images/no-pic.png", "no image uploaded", array("width" => 100, "height" => 100))))));
$techDetail = SewadardTechnicalDetail::model()->find("sewadar_id='{$model->sewadar_id}'");
if ($techDetail != null) {
    ?>
<table class="detail-view table table-striped table-condensed">
    <tr>
        <td>Job Type</td>
        <td>
            <?php 
    if ($techDetail->job_type == 1) {
        echo 'Govt Job';
    } else {
        if ($techDetail->job_type == 2) {
            echo 'Pvt Job';
        } else {
            if ($techDetail->job_type == 3) {
                echo 'Business';
            }
        }
    }
    ?>
        </td>
    </tr>
    <tr>
        <td>Department Company</td>
コード例 #2
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $file_Path = Yii::getPathOfAlias('webroot.attachments.sewadars_images');
     $model = $this->loadModel($id);
     $old_pic = $model->sewardar_picture;
     if ($model->is_technical) {
         $technical = SewadardTechnicalDetail::model()->find('sewadar_id=:user_id', array(':user_id' => $model->sewadar_id));
     } else {
         $technical = new SewadardTechnicalDetail();
     }
     if ($technical === null) {
         $technical = new SewadardTechnicalDetail();
     }
     $basic = new basic();
     $age = $basic->getAgeRange();
     $area = $basic->getAreas();
     $sections = $basic->getSewadarSections();
     $bloodGroup = basic::getBloodGroup();
     // $this->performAjaxValidation($model);
     if (isset($_POST['Sewadars'])) {
         $model->attributes = $_POST['Sewadars'];
         $model->blood_group = $_POST['Sewadars']['blood_group'];
         if ($_FILES['Sewadars']['name']['sewardar_picture'] != '') {
             $model->sewardar_picture = CUploadedFile::getInstance($model, 'sewardar_picture');
             $ext = pathinfo($model->sewardar_picture, PATHINFO_EXTENSION);
             $SName = basic::removeSpace($model->sewadar_name);
             $FileName = $model->badge_no . '_' . $SName . '.' . $ext;
             $saved = $model->sewardar_picture->saveAs($file_Path . '/' . $FileName);
             $model->sewardar_picture = $FileName;
         } else {
             if ($old_pic == '') {
                 $saved = true;
                 $model->sewardar_picture = '';
             } else {
                 $saved = true;
                 $model->sewardar_picture = $old_pic;
             }
         }
         if ($_POST['Sewadars']['is_technical'] == 1) {
             $technical->attributes = $_POST['SewadardTechnicalDetail'];
             $technical->department_company = $_POST['SewadardTechnicalDetail']['department_company'];
             $technical->period_from = $_POST['SewadardTechnicalDetail']['period_from'];
             $technical->period_to = $_POST['SewadardTechnicalDetail']['period_to'];
             $technical->sewadar_id = $model->sewadar_id;
         }
         if ($model->date_of_birth == '') {
             $model->date_of_birth = date('Y-m-d', strtotime("-{$model->age} years"));
         }
         if ($model->age == '') {
             $datetime1 = new DateTime($model->date_of_birth);
             $datetime2 = new DateTime(date('Y-m-d'));
             $interval = $datetime1->diff($datetime2);
             $model->age = $interval->format('%y');
         }
         if ($model->validate()) {
             if ($model->save()) {
                 if ($saved) {
                     if ($_POST['Sewadars']['is_technical'] == 1) {
                         $technicalModel = SewadardTechnicalDetail::model()->findByPk($technical->detail_id);
                         $technicalModel->attributes = $_POST['SewadardTechnicalDetail'];
                         $technicalModel->department_company = $_POST['SewadardTechnicalDetail']['department_company'];
                         $technicalModel->period_from = $_POST['SewadardTechnicalDetail']['period_from'];
                         $technicalModel->period_to = $_POST['SewadardTechnicalDetail']['period_to'];
                         $technicalModel->sewadar_id = $model->sewadar_id;
                         $technicalModel->save();
                     }
                     Yii::app()->user->setFlash('success', 'Record Inserted Successfully.');
                 } else {
                     Yii::app()->user->setFlash('error', 'error while uploading file.');
                 }
             }
             $this->refresh();
         }
     }
     $this->render('update', array('model' => $model, 'technical' => $technical, 'age' => $age, 'area' => $area, 'sections' => $sections, 'bloodGroup' => $bloodGroup));
 }