<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">المناقصات</a></li>
            <li><a href="Authorizations.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="Authorizations.php?do=update"
                      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-9">
                            <select name="request" id="request" class="select2 wdt100" required>
                                <option value="-1">--- اختر (العضو - العملية - تاريخ الجلسة - الجهة ) ---</option>
                                {foreach $requests as $req}
                                    <option value="{$req.tech_id}" {if $showData->request_id == $req.tech_id}selected{/if}>
                                       العضو: {$req.member_name} | 
                                       العملية: {$req.name} | 
                                       تاريخ الجلسة : {$req.session_date} | 
                                       الجهة: {$req.the_issuing_entity}
                                    </option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                        <!--==============================-->

                    <div class="form-group">
                        <label for="delegate" class="col-lg-2 control-label"> تاريخ التفويض</label>
                        <div class="col-lg-4"> 
                            <span id="sprytextfield3">
                                <input type="date" name="delegate" id="delegate" class="form-control" value="{$showData.delegation_date}" required>
                            </span>
                        </div>
                    </div>
                     <!--==============================-->
                     <div class="form-group">
                        <label class="col-lg-2 control-label">صورة التفويض</label>
                        <div class="col-lg-6">
                            {if $showData->image != "" && $showData->image != "." && $showData->image != "no image"}
                                <div style="margin-bottom: 10px;">
                                    <img src="../upload/Authorizations/{$showData->image}" width="90"  />
                                </div>
                            {/if}
                            
                            <input type="file" name="image" id="image" class="form-control" accept=".jpg, .jpeg, .png, .pdf" />
                            <input type="hidden" name="imageurl" id="imageurl" value="{$showData->image}" />
                            
                        </div>
                    </div>
                    <!--==============================-->
                    
                    
                    <input name="id" id="id" type="hidden" value="{$showData->id}" />

                    <!-- =================================================   -->
                    <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");
            $('#productCatName').trigger('blur');
            setTimeout(function () {
                var myForm = document.getElementById("spform");
                var SS = Spry.Widget.Form.validate(myForm);
                if (SS == true) {
                    myForm.submit();
                } else {
                    $('#spbutton').removeClass("processing");
                }
            }, 500);
        }
    });
    $(document).ready(function(){
    $('#name').on('change', function() {
        let sideValue = $(this).find('option:selected').data('side');
        if (sideValue) {
                $('#side').val(sideValue);
            } else {
                $('#side').val(''); 
            }
        });
})
</script>
{/literal}