<?php /* Smarty version Smarty-3.1.11, created on 2023-10-14 16:20:53
         compiled from "../views/default/clientPayedDeptview/add.html" */ ?>
<?php /*%%SmartyHeaderCode:397483479652a95b5df8786-78446628%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '1b6d4d0c500a0736cde25737a3e14a42891e0a77' => 
    array (
      0 => '../views/default/clientPayedDeptview/add.html',
      1 => 1696193544,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '397483479652a95b5df8786-78446628',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'path' => 0,
    'clientidFromGET' => 0,
    'Programsettingdata' => 0,
    'clientsData' => 0,
    'data' => 0,
    'suppliersData' => 0,
    'allCostcenter' => 0,
    'myallCostcenter' => 0,
    'projectid' => 0,
    'userData' => 0,
    'allSave' => 0,
    'todayx' => 0,
    'clientnegative' => 0,
    'today' => 0,
    'currency' => 0,
    'allCurrency' => 0,
    'sellers' => 0,
    'bank' => 0,
    'b' => 0,
    'item' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.11',
  'unifunc' => 'content_652a95b6261783_19028190',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_652a95b6261783_19028190')) {function content_652a95b6261783_19028190($_smarty_tpl) {?><script>

    function checkserail() {
        var serail = document.getElementById("voucher").value;
        //alert(serail);
        //alert('clientPayedDeptControllerAjax.php.php?do=checkserail&serail='+serail);

        $.ajax({
            url: 'clientPayedDeptControllerAjax.php?do=checkserail&serail=' + serail,
            success: function (x) {
                //alert(x);

                if (x == '1') {

                    alert('عفوا هذا الرقم موجود من قبل');
                    document.getElementById("voucher").value = document.getElementById("oldvoucher").value;
                    //document.getElementById("subbtn").style.display='none';

                } else {
                    //document.getElementById("subbtn").style.display='block'
                }

            }
        });

    }


    function checkserailpremium() {
        var serail = document.getElementById("voucherpremium").value;
        //alert(serail);
        //alert('clientPayedDeptControllerAjax.php.php?do=checkserail&serail='+serail);

        $.ajax({
            url: 'clientPayedDeptControllerAjax.php?do=checkserail&serail=' + serail,
            success: function (x) {
                //alert(x);

                if (x == '1') {

                    alert('عفوا هذا الرقم موجود من قبل');
                    document.getElementById("voucherpremium").value = document.getElementById("oldvoucherpremium").value;
                    //document.getElementById("subbtn").style.display='none';

                } else {
                    //document.getElementById("subbtn").style.display='block'
                }

            }
        });

    }


</script>
<script src="<?php echo $_smarty_tpl->tpl_vars['path']->value;?>
/SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="<?php echo $_smarty_tpl->tpl_vars['path']->value;?>
/SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />


<style>
    @media (min-width: 768px) {
        .form-horizontal .form-group {
            margin-right: -10px;
            margin-left: -10px;
        }

        .m10 {
            margin: 10px
        }

        h4 {
            font-size: 17px;
            font-weight: bold;
            color: #000000;
            margin: 10px 0 15px;
            font-family: sans-serif;
        }

        hr {
            margin: 20px;
            border: 0;
            border-top: 2px solid #d7d7d7;

        }

        #myModal .card {
            box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
            padding: 10px;
            margin: 40px 0;
            border-radius: 5px
        }

    }

    .wdt230 {
        width: 230px
    }

    .billtable thead>tr>th {
        color: #eeecda;
        background-color: #0081a8;
    }

    .add i {
        font-size: 20px;
        color: #607D8B;
    }

    .wdt50 {
        width: 50px
    }

    .mt-10 {
        margin-top: 10px
    }

    .data-search {
        margin: 10px 15px 0;
    }

    .btn-dark {
        color: #fff;
        background-color: #636262;
        border-color: #646464;
    }

    .data-search .form-control {
        border-radius: 3px
    }
</style>

<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="clientPayedDeptController.php"><?php echo @PAYED_DEPT_GENERAL_FEATURES;?>
</a></li>
            <li><a href="clientPayedDeptController.php?do=show"><?php echo @PAYED_DEPT_CLIENTS;?>
</a></li>
            <!--<li><a href="supplierPayedDeptController.php?do=show">الموردين</a></li>-->
            <li class="active"> <?php echo @PAYED_DEPT_RECEIPT_RECEIPT_CLIENT;?>
 </li>
        </ol>
        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title"><?php echo @PAYED_DEPT_RECEIPT_RECEIPT_CLIENT;?>
</h3>
            </div>
            <div class="panel-body">
                <input type="hidden" name="clientidFromGET" id="clientidFromGET" value="<?php echo $_smarty_tpl->tpl_vars['clientidFromGET']->value;?>
" />
                <form id="myform" class="form-horizontal" role="form" action="clientPayedDeptController.php?do=add"
                      method="post">
                    <!--<form id="submitnew" class="form-horizontal" role="form" action="clientPayedDeptController.php?do=add" method="post">-->
                    <div class="form-group" style="display: none">
                        <label class="col-lg-2 control-label"><?php echo @PAYED_DEPT_CHOOSE_CUSTOMER_SUPPLIER;?>

                        </label>
                        <div class="col-lg-4">
                            <input type="radio" class="clientorsupplier" id="client" name="clientorsupplier" value="1"
                                   checked>
                            <label for="client"> <?php echo @PAYED_DEPT_CLIENT;?>
</label>
                            <input type="radio" class="clientorsupplier" id="supplier" name="clientorsupplier"
                                   value="2">
                            <label for="supplier"> <?php echo @PAYED_DEPT_SUPPLIER;?>
</label>
                        </div>
                    </div>


                    <div class="form-group clientform">
                        <label for="partnerid" class="col-lg-2 control-label"><?php echo @PAYED_DEPT_CLIENT;?>
</label>
                        <div class="col-lg-4"><span id="spryselect1">
                                <input type="hidden" id="clientsearchvalue"
                                       value="<?php echo $_smarty_tpl->tpl_vars['Programsettingdata']->value->clientsearchvalue;?>
" />
                                <!-- <select class="select2Supp wdt100 clientPremium" name="clientid" id="clientid">
                                    <option value="-1"><?php echo @PAYED_DEPT_SELECT_CLIENT;?>
</option>
                                    <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['clientsData']->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;?>
" data-mobile="<?php echo $_smarty_tpl->tpl_vars['data']->value->clientmobile;?>
"><?php echo $_smarty_tpl->tpl_vars['data']->value->clientname;?>
</option>
                                    <?php } ?>
                                </select>
                                <div id="clientError" style="display:none;"></div> -->
                                <div id="clientDiv">
                                    <input type="hidden" name="clientid" id="clientid"
                                           class="select2Supp wdt100 clientPremium" />
                                    <input type="hidden" id="oldclientid" />
                                    <input type="hidden" id="oldclientname" />
                                </div>
                                <span class="selectInvalidMsg">*</span>
                            </span>

                        </div>

                    </div>


                    <div class="form-group supplierform" style="display:none">
                        <label class="col-lg-2 control-label"><?php echo @PAYED_DEPT_SUPPLIER_NAME;?>
</label>
                        <div class="col-lg-4">
                            <select name="supplierid" id="supplierid"
                                    data-placeholder="<?php echo @PAYED_DEPT_SELECT_SUPPLIER;?>
" class="select2 wdt100">
                                <option value="-1"><?php echo @PAYED_DEPT_SELECT_SUPPLIER;?>
 اختر مورد</option>
                                <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['suppliersData']->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->supplierid;?>
"><?php echo $_smarty_tpl->tpl_vars['data']->value->suppliername;?>
</option>
                                <?php } ?>
                            </select>
                            <div id="suppError" style="display:none;"></div>
                        </div>
                    </div>

                    <div class="clientNotPremium">
                        <input type="hidden" class="notPremium" name="notPremium">
                        <div class="form-group saveorbankform">
                            <label class="col-lg-2 control-label"><?php echo @PAYED_DEPT_SELECT_SAVE_BANK;?>
 </label>
                            <div class="col-lg-4">
                                <input type="radio" class="saveorbank" name="saveorbank" value="1" checked>
                                <label for="client"><?php echo @PAYED_DEPT_SAVE;?>
</label>
                                <input type="radio" class="saveorbank" name="saveorbank" value="2">
                                <label for="supplier"><?php echo @PAYED_DEPT_BANK;?>
</label>
                            </div>
                        </div>


                        <!-- =================================================   -->
                        <div class="saveshow">
                            <div class="form-group" <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->costcenter==0){?> <?php }else{ ?>
                                style="display:none" <?php }?> >
                                <label class="col-lg-2 control-label"><?php echo @PAYED_DEPT_COST_CENTER;?>
</label>
                                <div class="col-lg-4">
                                    <select class="select2 wdt100" name="Costcenterid" id="Costcenterid">
                                        <option value="-1"><?php echo @PAYED_DEPT_SELECT_COST_CENTER;?>
</option>
                                        <?php  $_smarty_tpl->tpl_vars['myallCostcenter'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['myallCostcenter']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allCostcenter']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['myallCostcenter']->key => $_smarty_tpl->tpl_vars['myallCostcenter']->value){
$_smarty_tpl->tpl_vars['myallCostcenter']->_loop = true;
?>
                                        <option value="<?php echo $_smarty_tpl->tpl_vars['myallCostcenter']->value->id;?>
" <?php if ($_smarty_tpl->tpl_vars['myallCostcenter']->value->id==$_smarty_tpl->tpl_vars['projectid']->value){?>selected=""<?php }?>><?php echo $_smarty_tpl->tpl_vars['myallCostcenter']->value->name;?>

                                        </option>
                                        <?php } ?>
                                    </select>
                                </div>
                            </div>
                            <!-- =================================================   -->
                            <?php if ($_smarty_tpl->tpl_vars['userData']->value->searchinonesave==0){?>
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><?php echo @PAYED_DEPT_SAVE;?>
</label>
                                <div class="col-lg-4">
                                    <select class="select2 wdt100" name="saveid" id="saveid">
                                        <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allSave']->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->saveid;?>
" data-curr="<?php echo $_smarty_tpl->tpl_vars['data']->value->currencyId;?>
" <?php if ($_smarty_tpl->tpl_vars['userData']->value->saveid==$_smarty_tpl->tpl_vars['data']->value->saveid){?>selected<?php }?>><?php echo $_smarty_tpl->tpl_vars['data']->value->savename;?>
 <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showCurrency==1){?>- <?php echo $_smarty_tpl->tpl_vars['data']->value->currencyName;?>
<?php }?>
                                        </option>
                                        <?php } ?>
                                    </select>
                                </div>
                            </div>
                            <?php }else{ ?>
                            <div class="form-group">
                                <label for="inputEmail1"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_SAVE;?>
</label>
                                <div class="col-lg-4">
                                    <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allSave']->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;
?>
                                    <?php if ($_smarty_tpl->tpl_vars['userData']->value->saveid==$_smarty_tpl->tpl_vars['data']->value->saveid){?><?php echo $_smarty_tpl->tpl_vars['data']->value->savename;?>
 <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showCurrency==1){?>- <?php echo $_smarty_tpl->tpl_vars['data']->value->currencyName;?>
<?php }?><?php }?>
                                    <input type="hidden" name="saveid" id="saveid" value="<?php echo $_smarty_tpl->tpl_vars['userData']->value->saveid;?>
" />
                                    <?php } ?>

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


                            <div class="form-group">
                                <label for="lastDate"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_RECEIPT_NUMBER;?>
 </label>
                                <div class="col-lg-4">
                                    <input type="text" name="voucher" id="voucher" readonly="" onkeyup="checkserail();"
                                           value="<?php echo $_smarty_tpl->tpl_vars['todayx']->value;?>
" class="form-control" />
                                    <div id="voucherError" style="display:none;"></div>
                                </div>
                            </div>


                            <input name="oldvoucher" id="oldvoucher" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['todayx']->value;?>
" />
                            <!-- =================================================   -->

                            <div class="form-group">
                                <label for="lastDate"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_PREVIOUS_PAYMENT_DATE;?>
</label>
                                <div class="col-lg-4">
                                    <input type="text" name="lastDate" id="lastDate" readonly="readonly"
                                           class="form-control" />
                                </div>
                            </div>
                            <input name="clientnegative" id="clientnegative" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['clientnegative']->value;?>
" />
                            <!-- =================================================   -->

                            <div class="form-group">
                                <label for="currentDate"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_CURRENT_PAYMENT_DATE;?>
</label>
                                <div class="col-lg-4">
                                    <!--<input type="text" name="currentDate" id="currentDate" class="form-control <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->allowdateedit!=1){?>awdatepicker<?php }?>" autocomplete="off"  <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->allowdateedit==1){?>readonly="readonly"<?php }?> data-date-format="yyyy-mm-dd" value="<?php echo $_smarty_tpl->tpl_vars['today']->value;?>
" />-->
                                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->allowdateedit!=1){?>
                                    <div class="input-group date form_datetime col-md-5" data-date=""
                                         data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                        <input class="form-control" size="16" type="text" value="<?php echo $_smarty_tpl->tpl_vars['today']->value;?>
"
                                               name="currentDate" id="currentDate" readonly="">
                                        <span class="input-group-addon "><span
                                                class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                        <span class="input-group-addon"><span
                                                class="glyphicon glyphicon-th col-lg-4"></span></span>
                                    </div>
                                    <?php }else{ ?>
                                    <input name="currentDate" id="currentDate" type="text" value="<?php echo $_smarty_tpl->tpl_vars['today']->value;?>
"
                                           class="form-control" autocomplete="off" readonly="readonly" />
                                    <?php }?>
                                    <div id="dateError" style="display:none;"></div>
                                </div>
                            </div>

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

                            <div class="form-group">
                                <label for="debtBefore"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_PREVIOUS_DEBT;?>
</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <input type="text" name="debtBefore" id="debtBefore" class="form-control"
                                               readonly="readonly" />
                                        <span class="input-group-addon"><?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</span>
                                    </div>
                                </div>
                            </div>


                            <!-- =================================================   -->
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->earlyrepayment==1){?>
                            <div class="form-group">
                                <label for="debtBefore"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_EARLY_PAYMENT_DISCOUNT;?>
</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <input type="text" name="earlyRepayment" id="earlyRepayment" value="0"
                                               onKeyUp="populateDebtAfter();" class="form-control" />
                                        <span class="input-group-addon"><?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</span>
                                    </div>
                                </div>
                            </div>
                            <?php }?>

                            <!-- =================================================   -->
                            <div class="form-group" <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showCurrency!=1){?>style="display:none;"<?php }?>>
                                <label class="col-lg-2 control-label"><?php echo @PAYED_DEPT_CURRENCY;?>
</label>
                                <div class="col-lg-4">
                                    <span id="spryselect1">
                                        <select class="select2" name="currencyId" id="currencyId">
                                            <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allCurrency']->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->id;?>
" data-cfactor="<?php echo $_smarty_tpl->tpl_vars['data']->value->conversionFactor;?>
">
                                                <?php echo $_smarty_tpl->tpl_vars['data']->value->name;?>
</option>
                                            <?php } ?>
                                        </select>
                                        <span class="selectRequiredMsg">*</span></span>
                                </div>
                            </div>
                            <div class="form-group" <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showCurrency!=1){?>style="display:none;"<?php }?>>
                                <label
                                    class="col-lg-2 control-label"><?php echo @PAYED_DEPT_CONVERSION_FACTOR;?>
</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <input type="text" name="cFactor" id="cFactor"
                                               class="form-control positivefloat" onkeyup="populateDebtAfter();" />
                                        <span class="input-group-addon"><?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</span>
                                    </div>
                                </div>
                            </div>
                            <!-- =================================================   -->
                            <div class="form-group delete-after-premium">
                                <label for="payedDept"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_PAID_UP;?>
</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <input type="text" name="payedDeptCurr" id="payedDeptCurr" value="0"
                                               onKeyUp="populateDebtAfter('payedDeptCurr');"
                                               class="form-control nopremiumpayedDeptCurr <?php if ($_smarty_tpl->tpl_vars['clientnegative']->value==1){?>numberinput<?php }else{ ?>positivefloat<?php }?>"
                                               placeholder="<?php echo @PAYED_DEPT_PAID_UP;?>
" />
                                        <span class="input-group-addon" id="currencyText"><?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</span>
                                    </div>
                                    <div id="payedDeptError" style="display:none;"></div>

                                </div>
                            </div>
                            <div class="form-group delete-after-premium" <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showCurrency!=1){?>style="display:none;"<?php }?>>
                                <label
                                    class="col-lg-2 control-label"><?php echo @PAYED_DEPT_PAID_MAIN_CURRENCY;?>
</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <input type="text" name="payedDept" id="payedDept"
                                               onKeyUp="populateDebtAfter('payedDept');"
                                               class="nopremiumpayedDept <?php if ($_smarty_tpl->tpl_vars['clientnegative']->value==1){?>numberinput<?php }else{ ?>positivefloat<?php }?> form-control" />
                                        <span class="input-group-addon"><?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</span>
                                    </div>
                                </div>
                            </div>

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

                            <div class="form-group">
                                <label for="debtAfter"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_CURRENT_DEBT;?>
</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <input type="text" name="debtAfter" id="debtAfter" class="form-control"
                                               readonly="readonly" />
                                        <span class="input-group-addon"><?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</span>
                                    </div>
                                </div>
                            </div>
                            <!-- =================================================   -->

                            <div class="form-group clientform">
                                <label class="col-lg-2 control-label"><?php echo @PAYED_DEPT_DELEGATE;?>
</label>
                                <div class="col-lg-4">
                                    <select class="select2 wdt100" name="seller" id="seller">
                                        <option value=""></option>
                                        <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['sellers']->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->userid;?>
"><?php echo $_smarty_tpl->tpl_vars['data']->value->employeename;?>
</option>
                                        <?php } ?>
                                    </select>
                                </div>
                            </div>

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


                            <div class="form-group">
                                <label for="debtAfter"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_COMMENT;?>
</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <textarea style="width: 358px;" name="comment" id="comment1" cols="50" rows="5"
                                                  class="form-control">   </textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--end Save-->

                        <!--bank-->
                        <div class="bankshow" style="display: none;">
                            <div class="form-group">
                                <label for="ddlBank"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_ELBANK;?>
</label>

                                <div class="col-lg-4">

                                    <select class="select2 wdt100" name="ddlBank" id="ddlBank"
                                            onchange="loadAccount(this.value);">
                                        <option value="-1"><?php echo @PAYED_DEPT_SELECT_BANK;?>
</option>

                                        <?php  $_smarty_tpl->tpl_vars['b'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['b']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['bank']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['b']->key => $_smarty_tpl->tpl_vars['b']->value){
$_smarty_tpl->tpl_vars['b']->_loop = true;
?>
                                        <option value="<?php echo $_smarty_tpl->tpl_vars['b']->value->bankid;?>
"><?php echo $_smarty_tpl->tpl_vars['b']->value->bankname;?>
</option>
                                        <?php } ?>

                                    </select>
                                    <div id="bankerror">

                                    </div>
                                </div>
                                <div class="col-lg-1">
                                    <span class="requiredField">*</span>
                                </div>
                            </div>

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


                            <div class="form-group">
                                <label for="accountbeginingbalanceDis"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_CUSTOMER_DEBT;?>
</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <input type="text" name="clientDebit" id="clientDebit"
                                               class="form-control numberinput" readonly="readonly" value="0"
                                               placeholder="<?php echo @PAYED_DEPT_CUSTOMER_DEBT;?>
" />

                                        <span class="input-group-addon"><?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</span>
                                    </div>
                                </div>
                            </div>
                            <!-- =================================================   -->


                            <div class="form-group">
                                <label for="accountid"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_ACCOUNT_NAME;?>
</label>

                                <div class="col-lg-4">
                                    <div id="accountName">

                                        <select class="select2 wdt100" name="accountid" id="accountid">
                                            <option value="-1"><?php echo @PAYED_DEPT_CHOOSE_ACCOUNT;?>
</option>

                                        </select>

                                    </div>

                                    <div id="counterror">

                                    </div>
                                </div>
                                <div class="col-lg-1">
                                    <span class="requiredField">*</span>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-lg-2 control-label"><?php echo @PAYED_DEPT_DATE;?>
 </label>
                                <div class="col-lg-4"> <span id="sprydate">
                                        <input type="text" class="form-control awdatepicker" autocomplete="off"
                                               data-date-format="yyyy-mm-dd" placeholder="<?php echo @PAYED_DEPT_DATE;?>
"
                                               value="<?php echo $_smarty_tpl->tpl_vars['today']->value;?>
" name="checkdate" id="bn">
                                        <span class="textfieldRequiredMsg">*</span></span>
                                </div>
                                <div class="col-lg-1">
                                    <span class="requiredField">*</span>
                                </div>
                            </div>

                            <div id="accountnumber">
                                <!-- =================================================   -->


                                <div class="form-group">
                                    <label for="accountnumberDis"
                                           class="col-lg-2 control-label"><?php echo @PAYED_DEPT_ACCOUNT_NUMBER;?>
</label>
                                    <div class="col-lg-4">
                                        <input name="txtPhone" type="text" id="accountnumberDis" name="accountnumberDis"
                                               class="numberinput form-control"
                                               placeholder="<?php echo @PAYED_DEPT_ACCOUNT_NUMBER;?>
"
                                               readonly="readonly" />

                                        <input type="hidden" name="accountnumber" id="accountnumber" />

                                    </div>
                                </div>

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

                                <div class="form-group">
                                    <label for="accountbeginingbalanceDis" class="col-lg-2 control-label">
                                        <?php echo @PAYED_DEPT_PREVIOUS_BALANCE;?>
</label>
                                    <div class="col-lg-4">
                                        <div class="input-group">
                                            <input type="text" name="accountbeginingbalanceDis"
                                                   id="accountbeginingbalanceDis" class="form-control numberinput"
                                                   readonly="readonly" value="0"
                                                   placeholder="<?php echo @PAYED_DEPT_PREVIOUS_BALANCE;?>
" />

                                            <span class="input-group-addon"><?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</span>
                                        </div>

                                        <input type="hidden" name="accountbeginingbalance"
                                               id="accountbeginingbalance" />
                                    </div>
                                </div>

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

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


                            <div class="form-group">
                                <label for="txtAmount"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_DEPOSIT_VALUE;?>
</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <input type="text" name="txtAmount" id="txtAmountxx"
                                               class="form-control <?php if ($_smarty_tpl->tpl_vars['clientnegative']->value==1){?>numberinput<?php }else{ ?>positivefloat<?php }?>"
                                               placeholder="<?php echo @PAYED_DEPT_DEPOSIT_VALUE;?>
" />
                                        <span class="input-group-addon"><?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</span>
                                        <div id="chekamount">

                                        </div>
                                    </div>
                                    <div id="chekamountError">

                                    </div>

                                </div>
                                <div class="col-lg-1">
                                    <span class="requiredField">*</span>
                                </div>
                            </div>
                            <!--==============================-->
                            <div class="form-group">
                                <label for="txtcheckNum"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_DEPOSIT_PROCESS_NUMBER;?>
</label>
                                <div class="col-lg-4">

                                    <input type="text" name="txtcheckNum" id="txtcheckNum"
                                           class="form-control numberinput positivefloat"
                                           placeholder="<?php echo @PAYED_DEPT_DEPOSIT_PROCESS_NUMBER;?>
" />
                                    <div id="chekerror">

                                    </div>
                                    <div id="chekerror2">

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

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


                            <div class="form-group">
                                <label for="txtUser"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_DEPOSITOR_NAME;?>
</label>
                                <div class="col-lg-4">

                                    <input type="text" name="txtUser" id="txtUser" class="form-control "
                                           placeholder="<?php echo @PAYED_DEPT_DEPOSITOR_NAME;?>
" />

                                    <div id="userdiv">

                                    </div>

                                </div>
                            </div>


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


                            <div class="form-group">
                                <label for="textNote"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_OTHER_DETAILS;?>
</label>
                                <div class="col-lg-4">

                                    <textarea class="form-control" rows="3" id="textNote" name="textNote"></textarea>

                                </div>
                            </div>

                        </div>
                        <!--end Bank-->

                        <input type="hidden" name="clientpremium" id="clientpremium" />
                        <input type="hidden" name="premiumid" id="premiumid" />
                        <input type="hidden" name="premiumDetailId" id="premiumDetailId" />
                    </div>


                    <div class="clientFindPremium" style="display: none;">
                        <input type="hidden" name="Premium" class="Premium">

                        <div class="form-group saveorbankform">
                            <label class="col-lg-2 control-label"> <?php echo @PAYED_DEPT_SELECT_SAVE_BANK;?>
</label>
                            <div class="col-lg-4">
                                <input type="radio" class="saveorbankPremium" name="saveorbankPremium" value="1"
                                       checked>
                                <label for="client"><?php echo @PAYED_DEPT_SAVE;?>
</label>
                                <input type="radio" class="saveorbankPremium" name="saveorbankPremium" value="2">
                                <label for="supplier"><?php echo @PAYED_DEPT_BANK;?>
</label>
                            </div>
                        </div>
                        <input type="hidden" name="clientpremium" value="1" />

                        <div class="saveshowPremium">
                            <?php if ($_smarty_tpl->tpl_vars['userData']->value->searchinonesave==0){?>
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><?php echo @PAYED_DEPT_SAVE;?>
</label>
                                <div class="col-lg-4">
                                    <select class="select2 wdt100" name="saveid" id="saveid">
                                        <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allSave']->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->saveid;?>
" data-curr="<?php echo $_smarty_tpl->tpl_vars['data']->value->currencyId;?>
" <?php if ($_smarty_tpl->tpl_vars['userData']->value->saveid==$_smarty_tpl->tpl_vars['data']->value->saveid){?>selected<?php }?>><?php echo $_smarty_tpl->tpl_vars['data']->value->savename;?>

                                        </option>
                                        <?php } ?>
                                    </select>
                                </div>
                            </div>
                            <?php }else{ ?>
                            <div class="form-group">
                                <label for="inputEmail1"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_SAVE;?>
</label>
                                <div class="col-lg-4">
                                    <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allSave']->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;
?>
                                    <?php if ($_smarty_tpl->tpl_vars['userData']->value->saveid==$_smarty_tpl->tpl_vars['data']->value->saveid){?><?php echo $_smarty_tpl->tpl_vars['data']->value->savename;?>
<?php }?>
                                    <input type="hidden" name="saveid" id="saveid" value="<?php echo $_smarty_tpl->tpl_vars['userData']->value->saveid;?>
" />
                                    <?php } ?>

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

                            <div class="form-group">
                                <label for="lastDate" class="col-lg-2 control-label">
                                    <?php echo @PAYED_DEPT_INSTALLMENT_NUMBER;?>
</label>
                                <div class="col-lg-4">
                                    <input type="text" name="voucherpremium" id="voucherpremium" readonly=""
                                           onkeyup="checkserailpremium();" value="<?php echo $_smarty_tpl->tpl_vars['todayx']->value;?>
" class="form-control" />
                                    <div id="voucherpremiumError" style="display:none;"></div>
                                </div>
                            </div>


                            <input name="oldvoucherpremium" id="oldvoucherpremium" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['todayx']->value;?>
" />

                            <div class="form-group">
                                <label for="debtBefore"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_PREVIOUS_DEBT;?>
</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <input type="text" name="debtBefore" class="form-control debtBefore"
                                               readonly="readonly" />
                                        <span class="input-group-addon"><?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
</span>
                                    </div>
                                </div>
                            </div>

                        </div>

                        <!--bank-->
                        <div class="bankshowPremium" style="display: none;">
                            <div class="form-group">
                                <label for="ddlBank"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_ELBANK;?>
</label>

                                <div class="col-lg-4">

                                    <select class="select2 wdt100" name="ddlBank" id="ddlBank"
                                            onchange="loadAccount(this.value);">
                                        <option value="-1"><?php echo @PAYED_DEPT_SELECT_BANK;?>
</option>

                                        <?php  $_smarty_tpl->tpl_vars['b'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['b']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['bank']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['b']->key => $_smarty_tpl->tpl_vars['b']->value){
$_smarty_tpl->tpl_vars['b']->_loop = true;
?>
                                        <option value="<?php echo $_smarty_tpl->tpl_vars['b']->value->bankid;?>
"><?php echo $_smarty_tpl->tpl_vars['b']->value->bankname;?>
</option>
                                        <?php } ?>

                                    </select>
                                    <div id="bankerror">

                                    </div>
                                </div>
                                <div class="col-lg-1">
                                    <span class="requiredField">*</span>
                                </div>
                            </div>

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


                            <div class="form-group">
                                <label for="accountid"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_ACCOUNT_NAME;?>
</label>

                                <div class="col-lg-4">
                                    <div id="accountName">

                                        <select class="select2 wdt100" name="accountid" id="accountid">
                                            <option value="-1"><?php echo @PAYED_DEPT_CHOOSE_ACCOUNT;?>
</option>

                                        </select>

                                    </div>

                                    <div id="counterror">

                                    </div>
                                </div>
                                <div class="col-lg-1">
                                    <span class="requiredField">*</span>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-lg-2 control-label"> <?php echo @PAYED_DEPT_DATE;?>
</label>
                                <div class="col-lg-4"> <span id="sprydate">
                                        <input type="text" class="form-control awdatepicker" autocomplete="off"
                                               data-date-format="yyyy-mm-dd" placeholder="<?php echo @PAYED_DEPT_DATE;?>
"
                                               value="<?php echo $_smarty_tpl->tpl_vars['today']->value;?>
" name="checkdate" id="bn">
                                        <span class="textfieldRequiredMsg">*</span></span>
                                </div>
                                <div class="col-lg-1">
                                    <span class="requiredField">*</span>
                                </div>
                            </div>

                            <div id="accountnumber">
                                <!-- =================================================   -->


                                <div class="form-group">
                                    <label for="accountnumberDis"
                                           class="col-lg-2 control-label"><?php echo @PAYED_DEPT_ACCOUNT_NUMBER;?>
</label>
                                    <div class="col-lg-4">
                                        <input name="txtPhone" type="text" id="accountnumberDis" name="accountnumberDis"
                                               class="numberinput form-control"
                                               placeholder="<?php echo @PAYED_DEPT_ACCOUNT_NUMBER;?>
"
                                               readonly="readonly" />

                                        <input type="hidden" name="accountnumber" id="accountnumber" />

                                    </div>
                                </div>



                            </div>

                            <!--==============================-->
                            <div class="form-group">
                                <label for="txtcheckNum"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_DEPOSIT_PROCESS_NUMBER;?>
</label>
                                <div class="col-lg-4">

                                    <input type="text" name="txtcheckNum" id="txtcheckNum"
                                           class="form-control numberinput positivefloat"
                                           placeholder="<?php echo @PAYED_DEPT_DEPOSIT_PROCESS_NUMBER;?>
" />
                                    <div id="chekerror">

                                    </div>
                                    <div id="chekerror2">

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

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


                            <div class="form-group">
                                <label for="txtUser"
                                       class="col-lg-2 control-label"><?php echo @PAYED_DEPT_DEPOSITOR_NAME;?>
</label>
                                <div class="col-lg-4">

                                    <input type="text" name="txtUser" id="txtUser" class="form-control "
                                           placeholder="<?php echo @PAYED_DEPT_DEPOSITOR_NAME;?>
" />

                                    <div id="userdiv">

                                    </div>

                                </div>
                            </div>



                        </div>
                        <!--end Bank-->

                        <div class="card Premium-client">

                        </div>
                    </div>
                    <!-- =================================================   -->
                    <input type="hidden" name="add_print" id="add_print" value="0" />
                    <input type="hidden" name="add_And_New" id="add_And_New" value="0" />


                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="button" id="saveBtn"
                                    class="btn btn-primary saveBtnClass"><?php echo @PAYED_DEPT_SAVES;?>
</button>
                            <button type="button" id="saveAndNewBtn"
                                    class="btn btn-primary saveBtnClass"><?php echo @PAYED_DEPT_SAVE_AND_NEW;?>
</button>
                            <button type="button" id="add_print_btn"
                                    class="btn btn-success saveBtnClass"><?php echo @PAYED_DEPT_PRINT_SAVE;?>
</button>
                            <!--<button type="button" id="submitnew" class="btn btn-primary submitnew saveBtnClass">حفظ </button>-->
                            <!--<button type="button"  id="add_print_btn" class="btn btn-success saveBtnClass">حفظ وطباعة</button>-->
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->premiums==0){?>
                            <a class="btn btn-info clientform" href="#" id="add_Premium" data-toggle="modal"
                               data-target="#myModal"
                               role="button"><?php echo @PAYED_DEPT_ADD_INSTALLMENTS_CUSTOMER;?>
</a>
                            <?php }?>

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


<div class="modal fade" id="myModal" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:1000px;">
        <div class="modal-content">
            <div class="modal-header text-center">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true"
                                                                               class="text-left">&times;</span><span class="sr-only"></span></button>
                <h3 class="modal-title" id="myModalLabel"><?php echo @PAYED_DEPT_INSTALLMENTS_CUSTOMER;?>
</h3>
            </div>
            <div class="modal-body">
                <form action="premiumController.php?do=add" method="post" id="form1"
                      class="form-horizontal nameToBeChecked">


                    <!-- المكونات -->
                    <div class="card">
                        <div class="col-lg-6">
                            <h4><?php echo @PAYED_DEPT_CUSTOMER_DATA;?>
</h4>
                        </div>
                        <div class="col-lg-3 ">
                            <div class="form-group mt-10">
                                <label class="col-lg-3"><?php echo @PAYED_DEPT_ELCLIENT;?>
 </label>
                                <div class="col-lg-9">
                                    <select class=" select2" id="clientID" name="clientID" required>
                                        <option value="-1"><?php echo @PAYED_DEPT_SELECT_CLIENT;?>
</option>
                                        <?php  $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['item']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['clientsData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value){
$_smarty_tpl->tpl_vars['item']->_loop = true;
?>
                                        <option value="<?php echo $_smarty_tpl->tpl_vars['item']->value->clientid;?>
"><?php echo $_smarty_tpl->tpl_vars['item']->value->clientname;?>
</option>
                                        <?php } ?>
                                    </select>
                                </div>

                            </div>
                        </div>

                        <div class="table-responsive">
                            <table class="table billtable table-bordered table-black " id="table">
                                <thead>
                                    <tr>
                                        <th class="wdt300"><?php echo @PAYED_DEPT_CLIENT_NAME;?>
</th>
                                        <th class="wdt120 "><?php echo @PAYED_DEPT_MOBILE_NUMBER;?>
</th>
                                        <th class="wdt120"><?php echo @PAYED_DEPT_REGION;?>
</th>
                                        <th class="wdt120"><?php echo @PAYED_DEPT_CLIENT_TYPE;?>
</th>
                                        <th class="wdt120"><?php echo @PAYED_DEPT_CLIENT_DEPT;?>
</th>
                                        <th class="wdt120"><?php echo @PAYED_DEPT_COMMENT;?>
</th>
                                    </tr>
                                </thead>
                                <tbody>
                                <td id="name"></td>
                                <td id="mobile"></td>
                                <td id="area"></td>
                                <td id="type"></td>
                                <td id="debt"></td>
                                <td id="comment"></td>
                                </tbody>
                            </table>
                        </div>

                    </div>
                    <!-- end of title row-->

                    <!-- المخرجات -->
                    <div class="card">

                        <div class="col-lg-6">
                            <h4><?php echo @PAYED_DEPT_INSTALLMENTS_CUSTOMER;?>
</h4>
                        </div>

                        <input type="hidden" name="premiumItr" id="premiumItr" value="1" />

                        <div class="table-responsive">
                            <table class="table billtable table-bordered table-black " id="wasteTable">
                                <thead>
                                    <tr>
                                        <th class="wdt300"><?php echo @PAYED_DEPT_INSTALLMENTS_DATE;?>
</th>
                                        <th class="wdt300"><?php echo @PAYED_DEPT_VALUE;?>
</th>
                                        <th class="wdt50"></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr data-itr="1">
                                        <td>
                                            <input type="text" class="form-control date" autocomplete="off"
                                                   data-date-format="yyyy-mm-dd" name="date1" id="date1">
                                        </td>
                                        <td>
                                            <input type="number" name="Amount1" id="Amount1" min="0"
                                                   class="form-control countAmount" value="" />
                                        </td>
                                        <td class="noprint"><a href="javascript:;" type="button"
                                                               class="btn add addWastePro" id="addWastePro1"><i
                                                    class="glyphicon glyphicon-plus-sign"></i></a></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>

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

                        <div class="row">
                            <div class="col-lg-12">
                                <button type="button" class="btn btn-dark pull-left ft-nor">
                                    <?php echo @PAYED_DEPT_INSTALLMENTS_TOTAL;?>
 <span class="badge wht-clo">
                                        <div id='allCost'>0</div>
                                    </span>
                                </button>
                            </div>
                        </div>

                    </div>
                    <!-- end of title row-->


                    <div class="row  hidden-print m10">
                        <div class="col-lg-12 text-center">
                            <button type="submit" class="btn btn-primary">
                                <i class="glyphicon glyphicon-ok "></i><?php echo @PAYED_DEPT_SAVES;?>

                            </button>

                            <button type="button" data-dismiss="modal" class="btn btn-primary">
                                <i class="glyphicon glyphicon-ok "></i> <?php echo @PAYED_DEPT_BACK;?>

                            </button>

                            <!--<button type="button" class="close" data-dismiss="modal">-->
                            <!--<span aria-hidden="true" class="text-left">رجوع</span>-->
                            <!--<span class="sr-only"></span>-->
                            <!--</button>-->

                        </div>


                    </div>
                    <!-- end of fifth row-->

                </form>
            </div>

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



<script type="text/javascript">
    jQuery(document).ready(function () {

        $(".select2Supp").select2({
            placeholder: "العميل",
            minimumInputLength: document.getElementById("clientsearchvalue").value,
            inimumInputLength: 0,
            multiple: false,
            quietMillis: 100,
            formatInputTooShort: function (input, min) {
                var n = min - input.length;
                $lenMsg = '<ul class="select2-results">';
                // if (supplierWithAddOption == 1)
                // $lenMsg += '<li class="select2-results-dept-0 select2-result select2-result-selectable" onclick="newOptionAtInputTooShort();"><div class="select2-result-label newoption"><span class="newoption">اضافة عميل جديد</span></div></li>';
                $lenMsg += '</ul><div class="select2-result-label"><span>من فضلك أدخل ' + n + ' حروف أكثر</span></div>';
                // Append it to the select
                return $lenMsg;
            },
            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: 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], mobile: item[6]};
                callback(data);
            },
            //dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
        }).on('select2-loaded', function (e) {// not "select2-open" nor "select2-opening" //http://mkurz.github.io/select2/index.html
            $('.newoption').parent().addClass('newoption');
        }).on("select2-selecting", function (e) {
            // the class to make diffrence of change from select2 itself "choose another option" ,it wont exist for triggering change
            $('#clientid').addClass('selectingClass');
        })
        //this is needed for ajax =>to obtain id from it  and use in ajax
        $('#clientid').select2('data', {id: $('#oldclientid').val(), text: $('#oldclientname').val()});
        setTimeout(function () {
            //this is needed as we need html to end drawing then put value => without it text will be undefined
            $('#clientid').select2('data', {id: $('#oldclientid').val(), text: $('#oldclientname').val()});
        }, 0)
    });
</script>
<?php }} ?>