
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">خصائص عامة</a></li>
            <li><a href="#">اداره الايجارات</a></li>
            <li class="active">فواتير الايجار</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">فاتوره جديده</h3>
            </div>
            <div class="panel-body">
                <form class="form-horizontal rentform" action="?do=add" method="post" id="rentform">

                    <div class="row">
                        <div class="col-lg-6">
                            <div class="form-group">
                                <label  class="col-lg-2 control-label">العميل</label>
                                <div class="col-lg-4">
                                    <select class="select2 wdt100" name="clientid" id="clientid" placeholder=" عميل - هاتف" required="">
                                        <option value=""></option>
                                        {foreach $clients as $client}
                                        <option value="{$client->clientid}">{$client->clientname} - {$client->clientmobile}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="form-group">
                                <label class="col-lg-2 control-label">تاريخ</label>
                                <div class="col-lg-4">
                                    <input name="createdate" type="text" id="createdate" data-date-format="yyyy-mm-dd" placeholder="تاريخ الفاتورة" value="{$today}" class="form-control adatepicker" required=""/>
                                </div>
                            </div>
                        </div>

                    </div>



                    <!--==============================-->

                    <div class="row">

                        <div class="col-lg-12">
                            <div class="row">
                                <hr/>
                                <div class="col-lg-6">
                                    <h4>الايجارات</h4>
                                </div>
                                <div class="col-lg-6">
                                    <button type="button" name="addrent" id="addrent" class="btn btn-primary pull-left ft-nor"> اضافة جديد</button>
                                </div>
                            </div>
                            <div class="table-responsive bd-gr">
                                <input name="hidden_itr" id="hidden_itr" type="hidden" value="1" />
                                <style>
                                    .nomarg{
                                        margin-right: -2px !important;
                                    }
                                    .typeout{
                                        display: none;
                                    }
                                    .maintypeout{
                                        display: none;
                                    }
                                    .billtable th {
                                        color: #fff;
                                        background-color: #757575;
                                    }
                                    .wdth150{
                                        width: 150px !important
                                    }
                                    .wdth50{
                                        width: 50px !important
                                    }
                                </style>
                                <table class="table billtable table-bordered table-black" id="containerpros">
                                    <thead>
                                        <tr>

                                            <th class="wdt240">اسم المنتج</th>

                                            <th class="wdt80">نوع</th>

                                            <th class="wdthauto">
                                    <table class="maintypeout">
                                        <th class="wdt120">اسم المورد</th>
                                        <th class="wdth50">سعر التكلفه</th>
                                        <th class="wdth50"> التكلفه اليوم</th>
                                        <th class="wdth50">اجمالى التكلفه</th>
                                    </table>
                                    </th>

                                    <th class="wdt20">العدد</th>

                                    <th>سعر الايجار</th>

                                    <th class="wdt60">اجمالى الايجار</th>
                                    <th class="wdt120">تاريخ البدا</th>
                                    <th class="wdt120">تاريخ النهايه</th>

                                    <th class="wdt60">عدد الايام</th>
                                    <th class="wdt80">اجمالى </th>
                                    <th>حذف</th>
                                    </tr>
                                    </thead>
                                    <tbody id="rentscontainer">
                                        <tr id="productraw1">
                                            <td>
                                                <!--select class="select2 wdt100 fetchproduct" name="productid1" id="productid1" placeholder="اختر المنتجات" required="" data-itr="1">
                                                    <option value=""></option>
                                                    {foreach $products as $product}
                                                    <option value="{$product->id}">{$product->name}</option>
                                                    {/foreach}
                                                </select-->
                                                <input type="hidden"  id="productid1" name="productid1" data-placeholder="اختر" required=""  data-itr="1" class="fetchproduct wdt100"/>
                                            </td>
                                            <td>
                                                <select class="select2 wdt100 renttype" name="renttype1" id="renttype1" data-itr="1">
                                                    <option value="0">داخلى</option>
                                                    <option value="1">خارجي</option>
                                                </select>
                                            </td>
                                            <td>
                                                <table class="typeout typeout1">
                                                    <tr>
                                                        <td>
                                                            <select class="select2 wdth150" name="supplierid1" id="supplierid1" placeholder="اختر مورد" required="" >
                                                                <option value=""></option>
                                                                {foreach $suppliers as $supplier}
                                                                <option value="{$supplier->supplierid}">{$supplier->suppliername}</option>
                                                                {/foreach}
                                                            </select>
                                                        </td>
                                                        <td>
                                                            <input type="text" name="buyprice1" id="buyprice1" number="true" min="1"  class="form-control txt-nonraduis wdth50 calptotal" data-itr="1" value="0" tabindex="7" />
                                                        </td>
                                                        <td>
                                                            <div id="buytotal1" class="wdth50">
                                                                0
                                                            </div>
                                                            <input type="hidden" name="hbuytotal1" id="hbuytotal1" value="0"/>
                                                        </td>
                                                        <td>
                                                            <div id="bbuytotal1" class="wdth50">
                                                                0
                                                            </div>
                                                            <input type="hidden" name="hbbuytotal1" id="hbbuytotal1" value="0"/>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>

                                            <td>
                                                <input type="text" style="float: right;width: 50%;" min="1" name="amount1" id="amount1"  class="form-control txt-nonraduis calptotal" data-itr="1" value="1" tabindex="7" />
                                                <div id="amountcount1" style="float: left;"></div>
                                            </td>
                                            <td>
                                                <input type="text" name="rentprice1" id="rentprice1"  class="form-control txt-nonraduis calptotal" number="true" min="1" data-itr="1" value="0" tabindex="7" />
                                            </td>
                                            <td>
                                                <div id="renttotal1">
                                                    0
                                                </div>
                                                <input type="hidden" name="hrenttotal1" id="hrenttotal1" class="prenttotal" value="0"/>
                                            </td>
                                            <td>
                                                <input name="startdate1" type="text" id="startdate1" data-date-format="yyyy-mm-dd" value="{$today}" class="form-control adatepicker caldate" data-itr="1" required=""/>
                                            </td>
                                            <td>
                                                <input name="enddate1" type="text" id="enddate1" data-date-format="yyyy-mm-dd"  class="form-control adatepicker caldate" data-itr="1" required=""/>
                                            </td>
                                            <td>
                                                <div id="rentdays1">
                                                    0
                                                </div>
                                                <input type="hidden" name="hrentdays1" id="hrentdays1" value="0"/>
                                            </td>
                                            <td>
                                                <div id="rentdaystotal1">
                                                    0
                                                </div>
                                                <input type="hidden" name="hrentdaystotal1" id="hrentdaystotal1" class="prentdaystotal" value="0"/>
                                            </td>
                                            <td>
                                                <button id="remove1" type="button" class="close flt-none removeicon removeproduct"  data-itr="1" 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="rentbilltotal">0</div>
                                </span>
                                <input type="hidden" name="hrentbilltotal" id="hrentbilltotal" value="0"/>
                            </button>

                            <div class="clearfix"></div>

                            <div class="row">
                                <!-- end of calucation center-->
                                <div class="col-lg-5" id="bankinfocontianter" style="display:none;">


                                    <div class="form-group mg-bt5">
                                        <label class="col-lg-3 control-label">البنك</label>
                                        <div class="col-lg-7">
                                            <select class="select2" name="bankid" id="bankid" placeholder="اختر بنك" required="" >
                                                <option value=""></option>
                                                {foreach $allbanks as $bank}
                                                <option value="{$bank->bankid}">{$bank->bankname}</option>
                                                {/foreach}
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group mg-bt5" id="accountcontainer">
                                        <label class="col-lg-3 control-label">الحساب</label>
                                        <div class="col-lg-7">
                                            <select class="select2" name="accountid" id="accountid" placeholder="اختر حساب" required="" >
                                                <option value=""></option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group mg-bt5">
                                        <label class="col-lg-3 control-label">رقم الشيك</label>
                                        <div class="col-lg-7">
                                            <input type="text" name="paperno" id="paperno" class="form-control"  placeholder="0" required="" digits="true"/>
                                        </div>
                                    </div>

                                    <div class="form-group mg-bt5">
                                        <label class="col-lg-3 control-label">قيمه الشيك</label>
                                        <div class="col-lg-7">
                                            <input type="text" name="paperval" readonly="" id="paperval" class="form-control"  placeholder="0" required="" number="true"/>
                                        </div>
                                    </div>

                                    <div class="form-group mg-bt5">
                                        <label class="col-lg-3 control-label">تاريخ الشيك</label>
                                        <div class="col-lg-7">
                                            <input name="paperdate" type="text" readonly="" id="paperdate" data-date-format="yyyy-mm-dd" placeholder="تاريخ الشيك" value="{$today}" class="form-control adatepicker" required=""/>
                                        </div>
                                    </div>


                                </div>


                                <div class="col-lg-5 pull-left">
                                    <hr/>



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

                                    <!-- end of form-group-->
                                    <div class="form-group mg-bt5">
                                        <label class="col-lg-5 control-label">نوع الدفع</label>
                                        <div class="col-lg-7">
                                            <div class="radio-inline">
                                                <label>
                                                    <input value="1"  class="radioR" name="payistype" type="radio" />
                                                    شيك </label>
                                            </div>
                                            <div class="radio-inline">
                                                <label>
                                                    <input value="0"  class="noradioR" checked="checked" name="payistype"  type="radio" />
                                                    نقدي </label>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group mg-bt5 forcash">
                                        <label class="col-lg-5 control-label">الخصم</label>
                                        <div class="col-lg-7">
                                            <input type="text" name="discount" id="discount" class="form-control payit" value="0"  placeholder="0" number="true"/>
                                        </div>
                                    </div>

                                    <hr class="mg-tp5 mg-bt5 forcash"/>
                                    <div class="form-group mg-bt5 bg-yel forcash">
                                        <label class="col-lg-5 control-label">المتبقى بعد الخصم</label>
                                        <div class="col-lg-7">
                                            <input type="hidden" name="distotal" id="distotal" value="0"/>
                                            <p class="form-control-static mg-tp10" id="discounttotal">0</p>
                                        </div>
                                    </div>
                                    <hr class="mg-tp5 mg-bt5 forcash"/>
                                    <!-- end of form-group-->
                                    <div class="form-group mg-bt5 forcash">
                                        <label class="col-lg-5 control-label">المدفوع</label>
                                        <div class="col-lg-7">
                                            <input type="text" name="genpay" id="genpay" class="form-control payit" value="0"  placeholder="0" required="" number="true"/>
                                        </div>
                                    </div>
                                    <!-- end of form-group-->
                                    <hr class="mg-tp5 mg-bt5 forcash"/>
                                    <div class="form-group mg-bt5 bg-yel forcash">
                                        <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>
                                <!-- end of totals center-->
                            </div>
                            <!-- end of fourth row-->
                            <div class="row">
                                <button type="submit" id="saveBill"  class="btn btn-primary">حفظ</button>

                                <!-- <button type="button" onclick="printData();" class="btn btn-info">طباعة</button>-->
                            </div>

                        </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div id="prod" class="hidden">
    {foreach $products as $product}
    <option value="{$product->id}">{$product->name}</option>
    {/foreach}
</div>
<div id="supls" class="hidden">
    {foreach $suppliers as $supplier}
    <option value="{$supplier->supplierid}">{$supplier->suppliername}</option>
    {/foreach}
</div>

<input type="hidden" id="todaydate" value="{$today}"/>

<input type="hidden" id="selectedIds" name="selectedIds" value="">
