
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">حسابات</a></li>
            <li><a href="#">موظف او طبيب</a></li>
            <li class="active">سلفة  / سداد سلفة</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">اضافة </h3>
            </div>
            <div class="panel-body">
                <form id="suppform" class="nameToBeChecked form-horizontal" action="employeedoctorController.php?do=savedebtandpay" method="post" >


                    <div class="form-group">
                        <label class="col-lg-2 control-label">العملية </label>
                        <div class="col-lg-4">
                            <div class="radio-inline">
                                <label>  <input value="0" name="thetype" type="radio">
                                    سلفة</label>
                            </div>
                            <div class="radio-inline">
                                <label> <input value="1" name="thetype" type="radio">
                                    سداد سلفة</label>
                            </div>
                        </div>
                    </div>
                    <!--==============================-->
                    <div class="form-group">
                        <label class="col-lg-2 control-label">العملية لــ </label>
                        <div class="col-lg-4">
                            <div class="radio-inline">
                                <label>  <input value="0" name="employeeOrDoctor" type="radio" checked>
                                    موظف</label>
                            </div>
                            <div class="radio-inline">
                                <label> <input value="1" name="employeeOrDoctor" type="radio">
                                    طبيب</label>
                            </div>
                        </div>
                    </div>
                    <!--==============================-->
                    <div class="form-group">
                        <label class="col-lg-2 control-label">الموظف / الطبيب</label>
                        <div class="col-lg-4">
                            <input type="hidden" name="employeeOrDoctorId" id="employeeOrDoctorId" value=""/>
                        </div>
                    </div>
                    <!--==============================-->
                    <div id="debtDiv" style="display: none">


                        <!--==============================-->
                        <div class="form-group">
                            <label class="col-lg-2 control-label">الخزنة </label>
                            <div class="col-lg-4">
                                <select name="saveidDebt" id="saveidDebt" class="select2">
                                    <option></option>
                                    {foreach $saveData as $data}
                                    <option value="{$data->saveid}">{$data->savename}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>



                    </div>
                    <div id="payDiv" style="display: none">


                        <div class="form-group">
                            <label class="col-lg-2 control-label">السداد </label>
                            <div class="col-lg-4">
                                <div class="radio-inline">
                                    <label>  <input value="0" name="paytype" type="radio" checked>
                                        مباشر</label>
                                </div>
                                <div class="radio-inline">
                                    <label> <input value="1" name="paytype" type="radio">
                                        من الراتب</label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group" id="ogoorDiv">
                            <label class="col-lg-2 control-label">حساب الأجور للموظف </label>
                            <div class="col-lg-4">
                                <div class="radio-inline">
                                    <label>  <input value="0" name="whatexpens" type="radio" checked>
                                        مصروفات عمومية</label>
                                </div>
                                <div class="radio-inline">
                                    <label> <input value="1" name="whatexpens" type="radio">
                                        مصروفات تشغيل</label>
                                </div>
                            </div>
                        </div>

                        <!--==============================-->
                        <div class="form-group" id="saveidpayDiv">
                            <label class="col-lg-2 control-label">الخزنة </label>
                            <div class="col-lg-4">
                                <select name="saveidpay" id="saveidpay" class="select2">
                                    <option></option>
                                    {foreach $saveData as $data}
                                    <option value="{$data->saveid}">{$data->savename}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <!--==============================-->




                    </div>

                    <!--==============================-->
                    <div class="form-group">
                        <label class="col-lg-2 control-label">المبلغ</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="text" name="val" id="val" class="positivefloat form-control"/>
                                <span class="input-group-addon">{$currency}</span>
                            </div>
                        </div>
                    </div>
                    <!--==============================-->
                    <div class="form-group">
                        <label class="col-lg-2 control-label">تعليق</label>
                        <div class="col-lg-4">
                            <textarea style="width: 358px;" name="comment" cols="50" rows="5" class="form-control"></textarea>
                        </div>
                    </div>


                    <!--==============================-->

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button name="saveIncBtn" type="submit" id="saveIncBtn" class="btn btn-primary pull-left" onclick="$(this).hide()">حفظ</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{literal}
<script>
    $('input[name="thetype"]').live('change', function () {
        var thetype = $('input[name="thetype"]:checked').val();
        if (thetype == 0) {
            $('#debtDiv').show();
            $('#payDiv').hide();
        } else if (thetype == 1) {
            $('#debtDiv').hide();
            $('#payDiv').show();
        }
    });
    $('input[name="employeeOrDoctor"]').live('change', function () {
        var val = $('input[name="employeeOrDoctor"]:checked').val();
        if (val == 0) {
            $('#ogoorDiv').show();
        } else if (val == 1) {
            $('#ogoorDiv').hide();
        }
    });
    $('input[name="paytype"]').live('change', function () {
        var paytype = $('input[name="paytype"]:checked').val();
        if (paytype == 0) {
            $('#saveidpayDiv').show();
        } else if (paytype == 1) {
            $('#saveidpayDiv').hide();
        }
    });
    $(function () {
        $("#employeeOrDoctorId").select2({
            placeholder: "اختر",
            minimumInputLength: 0,
            inimumInputLength: 0,
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "expensesControllerajex.php?do=getemployeeOrDoctorajax",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 7, // page size
                        employeeOrDoctor: $('input[name="employeeOrDoctor"]:checked').val(), // page size
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: function (data) {
                return  data.text;
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                //  var data = {id: item[0], text: item[1]};
                var data = {id: item[0], text: item[1]};
                callback(data);
            },
        });
    });
</script>
{/literal}
