Last active
September 29, 2016 12:25
-
-
Save nadeem14375/ccce3a20b3e4e24a1113cef50c1c103e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* *********************** Controller ************************** */ | |
<?PHP | |
class StuClassController extends RController | |
{ | |
public $layout='//layouts/main'; | |
public function filters() | |
{ | |
return array( | |
'rights', | |
); | |
} | |
public function actionAdd() | |
{ | |
self::setClasses(null); | |
} | |
public function actionUpdate($id) | |
{ | |
self::setClasses($id); | |
} | |
public function setClasses($id) | |
{ | |
if($id==null): | |
$model = new StuClass(); | |
else: | |
$model = StuClass::model()->findbypk($id); | |
endif; | |
if(isset($_POST['ajax']) && $_POST['ajax']==='class_form'){ | |
echo CActiveForm::validate($model); | |
Yii::app()->end(); | |
} | |
if(isset($_POST['StuClass']) && sizeof($_POST['StuClass'])){ | |
$model->attributes = $_POST['StuClass']; | |
$model->save(FALSE); | |
Yii::app()->user->setFlash('confirm','Successfully saved'); | |
} | |
$this->render('class_form',array('model'=>$model)); | |
} | |
public function actionManage(){ | |
$model = new StuClass('search'); | |
$this->render('manage_classes',array('model'=>$model)); | |
} | |
} | |
?> | |
/* ******************* view ********************* */ | |
<div class="ibox"> | |
<div class="ibox-heading"> | |
<div class="ibox-title"> | |
<h3><?PHP echo(($model->isNewRecord) ? 'Create Classes' : 'Update Classes'); ?></h3> | |
</div> | |
</div> | |
<!-- /.box-header --> | |
<!-- form start --> | |
<?php | |
$form = $this->beginWidget('CActiveForm', array( | |
'id' => 'class_form', | |
'enableAjaxValidation' => true, | |
'htmlOptions' => array( | |
'enctype' => 'multipart/form-data', | |
'role' => 'form' | |
), | |
'clientOptions' => array( | |
'validateOnSubmit' => true, | |
'validateOnChange' => true, | |
'validateOnType' => false, | |
), | |
)); ?> | |
<div class="ibox-content"> | |
<div class="row"> | |
<div class="col-md-6 col-xs-12"> | |
<div class="form-group"> | |
<?PHP | |
echo $form->label($model, 'class_name'); | |
echo $form->textField($model, 'class_name', array('placeholder' => 'Class Name', 'class' => 'form-control')); | |
echo $form->error($model,'class_name'); | |
?> | |
</div> | |
<div class="form-group"> | |
<?PHP | |
echo $form->label($model, 'class_abb'); | |
echo $form->textField($model, 'class_abb', array('placeholder' => 'abbreviation', 'class' => 'form-control')); | |
echo $form->error($model,'class_abb'); | |
?> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="ibox-footer col-md-12 col-xs-12"> | |
<button class="btn col-md-3 col-xs-12 btn-primary pull-left" type="submit"> | |
<?PHP echo Definations::SAVEFORM; ?> | |
</button> | |
</div> | |
<?PHP | |
echo Yii::app()->user->getFlash('success'); | |
$this->endWidget(); | |
?> | |
</div> | |
/* **************************** Controller ********************* */ | |
<?PHP | |
class FeeStructureController extends RController | |
{ | |
public $layout='//layouts/main'; | |
public function actionAdd() | |
{ | |
self::setFeeStructure(null); | |
} | |
public function actionUpdate($id) | |
{ | |
self::setFeeStructure($id); | |
} | |
public function setFeeStructure($id) | |
{ | |
if($id==null): | |
$model = new FeeStructure(); | |
else: | |
$model = FeeStructure::model()->findbypk($id); | |
endif; | |
$studentClasses =StuClass::getClasses(); | |
$feeTypes = FeeType::getFeeType(); | |
if(isset($_POST['ajax']) && $_POST['ajax']==='Fee_Structure_form'){ | |
echo CActiveForm::validate($model); | |
Yii::app()->end(); | |
} | |
if(isset($_POST['FeeStructure']) && sizeof($_POST['FeeStructure'])){ | |
$model->attributes = $_POST['FeeStructure']; | |
$model->save(FALSE); | |
Yii::app()->user->setFlash('confirm','Successfully saved'); | |
} | |
$this->render('Fee_Structure_form',array('model'=>$model,'studentClasses'=>$studentClasses,'feeTypes'=>$feeTypes)); | |
} | |
public function actionManage(){ | |
$model = new FeeStructure('search'); | |
$studentClasses =StuClass::getClasses(); | |
$feeTypes = FeeType::getFeeType(); | |
$this->render('manage_Fee_Structure',array('model'=>$model,'studentClasses'=>$studentClasses,'feeTypes'=>$feeTypes)); | |
} | |
} | |
?> | |
/* ********************** View ******************** */ | |
<div class="ibox"> | |
<div class="ibox-heading"> | |
<div class="ibox-title"> | |
<h3><?PHP echo(($model->isNewRecord) ? 'Create Fee Structure' : 'Update Fee Structure'); ?></h3> | |
</div> | |
</div> | |
<!-- /.box-header --> | |
<!-- form start --> | |
<?php | |
$form = $this->beginWidget('CActiveForm', array( | |
'id' => 'fee_structure_form', | |
'enableAjaxValidation' => true, | |
'htmlOptions' => array( | |
'enctype' => 'multipart/form-data', | |
'role' => 'form' | |
), | |
'clientOptions' => array( | |
'validateOnSubmit' => true, | |
'validateOnChange' => true, | |
'validateOnType' => false, | |
), | |
)); ?> | |
<div class="ibox-content"> | |
<div class="row"> | |
<div class="col-md-6 col-xs-12"> | |
<div class="form-group"> | |
<?PHP | |
echo $form->label($model, 'class_id'); | |
echo $form->dropDownList($model, 'class_id', $studentClasses,array('placeholder' => 'Class', 'class' => 'form-control')); | |
echo $form->error($model,'class_id'); | |
?> | |
</div> | |
<div class="form-group"> | |
<?PHP | |
echo $form->label($model, 'fee_type'); | |
echo $form->dropDownList($model, 'fee_type', $feeTypes, array('placeholder' => 'Fee Type', 'class' => 'form-control')); | |
echo $form->error($model,'fee_type'); | |
?> | |
</div> | |
<div class="form-group"> | |
<?PHP | |
echo $form->label($model, 'amount'); | |
echo $form->textField($model, 'amount', array('placeholder' => 'Amount', 'class' => 'form-control')); | |
echo $form->error($model,'amount'); | |
?> | |
</div> | |
<div class="form-group"> | |
<?PHP | |
echo $form->label($model, 'remarks'); | |
echo $form->textField($model, 'remarks', array('placeholder' => 'Remarks', 'class' => 'form-control')); | |
echo $form->error($model,'remarks'); | |
?> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="ibox-footer col-md-12 col-xs-12" style="margin-bottom: 60px;"> | |
<button class="btn col-md-3 col-xs-12 btn-primary pull-left" type="submit"> | |
<?PHP echo Definations::SAVEFORM; ?> | |
</button> | |
</div> | |
<?PHP | |
$this->endWidget(); | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment