first commit
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '200' ;
|
||||
|
||||
$adjustments = [ 'plus' => [], 'minus' => [] ] ;
|
||||
$staffs = [] ;
|
||||
$departments = [] ;
|
||||
$staff_departments = [] ;
|
||||
$all_tier = getAllTier( $array['lang'] ) ;
|
||||
|
||||
|
||||
|
||||
// select all adjustment
|
||||
$query_setting = " AND set_tier LIKE '%|".$staff_info['staff_tier']."|%'" ;
|
||||
switch ( $staff_info['staff_tier_is_adjustment'] ){
|
||||
case 'yes' :
|
||||
// do nothing
|
||||
break ;
|
||||
default :
|
||||
$query_setting = " AND a.adjustment_mode = 'fixed'" ;
|
||||
}
|
||||
|
||||
$select = $mysqli->query( "SELECT a.adjustment_id, a.adjustment_type, a.adjustment_mode, a.point, b.title FROM setting_adjustment a
|
||||
LEFT JOIN setting_adjustment_translation b ON ( a.adjustment_id = b.adjustment_id )
|
||||
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.adjustment_site = 'frontend' ".$query_setting." ORDER BY a.sortable" ) ;
|
||||
if ( $select->num_rows > 0 ){
|
||||
while ( $row = $select->fetch_assoc() ){
|
||||
$adjustments[$row['adjustment_type']][] = [
|
||||
'id' => $row['adjustment_id'],
|
||||
'mode' => $row['adjustment_mode'],
|
||||
'title' => dataFilter( $row['title'] ),
|
||||
'point' => $row['point']
|
||||
] ;
|
||||
}
|
||||
}
|
||||
|
||||
// select all staff
|
||||
$staff_tier = [] ;
|
||||
$staff_tier = getRelatedTierID( 'no', $staff_info['staff_tier_level'] ) ;
|
||||
|
||||
$where_staff = '' ;
|
||||
$where_branch = '' ;
|
||||
if ( $staff_info['staff_settings']['adjustmentbranch'] != 'yes' ){
|
||||
$where_staff .= " AND a.branch_id = '".$array['branch_id']."'" ;
|
||||
$where_branch .= " AND a.branch_id = '".$array['branch_id']."'" ;
|
||||
}
|
||||
|
||||
// select all staff
|
||||
$select = $mysqli->query( "SELECT a.staff_id, a.branch_id, a.staff_idno, a.staff_name, a.staff_shortname, a.staff_tier FROM staff a
|
||||
WHERE a.deleted_at IS NULL AND a.staff_id != '".$staff_info['staff_id']."' AND a.staff_tier IN ( '".implode("', '", $staff_tier)."' ) AND ( a.staff_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL ) " . $where_staff ) ;
|
||||
|
||||
if ( $select->num_rows > 0 ){
|
||||
while ( $row = $select->fetch_assoc() ){
|
||||
$get_staff_tier = $all_tier[$row['staff_tier']] ;
|
||||
|
||||
$staffs[$row['staff_id']] = [
|
||||
'id' => $row['staff_id'],
|
||||
'branch_id' => $row['branch_id'],
|
||||
'title' => $row['staff_shortname'] . ' ('.$row['staff_idno'].' / '.strtoupper( $get_staff_tier['title'] ).')',
|
||||
'name' => $row['staff_name'],
|
||||
'tier' => $get_staff_tier['level']
|
||||
] ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// select all department
|
||||
$select = $mysqli->query( "SELECT a.department_id, b.department_desc FROM setting_department a
|
||||
LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
|
||||
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ) ;
|
||||
if ( $select->num_rows > 0 ){
|
||||
while ( $row = $select->fetch_assoc() ){
|
||||
$departments[] = $row ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// select all branch
|
||||
$branches = [] ;
|
||||
$select_branch = $mysqli->query( "SELECT branch_id, branch_name FROM branch a
|
||||
WHERE a.deleted_at IS NULL" . $where_branch ) ;
|
||||
if ( $select_branch->num_rows > 0 ){
|
||||
while ( $row_branch = $select_branch->fetch_assoc() ){
|
||||
$branches[] = [
|
||||
'id' => $row_branch['branch_id'],
|
||||
'title' => dataFilter( $row_branch['branch_name'] )
|
||||
] ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// select all staff department
|
||||
$select = $mysqli->query( "SELECT a.staff_id, a.department_id FROM staff_department a
|
||||
WHERE a.deleted_at IS NULL" ) ;
|
||||
if ( $select->num_rows > 0 ){
|
||||
while ( $row = $select->fetch_assoc() ){
|
||||
if ( $staffs[ $row['staff_id'] ] != null && $staffs[ $row['staff_id'] ] != undefined ){
|
||||
$staff = $staffs[ $row['staff_id'] ] ;
|
||||
$staff_departments[$staff['branch_id']][$row['department_id']][] = $staff ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$reset_branches = [] ;
|
||||
foreach ( $branches as $kbranch => $vbranch ){
|
||||
// reset
|
||||
$reset_departments = [] ;
|
||||
$reset_departments[] = [
|
||||
'id' => '0',
|
||||
'title' => 'Cross Department',
|
||||
'staffs' => []
|
||||
] ;
|
||||
foreach ( $departments as $k => $v ){
|
||||
if ( $staff_departments[$vbranch['id']][$v['department_id']] != null && $staff_departments[$vbranch['id']][$v['department_id']] != undefined ){
|
||||
$reset_departments[] = [
|
||||
'id' => $v['department_id'],
|
||||
'title' => $v['department_desc'],
|
||||
'staffs' => $staff_departments[$vbranch['id']][$v['department_id']]
|
||||
] ;
|
||||
}
|
||||
}
|
||||
|
||||
$reset_branches[] = [
|
||||
'id' => $vbranch['id'],
|
||||
'title' => $vbranch['title'],
|
||||
'departments' => $reset_departments
|
||||
] ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$data = [
|
||||
'adjustments' => $adjustments,
|
||||
'default_branch' => $array['branch_id'],
|
||||
'branches' => $reset_branches
|
||||
] ;
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '201' ;
|
||||
|
||||
|
||||
// select all department
|
||||
$department_list = [] ;
|
||||
$select = $mysqli->query( "SELECT a.department_id, b.department_desc FROM setting_department a
|
||||
LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
|
||||
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ) ;
|
||||
if ( $select->num_rows > 0 ){
|
||||
while ( $row = $select->fetch_assoc() ){
|
||||
$department_list[$row['department_id']] = $row['department_desc'] ;
|
||||
}
|
||||
}
|
||||
|
||||
// select all staff
|
||||
$staff_list = [] ;
|
||||
$select = $mysqli->query( "SELECT a.staff_id, a.staff_name, a.staff_shortname, a.staff_idno FROM staff a
|
||||
WHERE a.deleted_at IS NULL AND ( a.staff_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL )" ) ;
|
||||
if ( $select->num_rows > 0 ){
|
||||
while ( $row = $select->fetch_assoc() ){
|
||||
$staff_list[$row['staff_id']] = $row['staff_shortname'] . ' ( '.$row['staff_idno'].' )' ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$search_query = '' ;
|
||||
if ( $array['search'] != '' ){
|
||||
$search_query .= " AND ( a.remark LIKE '%".$array['search']."%' OR b.title LIKE '%".$array['search']."%' )" ;
|
||||
}
|
||||
|
||||
$query = "SELECT a.adjustment_id, a.adjustment_so, a.adjustment_type, a.created_by, a.department_id, a.point, a.remark, a.created_at, b.title FROM staff_adjustment a
|
||||
LEFT JOIN setting_adjustment_translation b ON ( a.setting_adjustment_id = b.adjustment_id )
|
||||
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND ( a.created_branch_id = '".$array['branch_id']."' AND a.created_by = '".$staff_info['staff_id']."' ) " . $search_query ;
|
||||
$mysqli_query = $mysqli->query( $query . " ORDER BY a.adjustment_id DESC LIMIT " . getLimit( $current ) ) ;
|
||||
|
||||
if ( $mysqli_query->num_rows > 0 ){
|
||||
|
||||
$status = '200' ;
|
||||
|
||||
$list = [] ;
|
||||
while ( $row = $mysqli_query->fetch_assoc() ){
|
||||
|
||||
$row['department'] = $department_list[ $row['department_id'] ] ;
|
||||
$row['created_by_name'] = $staff_list[ $row['created_by'] ] ;
|
||||
$list[] = $row ;
|
||||
}
|
||||
|
||||
$data['list'] = $list ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
require( $require_path.'languages/'.$array['lang'].'.php' ) ;
|
||||
|
||||
$html = '' ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '201' ;
|
||||
|
||||
$search_year = ( $array['search_year'] != '' ? $array['search_year'] : date('Y') ) ;
|
||||
$search_type = ( $array['search_type'] != '' ? $array['search_type'] : 'personal' ) ;
|
||||
|
||||
$staff_settings = $staff_info['staff_settings'] ;
|
||||
|
||||
$months = [] ;
|
||||
$months_name = [ $lang['Jan'], $lang['Feb'], $lang['Mar'], $lang['Apr'], $lang['May'], $lang['Jun'], $lang['Jul'], $lang['Aug'], $lang['Sep'], $lang['Oct'], $lang['Nov'], $lang['Dec'] ] ;
|
||||
for ( $a = 1 ; $a <= 12 ; $a++ ){ $months[$a] = 0 ; }
|
||||
|
||||
// monthly report = by personal or whole branch
|
||||
$array_report = [
|
||||
'personal' => [
|
||||
'plus' => $months,
|
||||
'minus' => $months
|
||||
],
|
||||
] ;
|
||||
if ( $staff_settings['reportadjustmentbranch'] == 'yes' ){
|
||||
$array_report['branch'] = [
|
||||
'plus' => $months,
|
||||
'minus' => $months
|
||||
] ;
|
||||
}
|
||||
|
||||
$filtertype = [] ;
|
||||
foreach ( $array_report as $k => $v ){
|
||||
if ( $k == $search_type ){
|
||||
$filtertype[] = $k ;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $filtertype as $k => $v ){
|
||||
|
||||
$search_query = " AND ( b.created_branch_id = '".$array['branch_id']."' XXXXXX )" ;
|
||||
switch ( $v ){
|
||||
case 'personal' :
|
||||
$search_query = str_replace( 'XXXXXX', " AND b.created_by = '".$staff_info['staff_id']."'", $search_query ) ;
|
||||
break ;
|
||||
case 'branch' :
|
||||
$search_query = str_replace( 'XXXXXX', '', $search_query ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
$select_report = $mysqli->query( "SELECT SUM(a.point) as total, b.adjustment_type, MONTH(b.created_at) as month FROM staff_adjustment_point a
|
||||
LEFT JOIN staff_adjustment b ON ( a.adjustment_id = b.adjustment_id )
|
||||
WHERE a.deleted_at IS NULL AND b.deleted_at IS NULL AND b.created_at LIKE '%".$search_year."%' ".$search_query."
|
||||
GROUP BY b.adjustment_type, MONTH(b.created_at)" ) ;
|
||||
|
||||
if ( $select_report->num_rows > 0 ){
|
||||
while ( $row_report = $select_report->fetch_assoc() ){
|
||||
$array_report[$v][$row_report['adjustment_type']][$row_report['month']] = $row_report['total'] ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// direct echo
|
||||
if ( $array['iswebview'] == 'yes' ){
|
||||
|
||||
$html .= '
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="'.PATH.'css/bootstrap.css?v='.filemtime($require_path.'css/bootstrap.css').'" />
|
||||
<script src="'.PATH.'scripts/chart.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="report_chart_main">
|
||||
|
||||
<div class="report_chart_filter_year">
|
||||
<a href="?search_year='.( $search_year - 1 ).resetGetParams($array, [ 'search_year' ]).'" class="report_chart_filter_year_button">
|
||||
<i class="fa fa-chevron-left" aria-hidden="true"></i>
|
||||
</a>
|
||||
<span class="report_chart_filter_year_span">'. $search_year .'</span>
|
||||
<a href="?search_year='.( $search_year + 1 ).resetGetParams($array, [ 'search_year' ]).'" class="report_chart_filter_year_button">
|
||||
<i class="fa fa-chevron-right" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>' ;
|
||||
|
||||
if ( count($array_report) > 1 ){
|
||||
$html .= '
|
||||
<div class="report_chart_filter_type">
|
||||
<a href="?search_type=personal'.resetGetParams($array, [ 'search_type' ]).'" class="report_chart_filter_type_button '.( $search_type == 'personal' ? 'active' : '' ).'">
|
||||
'.$lang['By Personal'].'
|
||||
</a>
|
||||
<a href="?search_type=branch'.resetGetParams($array, [ 'search_type' ]).'" class="report_chart_filter_type_button '.( $search_type == 'branch' ? 'active' : '' ).'">
|
||||
'.$lang['By Branch'].'
|
||||
</a>
|
||||
</div>' ;
|
||||
}
|
||||
|
||||
foreach ( $array_report as $kreport => $vreport ){
|
||||
|
||||
if ( $kreport == $search_type ){
|
||||
|
||||
$title = $lang['By '.ucwords($kreport).' Report'] ;
|
||||
$titlename = $title.' ( '.$lang['Year'].' '.$search_year.' )' ;
|
||||
|
||||
$html .= '
|
||||
<div class="report_chart_line">
|
||||
<canvas id="myChart'.$kreport.'"></canvas>
|
||||
</div>
|
||||
<script>
|
||||
const ctx'.$kreport.' = document.getElementById("myChart'.$kreport.'") ;
|
||||
const config'.$kreport.' = {
|
||||
type : "line",
|
||||
data : {
|
||||
datasets : [
|
||||
{
|
||||
label : "'.$lang['Give Point'].'",
|
||||
data : [ "'.implode( '", "', $vreport['plus'] ).'" ]
|
||||
},
|
||||
{
|
||||
label : "'.$lang['Minus Point'].'",
|
||||
data : [ "'.implode( '", "', $vreport['minus'] ).'" ]
|
||||
}
|
||||
],
|
||||
labels : [ "'.implode( '", "', $months_name ).'" ]
|
||||
},
|
||||
options: {
|
||||
responsive : true,
|
||||
maintainAspectRatio : false,
|
||||
plugins : {
|
||||
legend : {
|
||||
position : "top",
|
||||
},
|
||||
title : {
|
||||
display : true,
|
||||
text : "'.$titlename.'"
|
||||
}
|
||||
}
|
||||
}
|
||||
} ;
|
||||
new Chart( ctx'.$kreport.', config'.$kreport.' ) ;
|
||||
</script>' ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '
|
||||
</div>
|
||||
</body>
|
||||
</html>' ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ( $array['iswebview'] == 'yes' ){
|
||||
echo $html ;
|
||||
exit ;
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '201' ;
|
||||
|
||||
|
||||
// select all department
|
||||
$department_list = [] ;
|
||||
$select = $mysqli->query( "SELECT a.department_id, b.department_desc FROM setting_department a
|
||||
LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
|
||||
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ) ;
|
||||
if ( $select->num_rows > 0 ){
|
||||
while ( $row = $select->fetch_assoc() ){
|
||||
$department_list[$row['department_id']] = $row['department_desc'] ;
|
||||
}
|
||||
}
|
||||
|
||||
// select all staff
|
||||
$staff_list = [] ;
|
||||
$select = $mysqli->query( "SELECT a.staff_id, a.staff_name, a.staff_shortname, a.staff_idno FROM staff a
|
||||
WHERE a.deleted_at IS NULL AND ( a.staff_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL )" ) ;
|
||||
if ( $select->num_rows > 0 ){
|
||||
while ( $row = $select->fetch_assoc() ){
|
||||
$staff_list[$row['staff_id']] = $row['staff_shortname'] . ' ( '.$row['staff_idno'].' )' ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$search_query = '' ;
|
||||
$search_query .= " AND a.adjustment_id = '".$array['adjustment_id']."'" ;
|
||||
|
||||
$query = "SELECT a.adjustment_id, a.adjustment_so, a.adjustment_type, a.created_by, a.department_id, a.point, a.remark, a.created_at, b.title FROM staff_adjustment a
|
||||
LEFT JOIN setting_adjustment_translation b ON ( a.setting_adjustment_id = b.adjustment_id )
|
||||
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
|
||||
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
|
||||
|
||||
if ( $mysqli_query->num_rows > 0 ){
|
||||
|
||||
$status = '200' ;
|
||||
|
||||
$row = $mysqli_query->fetch_assoc() ;
|
||||
|
||||
$search_query2 = '' ;
|
||||
if ( $row['created_by'] != $staff_info['staff_id'] ){
|
||||
$search_query2 .= " AND staff_id = '".$staff_info['staff_id']."'" ;
|
||||
}
|
||||
|
||||
$related_staff = [] ;
|
||||
$select_related = $mysqli->query( "SELECT staff_id FROM staff_adjustment_point
|
||||
WHERE deleted_at IS NULL AND adjustment_id = '".$array['adjustment_id']."'" . $search_query2 ) ;
|
||||
|
||||
if ( $select_related->num_rows > 0 ){
|
||||
while ( $row_related = $select_related->fetch_assoc() ){
|
||||
$related_staff[] = $staff_list[$row_related['staff_id']] ;
|
||||
}
|
||||
}
|
||||
|
||||
$row['title'] = dataFilter( $row['title'] ) ;
|
||||
$row['department'] = $department_list[ $row['department_id'] ] ;
|
||||
$row['created_by_name'] = $staff_list[ $row['created_by'] ] ;
|
||||
$row['related_staff'] = $related_staff ;
|
||||
$data = $row ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '300' ;
|
||||
|
||||
$adjustment_id = $array['adjustment_id'] ;
|
||||
|
||||
if ( $array['adjustment_type'] != '' && $array['setting_adjustment_id'] != '' && $array['department_id'] != '' && $array['point'] != ''&& arrayCheck( $array['related_staffs'] ) ){
|
||||
$status = '253' ;
|
||||
|
||||
$point = $array['point'] ;
|
||||
switch ( $array['adjustment_type'] ){
|
||||
case 'plus' :
|
||||
$point = ( $point > 0 ? $point : -($point) ) ;
|
||||
break ;
|
||||
case 'minus' :
|
||||
$point = ( $point > 0 ? -($point) : $point ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( $point > 0 || $point < 0 ){
|
||||
$status = '203' ;
|
||||
|
||||
$select_adjustment = $mysqli->query( "SELECT a.adjustment_id, a.adjustment_group, a.adjustment_scenario, a.adjustment_times, b.title FROM setting_adjustment a
|
||||
LEFT JOIN setting_adjustment_translation b ON ( a.adjustment_id = b.adjustment_id )
|
||||
WHERE a.deleted_at IS NULL AND b.lang = 'en' AND a.adjustment_id = '".$array['setting_adjustment_id']."'
|
||||
LIMIT 1" ) ;
|
||||
if ( $select_adjustment->num_rows > 0 ){
|
||||
$status = '271' ;
|
||||
|
||||
$row_adjustment = $select_adjustment->fetch_assoc() ;
|
||||
$adjustment_times = $row_adjustment['adjustment_times'] ;
|
||||
|
||||
$list_adjustment = [] ;
|
||||
$list_adjustment[]= $row_adjustment['adjustment_id'] ;
|
||||
if ( $row_adjustment['adjustment_group'] > 0 ){
|
||||
$select_group = $mysqli->query( "SELECT adjustment_id FROM setting_adjustment
|
||||
WHERE deleted_at IS NULL AND adjustment_site = 'frontend' AND adjustment_group = '".$row_adjustment['adjustment_group']."'" ) ;
|
||||
if ( $select_group->num_rows > 0 ){
|
||||
while ( $row_group = $select_group->fetch_assoc() ){
|
||||
$list_adjustment[] = $row_group['adjustment_id'] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$is_allow = false ;
|
||||
switch ( $row_adjustment['adjustment_scenario'] ){
|
||||
case 'none' :
|
||||
$is_allow = true ;
|
||||
break ;
|
||||
case 'daily' :
|
||||
|
||||
$boolean_all = true ;
|
||||
foreach ( $array['related_staffs'] as $k => $v ){
|
||||
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
|
||||
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND created_at LIKE '%".date( 'Y-m-d', time() )."%'" ) ;
|
||||
if ( $select_total->num_rows >= $adjustment_times ){
|
||||
$boolean_all = false ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $boolean_all ){
|
||||
$is_allow = true ;
|
||||
}
|
||||
|
||||
break ;
|
||||
case '2daily' :
|
||||
|
||||
$boolean_all = true ;
|
||||
foreach ( $array['related_staffs'] as $k => $v ){
|
||||
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
|
||||
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND ( created_at LIKE '%".date( 'Y-m-d', strtotime( "-1 days" ) )."%' OR created_at LIKE '%".date( 'Y-m-d', time() )."%' )" ) ;
|
||||
if ( $select_total->num_rows >= $adjustment_times ){
|
||||
$boolean_all = false ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $boolean_all ){
|
||||
$is_allow = true ;
|
||||
}
|
||||
|
||||
break ;
|
||||
case 'weekly' :
|
||||
|
||||
$boolean_all = true ;
|
||||
foreach ( $array['related_staffs'] as $k => $v ){
|
||||
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
|
||||
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND created_at BETWEEN '".date( 'Y-m-d', strtotime('monday this week') )." 00:00:00' AND '".date( 'Y-m-d', strtotime('sunday this week') )." 23:59:59'" ) ;
|
||||
if ( $select_total->num_rows >= $adjustment_times ){
|
||||
$boolean_all = false ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $boolean_all ){
|
||||
$is_allow = true ;
|
||||
}
|
||||
|
||||
break ;
|
||||
case 'monthly' :
|
||||
|
||||
$boolean_all = true ;
|
||||
foreach ( $array['related_staffs'] as $k => $v ){
|
||||
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
|
||||
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND ( created_at LIKE '%".date( 'Y-m', time() )."%' )" ) ;
|
||||
if ( $select_total->num_rows >= $adjustment_times ){
|
||||
$boolean_all = false ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $boolean_all ){
|
||||
$is_allow = true ;
|
||||
}
|
||||
|
||||
break ;
|
||||
case 'quaterly' :
|
||||
|
||||
$array_quarter = [
|
||||
'1' => [ '01', '02', '03' ],
|
||||
'2' => [ '04', '05', '06' ],
|
||||
'3' => [ '07', '08', '09' ],
|
||||
'4' => [ '10', '11', '12' ],
|
||||
] ;
|
||||
$current_month = date( "m", time() ) ;
|
||||
$current_quarter = ceil( $current_month / 3 ) ;
|
||||
$get_quarter = $array_quarter[$current_quarter] ;
|
||||
|
||||
$boolean_all = true ;
|
||||
foreach ( $array['related_staffs'] as $k => $v ){
|
||||
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
|
||||
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND ( created_at LIKE '%".date( 'Y-', time() ).$array_quarter[0]."%' OR created_at LIKE '%".date( 'Y-', time() ).$array_quarter[1]."%' OR created_at LIKE '%".date( 'Y-', time() ).$array_quarter[2]."%' )" ) ;
|
||||
if ( $select_total->num_rows >= $adjustment_times ){
|
||||
$boolean_all = false ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $boolean_all ){
|
||||
$is_allow = true ;
|
||||
}
|
||||
break ;
|
||||
case 'annually' :
|
||||
|
||||
$boolean_all = true ;
|
||||
foreach ( $array['related_staffs'] as $k => $v ){
|
||||
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
|
||||
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND ( created_at LIKE '%".date( 'Y-', time() )."%' )" ) ;
|
||||
if ( $select_total->num_rows >= $adjustment_times ){
|
||||
$boolean_all = false ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $boolean_all ){
|
||||
$is_allow = true ;
|
||||
}
|
||||
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( $is_allow ){
|
||||
|
||||
if ( $mysqli->query( "INSERT INTO staff_adjustment
|
||||
( `adjustment_type`, `created_branch_id`, `created_by`, `department_id`, `setting_adjustment_id`, `point`, `remark` ) VALUES
|
||||
( '".$array['adjustment_type']."', '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['department_id']."', '".$array['setting_adjustment_id']."', '".$point."', '".$array['remark']."' )" ) ){
|
||||
$status = '200' ;
|
||||
|
||||
|
||||
$adjustment_id = $mysqli->insert_id ;
|
||||
$adjustment_so = 'AD'.strPad( 6, $adjustment_id ) ;
|
||||
$mysqli->query( "UPDATE staff_adjustment SET adjustment_so = '".$adjustment_so."' WHERE adjustment_id = '".$adjustment_id."'" ) ;
|
||||
|
||||
// set point movement
|
||||
// $remark = $staff_info['staff_shortname'].' ('.$staff_info['staff_idno'].') '.( $point > 0 ? 'give' : 'deduct' ).' the point ('.$row_adjustment['title'].') from adjustment ( ' . $adjustment_so . ' )' ;
|
||||
$remark = 'You have been '.( $point > 0 ? 'given' : 'deducted' ).' the point ('.$row_adjustment['title'].') from adjustment (' . $adjustment_so . ')' ;
|
||||
|
||||
foreach ( $array['related_staffs'] as $k => $v ){
|
||||
$mysqli->query( "INSERT INTO staff_adjustment_point ( `adjustment_id`, `setting_adjustment_id`, `staff_id`, `point` ) VALUES ( '".$adjustment_id."', '".$array['setting_adjustment_id']."', '".$v['id']."', '".$point."' )" ) ;
|
||||
|
||||
pointMovement( 'adjustment', $adjustment_id, $array['adjustment_type'], 'normal', $v['id'], $point, $remark ) ;
|
||||
pushToUserCron( 'staff_adjustment', $adjustment_id, $v['id'], 'Point Adjustment', $remark ) ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
Reference in New Issue
Block a user