Skip to content

Commit

Permalink
Released 2.4-3
Browse files Browse the repository at this point in the history
  • Loading branch information
notrinos committed Jul 6, 2019
1 parent 823c8fe commit 98a370b
Show file tree
Hide file tree
Showing 49 changed files with 1,686 additions and 567 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Requirement

Installation
------------
##### From 01/Apr/2018 FrontHrm can be installed without any changes in FA core so following steps 2, 4 can be ignored.
1. Rename the folder to `FrontHrm` then copy to FA `modules` directory.
##### From 01/Apr/2018 FrontHrm can be installed without any changes in FA core so following steps 2, 3, 4 can be ignored.
1. Rename the folder to `FrontHrm` then copy to the FA `modules` directory.
2. ~~Copy `rep889.php` to FA `reporting` folder.~~
3. Copy `dejavu font files` to FA `reporting/font` folder.
3. ~~Copy `dejavu font files` to FA `reporting/font` folder.~~
4. ~~Replace `reporting/includes/reporting.inc` with `reporting.inc` in the FrontHrm.~~
5. For FrontAccounting 2.4.4 up to now: just install and active normally. For the earlier versions, do the following:

Expand Down
42 changes: 22 additions & 20 deletions hooks.php
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
<?php
/*=======================================================\
| FrontHrm |
|--------------------------------------------------------|
| Creator: Phương |
|--------------------------------------------------------|
| Creator: Phương <trananhphuong83@gmail.com> |
| Date : 09-Jul-2017 |
| Description: Frontaccounting Payroll & Hrm Module |
| Free software under GNU GPL |
| |
\=======================================================*/
\=======================================================*/
define ('SS_HRM', 251<<8);

