static function incExist($type, $id) { $type = strtolower($type); if (is_null(clsIncludes::${${type}})) { invalid_use("Invalid include type."); } $v = clsIncludes::${${type}}; return isset($v[$id]); }
function confirm_addr($_POST) { extract($_POST); if (!isset($sordid) or strlen($sordid) < 1) { invalid_use(); } db_connect(); #update database $update_sql = "UPDATE sorders SET del_addr = '{$del_addr}' WHERE sordid = '{$sordid}' AND div = '" . USER_DIV . "'"; $run_update = db_exec($update_sql) or errDie("Unable to update delivery address"); return "\n\t\t<script>\n\t\t\topener.document.form.submit()\n\t\t\twindow.close()\n\t\t</script>"; }
/** * returns key information for customer * * @param int $custid * @return array */ function trhKeyCust($custid, $cols = "*") { if ($cols == "*") { $cols = "email, recv_key, send_key, introtime, introip, ip, userid"; } $cols = preg_replace("/((?<![^ ,])ip|(recv|send)_key)/", "(key).\\1 AS \\1", $cols); $qry = new dbSelect("keys", "trh", grp(m("cols", "{$cols}"), m("where", "custid='{$custid}'"))); $qry->run(); if ($qry->num_rows() <= 0) { invalid_use("This customer isn't configured for Transheks transactioning."); } return $qry->fetch_array(); }
function buildlist(&$frm) { if (!isset($_GET["cusnum"])) { invalid_use(); } $cust = qryCustomer($_GET["cusnum"]); $qry = new dbSelect("plist_prices", "exten", grp(m("where", "listid='{$cust['pricelist']}' AND div='" . USER_DIV . "'"))); $qry->run(); $pli = array(); $pli_noshow = array(); while ($row = $qry->fetch_array()) { if ($row["show"] == "Yes") { $pli[$row["stkid"]] = $row["price"]; } else { $pli_noshow[$row["stkid"]] = $row["price"]; } } $qry = new dbSelect("stock", "cubit", grp(m("where", "div='" . USER_DIV . "'"))); $qry->run(); $plist = ""; while ($row = $qry->fetch_array()) { if (isset($pli_noshow[$row["stkid"]])) { continue; } if (isset($pli[$row["stkid"]])) { $price = $pli[$row["stkid"]]; } else { $price = $row["selamt"]; } $desc = preg_replace("/,/", "", $row["stkdes"]); $plist .= "{$row['stkcod']},{$price},{$desc}\n"; } /* @var $frm cForm */ $frm->setFormParm("post", "../emailsave_page.php"); $frm->setkey("sendmails"); $frm->add_hidden("emailsavepage_key", "sendmails", "string"); $frm->add_hidden("emailsavepage_action", "email", "string"); $frm->add_hidden("emailsavepage_content", base64_encode($plist), "string"); $frm->add_hidden("emailsavepage_mime", "text/plain", "string"); $frm->add_hidden("emailsavepage_subject", "Pricelist from " . COMP_NAME, "string"); $frm->add_hidden("emailsavepage_name", "pricelist.csv", "string"); $frm->add_heading("Sending Pricelist to Customer"); $frm->add_layout("\n\t\t<tr %bgc>\n\t\t\t<td>Customer:</td>\n\t\t\t<td>{$cust['surname']}</td>\n\t\t</tr>\n\t\t<tr %bgc>\n\t\t\t<td>%disp[0]</td>\n\t\t\t<td>%fld[0]</td>\n\t\t</tr>"); $frm->add_hidden("surnames[{$cust['cusnum']}]", $cust["surname"], "string"); $frm->add_text("E-mail", "emailcust[{$cust['cusnum']}]", $cust["email"], "string", "1:255"); return $frm->getfrm_input(); }
function enter(&$frm) { if (!isset($_REQUEST["id"])) { invalid_use(); } $frm->settitle("Supplier Stock Codes"); $frm->setmsg("Please enter the stock codes each of your suppliers use for the\n\t\tselected stock item.<br /><br />\n\t\t<li class='err'>To remove an item from supplier, simply leave field blank.</li>"); $frm->setkey("confirm"); $frm->add_hidden("id", $_REQUEST["id"], "num"); $qry = new dbSelect("suppliers", "cubit"); $qry->run(); $frm->add_heading("Details"); while ($si = $qry->fetch_array()) { $stkcod = trhSuppStkcod($si["supid"], $_REQUEST["id"]); $supdisp = "({$si['supno']}) {$si['supname']}"; $frm->add_text($supdisp, "stkcod[{$si['supid']}]", $stkcod, "string", "0:50"); } return $frm->getfrm_input(); }
function add() { extract($_REQUEST); $qry = new dbSelect("batch_cashbook", "cubit", grp(m("where", wgrp(m("cashid", "{$id}"))))); $qry->run(); if ($qry->num_rows() <= 0) { invalid_use("Invalid batch cashbook entry."); } $bcb = $qry->fetch_array(); if ($bcb["chrgvat"] == "exc") { $bcb["amount"] -= $bcb["vat"]; } extract($bcb, EXTR_SKIP); core_connect(); $accs = qryAccounts(); if ($accs->num_rows() <= 0) { $glacc = "There are no Income accounts in Cubit."; } $glacc = "<select name='accinv'>"; while ($acc = $accs->fetch_array()) { if (isDisabled($acc['accid'])) { continue; } if ($accinv == $acc['accid']) { $sel = "selected"; } else { $sel = ""; } $glacc .= "<option value='{$acc['accid']}' {$sel}>{$acc['accname']}</option>"; } $glacc .= "</select>"; $OUT = "\n\t\t\t\t<h3>Edit Bank Receipt</h3>\n\t\t\t\t<table " . TMPL_tblDflts . " width='100%'>\n\t\t\t\t<form action='" . SELF . "' method='POST' name='form'>\n\t\t\t\t\t<input type='hidden' name='key' value='confirm'>\n\t\t\t\t\t<input type='hidden' name='id' value='{$id}'>\n\t\t\t\t\t<input type='hidden' name='vat' value='{$bcb['vat']}' />\n\t\t\t\t\t<input type='hidden' name='orig_vatcode' value='{$bcb['vatcode']}' />\n\t\t\t\t\t<input type='hidden' name='orig_chrgvat' value='{$bcb['chrgvat']}' />\n\t\t\t\t\t<input type='hidden' name='orig_amount' value='{$bcb['amount']}' />\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>Field</th>\n\t\t\t\t\t\t<th>Value</th>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td>Bank Account</td>\n\t\t\t\t\t\t<td valign='center'>\n\t\t\t\t\t\t\t<select name='bankid'>"; db_connect(); $qry->setTable("bankacct", "cubit"); $qry->setOpt(grp(m("where", "btype!='int' AND div='" . USER_DIV . "'"))); $qry->run(); if ($qry->num_rows() <= 0) { return "<li class='err'> There are no accounts held at the selected Bank.\n\t\t\t<p><input type='button' onClick='JavaScript:history.back();' value='« Correct Selection'>"; } while ($acc = $qry->fetch_array()) { if (isset($bankid) && $bankid == $acc['bankid']) { $sel = "selected"; } else { $sel = ""; } $OUT .= "<option value='{$acc['bankid']}' {$sel}>{$acc['accname']} - {$acc['bankname']} ({$acc['acctype']})</option>"; } if (!isset($name)) { $name = ""; $descript = ""; $cheqnum = ""; $amount = ""; $chrgvat = ""; } db_conn('cubit'); $Sl = "SELECT * FROM vatcodes ORDER BY code"; $Ri = db_exec($Sl) or errDie("Unable to get vat codes"); $Vatcodes = "\n\t\t\t<select name='vatcode'>\n\t\t\t\t<option value='0'>Select</option>"; $vacs = qryVatcode(); $Vatcodes = db_mksel($vacs, "vatcode", $vatcode, "#id", "#code", "0:Select"); list($o_year, $o_month, $o_day) = explode('-', $date); $sel1 = ""; $sel2 = ""; $sel3 = ""; if ($chrgvat == "inc") { $sel1 = "checked=yes"; } else { if ($chrgvat == "exc") { $sel2 = "checked=yes"; } else { if ($chrgvat == "nov") { $sel3 = "checked=yes"; } else { $sel1 = "checked=yes"; } } } $OUT .= "\n\t\t</select>\n\t\t</td>\n\t</tr>\n\t<tr class='" . bg_class() . "'>\n\t\t<td>Date</td>\n\t\t<td>\n\t\t\t" . mkDateSelect("o", $o_year, $o_month, $o_day) . "\n\t\t</td>\n\t</tr>\n\t<tr class='" . bg_class() . "'>\n\t\t<td>Received from</td>\n\t\t<td valign='center'><input size='20' name='name' value='{$name}'></td>\n\t</tr>\n\t<tr class='" . bg_class() . "'>\n\t\t<td>Description</td>\n\t\t<td valign='center'><textarea col='18' rows='3' name='descript'>{$descript}</textarea></td>\n\t</tr>\n\t<tr class='" . bg_class() . "'>\n\t\t<td>Reference</td>\n\t\t<td valign='center'><input size='20' name='reference' value='{$reference}'></td>\n\t</tr>\n\t<tr class='" . bg_class() . "'>\n\t\t<td>Cheque Number</td>\n\t\t<td valign='center'><input size='20' name='cheqnum' value='{$cheqnum}'></td>\n\t</tr>\n\t<tr class='" . bg_class() . "'>\n\t\t<td>Amount</td>\n\t\t<td valign='center'>" . CUR . " <input type='text' size='10' name='amount' value='" . sprint($amount) . "'></td>\n\t</tr>\n\t<tr class='" . bg_class() . "'>\n\t\t<td>VAT </td>\n\t\t<td>\n\t\t\t<input type='radio' name='chrgvat' value='inc' {$sel1}>Inclusive \n\t\t\t<input type='radio' name='chrgvat' value='exc' {$sel2}>Exclusive \n\t\t\t<input type='radio' name='chrgvat' value='nov' {$sel3}>No VAT\n\t\t</td>\n\t</tr>\n\t<tr class='" . bg_class() . "'>\n\t\t<td>VAT Code</td>\n\t\t<td>{$Vatcodes}</td>\n\t</tr>\n\t<tr class='" . bg_class() . "'>\n\t\t<td valign='top'>Select Contra Account</td>\n\t\t<td>{$glacc}</td>\n\t</tr>\n\t<tr>\n\t\t<td> </td>\n\t\t<td valign='center' align='right'><input type='submit' value='Confirm »'></td>\n\t</tr>\n\t</table>"; # main table (layout with menu) $OUT .= mkQuickLinks(); return $OUT; }
function deny() { extract($_REQUEST); /* order info */ $qry = new dbSelect("recvpurch", "trh", grp(m("where", wgrp(m("id", $id))))); $qry->run(); if ($qry->num_rows() <= 0) { invalid_use("<li class='err'>Invalid Sales Order Id (TRHAPP).</li>"); } $soi = $qry->fetch_array(); /* set approve status */ $cols = grp(m("approved", "d")); $upd = new dbUpdate("recvpurch", "trh", $cols, "id='{$id}'"); $upd->run(DB_UPDATE); /* get customer trh config */ $keyinfo = trhKeyCust($soi["custid"]); $email = $keyinfo["email"]; /* send trh response message */ $purinfo = array("purid" => $soi["purid"], "status" => "d"); $ret = send_trhmsg("cust", $soi["custid"], $email, "rsppur", $purinfo); $OUT = listorders("<li class='err'>Successfully denied sales order.</li>"); return $OUT; }
function slip($_POST, $pure = false) { # get vars extract($_POST); $empnum += 0; # validate input require_lib("validate"); $v = new validate(); if (isset($from_day)) { $v->isOk($from_day, "num", 1, 2, "Invalid from Date day."); $v->isOk($from_month, "num", 1, 2, "Invalid from Date month."); $v->isOk($from_year, "num", 1, 4, "Invalid from Date Year."); $v->isOk($to_day, "num", 1, 2, "Invalid to Date day."); $v->isOk($to_month, "num", 1, 2, "Invalid to Date month."); $v->isOk($to_year, "num", 1, 4, "Invalid to Date Year."); # mix dates $fromdate = $from_year . "-" . $from_month . "-" . $from_day; $todate = $to_year . "-" . $to_month . "-" . $to_day; if (!checkdate($from_month, $from_day, $from_year)) { $v->isOk($fromdate, "num", 1, 1, "Invalid from date."); } if (!checkdate($to_month, $to_day, $to_year)) { $v->isOk($todate, "num", 1, 1, "Invalid to date."); } } else { if (isset($mon)) { $v->isOk($mon, "num", 1, 2, "Invalid month selected."); } } $v->isOk($empnum, "num", 1, 14, "Invalid employee selected."); # display errors, if any if ($v->isError()) { $confirmCust = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirmCust .= "<li class='err'>" . $e["msg"] . "</li>"; } $confirmCust .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>"; return $confirmCust; } #check what we have permission to $get_perm = "SELECT payroll_groups FROM users WHERE username = '******'USER_NAME']}' LIMIT 1"; $run_perm = db_exec($get_perm) or errDie("Unable to get payroll groups permission information."); if (pg_numrows($run_perm) > 0) { $parr = pg_fetch_array($run_perm); if (strlen($parr['payroll_groups']) > 0) { $pay_grps = explode(",", $parr['payroll_groups']); } else { $pay_grps = array(); } } else { $pay_grps = array(); } if (isset($emp_group) and is_array($emp_group)) { $emp_groups = array(); $emps = array(); foreach ($emp_group as $each) { if (!in_array($each, $pay_grps)) { continue; } $emp_groups[] = $each; $get_emp = "SELECT empnum FROM employees WHERE emp_group = '{$each}'"; $run_emp = db_exec($get_emp) or errDie("Unable to get employees information."); if (pg_numrows($run_emp) > 0) { while ($earr = pg_fetch_array($run_emp)) { $emps[] = $earr['empnum']; } } } } else { #check for which groups we have perm $get_check = "SELECT payroll_groups FROM users WHERE username = '******'USER_NAME']}' LIMIT 1"; $run_check = db_exec($get_check) or errDie("Unable to get employees group permissions."); if (pg_numrows($run_check) > 0) { $earr = pg_fetch_array($run_check); if (strlen($earr['payroll_groups']) > 0) { $eperms = explode(",", $earr['payroll_groups']); $egsearch = " AND (emp_group = '" . implode("' OR emp_group = '", $eperms) . "')"; } else { $egsearch = "AND FALSE"; } } $emp_groups[] = array(0 => '0'); $get_emp = "SELECT empnum FROM employees WHERE true {$egsearch}"; $run_emp = db_exec($get_emp) or errDie("Unable to get employees information."); while ($earr = pg_fetch_array($run_emp)) { $emps[] = $earr['empnum']; } } if (!isset($emps)) { $emps = array(0); } if (in_array('0', $emp_groups)) { $show_all = TRUE; } else { $show_all = FALSE; } $totgross = 0; $totcomm = 0; $totins = 0; $totuif = 0; $totpaye = 0; $totded = 0; $totsal = 0; if (!isset($salyear) or strlen($salyear) < 1) { $salyear = EMP_YEAR; } /* get employee details */ db_connect(); if (isset($from_day)) { $retfunc = "slctDate"; if ($empnum != "0") { #if not all then use selected employee $empw = "empnum='{$empnum}' AND "; } else { #else use all payslips ... but only with emps in selected group if (!$show_all) { $empw = ""; foreach ($emps as $each) { $empw .= "empnum='{$each}' OR "; } $empw .= "empnum='{$each}'"; } } if (substr($empw, -4) == "AND ") { $empw = substr($empw, 0, -4); } if (!isset($empw)) { $empw = "true"; } $sql = "SELECT 'salp' AS paytype, * FROM salpaid\n\t\t\t\tWHERE ({$empw}) AND saldate >= '{$fromdate}' AND saldate <= '{$todate}' AND div = '" . USER_DIV . "' AND cyear='{$salyear}'\n\t\t\t\tUNION\n\t\t\t\tSELECT 'salr' AS paytype, * FROM salr\n\t\t\t\tWHERE ({$empw}) AND saldate >= '{$fromdate}' AND saldate <= '{$todate}' AND div = '" . USER_DIV . "' AND cyear='{$salyear}'\n\t\t\t\tORDER BY true_ids ASC"; } else { if (isset($empnum)) { $retfunc = "slctEmployee"; $sql = "SELECT 'salp' AS paytype, * FROM salpaid\n\t\t\t\tWHERE month='{$mon}' AND empnum='{$empnum}' AND div = '" . USER_DIV . "' AND cyear='{$salyear}'\n\t\t\t\tUNION\n\t\t\t\tSELECT 'salr' AS paytype, * FROM salr\n\t\t\t\tWHERE month='{$mon}' AND empnum='{$empnum}' AND div = '" . USER_DIV . "' AND cyear='{$salyear}'\n\t\t\t\tORDER BY true_ids ASC"; } else { invalid_use(); } } $pRslt = db_exec($sql) or errDie("Unable to select employee payments from database."); if (pg_numrows($pRslt) < 1) { return "<li class='err'> - Employee salaries matching the search criteria not found.</li>" . $retfunc(); } $slip = ""; if (pg_numrows($pRslt) > 0) { $empdata = array(); $empcounter = array(); while ($pay = pg_fetch_array($pRslt)) { $en = $pay["empnum"]; $mwid = "{$pay['month']}:{$pay['week']}"; if (!isset($empdata[$en])) { $empdata[$en] = array(); } if (!isset($empdata[$en][$mwid])) { $empdata[$en][$mwid] = array("gross" => 0, "comm" => 0, "loanins" => 0, "uif" => 0, "paye" => 0, "salary" => 0, "saldate" => "", "payslip" => 0); } $ed =& $empdata[$en][$mwid]; $gross = $pay['salary'] - $pay['totallow'] - $pay['comm'] + $pay['totded'] + $pay['uif'] + $pay['paye'] + $pay['loanins']; $ed["saldate"] = $pay["saldate"]; if ($pay["paytype"] == "salp") { $ed["gross"] += $gross; $ed["comm"] += $pay["comm"]; $ed["loanins"] += $pay["loanins"]; $ed["uif"] += $pay["uif"]; $ed["paye"] += $pay["paye"]; // $ed["totded"] += $pay["totded"]; $ed["salary"] += $pay["salary"]; $ed["payslip"] = $pay["id"]; $totgross += $gross; $totcomm += $pay['comm']; $totins += $pay['loanins']; $totuif += $pay['uif']; $totpaye += $pay['paye']; $totded += $pay['totded']; $totsal += $pay['salary']; } else { $ed["gross"] -= $gross; $ed["comm"] -= $pay["comm"]; $ed["loanins"] -= $pay["loanins"]; $ed["uif"] -= $pay["uif"]; $ed["paye"] -= $pay["paye"]; // $ed["totded"] -= $pay["totded"]; $ed["salary"] -= $pay["salary"]; $ed["payslip"] = "{$pay['id']}&rev=true"; $totgross -= $gross; $totcomm -= $pay['comm']; $totins -= $pay['loanins']; $totuif -= $pay['uif']; $totpaye -= $pay['paye']; $totded -= $pay['totded']; $totsal -= $pay['salary']; } $get_deds = "SELECT distinct(type) FROM emp_ded WHERE payslip = '{$pay['id']}'"; $run_deds = db_exec($get_deds) or errDie("Unable to get salary deduction information."); if (pg_numrows($run_deds) > 0) { // $deductions = ""; // $ed["totded"] = array() $colspan = 0; while ($darr = pg_fetch_array($run_deds)) { $darr['type'] += 0; if ($darr['type'] > 0) { print "adding a deduction<br>"; $get_amt = "SELECT amount, description FROM emp_ded WHERE payslip = '{$pay['id']}' AND type = '{$darr['type']}' LIMIT 1"; $run_amt = db_exec($get_amt) or errDie("Unable to get employee deduction amount."); $deduction_heading .= "<th>" . pg_fetch_result($run_amt, 0, 1) . "</th>"; $ed["totded"][] = "<td nowrap>" . CUR . " " . sprint(pg_fetch_result($run_amt, 0, 0)) . "</td>"; // $deductions .= "<td nowrap>".CUR." ".sprint($darr['amount'])."</td>"; $colspan++; } } } else { // $deductions = ""; $colspan = 1; } } print "----------<br>"; print "<pre>"; var_dump($ed); print "</pre>"; print "<br>>>>>>>>>>>>>>>>>>>>><br>"; // print "<pre>"; // var_dump ($ foreach ($empdata as $empnum => $months) { foreach ($months as $monthweek => $sal) { list($month, $week) = explode(":", $monthweek); if (($emp = qryEmployee($empnum, "fnames, sname, basic_sal, payprd")) === false) { $emp = qryLEmployee($empnum, "fnames, sname, basic_sal, payprd"); } // not a date range but a single employee, store the name if (!isset($from_day)) { $empname = "{$emp['fnames']} {$emp['sname']}"; } /* create month week description */ $mw_desc = getMonthName($month); // weekly if ($emp["payprd"] == "w") { $mw_desc .= ", Week {$week}"; // fortnightly } else { if ($emp["payprd"] == "f") { if ($week == 1) { $week = "1-2"; } else { if ($week == 2) { $week = "3-4"; } else { $week = "5"; } } $mw_desc .= ", Week {$week}"; } } print "<pre>"; var_dump($sal["totded"]); print "</pre>"; $bgColor = bgcolorg(); $slip .= "\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td>{$emp['fnames']} {$emp['sname']}</td>\n\t\t\t\t\t\t<td nowrap>" . CUR . " " . sprint($sal["gross"]) . "</td>\n\t\t\t\t\t\t<td nowrap>" . CUR . " " . sprint($sal["comm"]) . "</td>\n\t\t\t\t\t\t<td nowrap>" . CUR . " " . sprint($sal["loanins"]) . "</td>\n\t\t\t\t\t\t<td nowrap>" . CUR . " " . sprint($sal["uif"]) . "</td>\n\t\t\t\t\t\t<td nowrap>" . CUR . " " . sprint($sal["paye"]) . "</td>\n\t\t\t\t\t\t" . implode("", $sal["totded"]) . "\n\t\t\t\t\t\t<td nowrap>" . CUR . " " . sprint($sal["salary"]) . "</td>\n\t\t\t\t\t\t<td nowrap>{$mw_desc}</td>\n\t\t\t\t\t\t<td nowrap>{$sal['saldate']}</td>"; if (!$pure) { $slip .= "\n\t\t\t\t\t\t<td><a href='payslip-view.php?empnum={$empnum}&id={$sal['payslip']}'>View</a></td>\n\t\t\t\t\t\t<td><a target='_blank' href='payslip-print.php?id={$sal['payslip']}'>Print</a></td>"; } $slip .= "</tr>"; } } # Format the totals $totgross = sprint($totgross); $totcomm = sprint($totcomm); $totins = sprint($totins); $totuif = sprint($totuif); $totpaye = sprint($totpaye); $totded = sprint($totded); $totsal = sprint($totsal); $slip .= "\n\t\t\t<tr class='bg-even'>\n\t\t\t\t<td><b>Total</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$totgross}</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$totcomm}</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$totins}</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$totuif}</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$totpaye}</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$totded}</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$totsal}</b></td>\n\t\t\t\t<td colspan='4'></td>\n\t\t\t</tr>"; } else { return "<li> - There are no salary payments for the selected month</li>"; } if (isset($from_day)) { $title = "<h3>Salaries Paid {$fromdate} TO {$todate}</h3>"; } else { $title = "<h3>Salaries for {$empname}</h3>"; } $slip = "\n\t\t<center>\n\t\t{$title}\n\t\t<table " . TMPL_tblDflts . " width='70%'>\n\t\t\t<tr>\n\t\t\t\t<th>Employee</th>\n\t\t\t\t<th>Gross Salary</th>\n\t\t\t\t<th>Commission</th>\n\t\t\t\t<th>Low or interest free loan</th>\n\t\t\t\t<th>UIF</th>\n\t\t\t\t<th>PAYE</th>\n\t\t\t\t<th colspan='{$colspan}'>Deductions</th>\n\t\t\t\t<th>Nett Income</th>\n\t\t\t\t<th>Month/Week</th>\n\t\t\t\t<th>Payment Date</th>\n\t\t\t\t" . (!$pure ? "<th colspan='2'>Options</th>" : "") . "\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th colspan='6'></th>\n\t\t\t\t{$deduction_heading}\n\t\t\t\t<th colspan='5'></th>\n\t\t\t</tr>\n\t\t\t{$slip}\n\t\t\t" . TBL_BR; if (!$pure) { $slip .= "\n\t\t\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t\t" . array2form($_REQUEST) . "\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='2'><input name=key type=submit value='Export to Spreadsheet'></td>\n\t\t\t\t</tr>\n\t\t\t</form>" . mkQuickLinks(ql("../admin-employee-add.php", "Add Employee")) . "\n\t\t\t</td></tR>"; } $slip .= "\n\t\t</table>\n\t\t</center>"; return $slip; }
<?php require "../settings.php"; invalid_use("Script Disabled."); exit; if (!isset($_REQUEST["key"])) { $_REQUEST["key"] = "select"; } $frm =& new cForm(); switch ($_REQUEST["key"]) { case "write": $OUTPUT = write($frm); break; case "confirm": $OUTPUT = confirm($frm); break; case "select": default: $OUTPUT = select($frm); break; } $OUTPUT .= "<br /><br />" . mkQuickLinks(ql("salaries-staff.php", "Process Employee Salary"), ql("settings-acc-edit.php", "General Settings"), ql("../admin-employee-add.php", "Add New Employee"), ql("../admin-employee-view.php", "View Employees")); parse(); function select($frm) { extract($_REQUEST); if (!isset($emp_year)) { $emp_year = getCSetting("EMP_TAXYEAR"); } /* @var $frm cForm */ $frm->setkey("confirm");
break; case "gather_emails": $OUTPUT = gather_emails(); break; case "sendmails": $OUTPUT = send_mails(); break; default: invalid_use(); } } } else { if (AJAX) { $OUTPUT = get_recip(); } else { invalid_use(); } } require "template.php"; function get_recip() { global $_SESSION; extract($_REQUEST); if (!AJAX) { $content = $_POST["emailsavepage_content"]; } if (!isset($action)) { $action = "listcust"; } /* session var prefix */ $SPRE = "custview_";
function send() { if (!isset($_REQUEST["id"])) { invalid_use(); } /* fetch purchase information */ $purchase = new dbSelect("purchases", "cubit", grp(m("where", "purid='{$_REQUEST['id']}'"))); $purchase->run(); if ($purchase->num_rows() <= 0) { invalid_use("Invalid purchase."); } $purdata = $purchase->fetch_array(); /* fetch the transheks email address of this supplier */ $qry = new dbSelect("keys", "trh", grp(m("cols", "email, (key).send_key AS send_key"), m("where", "suppid='{$purdata['supid']}'"))); $qry->run(); if ($qry->num_rows() <= 0) { invalid_use("This supplier isn't configured for Transheks transactioning."); } $keyinfo = trhKeySupp($purdata["supid"]); $email = $keyinfo["email"]; $send_key = $keyinfo["send_key"]; if (empty($send_key)) { invalid_use("This supplier hasn't confirmed the Transactioning request sent."); } /* fetch purchase item information */ $puritems = array(); $purchase->setTable("pur_items", "cubit"); $purchase->run(); if ($purchase->num_rows() <= 0) { invalid_use("Invalid purchase, purchase has no items."); } while ($row = $purchase->fetch_array()) { $puritems[] = $row; } /* build xml data */ $XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $attrs = array(); foreach ($purdata as $k => $v) { $attrs[] = "{$k}=\"{$v}\""; } $XML .= "<purdata " . implode(" ", $attrs) . ">\n"; foreach ($puritems as $puritem_data) { $attrs = array(); foreach ($puritem_data as $k => $v) { $attrs[] = "{$k}=\"{$v}\""; } $XML .= "\t<puritem " . implode(" ", $attrs) . " />\n"; } $XML .= "</purdata>\n"; $OUT = "<h3>Send Supplier Order</h3>"; if (($ret = send_trhmsg("supp", $purdata["supid"], $email, "reqpur", $XML)) !== true) { if ($ret === false) { $OUT .= "<li class='err'>There was an unknown error sending order to supplier.</li>"; } else { $OUT .= "<li class='err'>Error sending order to supplier: {$ret}.</li>"; } } else { $OUT .= "Successfully sent order to supplier."; } return $OUT; }
function enter($_POST, $err = "") { extract($_POST); global $PRDMON, $MONPRD; $salyr = getYearOfEmpMon($month); $curyr = getActiveFinYear(); if ($salyr > $curyr || $salyr == $curyr && $month > $PRDMON[12]) { header("Location: ../admin-employee-view.php?err=Cannot do transaction in future financial year. You need to close your year first before you can continue.&" . array2get($_POST)); exit; } if (!isset($emps) || !is_array($emps)) { header("Location: ../admin-employee-view.php?err=Please select at least one employee."); exit; } // first check if all the selected employees with EFT pay types have banking information // and their id numbers are valid $emp_err = array(); $emp_nam = array(); foreach ($emps as $e_empnum => $e_val) { /* previously selected to remove this employee from process */ if (isset($rememp[$e_empnum])) { unset($emps[$e_empnum]); continue; } $sql = "\n\t\t\tSELECT fnames, sname, paytype, bankname, bankaccno, idnum, flag, hiredate, payprd \n\t\t\tFROM employees \n\t\t\tWHERE div='" . USER_DIV . "' AND empnum='{$e_empnum}'"; $rslt = db_exec($sql) or errDie("error checking employee payment types."); $e_info = pg_fetch_array($rslt); /* if the employee's pay period doesn't match the selected button, don't include employee in checklist */ if (isset($d) && $e_info["payprd"] != "d") { continue; } else { if (isset($w) && $e_info["payprd"] != "w") { continue; } else { if (isset($b) && $e_info["payprd"] != "f") { continue; } else { if (isset($m) && $e_info["payprd"] != "m") { continue; } } } } $e_empnum += 0; $emp_err[$e_empnum] = 0; $emp_nam[$e_empnum] = "{$e_info['fnames']} {$e_info['sname']}"; if ($e_info["paytype"] == "EFT" && (empty($e_info["bankname"]) || empty($e_info["bankaccno"]))) { $emp_err[$e_empnum] |= 0x1; } if (!empty($e_info["idnum"])) { $bd_year = substr($e_info["idnum"], 0, 2); $bd_month = substr($e_info["idnum"], 2, 2); $bd_day = substr($e_info["idnum"], 4, 2); if (!checkdate($bd_month, $bd_day, $bd_year)) { $emp_err[$e_empnum] |= 0x2; } } if ($e_info["flag"] == "2.5EMP") { $emp_err[$e_empnum] |= 0x4; $special_error = 0x1; } if ($e_info["flag"] == "272PREVEMP") { $emp_err[$e_empnum] |= 0x4; $special_error = 0x2; } /* check hiredate after process date */ explodeDate($e_info["hiredate"], $hd_year, $hd_month, $hd_day); $MONempyear = getYearOfEmpMon($month); if ($hd_year > $MONempyear || $hd_year == $MONempyear && $hd_month > $month) { $emp_err[$e_empnum] |= 0x8; } } // list the employee information problems if (array_sum($emp_err) > 0) { $out = "\n\t\t\t<h3>Batch Salaries</h3>\n\t\t\t\t<form method='POST' action='" . SELF . "'>"; foreach ($_POST as $key => $value) { if (is_array($value)) { foreach ($value as $akey => $avalue) { $out .= "<input type='hidden' name='{$key}" . "[{$akey}]' value='{$avalue}'>"; } } else { $out .= "<input type='hidden' name='{$key}' value='{$value}'>"; } } if (isset($special_error)) { switch ($special_error) { case 0x1: $out .= "\n\t\t\t\t\t<li class='err'><strong>NOTICE:</strong> Due to changes in employee functionality from Cubit 2.5 to Cubit 2.6 <br>\n\t\t\t\t\t\tyou need to edit your employees' salary/deduction/allowance information</li>\n\t\t\t\t\t\t<br />"; break; case 0x2: $out .= "\n\t\t\t\t\t<li class='err'><strong>NOTICE:</strong> Due to the changes from Cubit 2.71 to Cubit 2.72 you should first update your employee's\n\t\t\t\t\t\tprevious employment information in the employee edit form.</li>\n\t\t\t\t\t\t<br />"; break; } } $out .= "\n\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='3' class='err'>There are problems with the following employees.<br />\n\t\t\t\t\t\tEdit their information or to remove an employee from the process select\n\t\t\t\t\t\tthe checkbox next to employee's name.<br /><br />\n\t\t\t\t\t\tClick the 'Done' button when ready to proceed.</td>\n\t\t\t\t</tr>"; $out .= "\n\t\t\t<tr>\n\t\t\t\t<td> </td>\n\t\t\t\t<th>Name</th>\n\t\t\t\t<th>Message</th>\n\t\t\t</tr>"; $i = 0; foreach ($emp_err as $e_empnum => $err_val) { $out .= "\n\t\t\t\t<tr bgcolor='" . bgcolor($i) . "'>\n\t\t\t\t\t<td><input type='checkbox' name='rememp[{$e_empnum}]' /></td>\n\t\t\t\t\t<th>{$emp_nam[$e_empnum]}</td>"; if ($err_val & 0x4) { $specerr_msg = "(See above notice for this employee)"; } else { $specerr_msg = ""; } if ($err_val & 0x1 && $err_val & 0x2) { $out .= "<td class='err'>Banking info and ID number {$specerr_msg}</td>"; } else { if ($err_val & 0x1) { $out .= "<td class='err'>Banking info {$specerr_msg}</td>"; } else { if ($err_val & 0x2) { $out .= "<td class='err'>ID number {$specerr_msg}</td>"; } else { if ($err_val & 0x8) { $out .= "<td class='err'>Employee was not employed in the period\n\t\t\t\t\trequested {$specerr_msg}</td>"; } else { $out .= "<td>Employee Info Correct {$specerr_msg}</td>"; } } } } if ($err_val && !($err_val == 0x8)) { $out .= "<td class='err'><a target='_blank' href='../admin-employee-edit.php?empnum={$e_empnum}'>Edit Employee</a></td>"; } $out .= "</tr>"; } $out .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='3' align='right'><input type='submit' value='Done' /></td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t\t</form>"; return $out; } if (!isset($date_day)) { $date_day = date("d"); $date_month = date("m"); $date_year = date("Y"); } if (!isset($date_month)) { $date_month = date("m"); } /* make week/day selections */ if (isset($w)) { $weekends = ""; $weeks = "<select name='week'>"; $stdate = mktime(0, 0, 0, $month, 1, DATE_YEAR); $endate = mktime(0, 0, 0, $month, DATE_DAYS, DATE_YEAR); $i = 1; while ($stdate <= $endate) { if (date("w", $stdate) == 5) { $weekends .= "<input type='hidden' name='weekends[{$i}]' value='" . date("j", $stdate) . "' />"; if (isset($week) && $week == $i) { $sel = "selected"; } else { $sel = ""; } $weeks .= "<option {$sel} value='{$i}'>Week {$i} (" . date("j M", $stdate) . ")</option>"; ++$i; } /* next day */ $stdate += 24 * 60 * 60; } /*<option value='1'>Week 1</option> <option value='2'>Week 2</option> <option value='3'>Week 3</option> <option value='4'>Week 4</option> <option value='5'>Week 5</option>*/ $weeks .= "</select>"; $weeks = "\n\t\t\t<th>Week</th>\n\t\t\t<td>{$weekends}{$weeks}</td>\n\t\t\t<td class='err'>Period salaries are processed for</td>"; } else { if (isset($b)) { $weekends = ""; $weeks = "<select name='week'>"; $i = 1; /* find first friday of tax year */ $stdate = mktime(0, 0, 0, 3, 1, getYearOfEmpMon(3)); while (date("w", $stdate) != 5) { $stdate = mktime(0, 0, 0, 3, ++$i, getYearOfEmpMon(3)); } // hack: go one week back so the +14 increases are easier $stdate -= 7 * 24 * 3600; /* end on the last day of the selected month */ $endate = mktime(0, 0, 0, $month + 1, 0, getYearOfEmpMon($month)); /* count weeks from start of tax year */ $i = 1; $c = 0; while ($stdate <= $endate) { if (date("m", $stdate) == $month && date("Y", $stdate) == getYearOfEmpMon($month)) { $c += 2; $cd = $c - 1 . "-{$c}"; $weekends .= "<input type='hidden' name='weekends[{$i}]' value='" . date("j", $stdate) . "' />"; if (isset($week) && $week == $i) { $sel = "selected"; } else { $sel = ""; } $weeks .= "<option {$sel} value='{$i}'>Week {$cd} (" . date("j M", $stdate) . ")</option>"; ++$i; } /* next day */ $stdate += 24 * 60 * 60 * 14; } /*<option value='1'>Week 1</option> <option value='2'>Week 2</option> <option value='3'>Week 3</option> <option value='4'>Week 4</option> <option value='5'>Week 5</option>*/ $weeks .= "\n\t\t</select>"; $weeks = "\n\t\t\t<th>Week</th>\n\t\t\t<td>{$weekends}{$weeks}</td>\n\t\t\t<td class='err'>Period salaries are processed for</td>"; } else { if (isset($d)) { $x = date("t", mktime(0, 0, 0, $month, 1, getYearOfFinMon($month))); $MONstr = getMonthNameS($month); if (!isset($proc_day)) { $proc_day = 0; } if (!isset($pday)) { $pday = $proc_day; } $days = "<select name='pday'>"; for ($i = 1; $i <= $x; ++$i) { if ($i == $pday) { $sel = "selected='t'"; } else { $sel = ""; } $days .= "<option {$sel} value='{$i}'>{$i} {$MONstr}</option>"; } $days .= "</select>"; $weeks = "\n\t\t\t<th>Day for Payment</th>\n\t\t\t<td>{$days}</td>\n\t\t\t<td class='err'>Period salaries are processed for</td>"; } else { $weeks = "<input type='hidden' name='week' value='0'>"; } } } /* payprd message */ if (isset($d)) { $cpayprd = "d"; } else { if (isset($w)) { $cpayprd = "w"; } else { if (isset($b)) { $cpayprd = "f"; } else { if (isset($m)) { $cpayprd = "m"; } else { invalid_use("Invalid payment type selected."); } } } } $dispmsg = getCSetting("EMP_SALMSG"); if (strpos($dispmsg, $cpayprd) === false) { $payprd_msg_ch = ""; } else { $payprd_msg_ch = "checked='t'"; } $payprd_msg = get_payprdmsg($cpayprd); /* print payslip on/off */ $printslip = getCSetting("EMP_PRINTSLIP"); $out = "\n\t\t<script>\n\t\t\tfunction update_salmsg(obj) {\n\t\t\t\tajaxRequest('payprdmsg.php', 'payprd_msg', AJAX_SET,'payprd={$cpayprd}&newval=' + obj.checked);\n\t\t\t}\n\t\t</script>\n\t\t<form action='" . SELF . "' method='POST' id='salfrm'>\n\t\t\t<input type='hidden' name='key' value='confirm' />\n\t\t\t<input type='hidden' name='month' value='{$month}' />\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<td colspan='9'>\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><h3>Processing Batch Salaries</h3></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<li class='err'>NOTE that Cubit is configured to compute employees' tax\n\t\t\t\t\t\t\t\t\tduring the employees' tax year that<br />\n\t\t\t\t\t\t\t\t\tstarts in March and ends in February,\n\t\t\t\t\t\t\t\t\tirrespective of the employer's financial year end.</li>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td id='payprd_msg' colspan='2'>{$payprd_msg}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th align='right'>Salary Help Message: <input type='checkbox' onclick='update_salmsg(this);' name='payprd_dispmsg' {$payprd_msg_ch} /></th>\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='6' valign='top' rowspan='2'>\n\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t{$weeks}\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<th>Processing Date:</th>\n\t\t\t\t\t\t<td nowrap>" . mkDateSelect("date", $date_year, $date_month, $date_day) . "</td>\n\t\t\t\t\t\t<td colspan='2' class='err'>Date used by Cubit for the ledgers.</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<th nowrap='t'>Print Salary Advice</th\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t<select name='printslip'>\n\t\t\t\t\t\t\t<option value='y' " . ($printslip != "n" ? "selected='t'" : "") . ">Yes</option>\n\t\t\t\t\t\t\t<option value='n' " . ($printslip == "n" ? "selected='t'" : "") . ">No</option>\n\t\t\t\t\t\t</select>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t\t<td colspan='3' align='right' nowrap='t'>\n\t\t\t\t\t<input type='submit' name='btn_back' value='« Correction'>\n\t\t\t\t\t<input type='submit' value='Confirm »'>\n\t\t\t\t</td>\n\t\t\t\t<td colspan='10' align='right' nowrap='t'>\n\t\t\t\t\t<input type='submit' name='btn_back' value='« Correction'>\n\t\t\t\t\t<input type='submit' value='Confirm »'>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<!--<td align='center' colspan='3' class='err'>An amount entered here (Special Bonus/Additional\n\t\t\t\t\tSalary) will be treated as a recurring bonus/payment per pay period for PAYE\n\t\t\t\t\tpurposes, the amount will not be treated as an annual payment. If the\n\t\t\t\t\tamount paid as a bonus is a once off/annual payment please use the\n\t\t\t\t\tBonus(Annual Payments) option. In other cases PAYE has to be manually\n\t\t\t\t\tadjusted <u>per directive</u> from SARS when processing salary.</td>-->\n\t\t\t\t<td colspan='3'> </td>\n\t\t\t\t<td colspan='3' class='err'><strong>LOAN NOTE:</strong><br />In the event that the employee repays more than the installment -\n\t\t\t\t\tenter that amount, plus interest that is remitted, in the \"Loan Repayment\" field below.\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='10'>{$err}</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>"; if (!isset($d)) { $out .= "\n\t\t\t<th>Total Work Hours</th>\n\t\t\t<th>Actual Hours Worked</th>"; } $out .= "\n\t\t\t<th>Normal Overtime</th>\n\t\t\t<th>Public Holiday Overtime</th>\n\t\t\t<th>Annual Bonus</th>\n\t\t\t<!--\n\t\t\t<th>Special Bonus/Additional Salary</th>\n\t\t\t<th>Annual/Once Off Bonus</th>\n\t\t\t-->\n\t\t\t<th>Commission</th>\n\t\t\t<th>Travel Allowance</th>\n\t\t\t<th>Loan Repayment</th>\n\t\t\t<th>Pension: Company Contribution</th>\n\t\t\t<th>Pension: Employee Deduction</th>\n\t\t\t<th>Provident: Company Contribution</th>\n\t\t\t<th>Provident: Employee Deduction</th>\n\t\t\t<!--\n\t\t\t<th>UIF: Company Contribution</th>\n\t\t\t<th>UIF: Employee Deduction</th>\n\t\t\t//-->\n\t\t\t<th>Retirement Annuity: Company Contribution</th>\n\t\t\t<th>Retirement Annuity: Employee Deduction</th>\n\t\t\t<th>Medical Contribution: Company</th>\n\t\t\t<th>Medical Contribution: Employee</th>\n\t\t\t<!--\n\t\t\t<th>Other: Company Contribution</th>\n\t\t\t<th>Other: Employee Deduction</th>\n\t\t\t//-->\n\t\t\t<th>Method of Payment</th>\n\t \t\t<th>Override PAYE</th>\n\t \t\t<th>Fringe Ben.</th>\n\t \t\t<th>Allowances</th>\n\t \t\t<th>Subsistence</th>\n\t \t\t<th>Deductions</th>\n\t \t\t<th>Reimbursements</th>\n\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."); $jsbonus_clear = array(); $uif_calc = array(); $jsbonus = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array(), 7 => array(), 8 => array(), 9 => array(), 10 => array(), 11 => array(), 12 => array()); $js_workhours_fields = ""; $subs_int = false; // whether there are internation subsistence allowances $counter = 0; while ($data = pg_fetch_array($Ri)) { if ($counter == 8) { #show headings... $out .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Nr.</th>\n\t\t\t\t\t<th>Name</th>\n\t\t\t\t\t<th>Remuneration</th>"; if (!isset($d)) { $out .= "\n\t\t\t\t\t<th>Total Work Hours</th>\n\t\t\t\t\t<th>Actual Hours Worked</th>"; } $out .= "\n\t\t\t\t\t<th>Normal Overtime</th>\n\t\t\t\t\t<th>Public Holiday Overtime</th>\n\t\t\t\t\t<th>Annual Bonus</th>\n\t\t\t\t\t<!--\n\t\t\t\t\t<th>Special Bonus/Additional Salary</th>\n\t\t\t\t\t<th>Annual/Once Off Bonus</th>\n\t\t\t\t\t-->\n\t\t\t\t\t<th>Commission</th>\n\t\t\t\t\t<th>Travel Allowance</th>\n\t\t\t\t\t<th>Loan Repayment</th>\n\t\t\t\t\t<th>Pension: Company Contribution</th>\n\t\t\t\t\t<th>Pension: Employee Deduction</th>\n\t\t\t\t\t<th>Provident: Company Contribution</th>\n\t\t\t\t\t<th>Provident: Employee Deduction</th>\n\t\t\t\t\t<!--\n\t\t\t\t\t<th>UIF: Company Contribution</th>\n\t\t\t\t\t<th>UIF: Employee Deduction</th>\n\t\t\t\t\t//-->\n\t\t\t\t\t<th>Retirement Annuity: Company Contribution</th>\n\t\t\t\t\t<th>Retirement Annuity: Employee Deduction</th>\n\t\t\t\t\t<th>Medical Contribution: Company</th>\n\t\t\t\t\t<th>Medical Contribution: Employee</th>\n\t\t\t\t\t<!--\n\t\t\t\t\t<th>Other: Company Contribution</th>\n\t\t\t\t\t<th>Other: Employee Deduction</th>\n\t\t\t\t\t//-->\n\t\t\t\t\t<th>Method of Payment</th>\n\t\t\t \t\t<th>Override PAYE</th>\n\t\t\t \t\t<th>Fringe Ben.</th>\n\t\t\t \t\t<th>Allowances</th>\n\t\t\t \t\t<th>Subsistence</th>\n\t\t\t \t\t<th>Deductions</th>\n\t\t\t \t\t<th>Reimbursements</th>\n\t\t\t\t</tr>"; $counter = 0; } $counter++; if (!isset($emps[$data['empnum']])) { continue; } $bgcolor = bgcolorc($i); $send = ""; $grossal = $data["basic_sal"] + $data["commission"] + $data["all_travel"] / 2 + $data["bonus"]; if (isset($d)) { $send = "<input type='hidden' name='d' value=''>"; if ($data['payprd'] != "d") { 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($b)) { $send = "<input type='hidden' name='b' value=''>"; if ($data['payprd'] != "f") { continue; } } else { continue; } /* set employee id */ $id = $data['empnum']; /* calculate basic salary divisors and multipliers * used for calculating deductions/allowances/etc. when the * salary type and payment period differs in length */ switch ($data["saltyp"]) { case "h": $divisor = 1; switch ($data["payprd"]) { case "d": $multiplier = $data["hpweek"] / 5; break; case "w": $multiplier = $data["hpweek"]; break; case "f": $multiplier = $data["hpweek"] * 2; break; case "m": $multiplier = $data["hpweek"] * 52 / 12; break; } break; case "m": $divisor = 1; switch ($data["payprd"]) { case "d": $multiplier = 12 / (5 * 52); break; case "w": $multiplier = 12 / 52; break; case "f": $multiplier = 12 / 26; break; case "m": $multiplier = 1; break; } break; case "w": $divisor = 52 / 12; switch ($data["payprd"]) { case "d": $multiplier = 1 / 5; break; case "w": $multiplier = 1; break; case "f": $multiplier = 2; break; case "m": $multiplier = 52 / 12; break; } break; case "f": $divisor = 26 / 12; switch ($data["payprd"]) { case "d": $multiplier = 1 / 10; break; case "w": $multiplier = 1 / 2; break; case "f": $multiplier = 1; break; case "m": $multiplier = 26 / 12; break; } break; } $bon_month = round($data["sal_bonus_month"]); $jsbonus_clear[] = "document.getElementById('salfrm').elements['bonus[{$id}]'].value='0.00';"; $jsbonus[$bon_month][] = "document.getElementById('salfrm').elements['bonus[{$id}]'].value = '{$data['sal_bonus']}';"; /* $uif_calc[] = " tmp_calc = parseFloat(document.getElementById('salfrm').elements['basic_sal[$id]'].value) + parseFloat(document.getElementById('salfrm').elements['annual[$id]'].value) + parseFloat(document.getElementById('salfrm').elements['all_travel[$id]'].value); tmp_calc_emp = tmp_calc * $data[emp_uif] / 100; tmp_calc_comp = tmp_calc * $data[comp_uif] / 100; tmp_calc_emp = tmp_calc_emp.toFixed(2); tmp_calc_comp = tmp_calc_comp.toFixed(2); document.getElementById('salfrm').elements['emp_uif[$id]'].value = tmp_calc_emp; document.getElementById('salfrm').elements['comp_uif[$id]'].value = tmp_calc_comp;";*/ $db = array("comp_pension" => $data["comp_pension"], "emp_pension" => $data["emp_pension"], "comp_provident" => $data["comp_provident"], "emp_provident" => $data["emp_provident"], "comp_uif" => $data["comp_uif"], "emp_uif" => $data["emp_uif"], "comp_other" => $data["comp_other"], "emp_other" => $data["emp_other"]); if (isset($basic_sal[$id])) { $data['basic_sal'] = $basic_sal[$id]; $data['bonus'] = $bonus[$id]; $data['commission'] = $commission[$id]; $date['abonus'] = $abonus[$id]; $data['all_travel'] = $all_travel[$id]; $data['loaninstall'] = $loaninstall[$id]; $data['comp_pension'] = $comp_pension[$id]; $data['emp_pension'] = $emp_pension[$id]; $data['comp_provident'] = $comp_provident[$id]; $data['emp_provident'] = $emp_provident[$id]; //$data['comp_uif']=$comp_uif[$id]; //$data['emp_uif']=$emp_uif[$id]; $data['comp_ret'] = $comp_ret[$id]; $data['emp_ret'] = $emp_ret[$id]; $data['comp_medical'] = $comp_medical[$id]; $data['emp_medical'] = $emp_medical[$id]; $data['comp_other'] = $comp_other[$id]; $data['emp_other'] = $emp_other[$id]; } else { if ($data["sal_bonus_month"] == $month) { $annual[$id] = sprint($data["sal_bonus"]); } else { $annual[$id] = "0.00"; } $novert[$id] = ""; $hovert[$id] = ""; $mpaye_amount[$id] = ""; if ($data["payprd"] == "w" || $data["payprd"] == "f") { $tmpmon = date("j"); $daycount = date("t"); $dayweek = date("D"); if (strtolower($dayweek) == $data["payprd_day"] && $date_day + 7 > $daycount) { $process_comp_deductions = true; } else { $process_comp_deductions = false; } } else { $process_comp_deductions = true; } //$data["emp_uif"] = sprint(($data["basic_sal"] + $data["all_travel"]) * ($data["emp_uif"]/100)); $effective_basicsal = $data["basic_sal"] * $multiplier; /* we only changing basic sal for non hourly employees, because for hourly employees we change the hours ($mutli) */ if ($data["saltyp"] != "h") { $data["basic_sal"] *= $multiplier; } if ($data["loaninstall"] > $data["loanamt"]) { $data["loaninstall"] = $data["loanamt"]; } $data["comp_pension"] = sprint($effective_basicsal * ($data["comp_pension"] / 100)); $data["comp_provident"] = sprint($effective_basicsal * ($data["comp_provident"] / 100)); $data["emp_pension"] = sprint($effective_basicsal * ($data["emp_pension"] / 100)); $data["emp_provident"] = sprint($effective_basicsal * ($data["emp_provident"] / 100)); $data["emp_medical"] = sprint($data["emp_medical"] / $divisor); $data["comp_medical"] = sprint($data["comp_medical"] / $divisor); $data["emp_ret"] = sprint($data["emp_ret"] / $divisor); $data["comp_ret"] = sprint($data["comp_ret"] / $divisor); $data["loaninstall"] = sprint($data["loaninstall"] / $divisor); $data["all_travel"] = sprint($data["all_travel"] / $divisor); explodeDate($data["loandate"], $loana_year, $loana_month, $loana_day); if ($loana_year > $salyr || $loana_year == $salyr && $loana_month > $month) { $data["loanint"] = 0; $data["loaninstall"] = 0; } } if ($data['paytype'] == "Cash") { $paydetails = "Cash\n\t\t\t<input type='hidden' name='accid[{$id}]' value='0'>"; } elseif ($data['paytype'] == "Ledger Account") { db_conn('core'); $Sl = "SELECT accid,accname FROM accounts ORDER BY accname"; $Rl = db_exec($Sl); $accounts = "<select name='account[{$id}]'>"; while ($ad = pg_fetch_array($Rl)) { if (isset($account[$id]) && $account[$id] == $ad['accid']) { $sel = "selected"; } else { $sel = ""; } $accounts .= "<option value='{$ad['accid']}' {$sel}>{$ad['accname']}</option>"; } $accounts .= "</select>"; $paydetails = "{$accounts}\n\t\t\t\t<input type='hidden' name='accid[{$id}]' value='0'>"; } else { db_conn('cubit'); $Sl = "SELECT * FROM bankacct WHERE btype != 'int' AND div = '" . USER_DIV . "' ORDER BY accname ASC"; $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='« Correct Selection'>"; } $banks = "<select name='accid[{$id}]'>"; while ($acc = pg_fetch_array($Ry)) { $banks .= "<option value='{$acc['bankid']}'>{$acc['accname']} ({$acc['acctype']})</option>"; } $banks .= "</select>"; $paydetails = "{$banks}"; } # fringe benefits $i = 0; db_conn("cubit"); $sql = "SELECT * FROM fringebens WHERE div = '" . USER_DIV . "' ORDER BY fringeben"; $rslt = db_exec($sql) or errDie("Unable to select fringe benefits from database."); if (pg_num_rows($rslt) < 1) { $fringes = "<table " . TMPL_tblDflts . ">"; $fringes .= "<tr><td class='" . bg_class() . "' colspan='2' align='center'>None found in database.</td></tr>"; $fringes .= "</table>"; } else { $fringes = "<table " . TMPL_tblDflts . ">"; while ($myFringe = pg_fetch_array($rslt)) { # check if employee has allowance $sql = "SELECT * FROM empfringe WHERE fringeid='{$myFringe['id']}' AND empnum='{$data['empnum']}' AND div = '" . USER_DIV . "'"; $empRslt = db_exec($sql) or errDie("Unable to retrieve fringe benefit info from database."); if (pg_numrows($empRslt) > 0) { $empFringe = pg_fetch_array($empRslt); if (substr($empFringe["type"], 0, 4) == "Perc") { $empFringe["amount"] = sprint($data["basic_sal"] * ($empFringe["amount"] / 100) / $divisor); } else { $empFringe['amount'] = sprint($empFringe['amount'] / $divisor); } $grossal += $empFringe["amount"]; $tmp_fringeaccs = $empFringe["accid"]; $tmp_fringebens = $empFringe["amount"]; } else { $tmp_fringeaccs = "0"; $tmp_fringebens = "0.00"; } $fringes .= "\n\t\t\t\t\t<input type='hidden' name='fringeaccs[{$id}][]' value='{$tmp_fringeaccs}'>\n\t\t\t\t\t<input type='hidden' name='fringeid[{$id}][]' value='{$myFringe['id']}'>\n\t\t\t\t\t<input type='hidden' name='fringename[{$id}][]' value='{$myFringe['fringeben']}'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>{$myFringe['fringeben']}</td>\n\t\t\t\t\t\t<td>" . CUR . "</td>\n\t\t\t\t\t\t<td><input type='text' size='10' name='fringebens[{$id}][]' value='{$tmp_fringebens}'></td>\n\t\t\t\t\t</tr>"; $i++; } $fringes .= "</table>"; } # get allowances $i = 0; 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 = "<table " . TMPL_tblDflts . ">"; $allowances .= "<tr><td>None</td></tr>"; $allowances .= "</table>"; } else { $allowances = "<table " . TMPL_tblDflts . ">"; 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) { $dataAllow = pg_fetch_array($empAllowRslt); $dataAllow['amount'] = sprint($dataAllow['amount'] / $divisor); $grossal += $dataAllow["amount"]; $tmp_allowaccs = $dataAllow["accid"]; $tmp_allowances = $dataAllow["amount"]; } else { $tmp_allowaccs = $myAllow["accid"]; $tmp_allowances = "0.00"; } $allowances .= "\n\t\t\t\t\t<input type='hidden' name='allowid[{$id}][]' value='{$myAllow['id']}'>\n\t\t\t\t\t<input type='hidden' name='allowname[{$id}][]' value='{$myAllow['allowance']}'>\n\t\t\t\t\t<input type='hidden' name='allowtax[{$id}][]' value='{$myAllow['add']}'>\n\t\t\t\t\t<input type='hidden' name='allowaccs[{$id}][]' value='{$tmp_allowaccs}'>\n\t\t\t\t\t<tr><td>{$myAllow['allowance']}</td>\n\t\t\t\t\t\t<td>" . CUR . "</td>\n\t\t\t\t\t\t<td><input type='text' size='10' name='allowances[{$id}][]' value='{$tmp_allowances}'></td>\n\t\t\t\t\t</tr>"; $i++; } $allowances .= "</table>"; } $subsistence = ""; $subslst = new dbSelect("subsistence", "cubit", array("where" => "div='" . USER_DIV . "'", "order" => "name")); $subslst->run(); if ($subslst->num_rows() > 0) { $i = 0; $subsistence .= "\n\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>Name</th>\n\t\t\t\t\t\t<th>Amount</th>\n\t\t\t\t\t\t<th>Days</th>\n\t\t\t\t\t</tr>"; $empsubs = new dbSelect("emp_subsistence", "cubit"); while ($subs = $subslst->fetch_array()) { $sid = $subs["id"]; $empsubs->setOpt(array("where" => "empnum='{$data['empnum']}' AND subid='{$sid}'")); $empsubs->run(); if ($empsubs->num_rows() <= 0) { $si["amount"] = "0.00"; $si["days"] = "0"; $si["accid"] = $subs["accid"]; } else { $si = $empsubs->fetch_array(); } if ($subs["in_republic"] != "yes") { $subs_int = true; } $subsistence .= "\n\t\t\t\t\t<input type='hidden' name='subsname[{$id}][{$sid}]' value='{$subs['name']}'>\n\t\t\t\t\t<input type='hidden' name='subsacc[{$id}][{$sid}]' value='{$si['accid']}'>\n\t\t\t\t\t<input type='hidden' name='subsrep[{$id}][{$sid}]' value='{$subs['in_republic']}'>\n\t\t\t\t\t<input type='hidden' name='subsmeal[{$id}][{$sid}]' value='{$subs['meals']}'>\n\t\t\t\t\t<tr bgcolor='" . bgcolor($i) . "'>\n\t\t\t\t\t\t<td>{$subs['name']}</td>\n\t\t\t\t\t\t<td nowrap>" . CUR . " <input type='text' size='5' name='subsamt[{$id}][{$sid}]' value='{$si['amount']}'></td>\n\t\t\t\t\t\t<td><input type='text' size='2' name='subsdays[{$id}][{$sid}]' value='{$si['days']}'></td>\n\t\t\t\t\t</tr>"; } $subsistence .= "\n\t\t\t\t</table>"; } # Deductions $i = 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 = "<table " . TMPL_tblDflts . ">"; $deductions .= "<tr><td>None</td></tr>"; $deductions .= "</table>"; } else { $deductions = "<table " . TMPL_tblDflts . ">"; 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) { $dataDeduct = pg_fetch_array($empDeductRslt); if ($dataDeduct["grosdeduct"] == "y") { $deductions_msg = "(Before PAYE)"; $sal_calcfrom = $grossal; } else { $deductions_msg = ""; $sal_calcfrom = $data["basic_sal"]; } if ($dataDeduct['type'] == "Amount") { $dataDeduct['amount'] = sprint($dataDeduct['amount'] / $divisor); } else { $dataDeduct['amount'] = sprint($sal_calcfrom * $dataDeduct['amount'] / 100 / $divisor); } // calculate employer contribution to deduction if ($dataDeduct["employer_type"] == "Amount") { $dataDeduct["employer_amount"] = sprint($dataDeduct["employer_amount"] / $divisor); } else { $dataDeduct["employer_amount"] = sprint($dataDeduct["amount"] * $dataDeduct["employer_amount"] / 100 / $divisor); } $tmp_deductions = $dataDeduct["amount"]; $tmp_dedaccs = $dataDeduct["accid"]; $tmp_emp_ded = $dataDeduct["employer_amount"]; } else { $tmp_deductions = "0.00"; $tmp_emp_ded = "0.00"; $tmp_dedaccs = $myDeduct["accid"] != 0 ? $myDeduct["accid"] : $myDeduct["expaccid"]; $deductions_msg = ""; } # check if we should be using deductions if ($data['emp_usescales'] == "1" and $myDeduct['type'] == "Percentage") { # check if this deduction has scales $get_scales = "SELECT * FROM salded_scales WHERE saldedid = '{$myDeduct['id']}' LIMIT 1"; $run_scales = db_exec($get_scales) or errDie("Unable to get deduction scale information."); if (pg_numrows($run_scales) > 0) { # scales exist $get_perc = "\n\t\t\t\t\t\t\tSELECT * FROM salded_scales \n\t\t\t\t\t\t\tWHERE scale_from <= '{$data['basic_sal']}' AND scale_to >= '{$data['basic_sal']}' AND saldedid = '{$myDeduct['id']}' \n\t\t\t\t\t\t\tLIMIT 1"; $run_perc = db_exec($get_perc) or errDie("Unable to get deduction scale information."); if (pg_numrows($run_perc) > 0) { # found a matching scale for this scaled duduction for a customer using scales .... $scale_arr = pg_fetch_array($run_perc); $tmp_deductions = sprint($data['basic_sal'] / 100 * $scale_arr['scale_amount']); } } } $deductions .= "\n\t\t\t\t\t<input type='hidden' size='10' name='deductid[{$id}][]' value='{$myDeduct['id']}'>\n\t\t\t\t\t<input type='hidden' size='30' name='deductname[{$id}][]' value='{$myDeduct['deduction']}'>\n\t\t\t\t\t<input type='hidden' size='10' name='deducttax[{$id}][]' value='{$myDeduct['add']}'>\n\t\t\t\t\t<input type='hidden' name='dedaccs[{$id}][]' value='{$tmp_dedaccs}'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>{$myDeduct['deduction']} {$deductions_msg}</td>\n\t\t\t\t\t\t<td>" . CUR . "</td>\n\t\t\t\t\t\t<td><input type='text' size='10' name='deductions[{$id}][]' value='{$tmp_deductions}'></td>\n\t\t\t\t\t\t<td>" . CUR . "</td>\n\t\t\t\t\t\t<td><input type='hidden' size='10' name='employer_deductions[{$id}][]' value='{$tmp_emp_ded}'></td>\n\t\t\t\t\t</tr>"; $i++; } $deductions .= "</table>"; } $rt = ""; 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 . ">"; while ($td = pg_fetch_array($Rl)) { if (!isset($rbsa[$id][$td['id']])) { $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><input type='text' size='10' name='rbsa[{$id}][{$td['id']}]' value='" . $rbsa[$id][$td['id']] . "' class='right'></td>\n\t\t\t\t\t</tr>"; $i++; } $rt .= "</table>"; } else { $rt .= "None"; } $salarr = array("m" => "Per Month", "w" => "Per Week", "f" => "Fortnightly", "h" => "Per Hour"); $salnarr = array("d" => "Day(s)", "h" => "Hour(s)"); $saltype = $salarr[$data['saltyp']]; if (!isset($multi[$id])) { $multi[$id] = $data["saltyp"] == "h" ? $multiplier : 1; } $multi[$id] = round($multi[$id]); if ($data['saltyp'] == 'd' || $data['saltyp'] == 'h') { $salntype = $salnarr[$data['saltyp']]; $multi_show = "x <input type='text' size='3' name='multi[{$id}]' value='{$multi[$id]}'> {$salntype}"; } else { $multi_show = "<input type='hidden' name='multi[{$id}]' value='{$multi[$id]}'>"; $saltype = ""; } if (isset($mpaye[$id])) { $ch = "checked=yes"; } else { $ch = ""; } if ($data["payprd"] == "m" || $data["payprd"] == "d") { // count the amount of weekdays in this month $workdays = 0; for ($i = 1; $i <= date("t", mktime(0, 0, 0, $month, 1, date("Y"))); ++$i) { $wd = date("w", mktime(0, 0, 0, $month, $i, date("Y"))); if ($wd != 0 && $wd != 6) { ++$workdays; } } // hours per day calculation $hpd = $data["hpweek"] / 5; if (!isset($wh_total[$id])) { $wh_total[$id] = $workdays * $hpd; } if (!isset($wh_actual[$id])) { $wh_actual[$id] = $wh_total[$id]; } } if ($data["payprd"] == "w") { if (!isset($wh_total[$id])) { $wh_total[$id] = $data["hpweek"]; } if (!isset($wh_actual[$id])) { $wh_actual[$id] = $wh_total[$id]; } } if ($data["payprd"] == "f") { if (!isset($wh_total[$id])) { $wh_total[$id] = $data["hpweek"] * 2; } if (!isset($wh_actual[$id])) { $wh_actual[$id] = $wh_total[$id]; } } $js_workhours_fields .= "\n\t\t\t<script>\n\t\t\t\tf_sal[{$id}]\t\t= sf.elements['basic_sal[{$id}]'];\n\t\t\t\tf_salbonus[{$id}] = sf.elements['sal_bonus[{$id}]'];\n\t\t\t\tf_whtot[{$id}]\t= sf.elements['wh_total[{$id}]'];\n\t\t\t\tf_whact[{$id}]\t= sf.elements['wh_actual[{$id}]'];\n\t\t\t\tf_cpension[{$id}]\t= sf.elements['comp_pension[{$id}]'];\n\t\t\t\tf_epension[{$id}] = sf.elements['emp_pension[{$id}]'];\n\t\t\t\tf_cprov[{$id}]\t= sf.elements['comp_provident[{$id}]'];\n\t\t\t\tf_eprov[{$id}]\t= sf.elements['emp_provident[{$id}]'];\n\t\t\t\t//f_cuif[{$id}]\t\t= sf.elements['comp_uif[{$id}]'];\n\t\t\t\t//f_euif[{$id}]\t\t= sf.elements['emp_uif[{$id}]'];\n\t\t\t\tf_cother[{$id}]\t= sf.elements['comp_other[{$id}]'];\n\t\t\t\tf_eother[{$id}]\t= sf.elements['emp_other[{$id}]'];\n\n\t\t\t\tdb_cpension[{$id}]\t= " . $db["comp_pension"] . ";\n\t\t\t\tdb_epension[{$id}]\t= " . $db["emp_pension"] . ";\n\t\t\t\tdb_cprov[{$id}]\t\t= " . $db["comp_provident"] . ";\n\t\t\t\tdb_eprov[{$id}]\t\t= " . $db["emp_provident"] . ";\n\t\t\t\t//db_cuif[{$id}]\t\t= " . $db["comp_uif"] . ";\n\t\t\t\t//db_euif[{$id}]\t\t= " . $db["emp_uif"] . ";\n\t\t\t\tdb_cother[{$id}]\t= " . $db["comp_other"] . ";\n\t\t\t\tdb_eother[{$id}]\t= " . $db["emp_other"] . ";\n\n\t\t\t\tval_sal[{$id}] = -1;\n\t\t\t</script>"; vsprint($data["basic_sal"]); $out .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<input type='hidden' name='emps[{$id}]' value='{$id}'>\n\t\t\t\t<input type='hidden' name='saltyp[{$id}]' value='{$data['saltyp']}'>\n\t\t\t\t<input type='hidden' name='process_comp_deductions[{$id}]' value='{$process_comp_deductions}'>\n\t\t\t\t<input type='hidden' name='divisor[{$id}]' value='{$divisor}'>\n\t\t\t\t<td nowrap>{$data['enum']}</td>\n\t\t\t\t<td>{$data['sname']}, {$data['fnames']}</td>\n\t\t\t\t<td nowrap><input type='text' size='8' name='basic_sal[{$id}]' value='{$data['basic_sal']}' class='right' onChange='changedfield({$id});'>{$saltype} {$multi_show}</td>"; if (isset($d)) { $out .= "\n\t\t\t\t<input type='hidden' name='wh_total' value='1'>\n\t\t\t\t<input type='hidden' name='wh_actual' value='1'>"; } else { $out .= "\n\t\t\t\t<td nowrap><input type='text' size='10' name='wh_total[{$id}]' value='{$wh_total[$id]}' class='right' onChange='workhours({$id});'></td>\n\t\t\t\t<td nowrap><input type='text' size='10' name='wh_actual[{$id}]' value='{$wh_actual[$id]}' class='right' onChange='workhours({$id});'></td>"; } if (!isset($abonus[$id])) { $abonus = 0; } $out .= "\n\t\t\t\t<td nowrap><input type='text' size='5' name='novert[{$id}]' value='{$novert[$id]}' class='right'> Hrs</td>\n\t\t\t\t<td nowrap><input type='text' size='5' name='hovert[{$id}]' value='{$hovert[$id]}' class='right'> Hrs</td>\n\t\t\t\t<td nowrap><input type='hidden' size='8' name='bonus[{$id}]' value='0' class='right'><input type='text' size='8' name='abonus[{$id}]' value='{$abonus[$id]}' class='right'></td>\n\t\t\t\t<input type='hidden' name='annual[{$id}]' value='0' />\n\t\t\t\t<!--<td nowrap><input type='text' size='8' name='annual[{$id}]' value='{$annual[$id]}' class='right'></td>-->\n\t\t\t\t<td nowrap><input type='text' size='8' name='commission[{$id}]' value='{$data['commission']}' class='right'></td>\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='all_travel[{$id}]' value='{$data['all_travel']}' class='right'></td>\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='loaninstall[{$id}]' value='{$data['loaninstall']}' class='right'></td>\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='comp_pension[{$id}]' value='{$data['comp_pension']}' class='right'></td>\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='emp_pension[{$id}]' value='{$data['emp_pension']}' class='right'></td>\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='comp_provident[{$id}]' value='{$data['comp_provident']}' class='right'></td>\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='emp_provident[{$id}]' value='{$data['emp_provident']}' class='right'></td>\n\t\t\t\t<!--\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='comp_uif[{$id}]' value='{$data['comp_uif']}' class='right'></td>\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='emp_uif[{$id}]' value='{$data['emp_uif']}' class='right'></td>\n\t\t\t\t//-->\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='comp_ret[{$id}]' value='{$data['comp_ret']}' class='right'></td>\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='emp_ret[{$id}]' value='{$data['emp_ret']}' class='right'></td>\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='comp_medical[{$id}]' value='{$data['comp_medical']}' class='right'></td>\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='emp_medical[{$id}]' value='{$data['emp_medical']}' class='right'></td>\n\t\t\t\t<input type=hidden name='comp_other[{$id}]' value='0'>\n\t\t\t\t<input type=hidden name='emp_other[{$id}]' value='0'>\n\t\t\t\t<!--\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='comp_other[{$id}]' value='{$data['comp_other']}' class='right'></td>\n\t\t\t\t<td nowrap>R<input type='text' size='8' name='emp_other[{$id}]' value='{$data['emp_other']}' class='right'></td>\n\t\t\t\t//-->\n\t\t\t\t<td>{$paydetails}</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td><input type='checkbox' name='mpaye[{$id}]' {$ch}></td>\n\t\t\t\t\t\t\t<td><input type='text' size='8' name='mpaye_amount[{$id}]' value='{$mpaye_amount[$id]}'></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\t<td>{$fringes}</td>\n\t\t\t\t<td>{$allowances}</td>\n\t\t\t\t<td>{$subsistence}<!--%%EXCHANGE%%--></td>\n\t\t\t\t<td>{$deductions}</td>\n\t\t\t\t<td>{$rt}</td>\n\t\t\t</tr>"; } if (!isset($id)) { header("Location: ../admin-employee-view.php?err=Please select at least one employee."); exit; } // replace the exchange rate place holder with the exchange rate form field if ($subs_int) { $exch = "\n\t\t\t<input type='hidden' name='subs_exch' value='1'>\n\t\t\t<li class='err'>Please calculate the rand amount prior to completing the amount above.</li>"; // <tr class='".bg_class()."'> // <th class='".bg_class()."'>Exchange (ZAR-USD):</th> // <td><input type='text' name='subs_exch' value='".xrate_get("USD")."'></td> // </tr>"; $out = str_replace("<!--%%EXCHANGE%%-->", $exch, $out); } $out .= "\n\t\t\t<tr><td><br></td></tr>\n\t\t\t{$send}\n\t\t\t<tr>\n\t\t\t\t<td colspan='9' align='right' nowrap='t'>\n\t\t\t\t\t<input type='submit' name='btn_back' value='« Correction'>\n\t\t\t\t\t<input type='submit' value='Confirm »'>\n\t\t\t\t</td>\n\t\t\t\t<td colspan='10' align='right' nowrap='t'>\n\t\t\t\t\t<input type='submit' name='btn_back' value='« Correction'>\n\t\t\t\t\t<input type='submit' value='Confirm »'>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form>\n\t\t<script>\n\t\t\tfunction monthchange(mondd) {\n\t\t\t\t" . implode("\n", $jsbonus_clear) . "\n\t\t\t\tswitch ( mondd.value ) {\n\t\t\t\tcase '1':\n\t\t\t\t\t" . implode("\n", $jsbonus[1]) . "\n\t\t\t\t\tbreak;\n\t\t\t\tcase '2':\n\t\t\t\t\t" . implode("\n", $jsbonus[2]) . "\n\t\t\t\t\tbreak;\n\t\t\t\tcase '3':\n\t\t\t\t\t" . implode("\n", $jsbonus[3]) . "\n\t\t\t\t\tbreak;\n\t\t\t\tcase '4':\n\t\t\t\t\t" . implode("\n", $jsbonus[4]) . "\n\t\t\t\t\tbreak;\n\t\t\t\tcase '5':\n\t\t\t\t\t" . implode("\n", $jsbonus[5]) . "\n\t\t\t\t\tbreak;\n\t\t\t\tcase '6':\n\t\t\t\t\t" . implode("\n", $jsbonus[6]) . "\n\t\t\t\t\tbreak;\n\t\t\t\tcase '7':\n\t\t\t\t\t" . implode("\n", $jsbonus[7]) . "\n\t\t\t\t\tbreak;\n\t\t\t\tcase '8':\n\t\t\t\t\t" . implode("\n", $jsbonus[8]) . "\n\t\t\t\t\tbreak;\n\t\t\t\tcase '9':\n\t\t\t\t\t" . implode("\n", $jsbonus[9]) . "\n\t\t\t\t\tbreak;\n\t\t\t\tcase '10':\n\t\t\t\t\t" . implode("\n", $jsbonus[10]) . "\n\t\t\t\t\tbreak;\n\t\t\t\tcase '11':\n\t\t\t\t\t" . implode("\n", $jsbonus[11]) . "\n\t\t\t\t\tbreak;\n\t\t\t\tcase '12':\n\t\t\t\t\t" . implode("\n", $jsbonus[12]) . "\n\t\t\t\t\tbreak;\n\t\t\t\t}"; //".implode("\n", $uif_calc)." $out .= "\n\t\t\t}\n\t\t</script>\n\t\t<script>\n\t\t\tsf = document.getElementById('salfrm');\n\t\t\tf_sal = new Array();\n\t\t\tf_salbonus = new Array();\n\t\t\tf_whtot = new Array();\n\t\t\tf_whact = new Array();\n\t\t\tf_cpension = new Array();\n\t\t\tf_epension = new Array();\n\t\t\tf_cprov = new Array();\n\t\t\tf_eprov = new Array();\n\t\t\t//f_cuif = new Array();\n\t\t\t//f_euif = new Array();\n\t\t\tf_cother = new Array();\n\t\t\tf_eother = new Array();\n\n\t\t\tdb_cpension = new Array();\n\t\t\tdb_epension = new Array();\n\t\t\tdb_cprov = new Array();\n\t\t\tdb_eprov = new Array();\n\t\t\t//db_cuif = new Array();\n\t\t\t//db_euif = new Array();\n\t\t\tdb_cother = new Array();\n\t\t\tdb_eother = new Array();\n\n\t\t\tval_sal = new Array();\n\t\t</script>\n \t\t{$js_workhours_fields}\n\t\t<script>\n\t\t\t// changing the workhours\n\t\t\tfunction workhours(id) {\n\t\t\t\tif ( val_sal[id] < 0 ) val_sal[id] = parseFloat(f_sal[id].value);\n\n\t\t\t\tval_whtot\t= parseFloat(f_whtot[id].value);\n\t\t\t\tval_whact\t= parseFloat(f_whact[id].value);\n\n\t\t\t\tif ( val_whtot >= val_whact ) {\n\t\t\t\t\tp = val_whact / val_whtot;\n\n\t\t\t\t\t// calculate the new basic salary\n\t\t\t\t\tx = val_sal[id] * p;\n\t\t\t\t\tx = x.toFixed(2);\n\t\t\t\t\tf_sal[id].value = x;\n\n\t\t\t\t\t// calculate the new values\n\t\t\t\t\tval_cpension \t= x * db_cpension[id] / 100;\n\t\t\t\t\tval_epension \t= x * db_epension[id] / 100;\n\t\t\t\t\tval_cprov\t\t= x * db_cprov[id] / 100;\n\t\t\t\t\tval_eprov\t\t= x * db_eprov[id] / 100;\n\t\t\t\t\t//val_cuif\t\t= x * db_cuif[id] / 100;\n\t\t\t\t\t//val_euif\t\t= x * db_euif[id] / 100;\n\t\t\t\t\tval_cother\t\t= x * db_cother[id] / 100;\n\t\t\t\t\tval_eother\t\t= x * db_eother[id] / 100;\n\n\t\t\t\t\tval_cpension \t= val_cpension.toFixed(2);\n\t\t\t\t\tval_epension \t= val_epension.toFixed(2);\n\t\t\t\t\tval_cprov \t\t= val_cprov.toFixed(2);\n\t\t\t\t\tval_eprov\t\t= val_eprov.toFixed(2);\n\t\t\t\t\t//val_cuif\t\t= val_cuif.toFixed(2);\n\t\t\t\t\t//val_euif\t\t= val_euif.toFixed(2);\n\t\t\t\t\tval_cother\t\t= val_cother.toFixed(2);\n\t\t\t\t\tval_eother\t\t= val_eother.toFixed(2);\n\n\t\t\t\t\tf_cpension[id].value\t= val_cpension;\n\t\t\t\t\tf_epension[id].value \t= val_epension;\n\t\t\t\t\tf_cprov[id].value \t\t= val_cprov;\n\t\t\t\t\tf_eprov[id].value\t\t= val_eprov;\n\t\t\t\t\t//f_cuif[id].value\t\t= val_cuif;\n\t\t\t\t\t//f_euif[id].value\t\t= val_euif;\n\t\t\t\t\tf_cother[id].value\t\t= val_cother;\n\t\t\t\t\tf_eother[id].value\t\t= val_eother;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction changedfield(id) {\n\t\t\t\tval_whtot\t= parseFloat(f_whtot[id].value);\n\t\t\t\tval_whact\t= parseFloat(f_whact[id].value);\n\n\t\t\t\tp = val_whtot / val_whact;\n\n\t\t\t\tval_sal[id] = parseFloat(f_sal[id].value) * p;\n\t\t\t\tval_sal[id] = val_sal[id].toFixed(2);\n\t\t\t}\n\n\t\t\tmonthchange(document.getElementById('salfrm').elements['month']);\n\t\t</script>"; return $out; }
/** * starts the script by calling the next function * * function names should equal key's, or should be mapped by the * keymap function. * * this function replaces the switches in the beginning * of each script. it initializes the cForm object and calls * the function specified by the key. * * @param string $firstfunc first function to call */ static function run($firstfunc) { global $FRAMEWORK; /* map the "-f" key to $firstfunc */ $FRAMEWORK->function_maps["-f"] = $firstfunc; if (!isset($_REQUEST["key"])) { $key = "-f"; } else { /* back button clicked */ if (isset($_REQUEST["btn_back"])) { /* look for the current target key's position */ $ppos = array_search($_REQUEST["key"], $FRAMEWORK->frm->keys); /* key not found */ if ($ppos === false) { invalid_use("No correction function found."); } /* if we didn't come from the second step (in which case we want to go back to the $firstfunc) */ if ($ppos >= 2) { $key = $FRAMEWORK->frm->keys[$ppos - 2]; } else { $key = "-f"; } } else { $key = $_REQUEST["key"]; } } if (isset($FRAMEWORK->function_maps[strtolower($key)])) { $funcname = $FRAMEWORK->function_maps[strtolower($key)]; } else { $funcname = $key; } if (!is_callable($funcname)) { invalid_use("Function \"{$funcname}()\" not found."); } $FRAMEWORK->o["result"] = $funcname($FRAMEWORK->frm); }