<?php // $cs = Yii::app()->getClientScript();    ?>
<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'accessibleuser-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
        ));
?>
<div class="tab-content">
    <div class="tab-pane active">

        <ul class="clearfix form-ul material">

            <?php echo $form->hiddenField($model, 'id'); ?>

            <li class="col-sm-6">
                <?php
                $read_only = false;
                if ($model->id > 0 && $model->mis_accessible_branches!='') {
                    //$read_only = true;
                    $model->mis_accessible_branches=explode(',',$model->mis_accessible_branches);
                }
                echo $form->dropdownList($model, 'mis_accessible_branches', MasInventoryWarehouse::getWarehouses(), array('data-label' => 'MIS Accessible Branches <span style="color:red">*</span>', 'multiple'=>'true','data-validation' => 'required', 'data-search' => true, 'disabled' => $read_only));
               

               
               ?>
            </li>
         

        </ul>
    </div>

</div>
<div class="modal-footer">
    <button type="button" class="btn btn-danger" id="user_close" data-dismiss="modal">Close</button>
    <?php
    $url = Yii::app()->createUrl('users/SaveMisAccessibleBranches');
    echo CHtml::ajaxSubmitButton('Save', $url, array(
        'dataType' => 'json',
        'type' => 'post',
        'success' => 'function(data) {
                                    $("#loader").hide();
                                    if(data.status=="success"){
                                         t8.success("MIS Accessible Branches Saved Successfully!");
                                         $("#user_close").click();
                                        //location.reload();
                                        reloadTable("#tbl_user_details");
                                    } else {
                                        $("#accessibleuser-form .user-save-btn").prop("disabled", false);
                                        $("#accessibleuser-form .user-save-btn").addClass("btn-theme").removeClass("btn_loding");
                                        $.each(data, function(key, val) {
                                                $("#accessibleuser-form #"+key+"_em_").text(val).show();
                                                t8.error(""+val+"");
                                        });
                                    }
                            }',
        'beforeSend' => 'function(){
                                $("#loader").show();
                                $("#accessibleuser-form .user-save-btn").prop("disabled", true);
                                $("#accessibleuser-form .user-save-btn").addClass("btn_loding").removeClass("btn-theme");
                                $(".toast8-error").hide();
                            }',
        'complete' => 'function(){
                                $("#loader").hide();

                            }'
            ), array('id' => 'mybtn' . rand(), 'class' => 'user-save-btn btn btn-theme'));
    ?>
</div>
<?php $this->endWidget(); ?>
<?php
$cs = Yii::app()->getClientScript();
$cs->registerScript("getpassword", "function getpassword(value)
    {
        var user_password = $('#hid_password').val();
        $('#User_password').val('');
    }", CClientScript::POS_HEAD);
$cs->registerScript("setpassword", "function setpassword()
    {
        var user_password = $('#hid_password').val();
        var new_password = $('#User_password').val();
        if(new_password=='')
        {
            $('#User_password').val(user_password);
        }
    }", CClientScript::POS_HEAD);