<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">المناقصات</a></li>
            <li><a href="repeatedletters.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="repeatedletters.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-6">
                            <select name="request" id="request" class="select2" style="width: 100%;">
                                {foreach $requests as $req}
                                    
                                    
                                    {assign var="val_first" value="`$req.accept_id`|first"}
                                    <option value="{$val_first}" {if $showData->report_id == $req.accept_id && $showData->type == 'first'}selected{/if}>
                                        [ خطاب أولي ] | العضو: {$req.member_name} | العملية: {$req.tender_name} | التاريخ: {$req.session_date}
                                    </option>

                                
                                    {assign var="val_final" value="`$req.final_id`|final"}
                                    <option value="{$val_final}" {if $showData->report_id == $req.final_id && $showData->type == 'final'}selected{/if}>
                                        [ خطاب نهائي ] | العضو: {$req.member_name} | العملية: {$req.tender_name} | التاريخ: {$req.session_date}
                                    </option>
                                    
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <!--==============================-->
                    <div class="form-group">
                        <label class="col-lg-2 control-label">اسم الخطاب</label>
                        <div class="col-lg-4">
                            <input type="text" name="letter" id="letter" class="form-control" value="{$showData->report_name}" required>
                        </div>
                    </div>
                    <!--==============================-->
                    <div class="form-group">
                        <label for="comment" class="col-lg-2 control-label">تعليق</label>
                        <div class="col-lg-4">
                            <textarea name="comment" id="comment" class="form-control" rows="3">{$showData->comment}</textarea>
                        </div>
                    </div>
                    
                    <!--==============================-->
                      <div class="form-group">
                        <label class="col-lg-2 control-label"> مرفقات</label>
                        <div class="col-lg-4">
                            {if $showData->extract_files != "" && $showData->extract_files !="." &&
                            $showData->extract_files !="no image"}
                            <div style="margin-bottom: 10px;">
                            {assign var="imgs" value=","|explode:trim($showData->extract_files)}
                            {foreach $imgs as $img}
                                <img src="../upload/repeated/{trim($img)}" width="80" height="60" style="border:1px solid #ccc; margin-left:5px;" />
                                
                            {/foreach}
                            </div>
                            {/if}
                            <input type="file" name="image[]" id="image" multiple accept=".jpg, .jpeg, .png, .pdf"/>
                            <input type="hidden" name="imageurl" id="imageurl" value="{$showData->extract_files}" />
                        </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);
        }
    });
</script>
{/literal}