<!-- === here the drop down list that fill the product list === -->
<style>
    .newoption {
        background-color:#CCCCCC !important;
        font-weight:bold !important;
    }
</style>
<script type="application/javascript">
    //$(document).ready(function(e) {
    //
    //	$("#pronum1").keydown(function(e) {
    //   // test for the enter key
    //	   if (e.keyCode == 40) {
    //		   alert(this.name);
    //		  // Do your function
    //		  $("#pronum2").select();
    //	 //    alert("sfdsfds");
    //	   }
    //
    //
    //	});
    //
    //
    //
    //		$("#textfield2").keydown(function(e) {
    //			   // test for the enter key
    //			   if (e.keyCode == 38) {
    //				  // Do your function
    //				  $("#textfield").select();
    //			 //    alert("sfdsfds");
    //			   }
    //
    //		});
    //
    //});
</script>




<!-- === end of drop down list === -->

<!-- === here the drop down list that fill the product list === -->

<div id="addunit" style="display:none"> </div>
<!-- === end of drop down list === -->

<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">ادارة الفواتير</a></li>
            <li><a href="sellbillController.php?do=show">فاتورة المبيعات</a></li>
            <li class="active">اضافة فاتورة</li>
        </ol>
        <h3>{$billnameAddData->name}</h3>
        <hr/>
        {literal}
        <form class="form-horizontal " role="form" action="sellbillController.php?do=add" method="post" id="sellbillForm" onsubmit="if (Spry.Widget.Form.validate(this)) {
                    $('#saveAndNew').css('display', 'none');
                    $('#saveBill').css('display', 'none');
                    return true;
                } else {
                    return false;
                }">
            {/literal}
            <div class="row">
                <div class="col-lg-8">
                    <div class="form-group">
                        <label class="col-lg-3 control-label">رقم الفاتورة</label>
                        <div class="col-lg-4">
                            <input type="text" name="bns" id="bns" class="form-control" placeholder="رقم الفاتورة">
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group"  >
                        <label class="col-lg-3 control-label">تاريخ الفاتورة</label>
                        <div class="col-lg-4"> <span id="sprydate">

                                <!--input type="text" class="form-control awdatepicker" autocomplete="off"  data-date-format="yyyy-mm-dd" placeholder="تاريخ الفاتورة" value="{$today}" name="bn" id="bn"-->
                                <div  class="input-group date form_datetime col-md-5" data-date="" data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                    <input class="form-control" size="16" type="text" value="{$today}" name="bn" id="bn readonly="">
                                    <span class="input-group-addon "><span class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-th col-lg-4"></span></span>
                                </div>
                                <span class="textfieldRequiredMsg">*</span></span> </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group" >
                        <label class="col-lg-3 control-label">اسم العميل المؤقت</label>
                        <div class="col-lg-4"> <span id="sprytempname">
                                <input type="text" class="form-control"  placeholder="الاسم المؤقت"  name="tempclientName" id="tempclientName" value="نقدى"  />
                                <span class="textfieldRequiredMsg">*</span></span> </div>
                    </div>
                    <!-- end of form-group-->

                </div>
                <!-- end of bill no-->

                <div class="col-lg-4">
                    <div class="form-group mg-bt5" >
                        <label class="col-lg-4 control-label">اسم العميل</label>
                        <div class="col-lg-8"> <span id="spryclient">
                                <div id="clientDiv">
                                    <select class="select2 wdt100" name="supplier" id="supplier" >



                                        <option  value="-2"  class="newoption">اضافة عميل جديد</option>




                                        <option value="">نور</option>


                                    </select>
                                </div>
                                <span class="selectInvalidMsg">*</span></span> </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5" >
                        <label class="col-lg-4 control-label">رصيد الدين</label>
                        <div class="col-lg-8">
                            <p class="form-control-static" id="debt">0 </p>
                            <input name="hidden_debt" id="hidden_debt" type="hidden" value="0" />
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5">
                        <label class="col-lg-4 control-label">نوع السعر</label>
                        <div class="col-lg-8">
                            <select class="select2 wdt100" name="pricetype" id="pricetype">
                                <option value="0">جملة</option>
                                <option value="1">تجزئة</option>
                                <option value="2">نصف جملة</option>
                            </select>
                            <input type="hidden" name="hiddenpricetype" id="hiddenpricetype" value="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <hr class="mg-bt5 mg-tp5"/>



                    <!-- end of form-group-->

                    <div class="form-group mg-bt5" >
                        <label class="col-lg-4 control-label">اسم {if $Programsettingdata->delegate_seller eq 0} بائع {elseif $Programsettingdata->delegate_seller == 1}مندوب {elseif $Programsettingdata->delegate_seller == 2}طبيب {/if}</label>
                        <div class="col-lg-8">
                            <select class="select2 wdt100" name="sellerid" id="sellerid">


                                {foreach $sellerData as $seller}


                                <option value="{$seller->userid}">{$seller->employeename}</option>


                                {/foreach}


                            </select>
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>

                <!-- end of client info-->

            </div>
            <!-- end of frist row-->
            <!-- hidden ===============================-->


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


            <div class="row" >
                <div class="row">
                    <hr/>
                    <div class="col-lg-6">
                        <h4>المبيعات</h4>
                    </div>
                    <div class="col-lg-6">
                        <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="wdt300">المخزن</th>
                                <th class="wdt400">اسم المنتج</th>
                                <th  class="wdt240">ملاحظات</th>

                                <th class="wdt100n">العدد</th>
                                <th class="wdt80">السعر</th>

                                <th class="wdt80">الخصم</th>




                                <!-------------------------------------discountvalue by hazem---------------------------------------------->
                                <!--th {if {$billsettingsData[8]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if} class="wdt80"> نسبة الخصم</th-->
                                <!-------------------------------------discountvalue by hazem---------------------------------------------->
                                <th class="wdt100n">
                                    <input name="hidden_itr" id="hidden_itr" type="hidden" value="1" />
                                    الاجمالى</th>
                                <th>حذف</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr  id="productraw1">



                                <td >
                                    <div id="prstoridsiv1">


                                        <select class="select2 wdt100" name="prstorid1" id="prstorid1">
                                            {foreach $storeData as $store}
                                            <option value="{$store->storeId}">{$store->storeName}</option>
                                            {/foreach}
                                        </select>



                                    </div>
                                </td>
                                <td>
                                    <div id="productdiv1">
                                        <select class="select2 wdt100" name="product1" id="product1">
                                            <option value="">aaa</option>
                                            <option value="">aaa</option>

                                        </select>
                                    </div>
                                </td>
                                <td>
                                    <textarea class="form-control txt-nonraduis enteraction" name="comment1" id="comment1" rows="1" tabindex="7"></textarea>
                                </td>

                                <td>
                                    <input type="text" name="pronum1" id="pronum1"  class="form-control txt-nonraduis getprototal enteraction numberinput"  value="1" tabindex="7" />
                                </td>
                                <td>
                                    <div id="propricechange1">
                                        <input type="text" name="proprice1" id="proprice1"  class="form-control getprototal enteraction numberinput txt-nonraduis" value="0" tabindex="7" />
                                    </div>
                                </td>


                                <td >
                                    <input type="text" name="prodis1" id="prodis1"   class="form-control txt-nonraduis getprototal enteraction numberinput" value="0" tabindex="7"  />
                                </td>
                                <!-------------------------------------discountvalue by hazem---------------------------------------------->
                                <!--td {if {$billsettingsData[8]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if}>
                                  <input type="text" name="prodisper1" id="prodisper1"  class="form-control txt-nonraduis getprototal enteraction numberinput" value="0" tabindex="7"  />
                                </td-->
                                <!-------------------------------------discountvalue by hazem---------------------------------------------->
                                <td>
                                    <div id="prototal1" class="form-control-static">0</div>
                                    <input name="hidden_prototal1" id="hidden_prototal1" type="hidden" value="0" />
                                </td>
                                <td>
                                    <button id="remove1" type="button" class="close flt-none removeicon removeproduct" aria-hidden="true">&times;</button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <button type="button" class="btn btn-primary pull-left ft-nor">
                    اجمالى المبيعات <span class="badge wht-clo">
                        <div id="sellbilltotal">0</div>
                    </span>
                    <input type="hidden" name="sellbillprice" id="sellbillprice" value="0"/>
                </button>
            </div>

            <!-- end of second row-->



            <!-- end of third row-->

            <div class="row">
                <div class="col-lg-7">
                    <div class="form-group mg-bt5">
                        <label class="col-lg-1 control-label">المدفوع</label>
                        <div class="col-lg-3">
                            <input type="text" class="form-control" placeholder="المدفوع" name="genpay2" id="genpay2"  onkeyup="calculateremain(this.value);">
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5">
                        <label class="col-lg-1 control-label">الباقى</label>
                        <div class="col-lg-3">
                            <p class="form-control-static" id="gen3total2">0 {$currency}</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>
                <!-- end of calucation center-->

                <div class="col-lg-5">
                    <hr/>
                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label">عدد القطع المباعة</label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="totalQty">0</p>
                            <input type="hidden" name="sellQuantity" id="sellQuantity" value="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->


                    <!-- end of form-group-->

                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label">قيمة الفاتورة</label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="gentotal">0</p>
                            <input type="hidden" name="sellbilltotalbill" id="sellbilltotalbill" value="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label">نوع الخصم</label>
                        <div class="col-lg-7">
                            <select id="distype" name="distype"  class="select2 wdt100" onchange="checkdisValue();">
                                <option value="1">مباشر</option>
                                <option value="2">نسبة</option>
                            </select>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label">قيمة الخصم</label>
                        <div class="col-lg-7"> <span id="sprytextfield4">
                                <input type="text" name="gendis" id="gendis"  class="form-control numberinput" placeholder="قيمة الخصم"   />
                                <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">ادخل القيمة صحيحة</span></span> </div>
                    </div>
                    <!-- end of form-group-->
                    <hr class="mg-tp5 mg-bt5"/>
                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label">الصافى</label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="gen2total">0</p>
                            <input type="hidden" name="sellbillaftertotalbill" id="sellbillaftertotalbill" value="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label">المدفوع</label>
                        <div class="col-lg-7">
                            <input type="text" name="genpay" id="genpay" readonly="readonly"   class="form-control numberinput"  placeholder="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <hr class="mg-tp5 mg-bt5"/>
                    <div class="form-group mg-bt5 bg-yel">
                        <label class="col-lg-5 control-label">المتبقى</label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="gen3total">0</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label">باقى الدين</label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="gen4total">0</p>
                            <input type="hidden" name="clientdebtafter" id="clientdebtafter" value="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>
                <!-- end of totals center-->
            </div>
            <!-- end of fourth row-->

            <div class="row">
                <button type="submit" id="saveBill" onclick="return addDataOnly();" class="btn btn-primary">حفظ</button>
                <button type="submit" id="saveAndNew" onclick="return addDataAndReturn();" class="btn btn-success">حفظ وجديد</button>

                <!-- <button type="button" onclick="printData();" class="btn btn-info">طباعة</button>-->
            </div>
            <br/>
            <div class="row">
                <style>
                    .unsufficient{
                        background-color: #f59a99 !important;
                    }
                    .note-warning{
                        background-color: #faeaa9;
                        border-color: #f3cc31;
                        color: #000;
                        border-right: 5px solid #f3cc31;
                        border-radius: 4px 0 0 4px;
                        margin: 0 0 20px;
                        padding: 15px 15px 15px 30px;
                    }
                </style>
                <input type="hidden" name="storenegative" id="storenegative" value="{$storenegative}"/>
                <div class="note-warning" style="display: none" id="check_store_div">
                    <h4 class="block" id="check_store_msg"></h4>
                </div>
            </div>
            <!-- end of fifth row-->

        </form>
    </div>
    <!-- end of container-->
</div>
<!-- end of main row-->

<!------------------------Client Model----------------------------->
<!-- Modal -->

<!-- /.modal -->

<!------------------------Product Model----------------------------->

<!-- Modal -->

<!-- /.modal -->

<!-- /////////////////////////Store Model/////////////////////////////////-->

<!-- Modal -->

<!-- /.modal -->

{literal}
<script type="text/javascript">
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
    var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "real");



    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {isRequired: false, invalidValue: "-1"});
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "real");
    var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "real");
    var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7", "real");
    var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8", "real");
    var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9", "integer");
    var sprytextfield10 = new Spry.Widget.ValidationTextField("sprytextfield10", "integer");
    var sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11");

</script>
{/literal}
<script type="text/javascript">
    var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "real");
</script>