class FrontHrm_app extends application {
function __construct() {
global $path_to_root;

parent::__construct('FrontHrm', _($this->help_context = 'Human Resource'));

$this->add_module(_('Transactions'));
$this->add_lapp_function(0, _('Attendance'), $path_to_root.'/modules/FrontHrm/manage/attendance.php?', 'SA_EMPL', MENU_TRANSACTION);
$this->add_lapp_function(0, _('Attendance'), $path_to_root.'/modules/FrontHrm/manage/attendance.php?', 'SA_EMPL', MENU_TRANSACTION);
$this->add_lapp_function(0, _('Payslip Entry'), $path_to_root.'/modules/FrontHrm/manage/payslip.php?NewPayslip=Yes', 'SA_EMPL', MENU_TRANSACTION);
$this->add_lapp_function(0, "","");
$this->add_lapp_function(0, _('Document Expiration'), $path_to_root.'/modules/FrontHrm/manage/employee_docs.php?', 'SA_ATTACHDOCUMENT', MENU_TRANSACTION);
$this->add_rapp_function(0, _('Payment Advice'), $path_to_root.'/modules/FrontHrm/manage/employee_bank_entry.php?NewPayment=Yes', 'SA_EMPL', MENU_TRANSACTION);
$this->add_rapp_function(0, _('Employee Advances'), $path_to_root.'/modules/FrontHrm/manage/employee_bank_entry.php?NewAdvance=Yes', 'SA_EMPL', MENU_TRANSACTION);

$this->add_module(_('Inquiries and Reports'));
$this->add_lapp_function(1, _('Timesheet'), $path_to_root.'/modules/FrontHrm/inquiry/time_sheet.php?', 'SA_EMPL', MENU_INQUIRY);
$this->add_lapp_function(1, _('Employee Transaction Inquiry'), $path_to_root.'/modules/FrontHrm/inquiry/emp_inquiry.php?', 'SA_EMPL', MENU_INQUIRY);
$this->add_rapp_function(1, _('Employee Document Inquiry'), $path_to_root.'/modules/FrontHrm/manage/employee_docs.php?View=yes', 'SA_EMPL', MENU_INQUIRY);
$this->add_lapp_function(1, _('Timesheet'), $path_to_root.'/modules/FrontHrm/inquiry/time_sheet.php?', 'SA_EMPL', MENU_INQUIRY);
$this->add_lapp_function(1, _('Employee Transaction Inquiry'), $path_to_root.'/modules/FrontHrm/inquiry/emp_inquiry.php?', 'SA_EMPL', MENU_INQUIRY);
$this->add_rapp_function(1, _('Employee Document Inquiry'), $path_to_root.'/modules/FrontHrm/manage/employee_docs.php?View=yes', 'SA_EMPL', MENU_INQUIRY);
$this->add_rapp_function(1, _("Employee &Reports"),
"reporting/reports_main.php?Class=8", 'SA_EMPL', MENU_REPORT);

$this->add_module(_('Maintenance'));
$this->add_lapp_function(2, _('Employees'), $path_to_root.'/modules/FrontHrm/manage/employee.php?', 'SA_EMPL', MENU_ENTRY);
$this->add_lapp_function(2, _('Document Types'), $path_to_root.'/modules/FrontHrm/manage/doc_type.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_lapp_function(2, _('Departments'), $path_to_root.'/modules/FrontHrm/manage/department.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_lapp_function(2, _('Manage Overtime'), $path_to_root.'/modules/FrontHrm/manage/overtime.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_lapp_function(2, _('Employees'), $path_to_root.'/modules/FrontHrm/manage/employee.php?', 'SA_EMPL', MENU_ENTRY);
$this->add_lapp_function(2, _('Document Types'), $path_to_root.'/modules/FrontHrm/manage/doc_type.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_lapp_function(2, _('Departments'), $path_to_root.'/modules/FrontHrm/manage/department.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_lapp_function(2, _('Manage Overtime'), $path_to_root.'/modules/FrontHrm/manage/overtime.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_lapp_function(2, _('Leave Types'), $path_to_root.'/modules/FrontHrm/manage/leave_types.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_lapp_function(2, _('Default Settings'), $path_to_root.'/modules/FrontHrm/manage/default_setup.php?', 'SA_HRSETUP', MENU_MAINTENANCE);

$this->add_rapp_function(2, _('Salary Scales'), $path_to_root.'/modules/FrontHrm/manage/salaryscale.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_rapp_function(2, _('Allowance and Deduction Account'), $path_to_root.'/modules/FrontHrm/manage/accounts.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_rapp_function(2, _('Allowance and Deduction Rules'), $path_to_root.'/modules/FrontHrm/manage/payroll_rules.php?', 'SA_HRSETUP', MENU_MAINTENANCE);

$this->add_rapp_function(2, _('Job Positions'), $path_to_root.'/modules/FrontHrm/manage/position.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_rapp_function(2, _('Manage Grades'), $path_to_root.'/modules/FrontHrm/manage/grade.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_rapp_function(2, _('Pay Elements'), $path_to_root.'/modules/FrontHrm/manage/accounts.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_rapp_function(2, _('Pay Elements Allocation'), $path_to_root.'/modules/FrontHrm/manage/payroll_rules.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_rapp_function(2, _('Salary Structure'), $path_to_root.'/modules/FrontHrm/manage/salary_structure.php?', 'SA_HRSETUP', MENU_MAINTENANCE);
$this->add_extensions();
$this->add_extensions();
}
}

class hooks_FrontHrm extends hooks {
function __construct() {
$this->module_name = 'FrontHrm';
}
$this->module_name = 'FrontHrm';
}

function install_tabs($app) {
$app->add_application(new FrontHrm_app);
Expand All @@ -70,7 +72,7 @@ function activate_extension($company, $check_only=true) {

return $this->update_databases($company, $updates, $check_only);
}
function deactivate_extension($company, $check_only=true) {
global $db_connections;

Expand Down
63 changes: 41 additions & 22 deletions includes/db/account_db.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,93 +2,112 @@
/*=======================================================\
| FrontHrm |
|--------------------------------------------------------|
| Creator: Phương |
| Creator: Phương <trananhphuong83@gmail.com> |
| Date : 09-Jul-2017 |
| Description: Frontaccounting Payroll & Hrm Module |
| Free software under GNU GPL |
| |
\=======================================================*/

function add_payroll_account($account) {
$sql= "INSERT INTO ".TB_PREF."payroll_account (account_code) VALUES (".db_escape($account).")";
function add_pay_element($name, $account) {
$sql= "INSERT INTO ".TB_PREF."pay_element (element_name, account_code) VALUES (".db_escape($name).",".db_escape($account).")";

db_query($sql, _('could not insert account'));
}

//--------------------------------------------------------------------------

function get_payroll_accounts() {
$sql = "SELECT pa.account_id, ac.account_code, ac.account_name FROM ".TB_PREF."chart_master ac, ".TB_PREF."payroll_account pa WHERE ac.account_code = pa.account_code";
function get_payroll_elements($id=false, $account=false) {
$sql = "SELECT e.element_id, e.element_name, a.account_code, a.account_name FROM ".TB_PREF."chart_master a, ".TB_PREF."pay_element e WHERE a.account_code = e.account_code";

if($id)
$sql .= " AND e.element_id = ".db_escape($id);
if($account)
$sql .= " AND e.account_code = ".db_escape($account);

return db_query($sql, _('Could not get accounts'));
$result = db_query($sql, _('Could not get accounts'));

if($account || $id)
return db_fetch($result);
else
return $result;
}

//--------------------------------------------------------------------------

function update_pay_element($id, $name) {

$sql = "UPDATE ".TB_PREF."pay_element SET element_name = ".db_escape($name)." WHERE element_id = ".db_escape($id);

db_query($sql, _('could not update pay element'));
}

//--------------------------------------------------------------------------

function delete_payroll_account($id) {

$sql = "DELETE FROM ".TB_PREF."payroll_account WHERE account_id=".db_escape($id);
$result = db_query($sql, _('Could not delete account'));
$sql = "DELETE FROM ".TB_PREF."pay_element WHERE element_id=".db_escape($id);
$result = db_query($sql, _('Could not delete element'));
}

//--------------------------------------------------------------------------

function payroll_account_exist($code) {
return check_empty_result("SELECT account_code FROM ".TB_PREF."payroll_account WHERE account_code=".db_escape($code));
return check_empty_result("SELECT account_code FROM ".TB_PREF."pay_element WHERE account_code=".db_escape($code));
}

//--------------------------------------------------------------------------

function payroll_account_used($id) {

return check_empty_result("SELECT pa.account_id, ps.payroll_rule, pa.account_code FROM ".TB_PREF."payroll_structure ps, ".TB_PREF."payroll_account pa WHERE pa.account_id=".db_escape($id)." AND ps.payroll_rule LIKE CONCAT('%',pa.account_code,'%')");
return check_empty_result("SELECT e.element_id, p.payroll_rule, e.account_code FROM ".TB_PREF."payroll_structure p, ".TB_PREF."pay_element e WHERE e.element_id=".db_escape($id)." AND p.payroll_rule LIKE CONCAT('%',e.account_code,'%')");
}

//--------------------------------------------------------------------------

function get_payroll_rules() {

$sql = "SELECT ca.account_code, ca.account_name, pa.account_code FROM ".TB_PREF."chart_master ca, ".TB_PREF."payroll_account pa WHERE ca.account_code = pa.account_code ORDER BY ca.account_code";
$sql = "SELECT e.element_name, c.account_code, c.account_name FROM ".TB_PREF."chart_master c, ".TB_PREF."pay_element e WHERE c.account_code = e.account_code ORDER BY c.account_code";

return db_query($sql, _('Could not get accounts'));
}

//--------------------------------------------------------------------------

function add_payroll_rule($salary_scale_id, $payroll_rule) {
function add_payroll_rule($position_id, $payroll_rule) {

$sql = "INSERT INTO ".TB_PREF."payroll_structure (salary_scale_id, payroll_rule ) VALUES (".db_escape($salary_scale_id).",".db_escape(implode(';',$payroll_rule)).")";
$sql = "INSERT INTO ".TB_PREF."payroll_structure (position_id, payroll_rule ) VALUES (".db_escape($position_id).",".db_escape(implode(';',$payroll_rule)).")";
db_query($sql, _('The payroll could not be added'));
}

//--------------------------------------------------------------------------

function update_payroll_rule($salary_scale_id, $payroll_rule) {
function update_payroll_rule($position_id, $payroll_rule) {

$sql = "UPDATE ".TB_PREF."payroll_structure SET payroll_rule=".db_escape(implode(';', $payroll_rule))."WHERE salary_scale_id=".db_escape($salary_scale_id);
$sql = "UPDATE ".TB_PREF."payroll_structure SET payroll_rule=".db_escape(implode(';', $payroll_rule))."WHERE position_id=".db_escape($position_id);

db_query($sql, _('The payroll could not be updated'));

}

//--------------------------------------------------------------------------

function payroll_rule_exist($salary_scale_id) {
function payroll_rule_exist($position_id) {

return check_empty_result("SELECT payroll_rule FROM ".TB_PREF."payroll_structure WHERE salary_scale_id=".db_escape($salary_scale_id));
return check_empty_result("SELECT payroll_rule FROM ".TB_PREF."payroll_structure WHERE position_id=".db_escape($position_id));
}

//--------------------------------------------------------------------------

function payroll_rule_used($salary_scale, $rule) {
return check_empty_result("SELECT id FROM ".TB_PREF."salary_structure WHERE salary_scale_id = ".db_escape($salary_scale)." AND pay_rule_id = ".db_escape($rule));
function payroll_rule_used($position, $rule) {
return check_empty_result("SELECT id FROM ".TB_PREF."salary_structure WHERE position_id = ".db_escape($position)." AND pay_rule_id = ".db_escape($rule));
}

//--------------------------------------------------------------------------

function reset_payroll($salary_scale_id) {
function reset_payroll($position) {

$sql = "DELETE FROM ".TB_PREF."payroll_structure WHERE salary_scale_id =".db_escape($salary_scale_id);
$sql = "DELETE FROM ".TB_PREF."payroll_structure WHERE position_id =".db_escape($position);

db_query($sql, _('could not reset payroll rules'));
}
Expand All @@ -97,7 +116,7 @@ function reset_payroll($salary_scale_id) {

function get_payroll_structure($id) {

$sql = "SELECT * FROM ".TB_PREF."payroll_structure WHERE salary_scale_id = ".db_escape($id);
$sql = "SELECT * FROM ".TB_PREF."payroll_structure WHERE position_id = ".db_escape($id);
$result = db_query($sql, _('could not get payroll structure'));
$row = db_fetch($result);

Expand Down
Loading

0 comments on commit 98a370b

Please sign in to comment.