<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">المناقصات</a></li>
            <li><a href="bidRequest.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="bidRequest.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">
                            
                        <select name="member_id" class="form-control select2" required data-placeholder="اختر العضو" class="select2 wdt100" >
                             <option value="-1">اختر العضو</option>
                            {foreach $allMembers as $member}
                                <option value="{$member->id}">{$member->member_name}</option>
                            {/foreach}
                        </select>
                        </span><span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>

                    <!-- =================================================   -->
                      <div class="form-group">
                        <label class="col-lg-2 control-label">العملية</label>
                        <div class="col-lg-4">
                            <span>
                                <select name="name" id="name" data-placeholder="اختر العملية" class="select2 wdt100">
                                    <option value="-1">اختر العملية</option>
                                    {foreach $allTenders as $tender}
                                        <option value="{$tender->id}" data-side="{$tender->the_issuing_entity}">{$tender->name}</option>
                                    {/foreach}
                                </select>
                            </span>
                        </div>
                    </div>
                    <!--==============================-->

                    <div class="form-group">
                        <label for="requestdate" class="col-lg-2 control-label"> تاريخ الجلسة</label>
                        <div class="col-lg-4"> <span id="sprytextfield3">
                                <input type="date" name="session" id="session">
                                <span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>
                    <!--==============================-->
                    <div class="form-group">
                        <label for="announcementSide" class="col-lg-2 control-label">الجهة</label>
                        <div class="col-lg-4">
                            <input type="text" name="side" id="side" class="form-control" readonly />
                        </div>
                    </div>
                     <!--==============================-->
                    <div class="form-group">
                        <label class="col-lg-2 control-label">صورة الطلب</label>
                        <div class="col-lg-4">
                            <input type="file" name="image" id="image"  accept=".jpg, .jpeg, .png, .pdf" />
                        </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() {
    $('#nature').on('change', function() {
        if ($(this).val() === 'other') {
            $('#other_input_container').show();
        } else {
            $('#other_input_container').hide(); 
            $('#other_nature').val(''); 
        }
    });
});
$(document).ready(function(){
    $('#name').on('change', function() {
        let sideValue = $(this).find(':selected').data('side');
        if (sideValue) {
                $('#side').val(sideValue);
            } else {
                $('#side').val(''); 
            }
        });
})
</script>
{/literal}