<h3>Add Warehouse</h3>

<?php echo CHtml::beginForm('', 'post', array('id'=>'warehouse-form')); ?>

<?php echo CHtml::hiddenField('MasWarehouse[id]', $model->id); ?>

<div>
<label>Warehouse Name</label><br>

<?php echo CHtml::textField(
'MasWarehouse[warehouse_name]',
$model->warehouse_name,
array('class'=>'form-control','required'=>true)
); ?>

</div>

<br>

<div>

<label>Base Warehouse</label><br>

<?php echo CHtml::dropDownList(
'MasWarehouse[is_base_warehouse]',
$model->is_base_warehouse,
array(
'Y'=>'Yes',
'N'=>'No'
),
array('class'=>'form-control')
); ?>

</div>

<br><br>

<button type="button" class="btn btn-primary" id="saveWarehouse">Save</button>

<?php echo CHtml::endForm(); ?>


<script>

$("#saveWarehouse").click(function(){

$.ajax({

url:'<?php echo Yii::app()->createUrl("MasWarehouse/create"); ?>',

type:'POST',

data:$("#warehouse-form").serialize(),

success:function(data){

var obj = JSON.parse(data);

if(obj.status=="success"){

t8.success("Warehouse Saved Successfully");

$(".close").click();

reloadTable("#tbl_Warehouse");

}else{

t8.error("Something went wrong");

}

}

});

});

</script>