function slctEmployee($err = "") { db_conn('cubit'); #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']); if (is_array($pay_grps)) { $egsearch = " AND (emp_group = '" . implode("' OR emp_group = '", $pay_grps) . "')"; } } else { $egsearch = "AND false"; } } $Sl = "SELECT empnum,enum, sname, fnames FROM employees WHERE div = '" . USER_DIV . "' ORDER BY sname,fnames"; $Ry = db_exec($Sl) or errDie("Unable to select employees from database."); if (pg_numrows($Ry) < 1) { return "<li class='err'>No Employees Found In Cubit.</li>"; } $Sl = "SELECT empnum,enum, sname, fnames FROM employees WHERE div = '" . USER_DIV . "' {$egsearch} ORDER BY sname,fnames"; $Ry = db_exec($Sl) or errDie("Unable to select employees from database."); if (pg_numrows($Ry) < 1) { return "<li class='err'>You Have Insufficient Permissions To Access The Cubit Payroll. You May Add The Permission <a href='../admin-usredit.php?username={$_SESSION['USER_NAME']}'>Here</a></li>"; } $employees = "<select size='1' name='empnum'>"; while ($myEmp = pg_fetch_array($Ry)) { $employees .= "<option value='{$myEmp['empnum']}'>{$myEmp['sname']}, {$myEmp['fnames']} ({$myEmp['enum']})</option>"; } $employees .= "</select>"; $slctEmployee = "\n\t\t<h3>Select employee to reverse</h3>\n\t\t{$err}\n\t\t<table " . TMPL_tblDflts . ">\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='prd'>\n\t\t\t<tr>\n\t\t\t\t<th colspan='2'>Employee</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Employee</td>\n\t\t\t\t<td align='center'>{$employees}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Select month</td>\n\t\t\t\t<td align=center>" . empMonList("MON", DATE_MONTH) . "</td>\n\t\t\t\t<td class='err'>This is the period for which you are processing the salary.</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td nowrap>Processing Date</td>\n\t\t\t\t<td nowrap>" . mkDateSelect("date") . "</td>\n\t\t\t\t<td class='err'>This is the date Cubit will use to enter transactions into the ledgers.</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='right'><input type='submit' value='Process »'></td>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>"; return $slctEmployee; }
function slctEmployee() { db_connect(); #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']); if (is_array($pay_grps)) { $egsearch = " AND (emp_group = '" . implode("' OR emp_group = '", $pay_grps) . "')"; } } else { $egsearch = "AND false"; } } $sql = "SELECT enum,empnum, sname, fnames FROM employees WHERE div = '" . USER_DIV . "' {$egsearch} ORDER BY sname"; $empRslt = db_exec($sql) or errDie("Unable to select employees from database."); if (pg_numrows($empRslt) < 1) { $employees = array(); // return "No employees found in database.<p>" // .mkQuickLinks(); } else { $employees = array(); while ($d = pg_fetch_array($empRslt)) { $employees[$d["empnum"]] = "{$d['sname']}, {$d['fnames']} ({$d['enum']})"; } } $fields = array("empnum" => 0, "mon" => date("m")); foreach ($fields as $fname => $dflt) { if (!isset(${$fname})) { ${$fname} = $dflt; } } $get_egroups = "SELECT * FROM emp_groups ORDER BY emp_group"; $run_egroups = db_exec($get_egroups) or errDie("Unable to get employee group information."); if (pg_numrows($run_egroups) < 1) { $emp_group_drop = "<input type='hidden' name='emp_group[]' value='0'>No Employee Groups Found."; } else { $emp_group_drop = "<select name='emp_group[]' multiple size='5'>"; $emp_group_drop .= "<option value='0'>All</option>"; while ($garr = pg_fetch_array($run_egroups)) { $emp_group_drop .= "<option value='{$garr['id']}'>{$garr['emp_group']}</option>"; } $emp_group_drop .= "</select>"; } $slctEmployee = "\n\t\t<h3>Select month to view</h3>\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='slip'>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Select Month</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'>" . empMonList("mon", $mon) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>Employee Group</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'>{$emp_group_drop}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>Employee</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'>" . extlib_cpsel("empnum", $employees, $empnum) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='right'><input type='submit' value='View »'></td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form>" . mkQuickLinks(); return $slctEmployee; }
function enterLoan($err = "") { global $_POST; # get vars extract($_POST); # validate input require_lib("validate"); $v = new validate(); $v->isOk($empnum, "num", 1, 20, "Invalid employee number."); # 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; } if (($fields["loanint"] = getCSetting("EMPLOAN_INT")) == "") { $fields["loanint"] = 9; } if (($fields["loanperiod"] = getCSetting("EMPLOAN_MTHS")) == "") { $fields["loanperiod"] = "6"; } $fields["loanamt"] = "0.00"; $fields["lday"] = date("d"); $fields["lmonth"] = date("m"); $fields["lyear"] = date("Y"); $fields["accid"] = 0; $fields["account"] = 0; $fields["loan_account"] = 0; foreach ($fields as $k => $v) { if (!isset(${$k})) { ${$k} = $v; } } $day = "<select name='lday'>"; for ($i = 1; $i <= 31; $i++) { if ($i == $lday) { $sel = "selected"; } else { $sel = ""; } $day .= "<option {$sel} value='{$i}'>{$i}</option>"; } $day .= "</select>"; $month = empMonList("lmonth", $lmonth); db_connect(); $sql = "SELECT * FROM bankacct WHERE div = '" . USER_DIV . "' AND btype='loc' ORDER BY accname ASC"; $bnks = db_exec($sql); if (pg_numrows($bnks) < 1) { return "<li class='err'> There are no bank accounts found in Cubit.\n\t\t<p><input type='button' onClick='JavaScript:history.back();' value='« Correct Selection'>"; } $banks = "\n\t\t<select name='accid'>\n\t\t\t<option value='0'>Select Bank Account</option>"; while ($acc = pg_fetch_array($bnks)) { if ($acc["bankid"] == $accid) { $sel = "selected"; } else { $sel = ""; } $banks .= "<option {$sel} value='{$acc['bankid']}'>{$acc['accname']} ({$acc['acctype']})</option>"; } $banks .= "</select>"; /* create account selection drop downs */ $accounts = "\n\t\t<select name='account'>\n\t\t\t<option value='0'>Select Account</option>"; $loan_accounts = "\n\t\t<select name='loan_account'>\n\t\t\t<option value='0'>Select Loan Account</option>"; db_conn('core'); $sql = "SELECT * FROM accounts WHERE div = '" . USER_DIV . "' ORDER BY topacc,accnum ASC"; $accRslt = db_exec($sql); if (pg_numrows($accRslt) < 1) { return "<li>There are No accounts in Cubit.</li>"; } $accs_found = array(); $prev_main = "000"; while ($acc = pg_fetch_array($accRslt)) { if (isb($acc['accid'])) { continue; } // sub account indentation logic if ($acc["accnum"] == "000" || $prev_main != $acc["topacc"]) { $spaces = ""; $prev_main = $acc["topacc"]; } else { $spaces = " "; } if ($acc["accid"] == $account) { $sel = "selected"; } else { $sel = ""; } $accounts .= "<option {$sel} value='{$acc['accid']}'>{$acc['topacc']}/{$acc['accnum']} {$spaces}- {$acc['accname']}</option>"; if ($acc["accid"] == $loan_account) { $sel = "selected"; } else { $sel = ""; } $loan_accounts .= "<option {$sel} value='{$acc['accid']}'>{$acc['topacc']}/{$acc['accnum']} {$spaces}- {$acc['accname']}</option>"; } $accounts .= "</select>"; $loan_accounts .= "</select>"; db_connect(); $get_loants = "SELECT * FROM loan_types ORDER BY loan_type"; $run_loants = db_exec($get_loants) or errDie("Unable to get loan types information."); if (pg_numrows($run_loants) < 1) { return "<li>There are No Loan Types in Cubit.</li><br><br>" . mkQuickLinks(ql("../loan_type_add.php", "Add Loan Type"), ql("../loan_type_view.php", "View Loan Types")); } else { if (!isset($loan_type)) { $loan_type = ""; } $loan_type_drop = "<select name='loan_type'>"; while ($larr = pg_fetch_array($run_loants)) { if ($loan_type == $larr['id']) { $loan_type_drop .= "<option selected value='{$larr['id']}'>{$larr['loan_type']}</option>"; } else { $loan_type_drop .= "<option value='{$larr['id']}'>{$larr['loan_type']}</option>"; } } $loan_type_drop .= "</select>"; } $enterLoan = "\n\t\t<h3>Complete Details To Apply For Loan</h3>\n\t\t{$err}\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<input type='hidden' name='key' value='confirm'>\n\t\t\t<input type='hidden' name='empnum' value='{$empnum}'>\n\t\t\t<tr>\n\t\t\t\t<th>Field</th>\n\t\t\t\t<th>Value</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Date Granted</td>\n\t\t\t\t<td>{$day} {$month}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Loan Type</td>\n\t\t\t\t<td>{$loan_type_drop}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Loan amount</td>\n\t\t\t\t<td>" . CUR . "<input type='text' size='10' name='loanamt' class='right' value='{$loanamt}'></td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Interest on loan</td>\n\t\t\t\t<td><input type='text' size='5' name='loanint' class='right' value='{$loanint}'>%</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Payback period (months)</td>\n\t\t\t\t<td><input type='text' size='5' name='loanperiod' class='right' value='{$loanperiod}'></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2'>\n\t\t\t\t\t<li class='err'>You must FIRST create an employee loan account which must be a sub account of<br>\n\t\t\t\t\t\tthe main account called 'Employee Loans'.</li>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Select Loan Account</td>\n\t\t\t\t<td align='center'>{$loan_accounts}</td>\n\t\t\t</tr>\n\t\t\t<tr><td> </td></tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2'>\n\t\t\t\t\t<li class='err'>Select one of the following. This selection is for the account to be Credited,<br>\n\t\t\t\t\tin other words, where the money comes from.</li>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Select Bank Account</td>\n\t\t\t\t<td>{$banks}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='center'><b>OR</b></td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Select Account</td>\n\t\t\t\t<td align='center'>{$accounts}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='right'><input type='submit' value='Confirm »'></td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form>\n\t\t<br />" . mkQuickLinks(ql("loan_apply.php", "Add Loan Application"), ql("loan_apply_view.php", "View Loan Applications"), ql("../admin-employee-add.php", "Add Employee"), ql("../admin-employee-view.php", "View Employees")); return $enterLoan; }
function viewEmp() { # Connect to db db_connect(); global $_GET; extract($_GET); if (!isset($err)) { $err = ""; } else { $err = "<li class='err'>{$err}</li>"; } if (!isset($month)) { $month = DATE_MONTH; } if (isset($emp_group) and $emp_group != 0) { $egsearch = "AND emp_group = '{$emp_group}'"; } 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 = ""; } } # Get employees from db $employees = ""; $i = 0; $sql = "SELECT * FROM employees WHERE div = '" . USER_DIV . "' {$egsearch} ORDER BY sname,fnames"; $empRslt = db_exec($sql) or errDie("Unable to select employees from database."); if (pg_numrows($empRslt) < 1) { $employees = "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td colspan='5'><li class='err'>No Employees Found.</li></td>\n\t\t\t</tr>"; } else { while ($myEmp = pg_fetch_array($empRslt)) { if (isset($all) || isset($emps[$myEmp["empnum"]])) { $ex = "checked=yes"; } else { $ex = ""; } // <a href='irp5-export.php?empnum=$myEmp[empnum]'>Export IRP 5</a> | $employees .= "\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>{$myEmp['enum']}</td>\n\t\t\t\t\t<td>{$myEmp['fnames']}</td>\n\t\t\t\t\t<td>{$myEmp['sname']}</td>\n\t\t\t\t\t<td align='right' nowrap>" . CUR . " {$myEmp['balance']}</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<a href='admin-employee-detail.php?empnum={$myEmp['empnum']}'>Details</a> |\n\t\t\t\t\t\t<a target=_blank href='salwages/irp5-data.php?empnum={$myEmp['empnum']}'>Year to Date</a> |\n\t\t\t\t\t\t<a href='salwages/employee-pay.php?id={$myEmp['empnum']}'>Pay</a> |\n\t\t\t\t\t\t<a href='salwages/employee-tran.php?id={$myEmp['empnum']}'>Transaction</a> |\n\t\t\t\t\t\t<a target='_blank' href='pdf/irp5-pdf.php?empnum={$myEmp['empnum']}'>IRP 5</a> |\n\n\t\t\t\t\t\t<a target='_blank' href='pdf/it3-pdf.php?empnum={$myEmp['empnum']}'>IT 3 (a)</a> |\n\t\t\t\t\t\t<a href='#' onClick=openwindowbg('docman/doc-view-type.php?xin={$myEmp['enum']}&type=empl');>View Documents</a> |\n\t\t\t\t\t\t<a href='admin-employee-edit.php?empnum={$myEmp['empnum']}'>Edit</a> |\n\t\t\t\t\t\t<a href='salwages/empacc-link.php?empnum={$myEmp['empnum']}'>Exp. Accs.</a> |\n\t\t\t\t\t\t<a href='salwages/employee-leave-avail.php?empnum={$myEmp['empnum']}'>View Available Leave</a> |\n\t\t\t\t\t\t<a href='admin-employee-rem.php?empnum={$myEmp['empnum']}'>Leave Company</a>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td><input type='checkbox' name='emps[{$myEmp['empnum']}]' {$ex}></td>\n\t\t\t\t</tr>"; } } $get_egroups = "SELECT * FROM emp_groups ORDER BY emp_group"; $run_egroups = db_exec($get_egroups) or errDie("Unable to get employee group information."); if (pg_numrows($run_egroups) < 1) { $emp_group_drop = "<input type='hidden' name='emp_group' value='0'>"; } else { $emp_group_drop = "<select name='emp_group' onChange='document.form1.submit();'>"; $emp_group_drop .= "<option value='0'>Select Employee Group</option>"; while ($egarr = pg_fetch_array($run_egroups)) { if (isset($emp_group) and $emp_group == $egarr['id']) { $emp_group_drop .= "<option value='{$egarr['id']}' selected>{$egarr['emp_group']}</option>"; } else { $emp_group_drop .= "<option value='{$egarr['id']}'>{$egarr['emp_group']}</option>"; } } $emp_group_drop .= "</select>"; } $get_pays = "SELECT payroll_groups FROM users WHERE username = '******'USER_NAME']}' LIMIT 1"; $run_pays = db_exec($get_pays) or errDie("Unable to get user payroll group information."); if (pg_numrows($run_pays) > 0) { $arr = pg_fetch_array($run_pays); #check if the current user has pems to view the current payroll group $perms = explode(",", $arr['payroll_groups']); if (isset($emp_group) and is_array($perms) and $emp_group != "0") { if (!in_array($emp_group, $perms)) { $employees = "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan='5'><li class='err'>You Do Not Have Permission To View This Payroll Group.</td>\n\t\t\t\t\t</tr>"; } } elseif (strlen($arr['payroll_groups']) < 1) { return "<li class='err'>You Have Insufficient Permissions To Access The Cubit Payroll. You May Add The Permission <a href='admin-usredit.php?username={$_SESSION['USER_NAME']}'>Here</a></li>"; } } # Set up table & form $enterEmp = "\n\t\t<h3>Employees</h3>\n\t\t{$err}\n\t\t<form action='salwages/salaries-batch.php' method='POST' name='form1'>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<td colspan='6'><input type='button' onClick='move(\"salwages/irp5-data.php\");'\n\t\t\t\t\tvalue ='Year to Date/Payslips for all Employees' /></td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr>\n\t\t\t\t<th>Filter By Employee Group</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$emp_group_drop}</td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr>\n\t\t\t\t<th>Nr.</th>\n\t\t\t\t<th>First names</th>\n\t\t\t\t<th>Last name</th>\n\t\t\t\t<th>Salary Due</th>\n\t\t\t\t<th colspan='4'>Options</th>\n\t\t\t</tr>\n\t\t\t{$employees}\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td colspan='6'>Total: {$i}</td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t \t<tr>\n\t\t \t\t<td colspan='5' align='right'><input type='submit' value='Select All' name='all'></td>\n\t\t \t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr>\n\t\t\t\t<td colspan='5' align='right'>\n\t\t\t\t\t<table " . TMPL_tblDflts . " width='350'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td width='100%'> </td>\n\t\t\t\t\t\t\t<th nowrap='t'>Salary Period:</th>\n\t\t\t\t\t\t\t<td bgcolor='" . bgcolorc(1) . "'>" . empMonList("month", $month) . "</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 colspan='3' align='right'><input type='submit' value='Process Daily Salaries »' name=d></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 colspan='3' align='right'><input type='submit' value='Process Weekly Salaries »'name=w></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 colspan='3' align='right'><input type='submit' value='Process Fortnightly Salaries »' name=b></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 colspan='3' align='right'><input type='submit' value='Process Monthly Salaries »' name=m></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</table>\n\t\t</form>" . mkQuickLinks(ql("admin-employee-add.php", "Add Employee")); return $enterEmp; }
function slctEmployee($err = "") { extract($_REQUEST); $fields = array("empnum" => false, "MON" => DATE_MONTH); extract($fields, EXTR_SKIP); if (!isset($proc_day)) { $trans_date_setting = getCSetting("USE_TRANSACTION_DATE"); if (isset($trans_date_setting) and $trans_date_setting == "yes") { $trans_date_value = getCSetting("TRANSACTION_DATE"); $date_arr = explode("-", $trans_date_value); $proc_year = $date_arr[0]; $proc_month = $date_arr[1]; $proc_day = $date_arr[2]; } else { $proc_year = date("Y"); $proc_month = date("m"); $proc_day = date("d"); } } db_conn('cubit'); if (isset($emp_group) and $emp_group != 0) { $egsearch = "AND emp_group = '{$emp_group}'"; } 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 = ""; } } $Sl = "SELECT empnum,enum, sname, fnames FROM employees WHERE div = '" . USER_DIV . "' {$egsearch} ORDER BY sname,fnames"; $Ry = db_exec($Sl) or errDie("Unable to select employees from database."); if (pg_numrows($Ry) < 1) { $display_output .= "<li class='err'>No employees found in database.</li></td></tr>"; } else { $employees = "<select size='1' name='empnum'>"; while ($myEmp = pg_fetch_array($Ry)) { if ($empnum == $myEmp["empnum"]) { $sel = "selected"; } else { $sel = ""; } $employees .= "<option {$sel} value='{$myEmp['empnum']}'>{$myEmp['sname']}, {$myEmp['fnames']} ({$myEmp['enum']})</option>"; } $employees .= "</select>"; $display_output = "{$employees}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Select month</td>\n\t\t\t\t<td align='center'>" . empMonList("MON", $MON) . "</td>\n\t\t\t\t<td class='err'>This is the period for which you are processing the salary.</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td nowrap>Processing Date</td>\n\t\t\t\t<td nowrap align='center'>\n\t\t\t\t\t" . mkDateSelect("proc", $proc_year, $proc_month, $proc_day) . "\n\t\t\t\t</td>\n\t\t\t\t<td class='err'>This is the date Cubit will use to enter transactions into the ledgers.</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='right'><input type='submit' name='process' value='Process »'></td>\n\t\t\t</tr>"; } $get_empgroups = "SELECT * FROM emp_groups ORDER BY emp_group"; $run_empgroups = db_exec($get_empgroups) or errDie("Unable to get employee groups information."); if (pg_numrows($run_empgroups) > 0) { $emp_group_drop = "<select name='emp_group' onChange='document.form1.submit();'>"; $emp_group_drop .= "<option value='0'>Select A Employee Group</option>"; while ($earr = pg_fetch_array($run_empgroups)) { if (isset($emp_group) and $emp_group == "{$earr['id']}") { $emp_group_drop .= "<option value='{$earr['id']}' selected>{$earr['emp_group']}</option>"; } else { $emp_group_drop .= "<option value='{$earr['id']}'>{$earr['emp_group']}</option>"; } } $emp_group_drop .= "</select>"; } $get_pays = "SELECT payroll_groups FROM users WHERE username = '******'USER_NAME']}' LIMIT 1"; $run_pays = db_exec($get_pays) or errDie("Unable to get user payroll group information."); if (pg_numrows($run_pays) > 0) { $arr = pg_fetch_array($run_pays); #check if the current user has pems to view the current payroll group $perms = explode(",", $arr['payroll_groups']); if (isset($emp_group) and is_array($perms) and $emp_group != "0") { if (!in_array($emp_group, $perms)) { $display_output = "<li class='err'>You Do Not Have Permission To View This Payroll Group.</td></tr>"; } } elseif (strlen($arr['payroll_groups']) < 1) { $display_output = "<li class='err'>You Have Insufficient Permissions To Access The Cubit Payroll. You May Add The Permission <a href='../admin-usredit.php?username={$_SESSION['USER_NAME']}'>Here</a></li></td></tr>"; } } $slctEmployee = "\n\t\t<h3>Select employee to process</h3>\n\t\t{$err}\n\t\t<form action='" . SELF . "' method='POST' name='form1'>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<input type='hidden' name='key' value='process'>\n\t\t\t<tr>\n\t\t\t\t<th colspan='2'>Employee</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Employee Group</td>\n\t\t\t\t<td>{$emp_group_drop}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Employee</td>\n\t\t\t\t<td align='center'>{$display_output}\n\t\t</table>\n\t\t</form>"; return $slctEmployee; }