<!-- File: src/Template/Articles/index.ctp -->
<div id="page-wrapper">
    <div class="header">
        <h1 class="page-header">

        </h1>
        <ol class="breadcrumb">
            <li><a href="#">SMS & Email</a></li>
            <li class="active">Receipt SMS</li>
        </ol>

    </div>
    <div id="page-inner">



        <div class="row">
            <div class="col-md-12">
                <!--   Kitchen Sink -->
                <div class="panel panel-default">
                    <div class="panel-heading d-flex justify-content-center">
                    Receipt SMS
                    </div>
                    <div class="panel-body">
<div class="app-title">
    <div>
       
    </div>
    <?php if (isset($_SESSION['mem_add']) && $_SESSION['mem_add'] != "") { ?>
        <div class="alert alert-success">
            <strong><?php echo $_SESSION['mem_add']; ?></strong>
        </div>
    <?php $_SESSION['mem_add'] = "";
    } ?>
   
</div>
<form method="post" action="<?php echo base_url(); ?>index.php/Demand/receipt_sms" id="member_add_" enctype='multipart/form-data'>
    <div class="row">
        <div class="col-sm-2">
            <div>Division</div>
            <select name="division" id="division_id" class="form-control">
                <option value="">All</option>
                <?php foreach ($divisions as $div) { ?>
                    <option value="<?php echo $div['division']; ?>"><?php echo $div['division']; ?></option>
                <?php } ?>
            </select>
        </div>
        <div class="col-sm-2">
            <div>Section</div>
            <select name="section" id="section_id" class="form-control">
                <option value="">All</option>
                <?php foreach ($sections as $sec) { ?>
                    <option value="<?php echo $sec['section']; ?>"><?php echo $sec['section']; ?></option>
                <?php } ?>
            </select>
        </div>
         <div class="col-sm-2">
            <div>Members</div>
            <select name="mem_no" id="mem_no" class="form-control">
                <option value="">All</option>
                <?php foreach ($members as $mem) { ?>
                    <option value="<?php echo $mem['me_no']; ?>"><?php echo $mem['me_no']."-".$mem['mem_name']; ?></option>
                <?php } ?>
            </select>
        </div>
        <div class="col-sm-2">
            <div>
                Date
            </div>
            <input type="date" name="added_on" id="added_on_id" value="<?php echo date("Y/m/d"); ?>" onchange="disable_month_year();" class="form-control mt-2">
        </div>
        <div class="col-sm-2">
            <div>Month</div>
            <select name="month" id="month_id" class="form-control mt-2">
                <option value="">Select Month</option>
                <option value="January">January</option>
                <option value="February">February</option>
                <option value="March">March</option>
                <option value="April">April</option>
                <option value="May">May</option>
                <option value="June">June</option>
                <option value="July">July</option>
                <option value="August">August</option>
                <option value="September">September</option>
                <option value="October">October</option>
                <option value="November">November</option>
                <option value="December">December</option>
            </select>
        </div>
        <div class="col-sm-1">Year
            <?php $y = date('Y'); ?>
            <select name="year" id="year_id" class="form-control">
                <option value="">Select Year</option>
                <?php for ($j = $y; $j >= 2019; $j--) { ?>
                    <option <?php if ($j == $y) {
                                echo "";
                            } ?> value="<?php echo $j; ?>"><?php echo $j; ?></option>
                <?php } ?>
            </select>
        </div>
        <div class="col-sm-1 mt-4"><button type="submit" class="btn btn-primary">Submit</button></div>
</form>
</div>
</div>


</div>
</div>
 
<script>

function disable_month_year()
{
   var added_on=$("#added_on_id").val();
   if(added_on!="")
   {
     $("#month_id").val("");
     $("#year_id").val("");
      $('#month_id').prop('disabled', 'disabled');
       $('#year_id').prop('disabled', 'disabled');
   }else{
        $('#month_id').prop('disabled', false);
       $('#year_id').prop('disabled', false);
   }
}

function editpodate(id)
{
    $("#edit_"+id).hide();
    $("#save_"+id).show();
    $("#divpo_"+id).hide();
    $("#input_"+id).show();
}
function savepodate(id)
{
   var paid_on=$("#paid_on_date_"+id).val();
   if(paid_on!="")
   {
      $.ajax({
            type: 'POST',
            url: "<?php echo base_url() ?>index.php/Demand/savepodate",
            data: {
                id:id,
                paid_on: paid_on
            },
            dataType: 'html',
            success: function(data) {
                alert("Paid date updated successfully");
 $("#edit_"+id).show();
    $("#save_"+id).hide();
    $("#divpo_"+id).show();
    $("#input_"+id).hide();
       $("#divpo_"+id).html(paid_on);
            }
        });
   }else{
       alert("Paid date should be filled out");
   }
}

$(document).ready(function() {
     $('.alert').fadeOut(3000);
    $('.datePicker')
        .datepicker({
            format: 'dd-mm-yyyy'
        })
        .on('changeDate', function(e) {
            // Revalidate the date field
            // $('#eventForm').formValidation('revalidateField', 'date');
        });


    // $('#eventForm').formValidation({
    //     framework: 'bootstrap',
    //     icon: {
    //         valid: 'glyphicon glyphicon-ok',
    //         invalid: 'glyphicon glyphicon-remove',
    //         validating: 'glyphicon glyphicon-refresh'
    //     },
    //     fields: {
    //         name: {
    //             validators: {
    //                 notEmpty: {
    //                     message: 'The name is required'
    //                 }
    //             }
    //         },
    //         date: {
    //             validators: {
    //                 notEmpty: {
    //                     message: 'The date is required'
    //                 },
    //                 date: {
    //                     format: 'MM/DD/YYYY',
    //                     message: 'The date is not a valid'
    //                 }
    //             }
    //         }
    //     }
    // });
});
</script>