<?php /* Smarty version Smarty-3.1.11, created on 2023-11-07 23:28:52
         compiled from "../views/default/salesreportbillsview/show.html" */ ?>
<?php /*%%SmartyHeaderCode:596972582654aac14227996-83312519%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '15feac36597b5f52d46479410c67651f46966302' => 
    array (
      0 => '../views/default/salesreportbillsview/show.html',
      1 => 1693253994,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '596972582654aac14227996-83312519',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'youtubes' => 0,
    'Programsettingdata' => 0,
    'Usergroupdata' => 0,
    'clients' => 0,
    'data' => 0,
    'user' => 0,
    'storeData' => 0,
    'store' => 0,
    'branchData' => 0,
    'branch' => 0,
    'sellerData' => 0,
    'userData' => 0,
    'storeIdS' => 0,
    'branchIdS' => 0,
    'selleridS' => 0,
    'useridS' => 0,
    'clientidS' => 0,
    'billidS' => 0,
    'billserialS' => 0,
    'billtypeS' => 0,
    'obgyBillTypeS' => 0,
    'message' => 0,
    'allDataArr' => 0,
    'totalsObj' => 0,
    'currency' => 0,
    'searchtype' => 0,
    'i' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.11',
  'unifunc' => 'content_654aac1480c7d6_59135006',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_654aac1480c7d6_59135006')) {function content_654aac1480c7d6_59135006($_smarty_tpl) {?><style>
    .myresult {
        -webkit-print-color-adjust: exact;
    }
    .nodata{
        background-color: #72B4EC;
        color: white;
        border-radius: 13px;
        margin: 14px;
        font-size: 24px;
        text-align: center;
        padding: 5px;
    }
    table.dataTable thead .sorting:after, table.dataTable thead .sorting_asc:after, table.dataTable thead .sorting_desc:after, table.dataTable thead .sorting_asc_disabled:after, table.dataTable thead .sorting_desc_disabled:after{
        display: none;
    }
    @media print {
        {
            width: 10px !important;
        }
    }

</style>
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">التقارير</a></li>
            <li class="active">تقرير فواتير المبيعات</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">تقرير فواتير المبيعات
                <a href="<?php echo $_smarty_tpl->tpl_vars['youtubes']->value[133]->url;?>
" target="_blank" class="hidden-print"><img src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube" style="width: 2%;"></a>
            </div>
            <div class="panel-body">
                <input type="hidden" id="searchvalue" value="<?php echo $_smarty_tpl->tpl_vars['Programsettingdata']->value->searchvalue;?>
">
                <input type="hidden" name="withNakdi" id="withNakdi" value="<?php echo $_smarty_tpl->tpl_vars['Usergroupdata']->value->showClientAndSupplierOne;?>
"/>
                <form class="form-inline hidden-print" action="salesreportbills.php" method="post" id="salesreportbills-form">
                    <div class="form-group" style="width: 30%;">
                        <label class="sr-only">العملاء</label>
                        <input type="hidden" name="clientid" id="clientid" class="select2Supp"/>
                        <input type="hidden" name="oldsupplierid" id="oldsupplierid" value=""/>
                        <input type="hidden" name="oldsuppliername" id="oldsuppliername" value=""/>
                        <!--                        <select class="select2 "  name="clientid" id="clientid" >
                                                    <option value="-1">اختر عميل</option>
                                                    <option value="0">كل العملاء</option>
                                                    <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['clients']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['data']->key => $_smarty_tpl->tpl_vars['data']->value){
$_smarty_tpl->tpl_vars['data']->_loop = true;
?>
                                                    <option value="<?php echo $_smarty_tpl->tpl_vars['data']->value->clientid;?>
"><?php echo $_smarty_tpl->tpl_vars['data']->value->clientname;?>
</option>
                                                    <?php } ?>
                                                </select>-->
                    </div>
                    <div class="form-group">
                        <label class="sr-only">التسلسل</label>
                        <input type="text" class="form-control" name="billid" >
                    </div>
                    <div class="form-group">
                        <label class="sr-only">رقم الفاتورة</label>
                        <input type="text" class="form-control" name="billserial" >
                    </div>
                    <div style="clear: both"></div>
                    <br />
                    <?php if ($_smarty_tpl->tpl_vars['user']->value->userstoreid==0){?>
                    <div class="form-group">
                        <label class="sr-only">المخزن</label>
                        <select class="select2 "  name="storeId" id="storeId" >
                            <option value="-1">اختر مخزن</option>
                            <option value="0">كل المخازن</option>
                            <?php  $_smarty_tpl->tpl_vars['store'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['store']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['storeData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['store']->key => $_smarty_tpl->tpl_vars['store']->value){
$_smarty_tpl->tpl_vars['store']->_loop = true;
?>
                            <option value="<?php echo $_smarty_tpl->tpl_vars['store']->value->storeId;?>
"><?php echo $_smarty_tpl->tpl_vars['store']->value->storeName;?>
</option>
                            <?php } ?>
                        </select>
                    </div>
                    <?php }?>
                    <?php if ($_smarty_tpl->tpl_vars['user']->value->branchId==0){?>
                    <div class="form-group">
                        <label class="sr-only">الفرع</label>
                        <select class="select2 "  name="branchId" id="branchId" >
                            <option value="-1">اختر الفرع</option>
                            <option value="0">كل الفروع</option>
                            <?php  $_smarty_tpl->tpl_vars['branch'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['branch']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['branchData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['branch']->key => $_smarty_tpl->tpl_vars['branch']->value){
$_smarty_tpl->tpl_vars['branch']->_loop = true;
?>
                            <option value="<?php echo $_smarty_tpl->tpl_vars['branch']->value->branchId;?>
"><?php echo $_smarty_tpl->tpl_vars['branch']->value->branchName;?>
</option>
                            <?php } ?>
                        </select>
                    </div>
                    <?php }?>
                    <div class="form-group">
                        <label class="sr-only"><?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==0){?> بائع <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==1){?>مندوب <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==2){?>طبيب <?php }?></label>
                        <select class="select2 "  name="sellerid" id="sellerid" >
                            <option value="-1">اختر <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==0){?> بائع <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==1){?>مندوب <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==2){?>طبيب <?php }?></option>
                            <option value="0"><?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==0){?> البائعين <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==1){?>المندوبين <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==2){?>الاطباء <?php }?></option>
                            <?php  $_smarty_tpl->tpl_vars['user'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['user']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['sellerData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['user']->key => $_smarty_tpl->tpl_vars['user']->value){
$_smarty_tpl->tpl_vars['user']->_loop = true;
?>
                            <option value="<?php echo $_smarty_tpl->tpl_vars['user']->value->userid;?>
"><?php echo $_smarty_tpl->tpl_vars['user']->value->employeename;?>
</option>
                            <?php } ?>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">المستخدم</label>
                        <select class="select2 "  name="userid" id="userid" >
                            <option value="-1">اختر المستخدم</option>
                            <option value="0">كل المستخدمين</option>
                            <?php  $_smarty_tpl->tpl_vars['user'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['user']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['userData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['user']->key => $_smarty_tpl->tpl_vars['user']->value){
$_smarty_tpl->tpl_vars['user']->_loop = true;
?>
                            <option value="<?php echo $_smarty_tpl->tpl_vars['user']->value->userid;?>
"><?php echo $_smarty_tpl->tpl_vars['user']->value->employeename;?>
</option>
                            <?php } ?>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">نوع الفاتورة</label>
                        <select class="select2 "  name="billtype" id="billtype" >
                            <option value="-1">اختر النوع</option>
                            <option value="1">مبيعات فقط</option>
                            <option value="2">مرتجعات فقط</option>
                            <option value="3">مبيعات و مرتجعات</option>
                            <option value="4">مبيعات بصريات</option>
                            <option value="5">مرتجعات بصريات</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">نوع الفاتورة</label>
                        <div  class="input-group" style="display: block">
                            <label>  <input value="1" name="obgyBillType" id="obgyBillType" type="radio">
                                مباشر</label>
                            <label>
                                <input value="2" name="obgyBillType" id="obgyBillType" type="radio">
                                مستهلك</label>
                            <label>
                                <input value="3" name="obgyBillType" id="obgyBillType" type="radio">
                                استقبال</label>
                        </div>
                    </div>
                    <div style="clear: both"></div>
                    <br />
                    <div class="form-group">
                        <label class="sr-only">من التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" name="datefrom" >
                    </div>
                    <div class="form-group">
                        <label class="sr-only">إلى التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" name="dateto" >
                    </div>
                    <div class="form-group">
                        <div><label class="sr-only">مجمل يوم</label></div>
                        <div class="radio-inline">
                            <input value="1" name="searchtype"  type="checkbox"/>
                        </div>
                    </div>

                    <div style="clear: both"></div>
                    <br />
                    <button type="submit" class="btn btn-primary">بحث</button>

                    <input type="hidden" name="storeIdS" value="<?php echo $_smarty_tpl->tpl_vars['storeIdS']->value;?>
"/>
                    <input type="hidden" name="branchIdS" value="<?php echo $_smarty_tpl->tpl_vars['branchIdS']->value;?>
"/>
                    <input type="hidden" name="selleridS" value="<?php echo $_smarty_tpl->tpl_vars['selleridS']->value;?>
"/>
                    <input type="hidden" name="useridS" value="<?php echo $_smarty_tpl->tpl_vars['useridS']->value;?>
"/>
                    <input type="hidden" name="clientidS" value="<?php echo $_smarty_tpl->tpl_vars['clientidS']->value;?>
"/>
                    <input type="hidden" name="billidS" value="<?php echo $_smarty_tpl->tpl_vars['billidS']->value;?>
"/>
                    <input type="hidden" name="billserialS" value="<?php echo $_smarty_tpl->tpl_vars['billserialS']->value;?>
"/>
                    <input type="hidden" name="billtypeS" value="<?php echo $_smarty_tpl->tpl_vars['billtypeS']->value;?>
"/>
                    <input type="hidden" name="obgyBillTypeS" value="<?php echo $_smarty_tpl->tpl_vars['obgyBillTypeS']->value;?>
"/>
                    <input type="hidden" name="day" id="day" value=""/>
                </form>

            </div>
            <div class="panel panel-default panel-m">
                <!-- Default panel contents -->
                <div class="panel-heading"><?php echo $_smarty_tpl->tpl_vars['message']->value;?>
</div>
                <div class="panel-body" style="overflow-x: auto;">
                    <?php if (count($_smarty_tpl->tpl_vars['allDataArr']->value)>0){?>
                    <hr/>
                    <div class="col-lg-offset-8 col-lg-4">
                        <div class="well well-sm">
                            <h4 class="text-center">صافى الربح <?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->billProfit;?>
 <?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</h4>
                        </div>
                    </div>
                    <style>
                        @media print {
                            @page {
                                size: landscape;
                                margin: 0;
                            }
                            .willprint ,.willprint td,.willprint th {
                                padding:  0px !important;
                                font-family: arial;
                                font-size: 10px;
                                border-collapse: collapse;
                                border: 1px solid #333 !important;
                            }
                            .willprint th{
                                background: #aaa !important;
                            }
                            .willprint tr:even-child td{
                                background: #333 !important;
                                color: #fff !important;
                            }
                        }
                    </style>
                    <?php if ($_smarty_tpl->tpl_vars['searchtype']->value=="0"){?>
                    <table class="dataTableClass willprint table-black" style="width: 100%">
                        <thead>
                            <tr>
                                <th>م</th>
                                <!--<th>  التسلسل</th>-->
                                <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['Programsettingdata']->value->billid;?>
<?php $_tmp1=ob_get_clean();?><?php if ($_tmp1!=1){?><th><center>رقم الفاتورة</center></th><?php }?>
                        <th><center>  نوع الفاتورة</center></th>
                        <th><center>اجمالى الفاتورة</center></th>
                        <th><center>عدد القطع</center></th>
                        <th><center>تاريخ الفاتورة ووقتها</center></th>
                        <th><center>خصم الفاتورة</center></th>
                        <th><center>خصومات الشبكة</center></th>
                        <th><center>ربح الفاتورة</center></th>
                        <th><center>العميل</center></th>
                        <th><center>البائع</center></th>
                        <th><center>المستخدم</center></th>
                        <th class="hidden-print"><center>تفاصيل الفاتورة</center></th>
                        </tr>
                        </thead>
                        <tbody>
                            <?php $_smarty_tpl->tpl_vars['i'] = new Smarty_variable(1, null, 0);?>
                            <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allDataArr']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['data']->key => $_smarty_tpl->tpl_vars['data']->value){
$_smarty_tpl->tpl_vars['data']->_loop = true;
?>
                            <tr>
                                <td><?php echo $_smarty_tpl->tpl_vars['i']->value;?>
</td>
                                <!--<td><?php echo $_smarty_tpl->tpl_vars['data']->value->billno;?>
</td>-->
                                <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['Programsettingdata']->value->billid;?>
<?php $_tmp2=ob_get_clean();?><?php if ($_tmp2!=1){?><td><center><?php echo $_smarty_tpl->tpl_vars['data']->value->billserial;?>
</center></td><?php }?>
                        <td><center><?php echo $_smarty_tpl->tpl_vars['data']->value->billtype;?>
</center></td>
                        <td><center><?php echo $_smarty_tpl->tpl_vars['data']->value->totalbill;?>
</center></td>
                        <td><center><?php echo $_smarty_tpl->tpl_vars['data']->value->noOfpieces;?>
</center></td>
                        <td><center><?php echo $_smarty_tpl->tpl_vars['data']->value->datetime;?>
</center></td>
                        <td><center><?php echo $_smarty_tpl->tpl_vars['data']->value->billdiscount;?>
</center></td>
                        <td><center><?php echo $_smarty_tpl->tpl_vars['data']->value->networkDiscount;?>
</center></td>
                        <td><center><?php echo $_smarty_tpl->tpl_vars['data']->value->billProfit;?>
</center></td>
                        <td><center><?php echo $_smarty_tpl->tpl_vars['data']->value->clientName;?>
</center></td>
                        <td><center><?php echo $_smarty_tpl->tpl_vars['data']->value->sellerName;?>
</center></td>
                        <td><center><?php echo $_smarty_tpl->tpl_vars['data']->value->userName;?>
</center></td>
                        <td class="hidden-print"><center><a href="<?php echo $_smarty_tpl->tpl_vars['data']->value->billURL;?>
" target="_blank" type="button" class="btn btn-default btn-lg notesicon"></a></center></td>

                        </tr>
                        <?php $_smarty_tpl->tpl_vars['i'] = new Smarty_variable($_smarty_tpl->tpl_vars['i']->value+1, null, 0);?>
                        <?php } ?>
                        <tr>
                            <td><span style="display: none">z</span></td>
                            <td></td>
                            <th style="text-align: center;">الاجمالى</th>
                            <td><?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->totalbill;?>
</td>
                            <td><?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->noOfpieces;?>
</td>
                            <td></td>
                            <td><?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->billdiscount;?>
</td>
                            <td><?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->networkDiscount;?>
</td>
                            <td><?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->billProfit;?>
</td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td class="hidden-print"></td>
                        </tr>


                        </tbody>

                    </table>
                    <?php }else{ ?>
                    <table class="dataTableClass willprint table-black" style="width: 100%">
                        <thead>
                            <tr>
                                <th>م</th>
                                <th>تاريخ الفاتورة ووقتها</th>
                                <th>اجمالى الفاتورة</th>
                                <th>عدد القطع</th>
                                <th>خصم الفاتورة</th>
                                <th>خصومات الشبكة</th>
                                <th>ربح الفاتورة</th>

                                <th class="hidden-print">تفاصيل الفاتورة</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $_smarty_tpl->tpl_vars['i'] = new Smarty_variable(1, null, 0);?>
                            <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allDataArr']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['data']->key => $_smarty_tpl->tpl_vars['data']->value){
$_smarty_tpl->tpl_vars['data']->_loop = true;
?>
                            <tr>
                                <td><?php echo $_smarty_tpl->tpl_vars['i']->value;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['data']->value->datetime;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['data']->value->totalbill;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['data']->value->noOfpieces;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['data']->value->billdiscount;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['data']->value->networkDiscount;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['data']->value->billProfit;?>
</td>

                                <td class="hidden-print"><a data-day="<?php echo $_smarty_tpl->tpl_vars['data']->value->datetime;?>
" style="color: blue;" class="daydetail">التفاصيل</a></td>
                                <!--td class="hidden-print"><?php echo $_smarty_tpl->tpl_vars['data']->value->billURL;?>
</td-->
                            </tr>
                            <?php $_smarty_tpl->tpl_vars['i'] = new Smarty_variable($_smarty_tpl->tpl_vars['i']->value+1, null, 0);?>
                            <?php } ?>
                            <tr>
                                <td><span style="display: none">z</span></td>
                                <th style="text-align: center;">الاجمالى</th>
                                <td><?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->totalbill;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->noOfpieces;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->billdiscount;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->networkDiscount;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->billProfit;?>
</td>
                                <td class="hidden-print"></td>
                            </tr>


                        </tbody>

                    </table>
                    <?php }?>

                    <div class="col-lg-offset-8 col-lg-4">
                        <div class="well well-sm">
                            <h4 class="text-center">صافى الربح <?php echo $_smarty_tpl->tpl_vars['totalsObj']->value->billProfit;?>
 <?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</h4>
                        </div>
                    </div>

                    <div class="clearfix"></div>
                    <hr />
                    <!--div  class="noprint">
                        <div class="col-lg-12">
                            <div class="form-group">
                                <div class="col-lg-4">
                                    <button type="button" onclick="print_Custom('mycustomheader');" class="btn btn-success pull-right hidden-print">طباعة</button>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                    </div-->
                    <?php }else{ ?>
                    <div class="nodata">عفوا لا توجد نتائج</div>
                    <?php }?>

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



<script>
    $(document).ready(function () {
        $('.daydetail').on('click', function () {
            var day = $(this).attr('data-day');
            $('#day').val(day);
            $('#salesreportbills-form').attr("target", "_blank");
            $('#salesreportbills-form').submit();
            $('#day').val("");
            $('#salesreportbills-form').removeAttr("target");
        });
    });
    $(function () {
        $(".select2Supp").select2({
            placeholder: "العميل",
            minimumInputLength: document.getElementById("searchvalue").value,
            inimumInputLength: 0,
            multiple: false,
            quietMillis: 100,
            //width: '80%',
            ajax: {
                url: "clientControllerAjax.php?do=select2ClientsAjax",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 7, // page size
                        withAddOption: 0,
                        withNakdi: function () {
                            return (Number($('#withNakdi').val()) == 1) ? 0 : 1;
                        },
                        //jsonRowRet: 1,
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: function (data) {
                if (Number(data.id) == -2) {
                    return  '<span class="newoption">' + data.text + '</span >';
                } else {
                    return  '<span>' + data.text + '</span >';
                }
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                //  var data = {id: item[0], text: item[1]};
                var data = {id: item[0], text: item[1], productquantity: item[2], price: item[3]};
                callback(data);
            },
            //dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
        })
        //this is needed for ajax =>to obtain id from it  and use in ajax
        $('#clientid').select2('data', {id: $('#oldsupplierid').val(), text: $('#oldsuppliername').val()});
    });
</script>

<?php }} ?>