<?php $lang=Yii::app()->session['lang'] ;
header('Content-Type:text/javascript'); 
?>

$("#other_operation_name").css("display", "none");
 $(document).ready(function(){
    
     var re=$("#Suggestions_relat").find(":selected").val();
     $('#Suggestions_relat').on('change', function() {
         var re=this.value ;
         if(re==5){
            
           $("#other_operation_name").css("display", "block");
           $('#Suggestions_other_operation_name').css("display", "block");
           $('#Suggestions_other_operation_name').prop('required',true);

         }else{
            //  $("#other_operation_name").hide();
             $("#other_operation_name").css("display", "none");
             $('#Suggestions_other_operation_name').css("display", "none");
             $('#Suggestions_other_operation_name').prop('required',false); 
         }
//   alert( re );
});

     $("#suggestions-form").submit( function(e){
         e.preventDefault();
         $.ajax({
             type:"POST",
             url: "<?php echo CController::createUrl('suggestion') ?>",
             data: $("#suggestions-form").serialize(),
             dataType: "json",
             success: function(response){
                 if(response.status=="sucsess"){
                 $(".modal-body").html(response.msg);
                 $("#myModal").modal('show');
                 $( "button" ).click(function() {
                    location.reload();
                    });
                    // $( "button" ).location.reload();
                    
                 }else if(response.status=="error"){
                      $(".modal-body").html(response.msg);
                 $("#myModal").modal('show');

                 }
             },
             error: function (data) {
             console.log('An error occurred.');
             console.log(data);
             },
        });
    }); 
 });