$wxul = "m";
    } else {
        if (USER_TYPE == "S" && !isset($_GET["lp"])) {
            $script = "pos-invoice-speed.php";
            $wxul = "m";
        } else {
            if (isset($_GET["lp"])) {
                $script = $_GET["lp"];
                unset($_GET["lp"]);
                $script = "{$script}?" . array2get($_GET);
                $wxul = "m";
            } else {
                if (isset($_GET["p"])) {
                    $script = $_GET["p"];
                    unset($_GET["p"]);
                    $script = "{$script}?" . array2get($_GET);
                    $wxul = "f";
                } else {
                    $script = "main.php";
                    $wxul = "f";
                }
            }
        }
    }
}
$script = preg_replace("/&/", "&", $script);
if (DEBUG > 0) {
    $dbgtitle = "- {$_SESSION['code']}";
} else {
    $dbgtitle = "";
}
function confirm($_POST)
{
    $_POST = var_makesafe($_POST);
    extract($_POST);
    if (!isset($date_day)) {
        exit;
    }
    if (isset($btn_back)) {
        header("Location: ../admin-employee-view.php?" . array2get($_POST));
        exit;
    }
    $ydate = "{$date_year}-{$date_month}-{$date_day}";
    # CHECK IF THIS DATE IS IN THE BLOCKED RANGE
    $blocked_date_from = getCSetting("BLOCKED_FROM");
    $blocked_date_to = getCSetting("BLOCKED_TO");
    if (strtotime($ydate) >= strtotime($blocked_date_from) and strtotime($ydate) <= strtotime($blocked_date_to) and !user_is_admin(USER_ID)) {
        return "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
    }
    $week += 0;
    /* check for blocked accounts */
    $salconacc = gethook("accnum", "salacc", "name", "salaries control");
    $salconacc_orig = gethook("accnum", "salacc", "name", "salaries control original");
    if ($salconacc != $salconacc_orig) {
        block_check($salconacc);
    }
    block_check(gethook("accnum", "salacc", "name", "Commission"));
    block_check(gethook("accnum", "salacc", "name", "Bonus"));
    block_check(gethook("accnum", "salacc", "name", "interestreceived"));
    block_check(gethook("accnum", "salacc", "name", "PAYE"));
    block_check(gethook("accnum", "salacc", "name", "UIF"));
    block_check(gethook("accnum", "salacc", "name", "uifbal"));
    block_check(gethook("accnum", "salacc", "name", "sdlbal"));
    block_check(gethook("accnum", "salacc", "name", "pension"));
    block_check(gethook("accnum", "salacc", "name", "medical"));
    block_check(gethook("accnum", "salacc", "name", "cash"));
    block_check(gethook("accnum", "salacc", "name", "retire"));
    block_check(gethook("accnum", "salacc", "name", "provident"));
    global $global_empnum;
    db_conn('cubit');
    $Sl = "SELECT * FROM employees WHERE div='" . USER_DIV . "' ORDER BY sname,fnames";
    $Ri = db_exec($Sl) or errDie("Unable to get data.");
    while ($data = pg_fetch_array($Ri)) {
        if (!isset($emps[$data['empnum']])) {
            continue;
        }
        $global_empnum = $id = $data["empnum"];
        $empname = "{$data['fnames']} {$data['sname']} ({$data['enum']})";
        // check for employee exp accs blocks
        block_check($data["expacc_provident"], $empname);
        block_check($data["expacc_ret"], $empname);
        block_check($data["expacc_pension"], $empname);
        block_check($data["expacc_uif"], $empname);
        block_check($data["expacc_medical"], $empname);
        block_check($data["expacc_other"], $empname);
        block_check($data["expacc_sdl"], $empname);
        block_check($data["expacc_salwages"], $empname);
        if ($data["expacc_loan"] > 0) {
            block_check($data["expacc_loan"], $empname);
        }
        if (isset($dedaccs[$id])) {
            foreach ($dedaccs[$id] as $checkacc) {
                block_check($checkacc, $empname);
            }
        }
        if (isset($allowaccs[$id])) {
            foreach ($allowaccs[$id] as $checkacc) {
                block_check($checkacc, $empname);
            }
        }
    }
    finish_block_check();
    /* check if hire date before pay date for any of the employees*/
    $sql = "SELECT * FROM employees WHERE div='" . USER_DIV . "' ORDER BY sname,fnames";
    $rslt = db_exec($sql) or errDie("Unable to get data.");
    $hderrs = array();
    while ($data = pg_fetch_array($rslt)) {
        if (!isset($emps[$data['empnum']])) {
            continue;
        }
        explodeDate($data["hiredate"], $hd_year, $hd_month, $hd_day);
        $MONempyear = getYearOfEmpMon($month);
        switch ($data["payprd"]) {
            case "m":
                $extra = false;
                break;
            case "d":
                $extra = $hd_year == $MONempyear && $hd_month == $month && $pday < $hd_day;
                break;
            case "w":
            case "f":
                $extra = $hd_year == $MONempyear && $hd_month == $month && $weekends[$week] < $hd_day;
                break;
        }
        if ($hd_year > $MONempyear || $hd_year == $MONempyear && $hd_month > $month || $extra) {
            $hderrs[] = "&nbsp; - &nbsp; {$data['sname']}, {$data['fnames']}<br />";
        }
    }
    if (count($hderrs) > 0) {
        $hderrs = "\n\t\t\t<li class='err'>\n\t\t\t\tThe following employees were not employed in the period requested.<br />\n\t\t\t\t" . implode("", $hderrs) . "\n\t\t\t</li>";
        return enter($_POST, $hderrs);
    }
    global $eMONPRD;
    $out = "\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='write'>\n\t\t\t<input type='hidden' name='month' value='{$month}'>\n\t\t\t<input type='hidden' name='week' value='{$week}'>\n\t\t\t<input type='hidden' name='printslip' value='{$printslip}' />\n\t\t\t" . (isset($pday) ? "<input type='hidden' name='pday' value='{$pday}' />" : "") . "\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<td colspan='4' valign='top'>\n\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan='2'><h3>Processing Batch Salaries</h3></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<th>Salary Period:</th>\n\t\t\t\t\t\t\t<td>" . getMonthName($month) . " " . getYearOfEmpMon($month) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<th>Processing Date:</th>\n\t\t\t\t\t\t\t<td nowrap>\n\t\t\t\t\t\t\t\t<input type='hidden' name='date_day' value='{$date_day}'> {$date_day} -\n\t\t\t\t\t\t\t\t<input type='hidden' name='date_month' value='{$date_month}'> {$date_month} -\n\t\t\t\t\t\t\t\t<input type='hidden' name='date_year' value='{$date_year}'> {$date_year}\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='3'><input type='submit' value='&laquo; Correction'></td>\n\t\t\t\t<td colspan='5'><input type='button' value='Pay Selected Employees In Full After Processing' onClick='emp_payall();'></td>\n\t\t\t\t<td colspan='2' align=right><input type='submit' value='Process Salaries &raquo;' name='button'></td>\n\t\t\t\t<td colspan='10' align=right><input type='submit' value='Process Salaries &raquo;' name='button'></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>Nr.</th>\n\t\t\t\t<th>Name</th>\n\t\t\t\t<th>Remuneration</th>\n\t\t\t\t<th>Amount Paid After Processing</th>\n\t\t\t\t<th>Annual Bonus</th>\n\t\t\t\t<!--\n\t\t\t\t<th>Special Bonus/Additional Salary</th>\n\t\t\t\t<th>Annual Bonus</th>\n\t\t\t\t-->\n\t\t\t\t<th>Commission</th>\n\t\t\t\t<th>Travel Allowance</th>\n\t\t\t\t<th>Loan Repayment</th>\n\t\t\t\t<th>Pension: Company Contribution</th>\n\t\t\t\t<th>Pension: Employee Deduction</th>\n\t\t\t\t<th>Provident: Company Contribution</th>\n\t\t\t\t<th>Provident: Employee Deduction</th>\n\t\t\t\t<th>UIF: Company Contribution</th>\n\t\t\t\t<th>UIF: Employee Deduction</th>\n\t\t\t\t<th>Retirement Annuity: Company Contribution</th>\n\t\t\t\t<th>Retirement Annuity: Employee Deduction</th>\n\t\t\t\t<th>Medical Contribution: Company</th>\n\t\t\t\t<th>Medical Contribution: Employee</th>\n\t\t\t\t<!--\n\t\t\t\t<th>Other: Company Contribution</th>\n\t\t\t\t<th>Other: Employee Deduction</th>\n\t\t\t\t//-->\n\t\t\t\t<th>Normal Overtime</th>\n\t\t\t\t<th>Public Holiday Overtime</th>\n\t\t\t\t<th>Method of Payment</th>\n\t\t\t\t<th>Medical Fringe Ben.</th>\n\t\t\t\t<th>Car 1 Fringe</th>\n\t\t\t\t<th>Car 2 Fringe</th>\n\t\t\t\t<th>Loan Fringe</th>\n\t\t\t\t<th>Fringe Ben.</th>\n\t\t \t\t<th>Allowances</th>\n\t\t \t\t<th>Subsistence</th>\n\t\t \t\t<th>Deductions</th>\n\t\t \t\t<th>Reimbursements</th>\n\t\t \t\t<th>Gross Salary</th>\n\t\t\t\t<th>PAYE</th>\n\t\t\t\t<th>Nett Pay + Reimbursements</th>\n\t\t\t</tr>";
    db_conn('cubit');
    $i = 0;
    $Sl = "SELECT * FROM employees WHERE div='" . USER_DIV . "' ORDER BY sname,fnames";
    $Ri = db_exec($Sl) or errDie("Unable to get data.");
    $errout = "";
    $payall_js = "";
    while ($data = pg_fetch_array($Ri)) {
        if (!isset($emps[$data['empnum']])) {
            continue;
        }
        $id = $data['empnum'];
        $basic_sal_save[$id] = $basic_sal[$id];
        $send = "";
        if (isset($b)) {
            $send = "<input type='hidden' name='b' value=''>";
            if ($data["payprd"] != "f") {
                continue;
            }
        } elseif (isset($w)) {
            $send = "<input type='hidden' name='w' value=''>";
            if ($data['payprd'] != "w") {
                continue;
            }
        } elseif (isset($m)) {
            $send = "<input type='hidden' name='m' value=''>";
            if ($data['payprd'] != "m") {
                continue;
            }
        } elseif (isset($d)) {
            $send = "<input type='hidden' name='d' value=''>";
            if ($data['payprd'] != "d") {
                continue;
            }
        } else {
            continue;
        }
        $yy = date("Y");
        $mm = $month;
        $mm += 0;
        if (!isset($myEmp)) {
            $myEmp = array("payprd" => "");
        }
        db_conn("cubit");
        if ($data["payprd"] == "d") {
            $Sl = "SELECT * FROM salpaid WHERE empnum='{$data['empnum']}' AND month='{$mm}' AND week='{$pday}' AND cyear='" . EMP_YEAR . "'";
            $Rq = db_exec($Sl);
            $paid = pg_num_rows($Rq);
            $Sl = "SELECT * FROM salr WHERE empnum='{$data['empnum']}' AND month='{$mm}' AND week='{$pday}' AND cyear='" . EMP_YEAR . "'";
            $Rq = db_exec($Sl);
            $upaid = pg_num_rows($Rq);
            $upaid += 0;
            $paid -= $upaid;
        } else {
            if ($myEmp['payprd'] != "m") {
                $Sl = "SELECT * FROM salpaid WHERE empnum='{$data['empnum']}' AND month='{$mm}' AND week='{$week}' AND cyear='" . EMP_YEAR . "'";
                $Rq = db_exec($Sl);
                $paid = pg_num_rows($Rq);
                $Sl = "SELECT * FROM salr WHERE empnum='{$data['empnum']}' AND month='{$mm}' AND week='{$week}' AND cyear='" . EMP_YEAR . "'";
                $Rq = db_exec($Sl);
                $upaid = pg_num_rows($Rq);
                $upaid += 0;
                $paid -= $upaid;
            }
        }
        if (isset($paid) && $paid > 0) {
            $out .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='1000'>\n\t\t\t\t\t\t<li class='err'>You have already processed a salary for this period, for {$data['sname']}, {$data['fnames']}</li>\n\t\t\t\t\t\t<input type='hidden' name='emps[{$id}]' value='{$id}'>\n\t\t\t\t\t\t<input type='hidden' name='emps_already[{$id}]' value='{$id}'>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>";
            continue;
        }
        if ($divisor[$id] != 1 && round($divisor[$id], 2) != round(52 / 12, 2) && round($divisor[$id], 2) != round(26 / 12, 2)) {
            /*$out .= "<tr><td colspan=1000>
            					<li class=err>Error with pay period (DIVIS), for $data[sname], $data[fnames]</li>
            					<input type=hidden name='emps[$id]' value='$id'>
            					<input type=hidden name='emps_already[$id]' value='$id'>
            				</td></tr>";
            		continue;*/
        }
        if (isset($basic_sal[$id])) {
        } else {
            $annual[$id] = "";
            $novert[$id] = "";
            $hovert[$id] = "";
        }
        if ($data['paytype'] == "Cash") {
            $paydetails = "Cash\n\t\t\t\t<input type='hidden' name='accid[{$id}]' value='0'>";
        } elseif ($data['paytype'] == "Ledger Account") {
            db_conn('core');
            $account[$id] += 0;
            $Sl = "SELECT accid,accname FROM accounts WHERE accid='{$account[$id]}'";
            $Rl = db_exec($Sl);
            $accounts = "<input type='hidden' name='account[{$id}]' value='{$account[$id]}'>";
            $ad = pg_fetch_array($Rl);
            $accounts .= "{$ad['accname']}";
            $paydetails = "{$accounts}\n\t\t\t\t<input type='hidden' name='accid[{$id}]' value='0'>";
        } else {
            $accid[$id] += 0;
            db_conn('cubit');
            $Sl = "SELECT * FROM bankacct WHERE bankid='{$accid[$id]}'";
            $Ry = db_exec($Sl) or errDie("Unable to get bank account.");
            if (pg_numrows($Ry) < 1) {
                return "<li class='err'> There are no bank accounts found in Cubit.\n\t\t\t\t<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct Selection'>";
            }
            $banks = "<input type='hidden' name='accid[{$id}]' value='{$accid[$id]}'>";
            $acc = pg_fetch_array($Ry);
            $banks .= "{$acc['accname']} ({$acc['acctype']})";
            $paydetails = "{$banks}";
        }
        // fringe benefits
        $fringe_tot[$id] = 0;
        $c = 0;
        $fringes = "<table " . TMPL_tblDflts . ">";
        if (isset($fringeid[$id]) && is_array($fringeid[$id])) {
            foreach ($fringeid[$id] as $i => $fid) {
                $fringes .= "\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td>" . $fringename[$id][$i] . "</td>\n\t\t\t\t\t\t<td>" . CUR . "</td>\n\t\t\t\t\t\t<td>" . $fringebens[$id][$i] . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<input type='hidden' name='fringeid[{$id}][{$i}]' value='" . $fringeid[$id][$i] . "'>\n\t\t\t\t\t<input type='hidden' name='fringebens[{$id}][{$i}]' value='" . $fringebens[$id][$i] . "'>\n\t\t\t\t\t<input type='hidden' name='fringename[{$id}][{$i}]' value='" . $fringename[$id][$i] . "'>\n\t\t\t\t\t<input type='hidden' name='fringeaccs[{$id}][{$i}]' value='" . $fringeaccs[$id][$i] . "'>";
                $fringe_tot[$id] += $fringebens[$id][$i];
            }
        }
        $fringes .= "</table>";
        if ($fringe_tot[$id] == 0) {
            $fringes = "";
        }
        $fringes .= "<input type='hidden' name='fringe_tot[{$id}]' value='{$fringe_tot[$id]}'>";
        /* allowances */
        $all_beforeamount[$id] = 0;
        $all_afteramount[$id] = 0;
        $Allowances = "";
        /*		db_conn('cubit');
        		$sql = "SELECT * FROM allowances WHERE div = '".USER_DIV."' ORDER BY allowance";
        		$allowRslt = db_exec ($sql) or errDie ("Unable to select allowances from database.");
        		if (pg_numrows ($allowRslt) < 1) {
        			$Allowances = "None";
        		} else {
        
        			$Allowances = "<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."'>";
        			while ($myAllow = pg_fetch_array ($allowRslt)) {
        				# check if employee has allowance
        				$sql = "SELECT * FROM empallow WHERE allowid='$myAllow[id]' AND empnum='$data[empnum]' AND div = '".USER_DIV."'";
        				$empAllowRslt = db_exec ($sql) or errDie ("Unable to select allowance info from database.");
        				if (pg_numrows ($empAllowRslt) > 0) {
        					$Allowances .= "<tr><td>$myAllow[allowance]</td>";
        					$dataAllow = pg_fetch_array ($empAllowRslt);
        					$dataAllow['amount']=sprint($dataAllow['amount']);
        
        					$allowances[$id][$i]=sprint($allowances[$id][$i]);
        					$Allowances .= "<td>R</td><td align=right>
        					<input type=hidden size=10 name='allowid[$id][]' value='$dataAllow[allowid]'>
        					<input type=hidden size=30 name='allowname[$id][]' value='$myAllow[allowance]'>
        					<input type=hidden size=10 name='allowtax[$id][]' value='$myAllow[add]'>
        					<input type=hidden name='allowaccs[$id][]' value='".$allowaccs[$id][$i]."'>
        					<input type=hidden name='allowances[$id][]' value='".$allowances[$id][$i]."'>".$allowances[$id][$i]."</td></tr>\n";
        
        					if($myAllow['add']=="Yes") {
        						$all_beforeamount[$id] += $allowances[$id][$i];
        					} else {
        						$all_afteramount[$id] += $allowances[$id][$i];
        					}
        				}
        				$i++;
        			}
        
        			$Allowances .= "</table>";
        		}*/
        if (isset($allowid[$id]) && is_array($allowid[$id]) && count($allowid[$id]) > 0) {
            $Allowances = "<table border='0' cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>";
            foreach ($allowid[$id] as $k => $dummy) {
                $Allowances .= "\n\t\t\t\t\t\t<input type='hidden' size='10' name='allowid[{$id}][{$k}]' value='" . $allowid[$id][$k] . "'>\n\t\t\t\t\t\t<input type='hidden' size='30' name='allowname[{$id}][{$k}]' value='" . $allowname[$id][$k] . "'>\n\t\t\t\t\t\t<input type='hidden' size='10' name='allowtax[{$id}][{$k}]' value='" . $allowtax[$id][$k] . "'>\n\t\t\t\t\t\t<input type='hidden' name='allowaccs[{$id}][{$k}]' value='" . $allowaccs[$id][$k] . "'>\n\t\t\t\t\t\t<input type='hidden' name='allowances[{$id}][{$k}]' value='" . $allowances[$id][$k] . "'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . $allowname[$id][$k] . "</td>\n\t\t\t\t\t\t\t<td>" . CUR . "</td>\n\t\t\t\t\t\t\t<td align='right'>" . $allowances[$id][$k] . "</td>\n\t\t\t\t\t\t</tr>";
                if ($allowtax[$id][$k] == "Yes") {
                    $all_beforeamount[$id] += $allowances[$id][$k];
                } else {
                    $all_afteramount[$id] += $allowances[$id][$k];
                }
            }
            $Allowances .= "</table>";
        } else {
            $Allowances = "";
        }
        $Allowances .= "\n\t\t\t<input type='hidden' name='all_beforeamount[{$id}]' value='{$all_beforeamount[$id]}'>\n\t\t\t<input type='hidden' name='all_afteramount[{$id}]' value='{$all_afteramount[$id]}'>";
        $subsistence = "";
        $subs_taxable[$id] = 0;
        $subs_total[$id] = 0;
        $i = 0;
        if (isset($subsname[$id])) {
            if (isset($subs_exch) && $subs_exch == 0) {
                $subs_exch = 1;
            }
            foreach ($subsname[$id] as $sid => $sn) {
                if ($subsrep[$id][$sid] == "yes") {
                    //2012
                    $nontax = $subsdays[$id][$sid] * ($subsmeal[$id][$sid] == "yes" ? 303 : 93);
                    $subs_total[$id] += $subsamt[$id][$sid];
                } else {
                    //TODO
                    //2012
                    // outside republic, 196 dollars
                    $nontax = $subsdays[$id][$sid] * (215 / $subs_exch);
                    $subs_total[$id] += $subsamt[$id][$sid] * $subs_exch;
                }
                $tmp = $subsamt[$id][$sid] - $nontax;
                if ($tmp > 0) {
                    $subs_taxable[$id] += $tmp / $divisor[$id];
                }
                $subsistence .= "\n\t\t\t\t\t<input type='hidden' name='subsname[{$id}][{$sid}]' value='" . $subsname[$id][$sid] . "'>\n\t\t\t\t\t<input type='hidden' name='subsacc[{$id}][{$sid}]' value='" . $subsacc[$id][$sid] . "'>\n\t\t\t\t\t<input type='hidden' name='subsamt[{$id}][{$sid}]' value='" . $subsamt[$id][$sid] . "'>\n\t\t\t\t\t<input type='hidden' name='subsrep[{$id}][{$sid}]' value='" . $subsrep[$id][$sid] . "'>\n\t\t\t\t\t<input type='hidden' name='subsmeal[{$id}][{$sid}]' value='" . $subsmeal[$id][$sid] . "'>\n\t\t\t\t\t<input type='hidden' name='subsdays[{$id}][{$sid}]' value='" . $subsdays[$id][$sid] . "'>\n\t\t\t\t\t<tr bgcolor='" . bgcolor($i) . "'>\n\t\t\t\t\t\t<td nowrap>" . $subsname[$id][$sid] . "</td>\n\t\t\t\t\t\t<td nowrap>" . CUR . " " . $subsamt[$id][$sid] . "</td>\n\t\t\t\t\t\t<td>" . $subsdays[$id][$sid] . "</td>\n\t\t\t\t\t</tr>";
            }
            if (!empty($subsistence)) {
                $subsistence = "\n\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Name</th>\n\t\t\t\t\t\t\t<th>Amount</th>\n\t\t\t\t\t\t\t<th>Days</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t{$subsistence}\n\t\t\t\t\t</table>";
            }
        }
        # Deductions
        $Deductions = "";
        $de_beforeamount[$id] = 0;
        $de_afteramount[$id] = 0;
        $de_beforeamount_emp[$id] = 0;
        $de_afteramount_emp[$id] = 0;
        /*		db_conn('cubit');
        		$sql = "SELECT * FROM salded WHERE div = '".USER_DIV."' ORDER BY deduction";
        		$deductRslt = db_exec ($sql) or errDie ("Unable to select deductions from database.");
        		if (pg_numrows ($deductRslt) < 1) {
        			$Deductions = "None";
        		} else {
        			$Deductions = "<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."'>";
        			while ($myDeduct = pg_fetch_array ($deductRslt)) {
        				# check if employee has deduction
        				$sql = "SELECT * FROM empdeduct WHERE dedid='$myDeduct[id]' AND empnum='$data[empnum]' AND div = '".USER_DIV."'";
        				$empDeductRslt = db_exec ($sql) or errDie ("Unable to select Deduction info from database.");
        				if (pg_numrows ($empDeductRslt) > 0) {
        					$Deductions .= "<tr><td>$myDeduct[deduction]</td>";
        					$dataDeduct = pg_fetch_array ($empDeductRslt);
        
        //					if($dataDeduct['type']=="Amount") {
        //						$dataDeduct['amount']=sprint($dataDeduct['amount']);
        //						$deductions[$id][$i]=sprint($deductions[$id][$i]);
        //					} else {
        //						$deductions[$id][$i]=sprint($data['basic_sal']*$deductions[$id][$i]/100);
        //						//$dataDeduct['amount']=sprint($data['basic_sal']*$dataDeduct['amount']/100);
        //					}
        					$Deductions .= "
        					<td>".CUR."</td><td align=right>
        						<input type=hidden size=10 name='deductid[$id][]' value='$myDeduct[id]'>
        						<input type=hidden size=30 name='deductname[$id][]' value='$myDeduct[deduction]'>
        						<input type=hidden name='deductions[$id][]' value='".$deductions[$id][$i]."'>".$deductions[$id][$i]."
        						<input type=hidden name='dedaccs[$id][]' value='".$dedaccs[$id][$i]."'>
        					</td>
        <!--					<td>".CUR."</td> //-->
        						<td>
        						<input type=hidden name='employer_deductions[$id][]' value='".$employer_deductions[$id][$i]."'>
        						<input type=hidden size=10 name='deducttax[$id][]' value='$myDeduct[add]'></td></tr>\n";
        
        
        					if($myDeduct['add']=="Yes") {
        						$de_beforeamount[$id] += $deductions[$id][$i]+$employer_deductions[$id][$i];
        						//$de_beforeamount_emp[$id] += $employer_deductions[$id][$i];
        					} else {
        						$de_afteramount[$id] += $deductions[$id][$i]+$employer_deductions[$id][$i];
        						//$de_afteramount_emp[$id] += $employer_deductions[$id][$i];
        					}
        
        					$i++;
        				}
        			}
        			$Deductions .= "</table>";
        		}*/
        if (isset($deductid[$id]) && is_array($deductid[$id]) && count($deductid[$id]) > 0) {
            $Deductions = "<table " . TMPL_tblDflts . ">";
            foreach ($deductid[$id] as $k => $dummy) {
                $Deductions .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<input type='hidden' name='deductid[{$id}][{$k}]' value='" . $deductid[$id][$k] . "'>\n\t\t\t\t\t\t<input type='hidden' name='deductname[{$id}][{$k}]' value='" . $deductname[$id][$k] . "'>\n\t\t\t\t\t\t<input type='hidden' name='deductions[{$id}][{$k}]' value='" . $deductions[$id][$k] . "'>\n\t\t\t\t\t\t<input type='hidden' name='dedaccs[{$id}][{$k}]' value='" . $dedaccs[$id][$k] . "'>\n\t\t\t\t\t\t<input type='hidden' name='employer_deductions[{$id}][{$k}]' value='" . $employer_deductions[$id][$k] . "'>\n\t\t\t\t\t\t<input type='hidden' name='deducttax[{$id}][{$k}]' value='" . $deducttax[$id][$k] . "'>\n\t\t\t\t\t\t<td>" . $deductname[$id][$k] . "</td>\n\t\t\t\t\t\t<td>" . CUR . "</td>\n\t\t\t\t\t\t<td>" . $deductions[$id][$k] . "</td>\n\t\t\t\t\t</tr>";
                if ($deducttax[$id][$k] == "Yes") {
                    $de_beforeamount[$id] += $deductions[$id][$k] + $employer_deductions[$id][$k];
                    //$de_beforeamount_emp[$id] += $employer_deductions[$id][$i];
                } else {
                    $de_afteramount[$id] += $deductions[$id][$k] + $employer_deductions[$id][$k];
                    //$de_afteramount_emp[$id] += $employer_deductions[$id][$i];
                }
            }
            $Deductions .= "</table>";
        } else {
            $Deductions = "None";
        }
        $Deductions .= "\n\t\t\t<input type='hidden' name='de_beforeamount[{$id}]' value='{$de_beforeamount[$id]}'>\n\t\t\t<input type='hidden' name='de_beforeamount_emp[{$id}]' value='{$de_beforeamount_emp[$id]}'>\n\t\t\t<input type='hidden' name='de_afteramount[{$id}]' value='{$de_afteramount[$id]}'>\n\t\t\t<input type='hidden' name='de_afteramount_emp[{$id}]' value='{$de_afteramount[$id]}'>";
        db_conn('cubit');
        $Sl = "SELECT * FROM rbs ORDER BY name";
        $Rl = db_exec($Sl) or errDie("Unable to get data.");
        $i = 0;
        if (pg_num_rows($Rl) > 0) {
            $rt = "<table " . TMPL_tblDflts . " width='100%'>";
            while ($td = pg_fetch_array($Rl)) {
                if (!isset($rbsa[$id][$td['id']])) {
                    $rbsa[$id][$td['id']] = "";
                }
                $rbsa[$id][$td['id']] = sprint($rbsa[$id][$td['id']]);
                $rt .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='hidden' name='rbs[{$id}][{$td['id']}]' value='{$td['id']}'>{$td['name']}</td>\n\t\t\t\t\t\t<td>" . CUR . "</td>\n\t\t\t\t\t\t<td align='right'><input type='hidden' name='rbsa[{$id}][{$td['id']}]' value='" . $rbsa[$id][$td['id']] . "'>" . $rbsa[$id][$td['id']] . "</td>\n\t\t\t\t\t</tr>";
                $i++;
            }
            $rt .= "</table>";
        } else {
            $rt = "None";
        }
        // calculate age of employee (if intl., ie has passport num only), act asif under 65
        if (!empty($data["idnum"])) {
            // calculate age of employee
            $bd_year = 1900 + substr($data["idnum"], 0, 2);
            $bd_month = substr($data["idnum"], 2, 2);
            $bd_day = substr($data["idnum"], 4, 2);
            /* get the current financial year */
            db_conn("core");
            $sql = "SELECT yrname FROM active";
            $rslt = db_exec($sql) or errDie("Error fetching financial year.");
            if (pg_num_rows($rslt) < 1) {
                return "Please run quick setup first.";
            }
            $fin_year = substr(pg_fetch_result($rslt, 0, 0), 1);
            $sql = "SELECT EXTRACT('year' FROM AGE('{$fin_year}-02-28', '{$bd_year}-{$bd_month}-{$bd_day}'))";
            $rslt = db_exec($sql) or errDie("Error calculating age at financial year end.");
            $age[$id] = pg_fetch_result($rslt, 0, 0);
        } else {
            $age[$id] = 1;
        }
        # The Paye
        $tyear = 12;
        switch ($data["payprd"]) {
            case 'm':
                $tyear = 12;
                break;
            case 'w':
                $tyear = 52;
                break;
            case 'f':
                $tyear = 26;
                break;
            case 'd':
                $tyear = 5 * 52;
                break;
        }
        if ($data["saltyp"] != "h") {
            if ($myEmp["saltyp"] == "w") {
                $perhr = sprint($basic_sal / $wh_actual);
            } else {
                $perhr = sprint($basic_sal[$id] * $tyear / ($data['hpweek'] * 52));
            }
        } else {
            $perhr = $basic_sal[$id];
        }
        $overamt[$id] = $novert[$id] * ($perhr * $data['novert']);
        $overamt[$id] += sprint($hovert[$id] * ($perhr * $data['hovert']));
        # Multiply basic_sal add overtime
        if (isset($multi[$id])) {
            $basic_sal[$id] = sprint($basic_sal[$id] * $multi[$id]);
            //$tyear = ($tyear/$multi[$id]);
        }
        // calculate loan fringe benefit amount for this month
        if (!empty($data["loanamt"]) && $data["gotloan"] == "t" && $data["loanamt"] > 0) {
            $loanpart = $loaninstall[$id] / $data["loanamt"];
            $fringe_loan[$id] = sprint($data["loanfringe"] * $loanpart);
        } else {
            $fringe_loan[$id] = "0.00";
        }
        $fringe_tot[$id] += $fringe_loan[$id];
        $fringe_tot[$id] += $comp_other[$id];
        $fringe_tot[$id] += $comp_ret[$id];
        //2012
        // calculate motor car fringe benefit
        if ($data["fringe_car1"] > 0) {
            $deduct_perc = 0;
            // Employee has travel allowance?
            if ($data["all_travel"] > 0) {
                $deduct_perc = 0.0325;
            } else {
                $deduct_perc = 0.035;
            }
            $fringe_car1 = $data["fringe_car1"] * $deduct_perc;
        }
        // Second fringe car will always be 3.25%
        if ($data["fringe_car2"] > 0) {
            $fringe_car2 = $data["fringe_car2"] * 0.0325;
        }
        vsprint($fringe_car1[$id]);
        vsprint($fringe_car2[$id]);
        $fringe_tot[$id] += $fringe_car1[$id] + $fringe_car2[$id];
        $fringe_tot[$id] += $de_afteramount_emp[$id] + $de_beforeamount_emp[$id];
        $fringe_tot[$id] += $subs_taxable[$id];
        // calc medical fringe benefits
        if ($comp_medical[$id] > 0) {
            // calculate dependants after first one
            $tmp_deps = $data["emp_meddeps"] - 2;
            if ($tmp_deps < 0) {
                $tmp_deps = 0;
            }
            //2009
            // calculate paragraph 12A amount
            //first 2 dependants are 530 each (1060) rest is 320 each.
            //$p12A_amt = ($data["emp_meddeps"] > 1 ? 1060 : 530) + ($tmp_deps * 320);
            //2010
            // calculate paragraph 12A amount
            //first 2 dependants are 625 each (1250) rest is 380 each.
            //$p12A_amt = ($data["emp_meddeps"] > 1 ? 1250 : 625) + ($tmp_deps * 380);
            //2011
            // calculate paragraph 12A amount
            //first 2 dependants are 670 each (1340) rest is 410 each.
            //$p12A_amt = ($myEmp["emp_meddeps"] > 1 ? 1340 : 820) + ($tmp_deps * 410);
            //2012
            // calculate paragraph 12A amount
            //first 2 dependants are 230 each (460) rest is 154 each.
            $p12A_amt = ($myEmp["emp_meddeps"] > 1 ? 460 : 230) + $tmp_deps * 154;
            // calculate taxable fringe benefit amount
            $fringe_medical[$id] = sprint($comp_medical[$id] - $p12A_amt / $divisor[$id]);
            if ($fringe_medical[$id] < 0) {
                $fringe_medical[$id] = 0;
            }
            $fringe_tot[$id] += $fringe_medical[$id];
        } else {
            $fringe_medical[$id] = 0;
        }
        if ($emp_pension[$id] > $basic_sal[$id] * 7.5 / 100) {
            $emp_mpension[$id] = $basic_sal[$id] * 7.5 / 100;
        } else {
            $emp_mpension[$id] = $emp_pension[$id];
        }
        // calculate total gross salary
        $grossal[$id] = $basic_sal[$id] + $commission[$id] + $abonus[$id] + $overamt[$id] + $bonus[$id] + $annual[$id] + $all_beforeamount[$id] + $all_travel[$id] * 0.8 - $de_beforeamount[$id];
        // deductions deducted before paye (non taxible)
        $grossal_2 = $grossal[$id];
        $taxed_all[$id] = $all_afteramount[$id] + $all_travel[$id] * 0.8;
        $grossal_nodedall[$id] = $basic_sal[$id] + $overamt[$id] + $bonus[$id] + $annual[$id] + $all_travel[$id];
        #UIF HAX
        $uif_grossal[$id] = $grossal[$id];
        // pension/provident/ra: calculate deduction amounts, limiting them to maximum amount and only deducting
        // ONE of them for taxable income
        if ($comp_pension[$id] + $emp_pension[$id] > 0) {
            $tmp = ($grossal_2 + $fringe_tot[$id]) * $tyear;
            $maxallowed = $tmp * 0.075 > 1750 ? $tmp * 0.075 : 1750;
            if ($emp_mpension[$id] > $maxallowed) {
                $tmp_ded = $maxallowed;
            } else {
                $tmp_ded = $emp_mpension[$id];
            }
            $grossal[$id] -= $tmp_ded;
        }
        if ($comp_ret[$id] + $emp_ret[$id] > 0) {
            $tmp = ($grossal_2 + $fringe_tot[$id]) * $tyear;
            // if their is a pension contributions the percentage is 0
            if ($comp_pension[$id] + $emp_pension[$id] + $comp_provident[$id] + $emp_provident[$id] > 0) {
                $PERC = 0;
            } else {
                $PERC = 0.15;
            }
            $maxallowed = $tmp * $PERC > 1750 ? $tmp * $PERC : 1750;
            $maxallowed = $maxallowed > 3500 - $emp_pension[$id] * $divisor[$id] * 12 ? $maxallowed : 3500 - $emp_pension[$id] * 12;
            if (($emp_ret[$id] + $comp_ret[$id]) * $divisor[$id] > $maxallowed / 12) {
                $tmp_ded = $maxallowed / 12 / $divisor[$id];
            } else {
                $tmp_ded = $emp_ret[$id] + $comp_ret[$id];
            }
            $grossal[$id] -= $tmp_ded;
        }
        // calculate total paye salary
        // just remove annual this month, and add annual divided by 12
        // because paye is calculate for full twelve months and therefore
        // paye salary is average received each month
        $paye_salary[$id] = $grossal[$id] - $annual[$id] + $fringe_tot[$id];
        // total fringe benefits;
        #UIF HAX
        $uif_paye_salary[$id] = $uif_grossal[$id] - $annual[$id] + $fringe_tot[$id];
        /* calculate uif */
        $tmp_remun = $paye_salary[$id] + $annual[$id] - $commission[$id] - $abonus[$id];
        #UIF HAX
        $uif_tmp_remun = $uif_paye_salary[$id] + $annual[$id] - $commission[$id] - $abonus[$id];
        //		$comp_uif[$id] = sprint($tmp_remun * ($data["comp_uif"] / 100));
        //		$emp_uif[$id] = sprint($tmp_remun * ($data["emp_uif"] / 100));
        #UIF HAX
        $comp_uif[$id] = sprint($uif_tmp_remun * ($data["comp_uif"] / 100));
        $emp_uif[$id] = sprint($uif_tmp_remun * ($data["emp_uif"] / 100));
        $uifmax = getCSetting("UIF_MAX");
        if ($emp_uif[$id] > $uifmax) {
            $emp_uif[$id] = sprint($uifmax);
        }
        if ($comp_uif[$id] > $uifmax) {
            $comp_uif[$id] = sprint($uifmax);
        }
        /* calculate sdl */
        $tmp_remun = $paye_salary[$id] + $annual[$id];
        if (getCSetting("SDLPAYABLE") == "y") {
            $tmp_sdl = $tmp_remun;
            if ($age > 65) {
                $tmp_sdl -= $comp_medical[$id];
            }
            $comp_sdl[$id] = $tmp_sdl * ($data["comp_sdl"] / 100);
        } else {
            $comp_sdl[$id] = 0;
        }
        // a little hack, apparently the grossal is displayed wrong, in a strictly antisocial.co.za opinion,
        // i think the person who thinks that must suck
        $grossal[$id] += $comp_ret[$id];
        // add rest of travel allowance
        $grossal[$id] += $all_travel[$id] * 0.2;
        if (isset($mpaye[$id])) {
            $paye[$id] = $mpaye_amount[$id];
        } else {
            // calculate paye (take age of 65+ threshold into account)
            //2008
            //			if ( ($age[$id] >= 65 && ($paye_salary[$id] * $tyear) < 69000) || ($paye_salary[$id] * $tyear) < 43000 ) {
            //2009
            // 			if ( ($age[$id] >= 65 && ($paye_salary[$id] * $tyear) < 74000) || ($paye_salary[$id] * $tyear) < 46000 ) {
            //2010
            //			if ( ($age[$id] >= 65 && ($paye_salary[$id] * $tyear) < 84200) || ($paye_salary[$id] * $tyear) < 54200 ) {
            //2011
            //if ( ($age[$id] >= 65 && ($paye_salary[$id] * $tyear) < 88528) || ($paye_salary[$id] * $tyear) < 57000 ) {
            //2012
            if ($age[$id] >= 65 && $age[$id] < 75 && $paye_salary[$id] * $tyear < 99056 || $age[$id] >= 75 && $paye_salary[$id] * $tyear < 110889 || $paye_salary[$id] * $tyear < 63556) {
                $paye[$id] = "0.00";
            } else {
                if ($data["payprd"] == "w" || $data["payprd"] == "f") {
                    $paye_prd = "{$month}:{$week}";
                } else {
                    if ($data["payprd"] == "d") {
                        $paye_prd = "{$month}:{$pday}";
                    } else {
                        $paye_prd = "{$month}";
                    }
                }
                $paye[$id] = calculate_paye($data, $paye_prd, $paye_salary[$id], $tyear, $age[$id]);
                if ($annual[$id] > 0) {
                    $tmp_bonpaye = calculate_paye($data, $paye_prd, $paye_salary[$id] + $annual[$id] / 12, $tyear, $age[$id]);
                    $paye[$id] += $tmp_bonpaye * $tyear - $paye[$id] * $tyear;
                }
            }
        }
        $nonretfunding = $grossal[$id] - $paye[$id] - $loaninstall[$id] - $de_afteramount[$id] + $de_afteramount_emp[$id] + $all_afteramount[$id] - $emp_pension[$id] - $emp_medical[$id] - $emp_provident[$id] - $emp_uif[$id] - $emp_other[$id];
        /*		$ret_max = (1800>($nonretfunding*0.15))?1800:($nonretfunding*0.15);
        
        		if ( $comp_ret[$id] + $emp_ret[$id] > $ret_max ) {
        			$comp_ret[$id] = $ret_max - $emp_ret[$id];
        
        			if ( $comp_ret[$id] < 0 ) {
        				$comp_ret[$id] = 0;
        				$emp_ret[$id] = $ret_max;
        			}
        		}*/
        $nettpay[$id] = $basic_sal[$id] + $overamt[$id] - $paye[$id] + $commission[$id] + $abonus[$id] - $loaninstall[$id] - $de_afteramount[$id] - $de_beforeamount[$id] + $all_afteramount[$id] + $all_beforeamount[$id] - $emp_pension[$id] - $emp_medical[$id] - $emp_ret[$id] - $emp_uif[$id] - $emp_provident[$id] - $emp_other[$id] + $all_travel[$id] + $annual[$id] + $bonus[$id] - $data["fringe_car1_contrib"] - $data["fringe_car2_contrib"] + $subs_total[$id];
        if (isset($rbsa[$id])) {
            $nettpay[$id] += array_sum($rbsa[$id]);
        }
        $nettpay[$id] = sprint($nettpay[$id]);
        //<td><table><tr><td><input type=checkbox name='mpaye[$id]'></td><td><input type=text size=8 name='mpaye_amount[$id]'></td></tr></table></td>
        $totded[$id] = sprint($de_beforeamount[$id] + $de_afteramount[$id] + $emp_pension[$id] + $emp_medical[$id] + $emp_provident[$id] + $emp_ret[$id] + $emp_other[$id]);
        $totded_employer[$id] = sprint($de_beforeamount_emp[$id] + $de_afteramount_emp[$id] + $comp_pension[$id] + $comp_medical[$id] + $comp_provident[$id] + $comp_ret[$id] + $comp_other[$id]);
        $totall[$id] = sprint($all_beforeamount[$id] + $all_afteramount[$id] + $all_travel[$id]);
        if (isset($mpaye[$id])) {
            $che = "<input type='hidden' name='mpaye[{$id}]' value=''>";
        } else {
            $che = "";
        }
        vsprint($grossal[$id]);
        vsprint($basic_sal[$id]);
        vsprint($bonus[$id]);
        vsprint($annual[$id]);
        vsprint($commission[$id]);
        vsprint($abonus[$id]);
        vsprint($all_travel[$id]);
        vsprint($loaninstall[$id]);
        vsprint($comp_pension[$id]);
        vsprint($emp_pension[$id]);
        vsprint($comp_provident[$id]);
        vsprint($emp_provident[$id]);
        vsprint($comp_ret[$id]);
        vsprint($emp_ret[$id]);
        vsprint($comp_medical[$id]);
        vsprint($emp_medical[$id]);
        vsprint($comp_other[$id]);
        vsprint($emp_other[$id]);
        vsprint($novert[$id]);
        vsprint($novert[$id]);
        vsprint($fringe_medical[$id]);
        vsprint($paye[$id]);
        $out .= "\n\t\t\t<input type='hidden' name='mpaye_amount[{$id}]' value='{$mpaye_amount[$id]}'>\n\t\t\t{$che}\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<input type='hidden' name='overamt[{$id}]' value='{$overamt[$id]}'>\n\t\t\t\t<input type='hidden' name='comp_sdl[{$id}]' value='{$comp_sdl[$id]}'>\n\t\t\t\t<input type='hidden' name='process_comp_deductions[{$id}]' value='{$process_comp_deductions[$id]}'>\n\t\t\t\t<input type='hidden' name='grossal[{$id}]' value='{$grossal[$id]}'>\n\t\t\t\t<input type='hidden' name='grossal_nodedall[{$id}]' value='{$grossal_nodedall[$id]}'>\n\t\t\t\t<input type='hidden' name='totded[{$id}]' value='{$totded[$id]}'>\n\t\t\t\t<input type='hidden' name='totded_employer[{$id}]' value='{$totded_employer[$id]}'>\n\t\t\t\t<input type='hidden' name='totall[{$id}]' value='{$totall[$id]}'>\n\t\t\t\t<input type='hidden' name='emps[{$id}]' value='{$id}'>\n\t\t\t\t<input type='hidden' name='fringe_tot[{$id}]' value='{$fringe_tot[$id]}'>\n\t\t\t\t<input type='hidden' name='paye_salary[{$id}]' value='{$paye_salary[$id]}' />\n\t\t\t\t<input type='hidden' name='multi[{$id}]' value='{$multi[$id]}'>\n\t\t\t\t<input type='hidden' name='tyear[{$id}]' value='{$tyear}'>\n\t\t\t\t<input type='hidden' name='taxed_all[{$id}]' value='{$taxed_all[$id]}' />\n\t\t\t\t<td>{$data['enum']}</td>\n\t\t\t\t<td>{$data['sname']}, {$data['fnames']}</td>\n\t\t\t\t<td><input type='hidden' name='basic_sal[{$id}]' value='{$basic_sal_save[$id]}' class='right'>{$basic_sal[$id]}</td>\n\t\t\t\t<td><input type='text' size='8' name='paidamount[{$id}]' id='paidamount[{$id}]' value='0.00'></td>\n\t\t\t\t<td><input type='hidden' name='bonus[{$id}]' value='{$bonus[$id]}' class='right'><input type='hidden' name='abonus[{$id}]' value='{$abonus[$id]}'>{$abonus[$id]}</td>\n\t\t\t\t<input type='hidden' name='annual[{$id}]' value='{$annual[$id]}' />\n\t\t\t\t<!--<td><input type='hidden' name='annual[{$id}]' value='{$annual[$id]}' class='right'>{$annual[$id]}</td>-->\n\t\t\t\t<td><input type='hidden' name='commission[{$id}]' value='{$commission[$id]}' class='right'>{$commission[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='all_travel[{$id}]' value='{$all_travel[$id]}' class='right'>{$all_travel[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='loaninstall[{$id}]' value='{$loaninstall[$id]}' class='right'>{$loaninstall[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='comp_pension[{$id}]' value='{$comp_pension[$id]}' class='right'>{$comp_pension[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='emp_pension[{$id}]' value='{$emp_pension[$id]}' class='right'>{$emp_pension[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='comp_provident[{$id}]' value='{$comp_provident[$id]}' class='right'>{$comp_provident[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='emp_provident[{$id}]' value='{$emp_provident[$id]}' class='right'>{$emp_provident[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='comp_uif[{$id}]' value='{$comp_uif[$id]}' class='right'>{$comp_uif[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='emp_uif[{$id}]' value='{$emp_uif[$id]}' class='right'>{$emp_uif[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='comp_ret[{$id}]' value='{$comp_ret[$id]}' class='right'>{$comp_ret[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='emp_ret[{$id}]' value='{$emp_ret[$id]}' class='right'>{$emp_ret[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='comp_medical[{$id}]' value='{$comp_medical[$id]}' class='right'>{$comp_medical[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='emp_medical[{$id}]' value='{$emp_medical[$id]}' class='right'>{$emp_medical[$id]}</td>\n\n\t\t\t\t<input type='hidden' name='comp_other[{$id}]' value='{$comp_other[$id]}' class='right'>\n\t\t\t\t<input type='hidden' name='emp_other[{$id}]' value='{$emp_other[$id]}' class='right'>\n\t\t\t\t<!--\n\t\t\t\t<td><input type='hidden' name='comp_other[{$id}]' value='{$comp_other[$id]}' class='right'>{$comp_other[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='emp_other[{$id}]' value='{$emp_other[$id]}' class='right'>{$emp_other[$id]}</td>\n\t\t\t\t//-->\n\n\t\t\t\t<td><input type='hidden' name='novert[{$id}]' value='{$novert[$id]}'>{$novert[$id]}</td>\n\t\t\t\t<td><input type='hidden' name='hovert[{$id}]' value='{$hovert[$id]}'>{$hovert[$id]}</td>\n\t\t\t\t<td>{$paydetails}</td>\n\t\t\t\t<td nowrap><input type='hidden' name='fringe_medical[{$id}]' value='{$fringe_medical[$id]}'>" . CUR . " {$fringe_medical[$id]}</td>\n\t\t\t\t<td nowrap><input type='hidden' name='fringe_car1[{$id}]' value='{$fringe_car1[$id]}'>" . CUR . " {$fringe_car1[$id]}</td>\n\t\t\t\t<td nowrap><input type='hidden' name='fringe_car2[{$id}]' value='{$fringe_car2[$id]}'>" . CUR . " {$fringe_car2[$id]}</td>\n\t\t\t\t<td nowrap><input type='hidden' name='fringe_loan[{$id}]' value='{$fringe_loan[$id]}'>" . CUR . " {$fringe_loan[$id]}</td>\n\t\t\t\t<td>{$fringes}</td>\n\t\t\t\t<td>{$Allowances}</td>\n\t\t\t\t<td>{$subsistence}</td>\n\t\t\t\t<td>{$Deductions}</td>\n\t\t\t\t<td>{$rt}</td>\n\t\t\t\t<td>{$grossal[$id]}<input type='hidden' name='grossal[{$id}]' value='{$grossal[$id]}'></td>\n\t\t\t\t<td>{$paye[$id]}<input type='hidden' name='paye[{$id}]' value='{$paye[$id]}'></td>\n\t\t\t\t<td>{$nettpay[$id]}<input type='hidden' id='nettpay[{$id}]' name='nettpay[{$id}]' value='{$nettpay[$id]}'></td>\n\t\t\t</tr>";
        $payall_js .= "getObject('paidamount[{$id}]').value = getObject('nettpay[{$id}]').value;";
    }
    $out .= "\n\t\t\t<tr><td><br></td></tr>{$send}\n\t\t\t<script>\n\t\t\t\tfunction emp_payall() {\n\t\t\t\t\t{$payall_js}\n\t\t\t\t}\n\t\t\t</script>\n\t\t\t<tr>\n\t\t\t\t<td colspan='3'><input type='submit' value='&laquo; Correction'></td>\n\t\t\t\t<td colspan='5'><input type='button' value='Pay Selected Employees In Full After Processing' onClick='emp_payall();'></td>\n\t\t\t\t<td colspan='2' align='right'><input type='submit' value='Process Salaries &raquo;' name='button'></td>\n\t\t\t\t<td colspan='10' align='right'><input type='submit' value='Process Salaries &raquo;' name='button'></td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form>";
    return $out;
}