<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">شئون العاملين</a></li>
            <li><a href="distributionofprofits.php?do=show">توزيع ارباح </a></li>
            <li class="active">اضافة</li>
        </ol>
        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title">اضافة</h3>
            </div>
            <div class="panel-body"> {literal}
                <form class="nameToBeChecked form-horizontal" role="form" action="distributionofprofits.php?do=add"
                      method="post" enctype="multipart/form-data" id="spform">
                    {/literal}

                    <!-- =================================================   -->
                   <div class="form-group">
                        <label class="col-lg-2 control-label">الموظف</label>
                         <div class="col-lg-4">
                            <span>
                        <select name="name" class=" select2" required data-placeholder="اختر الموظف" class="select2 wdt100" >
                             <option value="-1">اختر الموظف</option>
                            {foreach $showData as $data}
                                <option value="{$data.id}">{$data.name}</option>
                            {/foreach}
                        </select>
                        </span>
                        </div>
                    </div>
                   <div class="form-group">
                        <label class="col-lg-2 control-label">اختر سنة :</label>
                        <div  class="col-lg-4">
                            <input type="text" name="year" id="yearOnlyPicker" class="form-control" value="{$currentYear}" readonly>
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label">المرتب السنوي</label>
                            <div class="col-lg-4">
                                <span id="sprytextfield2">
                                    <input name="basic_salary" id="basic_salary" type="number" class="calc-input form-control " />
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                      <label class="col-lg-2 control-label">النسبة المئوية</label>
                        <div class="col-lg-4">
                            <input name="percentage" id="percentage" type="number" class="calc-input form-control"  />
                        </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label">المبلغ</label>
                            <div class="col-lg-4">
                                <input name="total" id="total" type="number" class="calc-input form-control" />
                                
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label">اضافات اخري</label>
                            <div class="col-lg-4">
                                <input name="other_additions" id="other_additions" type="number" class="calc-input form-control"  />
                                
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label">خصومات اخري</label>
                            <div class="col-lg-4">
                                <input name="other_discounts" id="other_discounts" type="number" class="calc-input form-control"  />
                                
                            </div>
                        </div>
                    <!-- =================================================   -->
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="button" class="btn btn-primary pull-left" id="spbutton">حفظ</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{literal}
<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
    $('#spbutton').live('click', function (e) {
        if (!$('#spbutton').hasClass("processing")) {
            $('#spbutton').addClass("processing");
            var myForm = document.getElementById("spform");
            var SS = Spry.Widget.Form.validate(myForm);
            if (SS == true) {
                myForm.submit();
            } else {
                $('#spbutton').removeClass("processing");
            }
        }
    });

$(document).ready(function(){
    $('#name').on('change', function() {
        let sideValue = $(this).find(':selected').data('side');
        if (sideValue) {
                $('#side').val(sideValue);
            } else {
                $('#side').val(''); 
            }
        });
});

  $(document).ready(function() {
    $('#yearOnlyPicker').datepicker({
        format: "yyyy",             
        viewMode: "years",          
        minViewMode: "years",       
        autoclose: true,            
        orientation: "bottom"
    }).on('changeDate', function(e) {
        var selectedYear = e.format();
        window.location.href = 'distributionofprofits.php?do=show&year=' + selectedYear;
    });
});


</script>
{/literal}
 