<script>
    $(document).ready(function (e) {

        var printingpapersize = document.getElementById("printingpapersize").value;
        var id = document.getElementById("buybillid").value;
        if (printingpapersize == 1) {
            window.open("buyBillprintController.php?do=editprint&id=" + id);
        } else {
            window.open("buyBillprintController.php?do=editprint&id=" + id);
        }
    });

</script>
<style>
    .row {
        -webkit-print-color-adjust: exact;
    }
</style>



<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">إدارة الفواتير</a></li>
            <li><a href="#">فاتورة الشراء</a></li>
            <li class="active">عرض فاتورة</li>
        </ol>
        <h3>{$billnameAddData->name}</h3>
        <hr />
        <form class="form-horizontal" role="form" action="buyBillController.php?do=show" method="post" id="billform">
            <input name="printingpapersize" id="printingpapersize" type="hidden"
                value="{$Programsettingdata->printingpapersize}" />
            <!-- =========================== START BUY BILL SETTINGS ================================== -->
            <input type="hidden" name="billnameid" id="billnameid" value="{$billnameid}" />
            <input type="hidden" name="returnBillSetting" id="returnBillSetting"
                value="{$billsettingsData[0]->billsettingsvalue}" />
            <input type="hidden" name="storeSetting" id="storeSetting"
                value="{$billsettingsData[2]->billsettingsvalue}" />
            <input type="hidden" name="parcodeSetting" id="parcodeSetting"
                value="{$billsettingsData[4]->billsettingsvalue}" />
            <input type="hidden" name="dateSetting" id="dateSetting"
                value="{$billsettingsData[5]->billsettingsvalue}" />
            <input type="hidden" name="newProductSetting" id="newProductSetting"
                value="{$billsettingsData[6]->billsettingsvalue}" />
            <input type="hidden" name="noteSetting" id="noteSetting"
                value="{$billsettingsData[7]->billsettingsvalue}" />
            <input type="hidden" name="productDiscountSetting" id="productDiscountSetting"
                value="{$billsettingsData[8]->billsettingsvalue}" />
            <!-- ==========================  END BUY BILL SETTINGS ============================ -->

            <!-- =========================== START GENERAL INFO PANEL =====================-->
            <div class="row">
                <div class="col-lg-8">
                    {if $Programsettingdata->clientserial eq 1}

                    <div class="form-group">
                        <label class="col-lg-2 control-label">رقم تسلسل الفاتورة</label>
                        <div class="col-lg-4">
                            <p class="form-control-static">
                                {$buyBillData->buybillid}
                            </p>
                        </div>
                    </div>
                    {/if}

                    <!----------------=========================================================-------------->
                    <div class="form-group mg-bt5" {if {$billsettingsData[45]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-4 control-label">مركز التكلفة </label>
                        <div class="col-lg-8">

                            {foreach $allCostcenter as $myallCostcenter}

                            {if {$buyBillData->costcenterid} eq {$myallCostcenter->id}} {$myallCostcenter->name} {/if}
                            {/foreach}


                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group" {if {$billsettingsData[61]->billsettingsvalue} eq 0} style="display:block"
                        {else} style="display:none" {/if}>
                        <label class="col-lg-2 control-label">رقم الفاتورة</label>
                        <div class="col-lg-4">
                            <p class="form-control-static">
                                {$buyBillData->buybillSerial}
                            </p>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group" {if $billsettingsData[5]->billsettingsvalue eq 0} {else} style="display:none
                        !important;" {/if}>
                        <label class="col-lg-2 control-label">تاريخ الفاتورة</label>
                        <div class="col-lg-4">
                            <p class="form-control-static">
                                {$buyBillData->buybilldate}
                            </p>
                        </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">
                            <p class="form-control-static"> {$buyBillData->suppliername}</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}" {if
                        {$billsettingsData[56]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-4 control-label">رصيد الدين</label>
                        <div class="col-lg-8">
                            <div id="debt" class="form-control-static">{$buyBillData->buybilltotaldeptbefor} </div>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <hr class="mg-bt5 mg-tp5" />
                    <div class="form-group mg-bt5" {if $billsettingsData[2]->billsettingsvalue eq 0} {else}
                        style="display:none !important;" {/if}>
                        <label class="col-lg-4 control-label">المخزن</label>
                        <div class="col-lg-8">
                            <p class="form-control-static">
                                {$buyBillData->storeName}
                            </p>
                        </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">
                                {$buyBillData->comment}
                            </p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>
                <!-- end of client info-->

            </div>
            <!-- =========================== END GENERAL INFO PANEL ====================== -->

            <!-- =========================== START BUY BILL PANEL ======================= -->
            <div class="row">
                <div class="row">
                    <hr />
                    <div class="col-lg-6">
                        <h4>المشتريات</h4>
                    </div>
                    <div class="col-lg-6">
                    </div>
                </div>
                <!-- end of title row-->
                <div class="table-responsive">
                    <table class="table billtable table-bordered table-black" id="containerpros">
                        <thead>
                            <tr>
                                <th class="wdt20" {if {$billsettingsData[40]->billsettingsvalue} eq 0} {else}
                                    style="display:none !important;" {/if}>رقم</th>
                                <th class="wdt120" {if {$billsettingsData[59]->billsettingsvalue} eq 0} {else}
                                    style="display:none" {/if}>الباركود</th>
                                <th class="wdt120">اسم المنتج</th>
                                <th class="wdt240" {if $billsettingsData[7]->billsettingsvalue eq 0} {else}
                                    style="display:none !important;" {/if}>ملاحظات</th>
                                <th class="wdt100n" {if {$billsettingsData[53]->billsettingsvalue} eq 0} {else}
                                    style="display:none !important" {/if}>الوحدة</th>

                                <th class="wdt100n" {if {$billsettingsData[64]->billsettingsvalue} eq 0} {else}
                                    style="display:none" {/if}>العدد</th>
                                <th
                                    class="wdt100n check_tr_unit  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    {$Programsettingdata->scunitname}</th>

                                <th class="wdt100n {if $usergroup->hideBillPrices == 1}hidden{/if}">السعر</th>
                                <!-- <th class="wdt100n {if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billsettingsData[57]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>الخصم</th> -->
                                <th class="wdt100n {if $usergroup->hideBillPrices == 1}hidden{/if}" {if
                                    {$billsettingsData[8]->billsettingsvalue} eq 0} {else} style="display:none"
                                    {/if}>الخصم</th>
                                <th class="wdt100n {if $usergroup->hideBillPrices == 1}hidden{/if}" {if
                                    {$billsettingsData[96]->billsettingsvalue} eq 0} {else} style="display:none"
                                    {/if}>ضريبة</th>
                                <th class="wdt100n {if $usergroup->hideBillPrices == 1}hidden{/if}">الاجمالى
                                    <input name="hidden_itr" id="hidden_itr" type="hidden" value="0" />
                                </th>

                            </tr>
                        </thead>
                        <tbody>
                            {foreach $buyBillDetails as $detail}
                            <tr class="aw_td" id="newProduct1">
                                <td {if {$billsettingsData[40]->billsettingsvalue} eq 0} {else} style="display:none
                                    !important;" {/if}>{$detail@iteration}</td>
                                <td {if $billsettingsData[59]->billsettingsvalue eq 0} {else} style="display:none
                                    !important;" {/if}>
                                    <div id="parcodeDiv1">
                                        <p class="form-control-static"> {$detail->parcode}
                                        </p>
                                    </div>
                                </td>

                                <td>
                                    <div id="productdiv1" class="aw_width aw_mt5">
                                        <p class="form-control-static">
                                            {$detail->productName} / {$detail->productCatName}
                                            {if {$billsettingsData[79]->billsettingsvalue} eq 0}
                                            {if isset($detail->sizeName) && $detail->sizeName
                                            !=""}/{$detail->sizeName}{/if}
                                            {if isset($detail->colorName) && $detail->colorName
                                            !=""}/{$detail->colorName}{/if}
                                            {/if}
                                        </p>

                                    </div>
                                </td>

                                <td {if $billsettingsData[7]->billsettingsvalue eq 0} {else} style="display:none
                                    !important;" {/if}>
                                    <p class="form-control-static">
                                        {$detail->note}
                                    </p>
                                </td>

                                <td {if {$billsettingsData[53]->billsettingsvalue} eq 0} {else} style="display:none
                                    !important" {/if}>
                                    <div id="unitDiv1">
                                        <p class="form-control-static">
                                            {$detail->unitName}
                                        </p>
                                    </div>
                                </td>
                                <td {if {$billsettingsData[64]->billsettingsvalue} eq 0} {else} style="display:none"
                                    {/if}><p class="form-control-static"> {$detail->buybilldetailquantity}</p>
                                </td>

                                <td
                                    class="check_tr_quantity  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    <p class="form-control-static"> {$detail->otherdetailquantity}</p>
                                </td>

                                <td class="{if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    <div id="propricechange1">
                                        <p class="form-control-static"> {$detail->buybilldetailprice}</p>
                                    </div>
                                </td>


                                <!-- <td class="{if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billsettingsData[57]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                                    <p class="form-control-static"> {$detail->discountvalue}</p></td> -->

                                <td class="{if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billsettingsData[8]->
                                    billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                                    <p class="form-control-static"> {$detail->discountvalue}</p>
                                </td>

                                <td class="{if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billsettingsData[96]->
                                    billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                                    <p class="form-control-static"> {$detail->rowtaxper}%</p>
                                </td>

                                <td class="aw_totalprice {if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    <div id="prototal1" class="aw_mt">
                                        <p class="form-control-static">
                                            {$detail->buybilldetailtotalprice}
                                        </p>
                                    </div>
                                </td>
                            </tr>
                            {/foreach}
                        </tbody>
                    </table>
                </div>
                <!--        <button type="button" class="btn btn-primary pull-left ft-nor"> إجمالي المشتريات <span class="badge wht-clo"><div id="buyBillTotal">0</div></span></button>
                -->
            </div>
            <!-- end of second row-->
            <!-- =========================== END BUY BILL PANEL ==================== -->


            <!-- =========================== START TOTAL VALUES PANEL ======================= -->
            <div class="row">
                <div class="col-lg-9">
                    <div class="form-group mg-bt5">
                        <!--{if {$billsettingsData[58]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}-->
                        <label class="col-lg-5 control-label ">المرفقات</label>
                        <div class="col-lg-7">
                            {assign var=i value=1}
                            {foreach $buyBillData->filesArr as $file}
                            {if $file != "" && $file !="." && $file !="no image"}
                            <a href="../upload/buyBillFiles/{$file}" target="_blank" style="color: blue;"> ({$i}) </a>
                            {assign var=i value=$i+1}
                            {/if}
                            {/foreach}
                        </div>
                    </div>
                </div>
                <div class="col-lg-3">
                    <hr />
                    <div class="form-group mg-bt5" {if {$billsettingsData[58]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-5 control-label">عدد القطع</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="totalQty">{$countBillDetails}</p>
                        </div>
                    </div><!-- end of form-group-->

                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}">
                        <label class="col-lg-5 control-label">الاجمالى العام</label>
                        <div class="col-lg-7">


                            <p class="form-control-static" id="gentotal">{$buyBillData->buybilltotalbill}</p>
                        </div>
                    </div><!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}" {if
                        {$billsettingsData[57]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label">نوع الخصم</label>
                        <div class="col-lg-7">
                            <p class="form-control-static">
                                {if $buyBillData->buybilldiscountrype eq 0}
                                خصم مباشر
                                {else}
                                خصم بنسبه مئويه
                                {/if}
                            </p>
                        </div>
                    </div><!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}" {if
                        {$billsettingsData[57]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label">قيمة الخصم</label>
                        <div class="col-lg-7">
                            <p class="form-control-static">
                                {$buyBillData->buybilldiscount}
                            </p>
                        </div>
                    </div><!-- end of form-group-->


                    <!------------------------------------------------------>
                    <div {if {$billsettingsData[36]->billsettingsvalue} eq "0"} {else} style="display:none" {/if}>
                        <hr class="mg-tp5 mg-bt5" />
                        <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}">
                            <label class="col-lg-5 control-label">ضريبه القيمة المضافة</label>
                            <div class="col-lg-7">

                                <div class="input-group">
                                    {$buyBillData->payedtax} %
                                </div>
                                <div class="input-group" style="padding-top: 1px;">
                                    {$taxvalue}
                                    {$Programsettingdata->currancy}
                                </div>
                            </div>
                        </div>


                    </div>
                    <!------------------------------------------------------->


                    <hr class="mg-tp5 mg-bt5" />
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}" {if
                        {$billsettingsData[51]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label">الصافى </label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="gen2total">{$buyBillData->buybillaftertotalbill}</p>
                        </div>
                    </div><!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}" {if
                        {$billsettingsData[54]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label">المدفوع</label>
                        <div class="col-lg-7">
                            <p class="form-control-static">
                                {$buyBillData->buybilltotalpayed} </p>
                        </div>
                    </div><!-- end of form-group-->
                    <hr class="mg-tp5 mg-bt5" />
                    <div class="form-group mg-bt5 bg-yel {if $usergroup->hideBillPrices == 1}hidden{/if}" {if
                        {$billsettingsData[55]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label">المتبقى</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="gen3total">{$buyBillData->buybillfinalbill}</p>
                        </div>
                    </div><!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}">
                        <label class="col-lg-5 control-label">باقى الدين</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="gen4total">{$buyBillData->buybilltotaldeptafter}</p>
                        </div>
                    </div><!-- end of form-group-->
                </div><!-- end of totals center-->
            </div><!-- end of fourth row-->


            <div class="row hidden-print">
                <!--                <button type="submit"  class="btn btn-primary">رجوع</button>-->
                {if {$Programsettingdata->printingpapersize} eq 0}
                <button type="button" onClick="print_Custom('mycustomheader');" class="btn btn-info">طباعة</button>
                {/if}
                {if {$buyBillData->deletedbuyid} > 0 && {$buyBillData->deletedbuyid} <> NULL &&
                    {$buyBillData->deletedbuyid} <> ''}
                        <a target="_new"
                            href="{$buyBillData->controlname}?do=editprint&id={$buyBillData->deletedbuyid}">
                            <button type="button" class="btn btn-primary">الايصال القديم</button></a>
                        {/if}
                        <input name="buybillid" id="buybillid" type="hidden" value="{$buyBillData->buybillid}" />
                        {if {$Programsettingdata->printingpapersize} eq 1}
                        <a target="_new" href="buyBillprintController.php?do=editprint&id={$buyBillData->buybillid}">
                            <button type="button" class="btn btn-info">طباعه ايصال</button></a>
                        {/if}

                        <a href="buyBillController.php?do=addoneserial&id={$buyBillData->buybillid}&type=2"
                            type="button"> <button type="button" class="btn btn-info">تكويد المنتجات</button></a>

                        <a href="buyBillController.php?do=addserial&id={$buyBillData->buybillid}&type=2" type="button">
                            <button type="button" class="btn btn-info">تكويد منتجات متعدد</button></a>

                        <a href="productController.php?do=showbarcodebuybill&buybillid={$buyBillData->buybillid}&type=2"
                            type="button">
                            <button type="button" class="btn btn-info">طباعة باركود الفاتورة</button>
                        </a>
            </div><!-- end of fifth row-->

            <!-- =========================== END TOTAL VALUESPANEL ====================== -->
        </form>


    </div>
</div>