<?php /* Smarty version Smarty-3.1.11, created on 2024-07-23 15:31:16
         compiled from "..\views\default\buyBillview\addoneseria.html" */ ?>
<?php /*%%SmartyHeaderCode:21309669fa294a47216-85962945%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '527e134ee0d91d2acfcc1b99bf4ba0da30787007' => 
    array (
      0 => '..\\views\\default\\buyBillview\\addoneseria.html',
      1 => 1672089199,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '21309669fa294a47216-85962945',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'billnameid' => 0,
    'billsettingsData' => 0,
    'buyBillData' => 0,
    'countmyusedserial' => 0,
    'detail' => 0,
    'buyBillDetails' => 0,
    'x' => 0,
    'foo' => 0,
    'm' => 0,
    'z' => 0,
    'countBillDetails' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.11',
  'unifunc' => 'content_669fa294cf7201_35955278',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_669fa294cf7201_35955278')) {function content_669fa294cf7201_35955278($_smarty_tpl) {?><script>
    function gettotal(i)
    {

    var totalproduct = Number(document.getElementById('totalproduct' + i + '').value);
            // alert(totalproduct);
            var mytotal = 0;
            for (var x = 1; x <= totalproduct; x++)
    {
    // alert('quantity'+x+i+'');
    //alert (document.getElementById('quantity'+x+i+'').value);
    var quantity = Number(document.getElementById('quantity' + x + i + '').value);
            // alert('tt'+tt);
            mytotal = mytotal + quantity;
            // alert('mytotal'+mytotal);
            if (mytotal > totalproduct)
    {
    //alert('in if')
    alert('من فضلك  عدل اعددا المنتجات لتصل الى ' + totalproduct);
            document.getElementById("subbtn").style.display = "none";
            break;
    }
    else
    {
    //alert('in else')
    document.getElementById("subbtn").style.display = "block";
    }
    }

    }

    function deleteitr(id)
    {

    // delete by parents
    $("#serialnumber" + id).parent().parent().remove();
            return false;
    }
</script>

<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>فاتورة المشتريات</h3>
        <hr/>
        <form class="form-horizontal" role="form" action="buyBillController.php?do=saveserail" method="post" id="billform">

            <!-- =========================== START BUY BILL SETTINGS ================================== -->
            <input type="hidden" name="billnameid" id="billnameid" value="<?php echo $_smarty_tpl->tpl_vars['billnameid']->value;?>
"/>
            <input type="hidden" name="returnBillSetting" id="returnBillSetting" value="<?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[0]->billsettingsvalue;?>
"/>
            <input type="hidden" name="storeSetting" id="storeSetting" value="<?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[2]->billsettingsvalue;?>
"/>
            <input type="hidden" name="parcodeSetting" id="parcodeSetting" value="<?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[4]->billsettingsvalue;?>
"/>
            <input type="hidden" name="dateSetting" id="dateSetting" value="<?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[5]->billsettingsvalue;?>
"/>
            <input type="hidden" name="newProductSetting" id="newProductSetting" value="<?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[6]->billsettingsvalue;?>
"/>
            <input type="hidden" name="noteSetting" id="noteSetting" value="<?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[7]->billsettingsvalue;?>
"/>

            <!-- ==========================  END BUY BILL SETTINGS ============================ -->

            <!-- =========================== START GENERAL INFO PANEL =====================-->
            <div class="row">
                <div class="col-lg-8">
                    <div class="form-group" <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[61]->billsettingsvalue;?>
<?php $_tmp1=ob_get_clean();?><?php if ($_tmp1==0){?>  <?php }else{ ?> style="display:none !important" <?php }?>>
                        <label class="col-lg-4 control-label">رقم  الفاتورة</label>
                        <div class="col-lg-4">
                            <?php echo $_smarty_tpl->tpl_vars['buyBillData']->value->buybillSerial;?>

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

                    <div class="form-group"  <?php if ($_smarty_tpl->tpl_vars['billsettingsData']->value[5]->billsettingsvalue==0){?> style="display:block !important;" <?php }else{ ?> style="display:none !important;" <?php }?>>
                        <label class="col-lg-4 control-label">تاريخ الفاتورة</label>
                        <div class="col-lg-4">
                            <?php echo $_smarty_tpl->tpl_vars['buyBillData']->value->buybilldate;?>

                        </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">
                            <div id="supplierIdDiv">   <?php echo $_smarty_tpl->tpl_vars['buyBillData']->value->suppliername;?>

                                <input type="hidden" name="buybillid" id="buybillid" value="<?php echo $_smarty_tpl->tpl_vars['buyBillData']->value->buybillid;?>
"/> </div>
                        </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">
                            <div id="debt" class="form-control-static"> </div>
                            <?php echo $_smarty_tpl->tpl_vars['buyBillData']->value->buybilltotaldeptbefor;?>
</div>
                    </div>
                    <!-- end of form-group-->
                    <hr class="mg-bt5 mg-tp5"/>
                    <div class="form-group mg-bt5"   <?php if ($_smarty_tpl->tpl_vars['billsettingsData']->value[2]->billsettingsvalue==0){?> style="display:block !important;" <?php }else{ ?> style="display:none !important;" <?php }?>>
                        <label class="col-lg-4 control-label">المخزن</label>
                        <div class="col-lg-8">
                            <?php echo $_smarty_tpl->tpl_vars['buyBillData']->value->storeName;?>

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

                    <!-- end of form-group-->
                </div>
                <!-- end of client info-->

            </div>
            <!-- =========================== END GENERAL INFO PANEL ====================== -->
            <input name="countmyusedserial"  value="<?php echo $_smarty_tpl->tpl_vars['countmyusedserial']->value;?>
" type="hidden" />
            <!-- =========================== 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 class="aw_td" id="newProduct1" style="background:#A3B0B1" >

                               <td colspan="4">
                                 <div id="productdiv1" class="aw_width aw_mt5">



                                 اسم المنتج: <?php echo $_smarty_tpl->tpl_vars['detail']->value->productName;?>
 / <?php echo $_smarty_tpl->tpl_vars['detail']->value->productCatName;?>




                                 </div>
                               </td>


                             </tr>
                             <tr>
                                <th>السيريال</th>
                                <th>التعليق</th>
                                <th>تاريخ البدايه</th>
                                <th>تاريخ النهايه</th>
                             </tr-->


                        </thead>
                        <tbody>
                            <?php $_smarty_tpl->tpl_vars['x'] = new Smarty_variable(1, null, 0);?>
                            <?php  $_smarty_tpl->tpl_vars['detail'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['detail']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['buyBillDetails']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['detail']->key => $_smarty_tpl->tpl_vars['detail']->value){
$_smarty_tpl->tpl_vars['detail']->_loop = true;
?>
                            <tr class="aw_td" id="newProduct1" style="background:#A3B0B1" >

                                <td colspan="5">
                                    <div id="productdiv1" class="aw_width aw_mt5">



                                        اسم المنتج: <?php echo $_smarty_tpl->tpl_vars['detail']->value->productName;?>
 / <?php echo $_smarty_tpl->tpl_vars['detail']->value->productCatName;?>

                                        <?php if ($_smarty_tpl->tpl_vars['detail']->value->sizeName!=''){?> / <?php echo $_smarty_tpl->tpl_vars['detail']->value->sizeName;?>
<?php }?>
                                        <?php if ($_smarty_tpl->tpl_vars['detail']->value->colorName!=''){?> / <?php echo $_smarty_tpl->tpl_vars['detail']->value->colorName;?>
<?php }?>
                                        ------------العدد:<?php echo $_smarty_tpl->tpl_vars['totalproduct'.($_smarty_tpl->tpl_vars['x']->value)]->value;?>




                                    </div>
                                </td>


                            </tr>
                            <tr>
                                <th>السيريال</th>
                                <th>الكميه</th>
                                <th>التعليق</th>
                                <th>تاريخ البدايه</th>
                                <th>تاريخ النهايه</th>
                            </tr>

                        <input name="productid<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['detail']->value->buybilldetailproductid;?>
">
                        <input name="sizeid<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['detail']->value->sizeid;?>
">
                        <input name="colorid<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['detail']->value->colorid;?>
">
                        <input name="productid<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['detail']->value->buybilldetailproductid;?>
">
                        <input name="buybilldetailid<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['detail']->value->buybilldetailid;?>
">
                        <input name="totalproduct<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
"  id="totalproduct<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['totalproduct'.($_smarty_tpl->tpl_vars['x']->value)]->value;?>
">

                        <tr>
                            <td  colspan="5">
                                <table width="100%" class="table-black">
                                    <?php if (empty($_smarty_tpl->tpl_vars['allseraildata'.($_smarty_tpl->tpl_vars['x']->value)]->value)){?>
                                    <?php $_smarty_tpl->tpl_vars['m'] = new Smarty_variable(1, null, 0);?>
                                    <?php $_smarty_tpl->tpl_vars['foo'] = new Smarty_Variable;$_smarty_tpl->tpl_vars['foo']->step = 1;$_smarty_tpl->tpl_vars['foo']->total = (int)ceil(($_smarty_tpl->tpl_vars['foo']->step > 0 ? $_smarty_tpl->tpl_vars['totalproductx'.($_smarty_tpl->tpl_vars['x']->value)]->value+1 - (1) : 1-($_smarty_tpl->tpl_vars['totalproductx'.($_smarty_tpl->tpl_vars['x']->value)]->value)+1)/abs($_smarty_tpl->tpl_vars['foo']->step));
if ($_smarty_tpl->tpl_vars['foo']->total > 0){
for ($_smarty_tpl->tpl_vars['foo']->value = 1, $_smarty_tpl->tpl_vars['foo']->iteration = 1;$_smarty_tpl->tpl_vars['foo']->iteration <= $_smarty_tpl->tpl_vars['foo']->total;$_smarty_tpl->tpl_vars['foo']->value += $_smarty_tpl->tpl_vars['foo']->step, $_smarty_tpl->tpl_vars['foo']->iteration++){
$_smarty_tpl->tpl_vars['foo']->first = $_smarty_tpl->tpl_vars['foo']->iteration == 1;$_smarty_tpl->tpl_vars['foo']->last = $_smarty_tpl->tpl_vars['foo']->iteration == $_smarty_tpl->tpl_vars['foo']->total;?>

                                    <tr>
                                        <td><input name="serialnumber<?php echo $_smarty_tpl->tpl_vars['foo']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
"  value="<?php echo $_smarty_tpl->tpl_vars['returnedSerial'.($_smarty_tpl->tpl_vars['x']->value).($_smarty_tpl->tpl_vars['m']->value)]->value;?>
"  type="text"></td>
                                        <td><input name="quantity<?php echo $_smarty_tpl->tpl_vars['foo']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" id="quantity<?php echo $_smarty_tpl->tpl_vars['foo']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
"  value="<?php echo $_smarty_tpl->tpl_vars['totalproduct'.($_smarty_tpl->tpl_vars['x']->value)]->value;?>
"   type="text" onkeyup="gettotal(<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
);"></td>
                                        <td><textarea name="comment<?php echo $_smarty_tpl->tpl_vars['foo']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
"></textarea></td>
                                        <td><input name="stratdate<?php echo $_smarty_tpl->tpl_vars['foo']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" type="text" class="stratdate"></td>
                                        <td><input name="enddate<?php echo $_smarty_tpl->tpl_vars['foo']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
"  type="text" class="enddate"></td>
                                    </tr>
                                    <?php $_smarty_tpl->_capture_stack[0][] = array('default', 'm', null); ob_start(); ?><?php echo $_smarty_tpl->tpl_vars['m']->value+1;?>
<?php list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
if (!empty($_capture_buffer)) {
 if (isset($_capture_assign)) $_smarty_tpl->assign($_capture_assign, ob_get_contents());
 if (isset( $_capture_append)) $_smarty_tpl->append( $_capture_append, ob_get_contents());
 Smarty::$_smarty_vars['capture'][$_capture_buffer]=ob_get_clean();
} else $_smarty_tpl->capture_error();?>
                                    <?php }} ?>
                                    <?php }else{ ?>
                                    <?php $_smarty_tpl->tpl_vars['z'] = new Smarty_variable(1, null, 0);?>
                                    <?php  $_smarty_tpl->tpl_vars['myallseraildata'.($_smarty_tpl->tpl_vars['x']->value)] = new Smarty_Variable; $_smarty_tpl->tpl_vars['myallseraildata'.($_smarty_tpl->tpl_vars['x']->value)]->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allseraildata'.($_smarty_tpl->tpl_vars['x']->value)]->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['myallseraildata'.($_smarty_tpl->tpl_vars['x']->value)]->key => $_smarty_tpl->tpl_vars['myallseraildata'.($_smarty_tpl->tpl_vars['x']->value)]->value){
$_smarty_tpl->tpl_vars['myallseraildata'.($_smarty_tpl->tpl_vars['x']->value)]->_loop = true;
?>

                                    <tr>
                                        <td><input name="serialnumber<?php echo $_smarty_tpl->tpl_vars['z']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" id="serialnumber<?php echo $_smarty_tpl->tpl_vars['z']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" value="<?php echo $_smarty_tpl->tpl_vars['myallseraildata'.($_smarty_tpl->tpl_vars['x']->value)]->value->serialnumber;?>
"   type="text"></td>
                                        <td><input name="quantity<?php echo $_smarty_tpl->tpl_vars['z']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" id="quantity<?php echo $_smarty_tpl->tpl_vars['z']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
"   value="<?php echo $_smarty_tpl->tpl_vars['myallseraildata'.($_smarty_tpl->tpl_vars['x']->value)]->value->don;?>
" type="text" onkeyup="gettotal(<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
);"></td>
                                        <td><textarea name="comment<?php echo $_smarty_tpl->tpl_vars['z']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
"><?php echo $_smarty_tpl->tpl_vars['myallseraildata'.($_smarty_tpl->tpl_vars['x']->value)]->value->comment;?>
</textarea></td>
                                        <td><input name="stratdate<?php echo $_smarty_tpl->tpl_vars['z']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" value="<?php echo $_smarty_tpl->tpl_vars['myallseraildata'.($_smarty_tpl->tpl_vars['x']->value)]->value->startdate;?>
"  type="text" class="stratdate"></td>
                                        <td><input name="enddate<?php echo $_smarty_tpl->tpl_vars['z']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
"  value="<?php echo $_smarty_tpl->tpl_vars['myallseraildata'.($_smarty_tpl->tpl_vars['x']->value)]->value->enddate;?>
"  type="text" class="enddate"></td>
                                        <td> <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['countmyusedserial']->value;?>
<?php $_tmp2=ob_get_clean();?><?php if ($_tmp2>0){?>
                                            لا يمكن حذفه
                                            <?php }else{ ?>
                                            <input type="button" onclick="deleteitr(<?php echo $_smarty_tpl->tpl_vars['z']->value;?>
<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
)" value="حذف" />
                                            <?php }?>
                                        </td>
                                    </tr>
                                    <?php $_smarty_tpl->_capture_stack[0][] = array('default', 'z', null); ob_start(); ?><?php echo $_smarty_tpl->tpl_vars['z']->value+1;?>
<?php list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
if (!empty($_capture_buffer)) {
 if (isset($_capture_assign)) $_smarty_tpl->assign($_capture_assign, ob_get_contents());
 if (isset( $_capture_append)) $_smarty_tpl->append( $_capture_append, ob_get_contents());
 Smarty::$_smarty_vars['capture'][$_capture_buffer]=ob_get_clean();
} else $_smarty_tpl->capture_error();?>
                                    <?php } ?>
                                    <?php }?>
                                    <input name="totalproduct<?php echo $_smarty_tpl->tpl_vars['x']->value;?>
" value="<?php echo $_smarty_tpl->tpl_vars['totalproduct'.($_smarty_tpl->tpl_vars['x']->value)]->value;?>
" type="hidden">

                                </table>
                            </td>
                        </tr>
                        <?php $_smarty_tpl->_capture_stack[0][] = array('default', 'x', null); ob_start(); ?><?php echo $_smarty_tpl->tpl_vars['x']->value+1;?>
<?php list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
if (!empty($_capture_buffer)) {
 if (isset($_capture_assign)) $_smarty_tpl->assign($_capture_assign, ob_get_contents());
 if (isset( $_capture_append)) $_smarty_tpl->append( $_capture_append, ob_get_contents());
 Smarty::$_smarty_vars['capture'][$_capture_buffer]=ob_get_clean();
} else $_smarty_tpl->capture_error();?>
                        <?php } ?>



                        <input name="itr" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['countBillDetails']->value;?>
">
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- end of second row-->
            <!-- =========================== END BUY BILL PANEL ==================== -->





            <div class="row">
                <button type="submit"  id="subbtn" class="btn btn-primary">حفظ</button>
            </div><!-- end of fifth row-->

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


    </div>
</div><?php }} ?>