<style type="text/css">
    #autoSuggestionsList > li {
        background: none repeat scroll 0 0 #F3F3F3;
        border-bottom: 1px solid #E3E3E3;
        list-style: none outside none;
        padding: 3px 15px 1px 20px;
        text-align: right;
    }
    #autoSuggestionsList > li a { color: #800000; }
    .auto_list {
        border: 1px solid #E3E3E3;
        border-radius: 5px 5px 5px 5px;
        position: absolute;
    }
</style>
<script type="text/javascript">

    function ajaxSearch() {

        var input_data = $('#pi_name').val();
        if (input_data.length === 0) {
            $('#suggestions').hide();
        } else {

            var post_data = {
                'pi_name': input_data,
                '<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>'
            };

            $.ajax({
                type: "POST",
                url: "<?php echo base_url(); ?>charge/admin_charge/autocomplete/",
                data: post_data,
                success: function(data) {
                    // return success
                    if (data.length > 0) {
                        $('#suggestions').show();
                        $('#autoSuggestionsList').addClass('auto_list');
                        $('#autoSuggestionsList').html(data);
                    }
                }
            });

        }
    }


    $(document).on("click", ".branch", function() {
//        alert("ahmed");

        var br_id = this.id;
        var br_data = br_id.split("-");
        jQuery("input[name='pi_name']").val(br_data[0]);
        //   jQuery("#chg_pi_id").html(br_data[1]);
        jQuery("#suggestions").hide();
    });



</script>
<script type="text/javascript">

    $(document).ready(function() {
        $("#date, #date2,#date3,#date4").datepicker();
        $("#date,#date2,#date3,#date4 ").datepicker("option", "dateFormat", "yy/mm/dd");

        var d = new Date();
        var twoDigitMonth = (d.getMonth() + 1) + "";
        if (twoDigitMonth.length == 1)
            twoDigitMonth = "0" + twoDigitMonth;
        var twoDigitDate = d.getDate() + "";
        if (twoDigitDate.length == 1)
            twoDigitDate = "0" + twoDigitDate;
        var todaysM = d.getFullYear() + "/" + twoDigitMonth + "/" + twoDigitDate;
        if ($("#date,#date2,#date3,#date4").val() == "") {
            $("#date,#date2,#date3,#date4").val(todaysM);
        }
    });

</script>

<div class="block">
    <div class="title lightTextShadow">تقرير المصروفات الشخصية</div>
    <div class="content">
        <?php echo form_open('charge/admin_charge/charge_result', array('id' => 'charge_new')) ?>
        <fieldset class="form boxStyle">
            <?php echo $this->template->flash_msg(); ?>

            <div class="inlineBlock">
                <label for="chg_pi_id" class="label">رقم الحالة :</label>
                <input id="chg_pi_id" class="textBox med2 rnd5" name="chg_pi_id" value="<?= set_value('chg_pi_id') ?>"/><br />
                <?php echo form_error('chg_pi_id'); ?>

                <label for="date" class="label">من تاريخ :</label>
                <input class="inputDate textBox rnd5" id="date" name="chg_date"  value="<?= set_value('chg_date') ?>" /><br />

                <label for="date2" class="label">الى تاريخ :</label>
                <input class="inputDate2 textBox rnd5" id="date2" name="chg_date2"  value="<?= set_value('chg_date2') ?>" /><br />
            </div>

            <div class="inlineBlock">
                <label for="suggest1" class="label">اسم المريض :</label>
                <input  class="textBox med2 rnd5 ac_input" name="pi_name" id="pi_name" type="text" onkeyup="ajaxSearch();">
                <div class="something">
                    <div id="suggestions">
                        <div id="autoSuggestionsList">  
                        </div>
                    </div>
                </div>

                <label for="chg_cost" class="label">التكلفة :</label>
                <input id="chg_cost" class="textBox med2 rnd5" name="chg_cost"  value="<?= set_value('chg_cost') ?>"/><br />

                <label class="label">الفرع :</label>
                <?php echo form_dropdown('pi_branch_id', $branch_category, '', 'class="select med3 rnd5"'); ?>
                <?php echo form_error('pi_branch_id'); ?><br />
            </div><br/>

            <div class="center">
                <input id="submit" type="reset" value="تفريغ الحقول" class="button sub inlineBlock rnd3 lightTextShadow" />
                <input id="submit2" type="submit" value="طباعة" class="button sml inlineBlock rnd5 drkTextShadow" />
            </div>
        </fieldset>
        </form>
    </div>
</div><!-- Form End -->
