<!-- === here the drop down list that fill the product list === -->
<style>
    .proDetails{
        cursor: pointer;
    }
    .proDetails:hover{
        text-decoration: underline;
        color: blue;
        font-weight: bold;
    }
    .newoption {
        background-color:#CCCCCC !important;
        font-weight:bold !important;
    }
    /*for select2-drop of product*/
    .largeWidthForDropDown{
        width:500px !important;
    }
</style>

<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">ادارة الفواتير</a></li>
            <li><a href="billTemplateController.php?do=show">الفواتير المحفوظة</a></li>
            <li class="active">الفواتير المحفوظة</li>
        </ol>
        <h3>تعديل فاتورة محفوظة</h3>
        <hr/>


        <div id="addunit" style="display:none"> </div>
        <input type="hidden" id="searchvalue" value="{$Programsettingdata->searchvalue}">
        <form class="form-horizontal " role="form" action="billTemplateController.php?do=update" method="post" id="billTemplateForm">
            <div class="">
                <div class="form-group">
                    <div class="col-lg-6">
                        <label class="sr-only">الاسم </label>
                        <input type="text" class="form-control" name="name" id="name" value="{$billTemplate->name}">
                    </div>
                </div>
            </div>

            <!-- end of hidden ===============================-->


            <div class="" {if {$billsettingsData[14]->billsettingsvalue} eq 0}  {else} style="display:none !important"  {/if}>
                <div class="row mobile-p">
                    <hr/>
                    <div class="col-lg-6 col-sm-4">
                        <h4 id="header4Sell">فاتورة المبيعات</h4>
                    </div>
                    <div class="col-lg-6 col-sm-8">
                        <button type="button" name="addpro" id="addpro" class="btn btn-primary pull-left ft-nor">اضافة جديد</button>
                    </div>
                </div>
                <!-- end of title row-->
                <div class="table-responsive bd-gr">
                    <table class="table billtable table-bordered  table-black" id="containerpros">
                        <thead>
                            <tr>
                                <th class="wdt120">الرقم</th>
                                <th class="wdt120 check_tr_parcode">الباركود</th>
                                <th class="wdt400">المنتج</th>
                                <th class="wdt100n check_tr_unit hidden">الوحدة</th>
                                <th class="wdt100n check_tr_quantity" >الكمية</th>
                                <th class="wdt120">
                                    حذف
                                    <input name="hidden_itr" id="hidden_itr" type="hidden" value="{$itrSell}" />
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {assign var=i value=1}
                            {foreach $billTemplateSell as $item}
                            <tr>
                                <td>{$i}<input type="hidden" name="detailid{$i}" value="{$item->id}"></td>
                                <td>
                                    <div id="productparcode{$i}" >
                                        <input type="text" name="parcode{$i}" id="parcode{$i}"  value="{$item->parcode}"  class="form-control txt-nonraduis" tabindex="7"  onkeypress="getproductbyParcode(event, this.value, {$i});" size="3"  placeholder="الباركود" />
                                    </div>
                                </td>
                                <td>
                                    <div id="productdiv{$i}">
                                        <input type="hidden" id="product{$i}" name="product{$i}"  class="select2product wdt100"   tabindex="7" />

                                        <input type="hidden" id="oldproduct{$i}" name="oldproduct{$i}"  value="{if $item->sizeid > 0 && $item->colorid > 0}hasSizeColor{$item->productid}-{$item->sizeid}-{$item->colorid}{else}{$item->productid}{/if}"  />
                                        <input type="hidden" id="oldname{$i}" name="oldname{$i}"  value="{$item->productName}"  />

                                    </div>
                                </td>
                                <td class="wdt100n check_tr_unit hidden">
                                    <div id="productunitdiv{$i}">
                                        <input type="hidden" name="proNum{$i}" id="proNum{$i}" value=""/>
                                        <select id="productunit{$i}" name="productunit{$i}" class="select2 wdt100" tabindex="7"  onChange="getunitprice({$i});">
                                            <option value="-1"></option>
                                            {foreach $myunitdata{$i} as $mymyunitdata}
                                            <option   {if {$item->unitid} eq {$mymyunitdata->productunitid} } selected="selected"  {/if} data-pu-num="{$mymyunitdata->productnumber}"  value="{$mymyunitdata->productunitid}" >{$mymyunitdata->unitName}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </td>
                                <td> <input type="text" name="pronum{$i}" id="pronum{$i}"  value="{$item->quantity}" class="form-control txt-nonraduis getprototal enteraction numberinput positivefloat" onKeyUp="checkquantity({$i}, event);" tabindex="7" /></td>
                                <td><button id="remove{$i}" type="button" class="close flt-none removeicon removeproduct" aria-hidden="true">×</button></td>
                            </tr>
                            {assign var=i value=$i+1}
                            {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>

            <!-- end of second row-->

            <div class="" {if {$billsettingsData[0]->billsettingsvalue} eq 0}  {else} style="display:none !important"  {/if}>
                <div class="row">
                    <hr/>
                    <div class="col-lg-6">
                        <h4 id="header4retSell">مردودات المبيعات</h4>
                    </div>
                    <div class="col-lg-6">
                        <button type="button" name="addreturn" id="addreturn" class="btn btn-primary pull-left ft-nor">اضافة جديد</button>
                    </div>
                </div>
                <!-- end of title row-->
                <div class="table-responsive bd-rd">
                    <table class="table billtable table-bordered table-black" id="containerReturn">
                        <thead>
                            <tr>
                                <th class="wdt120">الرقم</th>
                                <th class="wdt120 check_tr_parcode">الباركود</th>
                                <th class="wdt400">المنتج</th>
                                <th class="wdt100n check_tr_unit hidden">الوحدة</th>
                                <th class="wdt100n check_tr_quantity" >الكمية</th>
                                <th class="wdt120">
                                    حذف
                                    <input name="returnhidden_itr" id="returnhidden_itr" type="hidden" value="{$itrRet}" />
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {assign var=i value=1}
                            {foreach $billTemplateRet as $item}
                            <tr>
                                <td>{$i}<input type="hidden" name="detailidRet{$i}" value="{$item->id}"></td>
                                <td>
                                    <div id="returnproductparcode{$i}">
                                        <input type="text" name="returnparcode{$i}" id="returnparcode{$i}"  class="form-control txt-nonraduis" placeholder="الباركود" onkeypress="getreturnproductbyParcode(event, this.value, {$i});" tabindex="301" value="{$item->parcode}">
                                    </div>
                                </td>
                                <td>
                                    <div id="returnproductdiv{$i}">
                                        <input type="hidden" id="returnproduct{$i}" name="returnproduct{$i}"  class="select2returnproduct wdt100"  data-placeholder="اختر منتج" tabindex="301" />

                                        <input type="hidden" id="reoldproduct{$i}" name="reoldproduct{$i}" value="{if $item->sizeid > 0 && $item->colorid > 0}hasSizeColor{$item->productid}-{$item->sizeid}-{$item->colorid}{else}{$item->productid}{/if}"  />
                                        <input type="hidden" id="reoldname{$i}" name="reoldname{$i}"  value="{$item->productName}"  />

                                    </div>
                                </td>
                                <td class="wdt100n check_tr_unit hidden">
                                    <div id="returnproductunitdiv{$i}">

                                        <input type="hidden" name="retProNum{$i}" id="retProNum{$i}" value=""/>
                                        <select  class="select2 wdt100" id="returnproductunit{$i}" name="returnproductunit{$i}"  onChange="getreturnunitprice({$i});" >
                                            <option value="-1"></option>
                                            {foreach $myreunitdata{$i} as $remymyunitdata}
                                            <option data-pu-num="{$remymyunitdata->productnumber}" value="{$remymyunitdata->productunitid}" {if $item->unitid eq $remymyunitdata->productunitid}  selected="selected"   {/if}>{$remymyunitdata->unitName} </option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </td>
                                <td><input type="text" name="returnpronum{$i}" id="returnpronum{$i}" value="{$item->quantity}" class="form-control txt-nonraduis getreurnprototal returnenteraction positivefloat" onKeyUp="returncheckquantity({$y}, event);" tabindex="301"/></td>
                                <td>
                                    <button type="button" id="returnremove{$i}" class="close flt-none returnremoveproduct" aria-hidden="true">×</button>
                                </td>
                            </tr>
                            {assign var=i value=$i+1}
                            {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>
            <input type="hidden" name="id" id="id" value="{$billTemplate->id}"/>
            <!-- end of third row-->
            <div class="clearfix"></div>
            <!-- end of fourth row-->
            <div class="row text-center">
                <button type="button" id="saveBill" class="btn btn-primary">تعديل</button>
            </div>
            <br/>

        </form>
    </div>
</div>
<!-- end of container-->
<!------------------------Client Model----------------------------->
<!-- Modal -->
<div class="modal fade" id="productDetailsModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 800px;">
        <div class="modal-content bg-modal">
            <div class="modal-header">
                <button type="button" class="close pull-left savemodel2" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">تفاصيل المنتج</h4>
            </div>
            <div class="modal-body">
                <form id="productDetailsForm" class="form-horizontal">

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">اغلاق</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<!-- ============================================= -->