示例#1
0
?>

	<?php 
echo $form->textFieldRow($model, 'centre_name', array('class' => 'span5', 'maxlength' => 45));
?>

	<?php 
echo $form->textFieldRow($model, 'centre_secretary_name', array('class' => 'span5', 'maxlength' => 45));
?>

	<?php 
echo $form->textFieldRow($model, 'centre_secretary_mobile_number', array('class' => 'span5', 'maxlength' => 45));
?>

	<?php 
//echo $form->textFieldRow($model,'centre_code',array('class'=>'span5','maxlength'=>45));
?>

    <?php 
echo $form->dropDownListRow($model, 'area_id', CHtml::listData(basic::getAreas(), 'area_id', 'area_name'));
?>

	<div class="form-actions">
		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Save' : 'Update'));
?>
        <input type="button" name="cancel" class="btn btn-primary" value="Cancel" onclick="javascript:window.history.back()">
	</div>

<?php 
$this->endWidget();
示例#2
0
<div class="container">
<h2>Please Select Area Where You Want To Send Sewa</h2>

<div class="span-10">
    <?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'nominal-roll-form-register-area', 'enableAjaxValidation' => false));
?>
    <div class="form-data">
        <label for="SatsangCentre_centre_name" class="required">Area </label>
        <?php 
$area = CHtml::ListData(basic::getAreas(), 'area_id', 'area_name');
echo CHtml::dropDownList('area', '', $area, array('empty' => 'Select An Area'));
?>
    </div>
    <div class="form-data">
        <label for="SatsangCentre_centre_name" class="required">Centre</label>
        <?php 
$centre = CHtml::ListData(basic::getSatsangCentre(), 'centre_id', 'centre_name');
echo CHtml::dropDownList('centre', '', $centre, array('empty' => 'Select a Centre'));
?>
    </div>
    <div class="form-data submit">
        <?php 
echo CHtml::submitButton('submit');
?>
    </div>

<?php 
$this->endWidget();
?>
</div>
 /**
  * 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));
 }