<?php
include"initialize_page.php";
include"systemfunctions.php";
?>
<?php include('resources/header.php') ?>
<title></title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<?php include('resources/css-file.php') ?>
<?php include('resources/navigation.php') ?> 

<style>
    .hide{
        display:none;
    }
.table > tbody > tr > td{
    padding: 18px 7px;
}

</style> 
<script type="text/javascript">
    function deletepayto(id)
                     {
                       var r=confirm("Do you want to delete this Merchant??");
  if(r==true)
  { 
               
  $.post("controller.php", { id:id, q:"delete_user" } , function(data)
    {
     if(data==1){
        alert("Deleted successfully");
        window.location.href='<?php   echo website_settingdata('x_weburl');   ?>user/deletepaytoaccount';  
        }
        else{
        alert("error");
        }
    });
  }
  
    
        
        }   
</script>
<!-- Dashboard wrapper starts -->
<div class="dashboard-wrapper">
    <div class="main-container">				
        <div class="row">
            <div class="col-sm-12 ac-summ">
                <h2>Customise Your Bill Pay</h2>
            </div>
        </div>
       

        <div class="row gutter">


            <div class="col-lg-10 col-md-10 col-sm-12 col-xs-12 col-md-offset-1">
               
                       
                       
                        <div class="panel">
                            
                            <div class="panel-body">
                               <!--  <h4>Select Fields which we want to display in list</h4>
                                 <form method="post" action="" id="set_display_list">
                                    <div class="form-group">
                                            <input type="hidden" name="q" value="set_display_list" class="form-control">
                                        </div>   
                                     <div class="col-sm-12 form-group">
                                            <div class="col-sm-3" style="text-align: right;">
                                            <label ><strong>Name:</strong> </label>
                                            <input type="checkbox" name="name">
                                        </div>
                                        </div>

                                        <div class="col-sm-12 form-group">
                                            <div class="col-sm-3" style="text-align: right;">
                                            <label ><strong>Nick Name:</strong> </label>
                                            <input type="checkbox" name="nikname">
                                        </div>
                                        </div>

                                        <div class="col-sm-12 form-group">
                                            <div class="col-sm-3" style="text-align: right;">
                                            <label ><strong>Category:</strong> </label>
                                            <input type="checkbox" name="category">
                                        </div>
                                        </div>
                                    </form> -->
                                    <form  method="post" action="" id="set_priority_merchant">
                                        <input type="hidden" name="q" value="set_priority_merchant">
                                        <h4>
                                        Arrange Merchants</h4>
                                        <div class="col-sm-12" style="padding: 10px;">
                                            <div class="col-sm-3">Nick Name</div>
                                    <div  class="col-sm-3">Category</div>
                                    <div class="col-sm-3">State</div>
                                    <div class="col-sm-3">City</div>
                                        </div>
                                        <ul id="sortable">
                                    <?php
                                    $select_query = "select * from x_merchants,x_billpay where x_user_id=$user_id and x_billpay.x_merchant_id=x_merchants.x_merchant_id and x_status=1 order by x_priority";
                                $select_result = mysqli_query($con,$select_query);
                                $num = mysqli_num_rows($select_result);
                            
                                $i=0;
                                if($num >0)
                                {
                                    
                                    while($row = mysqli_fetch_array($select_result))
                                    {

                                        ?>
                                    <li class="ui-state-default col-sm-12">

                                    <div class="col-sm-3"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span><?php echo $row['x_nick_name'];?></div>
                                    <div  class="col-sm-3"><?php echo $row['x_category'];?></div>
                                    <div class="col-sm-3"><?php echo $row['x_state'];?></div>
                                    <div class="col-sm-3"><?php echo $row['x_city'];?></div>
                                    <input type="hidden" name="key[]" value="<?php echo $row['x_merchant_id']; ?>">
                                </li>

                            <?php }
                            }?>
                           </ul>
                           <div class="col-sm-12" >
                                <input type="submit" value="save" style="float: right" class="btn btn-info">
                                </div>
                            </div>
                                </form>
                           
                  
            </div>
        </div>	
        </br>
    </div>
    <!-- Main container ends -->
</div>
<!-- Dashboard wrapper ends -->
<?php include('resources/footer.php') ?>
<?php include('resources/js-file.php') ?>
<script src="js/jQuery.style.switcher.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script type="text/javascript">
    $( function() {
   
   
      $( ".datepicker" ).datepicker({
      changeMonth: true,
      changeYear: false,
      dateFormat:'mm/dd'
    });

  

});
    $(document).ready(function () {
        $("#set_priority_merchant").submit(function (e) {
            e.preventDefault();
            $.ajax({
                url: "controller.php", // Url to which the request is send
                type: 'POST', // Type of request to be send, called as method
                data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
                contentType: false, // The content type used when sending data to the server.
                cache: false, // To unable request pages to be cached
                processData: false, // To send DOMDocument or non processed data file it is set to false
                success: function (data)   // A function to be called if request succeeds
                {
                    if (data == 1)
                    {
                        //setTimeout(function(){  }, 3000);
                       alert('saved successfully');
                       /*  window.location.href = '<?php echo website_settingdata('x_weburl'); ?>user/billpay';*/
                    }
                    if (data == 0)
                    {
                        alert("Amount should be in numeric..");
                    }
                    
                }
            });
        });
    });

</script>



<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#sortable" ).sortable({
      placeholder: "ui-state-highlight"
    });
    $( "#sortable" ).disableSelection();
  } );
  </script>
  <style>
  #sortable { list-style-type: none; margin: 0; padding: 0; width: 100%; }
  #sortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; height: 1.5em; }
  html>body #sortable li { height: 2.5em; line-height: 1.2em; }
  .ui-state-highlight { height: 1.5em; line-height: 1.2em; }
  </style>