<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'vendorcontact-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
        ));
?>
<ul class="clearfix form-ul material">
    <input type="hidden" name="hid_vendor_id" id="hid_vendor_id" value="<?php
    if (!empty($models->vendor_id)) {
        echo $models->vendor_id;
    } else {
        echo $c_id;
    }
    ?>">
    <li class="col-sm-6">
        <?php echo $form->textField($models, 'person_name', array('data-label' => 'Contact Person <span style="color:red;">*</span>')); ?>
        <?php echo $form->error($models, 'person_name'); ?>
        <?php echo $form->hiddenField($models, 'id'); ?>
    </li>

    <li class="col-sm-6">
        <?php echo $form->textField($models, 'designation', array('data-label' => 'Designation')); ?>
        <?php echo $form->error($models, 'designation'); ?>
    </li>
    <li class="col-sm-6">
        <?php echo $form->textField($models, 'contact_phone_no', array('data-label' => 'Phone')); ?>
        <?php echo $form->error($models, 'contact_phone_no'); ?>
    </li>
    <li class="col-sm-6">
        <?php echo $form->textField($models, 'department', array('data-label' => 'Department ')); ?>
        <?php echo $form->error($models, 'department'); ?>
    </li>
    <li class="col-sm-6">
        <?php echo $form->textField($models, 'contact_mobile_no', array('data-label' => 'Mobile ')); ?>
        <?php echo $form->error($models, 'contact_mobile_no'); ?>
    </li>

    <li class="col-sm-6">
        <?php echo $form->textField($models, 'contact_email_id', array('data-label' => 'Email ')); ?>
        <?php echo $form->error($models, 'contact_email_id'); ?>
    </li>
    <li class="col-sm-6">
        <?php echo $form->textArea($models, 'notes', array('title' => 'Please enter notes', 'data-label' => 'Notes')); ?>
        <?php echo $form->error($models, 'notes'); ?>
    </li>
    <li class="col-sm-6">
        <?php echo $form->dropDownList($models, 'isActive', array('Y' => 'Active', 'N' => 'Blocked'), array('title' => 'Status', 'data-label' => 'Status')); ?>
        <?php echo $form->error($models, 'isActive'); ?>
    </li>
</ul>
<?php ?>
<div class="modal-footer">

    <button type="button" class="btn btn-danger" onclick="loadPopupModal('vendor/create&id=<?php
            if (!empty($models->vendor_id)) {
                echo $models->vendor_id;
            } else {
                echo $c_id;
            }
            ?>', 'Edit Vendor', 'lg')">Close</button>
            <?php
            $url = Yii::app()->createUrl('vendor/savecontact');
            echo CHtml::ajaxSubmitButton('Save', $url, array(
                'dataType' => 'json',
                'type' => 'post',
                'success' => 'function(data) {

                                var cust = $("#hid_vendor_id").val();
                                    if(data.status=="success"){
                                         t8.success("Contact Details Saved Successfully!");
                                         loadPopupModal("vendor/create&id="+cust,"Edit Vendor","lg");
                                    } else {
                                         $.each(data, function(key, val) {
                                                $("#vendorcontact-form#"+key+"_em_").text(val).show();
                                                t8.error(""+val+"");
                                            });
                                    }
                                    }',
                'beforeSend' => 'function(){
                                $("#vendorcontact-form.contact-save-btn").prop("disabled", true);

                                $("#vendorcontact-form.contact-save-btn").addClass("btn_loding").removeClass("btn btn-primary"); $(".errorMessage").hide(); }'
                    ), array('id' => 'mybtn' . rand(), 'class' => 'contact-save-btn btn btn-theme'));
            ?>
</div>
<?php $this->endWidget(); ?>