first commit

This commit is contained in:
LAPTOP-V9RRD1TL\Michelle's Computer
2025-07-21 21:38:17 +08:00
commit f8f8fcaf96
2529 changed files with 227800 additions and 0 deletions
+150
View File
@@ -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' ) ;
?>
+61
View File
@@ -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' ) ;
?>
+172
View File
@@ -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' ) ;
?>
+72
View File
@@ -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' ) ;
?>
+199
View File
@@ -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' ) ;
?>
+44
View File
@@ -0,0 +1,44 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '312' ;
if ( $array['is_tick'] == 'yes' ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND announcement_id = '".$array['id']."'" ;
$query = "SELECT announcement_id FROM announcement
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$mysqli->query( "INSERT INTO staff_announcement
( announcement_id, staff_id ) VALUES
( '".$array['id']."', '".$staff_info['staff_id']."' ) " ) ;
// update inbox as read
$select_inbox = $mysqli->query( "SELECT a.view_id FROM staff_inbox_view a
LEFT JOIN inbox b ON ( a.inbox_id = b.inbox_id )
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.is_read = '0' AND b.deleted_at IS NULL AND b.from_table = 'announcement' AND b.from_id = '".$array['id']."'" ) ;
if ( $select_inbox->num_rows > 0 ){
while ( $row_inbox = $select_inbox->fetch_assoc() ){
$mysqli->query( "UPDATE staff_inbox_view SET
is_read = '1'
WHERE view_id = '".$row_inbox['view_id']."'" ) ;
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+70
View File
@@ -0,0 +1,70 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'MPDF/mpdf.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$id = $array['id'] ;
$search_query = '' ;
$search_query .= " AND a.announcement_id = '".$id."'" ;
$query = "SELECT a.announcement_id, a.file, a.is_showagree, a.created_at, b.title, b.content FROM announcement a
LEFT JOIN announcement_translation b ON ( a.announcement_id = b.announcement_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$content = dataFilter( $row['content'] ) ;
$file = ( $row['file'] != '' ? PATH.'uploads/Announcement/b/'.$row['file'] : '' ) ;
// check if agree or not
$is_agreed = 'no' ;
$select_agree = $mysqli->query( "SELECT * FROM staff_announcement
WHERE deleted_at IS NULL AND announcement_id = '".$array['id']."' AND staff_id = '".$staff_info['staff_id']."' LIMIT 1" ) ;
if ( $select_agree->num_rows > 0 ){
$is_agreed = 'yes' ;
}
$filename = 'pdfs/announcement-'.strPad( 3, $id ).'.pdf' ;
$filename_save = $require_path . $filename ;
$filename_source = PATH . $filename ;
$header = '' ;
$footer = '' ;
$html = mergeImageWithContent( $file, $content ) ;
$mpdf = new mPDF( 'utf-8', 'A4', '', 'freesans', 15, 15, 15, 15, 5, 5 ) ;
$mpdf->mirrorMargins = 1 ;
$mpdf->useAdobeCJK = true ;
$mpdf->SetHTMLHeader( $header ) ;
$mpdf->SetHTMLHeader( $header,'E' ) ;
$mpdf->SetHTMLFooter( $footer ) ;
$mpdf->SetHTMLFooter( $footer,'E' ) ;
$mpdf->WriteHTML( $html ) ;
$mpdf->Output( $filename_save, 'F' ) ;
$row['id'] = dataFilter( $row['announcement_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = $content ;
$row['file'] = $file ;
$row['created_at'] = dataFilter( $row['created_at'] ) ;
$row['is_agreed'] = $is_agreed ;
$row['source'] = $filename_source ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.announcement_id, a.is_hide, a.file, a.created_at, b.title FROM announcement a
LEFT JOIN announcement_translation b ON ( a.announcement_id = b.announcement_id )
WHERE a.deleted_at IS NULL AND a.status = 'active' AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['announcement_id'] ) ;
$row['title'] = ( $row['is_hide'] == 'no' ? dataFilter( $row['title'] ) : '' ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Announcement/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,42 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$join_filter = '' ;
$join_query = '' ;
$query_sortable = 'ORDER BY a.sortable ASC, a.created_at DESC' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.category_id, a.file, b.title FROM association_category a
LEFT JOIN association_category_translation b ON ( a.category_id = b.category_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' AND a.status = 'active' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ".$query_sortable." LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/AssociationCategory/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+46
View File
@@ -0,0 +1,46 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND association_id = '".$array['id']."'" ;
$query = "SELECT association_id, association_type, date_start, date_end, file, status, created_at FROM association
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '248' ;
$row = $mysqli_query->fetch_assoc() ;
$is_association = 'no' ;
if ( $row['status'] == 'active' ){
if ( $row['association_type'] == 'all' || ( $row['association_type'] == 'date' && $row['date_start'] <= TODAYDAY && $row['date_end'] >= TODAYDAY ) ){
$is_association = 'yes' ;
}
}
if ( $is_association == 'yes' ){
$status = '200' ;
$mysqli->query( "INSERT INTO staff_association
( association_id, branch_id, staff_id, status ) VALUES
( '".$array['id']."', '".$array['branch_id']."', '".$staff_info['staff_id']."', 'pending' ) " ) ;
$view_id = $mysqli->insert_id ;
$association_so = 'AS'.strPad( 6, $view_id ) ;
$mysqli->query( "UPDATE staff_association SET association_so = '".$association_so."' WHERE view_id = '".$view_id."'" ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+60
View File
@@ -0,0 +1,60 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.association_id = '".$array['id']."'" ;
$join_filter = "" ;
$join_query = "" ;
if ( $array['mode'] == 'view' ){
$join_filter .= ", c.association_so, c.status as association_status, c.remark as association_remark, c.rated as association_rated, c.comment as association_comment" ;
$join_query .= " LEFT JOIN staff_association c ON ( a.association_id = c.association_id )" ;
$search_query .= " AND c.view_id = '".$array['view_id']."' AND c.staff_id = '".$staff_info['staff_id']."'" ;
}
$query = "SELECT a.association_id, a.association_type, a.date_start, a.date_end, a.file, a.status, a.created_at, b.title, b.content ".$join_filter." FROM association a
LEFT JOIN association_translation b ON ( a.association_id = b.association_id )
".$join_query."
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$generatecode = generateQrcode( '', $row['association_so'], $row['association_so'] ) ;
$row = $mysqli_query->fetch_assoc() ;
$row['id'] = dataFilter( $row['association_id'] ) ;
$row['sonumber'] = dataFilter( $row['association_so'] ) ;
$row['qrcode'] = $generatecode['url'] ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Association/b/'.$row['file'] : '' ) ;
$is_association = 'no' ;
if ( $row['status'] == 'active' ){
if ( $row['association_type'] == 'all' || ( $row['association_type'] == 'date' && $row['date_start'] <= TODAYDAY && $row['date_end'] >= TODAYDAY ) ){
$is_association = 'yes' ;
}
}
$row['is_association'] = $is_association ;
$row['date_start'] = resetDateFormat( $row['date_start'] ) ;
$row['date_end'] = resetDateFormat( $row['date_end'] ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$row['association_status'] = ( checkExists( $row['association_status'] ) != '' ? $row['association_status'] : '') ;
$row['association_remark'] = dataFilter( checkExists( $row['association_remark'] ) != '' ? $row['association_remark'] : '') ;
$row['association_rated'] = dataFilter( checkExists( $row['association_rated'] ) != '' ? $row['association_rated'] : 0) ;
$row['association_comment'] = dataFilter( checkExists( $row['association_comment'] ) != '' ? $row['association_comment'] : '') ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,35 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$join_filter = '' ;
$join_query = '' ;
$query = "SELECT a.category_id, b.title FROM association_gallery_category a
LEFT JOIN association_gallery_category_translation b ON ( a.category_id = b.category_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' AND a.status = 'active'" ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['category_id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,46 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$join_filter = '' ;
$join_query = '' ;
$query_sortable = 'ORDER BY created_at DESC' ;
$search_query = '' ;
switch ( $array['filter'] ){
case 'myself' :
$search_query .= " AND staff_id = '".$staff_info['staff_id']."'" ;
break ;
case 'group' :
$search_query .= " AND branch_id = '".$array['branch_id']."' AND status = 'confirmed' AND category_id = '".$array['category_id']."'" ;
break ;
}
$query = "SELECT title, file, filetype, status, created_at FROM association_gallery
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ".$query_sortable." LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['date'] = resetDateFormat( $row['created_at'] ) ;
$row['time'] = resetTimeFormat( $row['created_at'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/AssociationGallery/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,35 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$title = $array['title'] ;
$photos = $array['photos'] ;
if ( $title != '' && $array['photos'] != '' && count( $photos ) > 0 ){
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'AssociationGallery', time(), $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO association_gallery
( branch_id, staff_id, title, file, filetype ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$title."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$is_going = $array['is_going'] ;
$update_status = ( $is_going == 'yes' ? 'confirmed' : 'cancelled' ) ;
if ( $array['id'] != '' && $array['view_id'] != '' && $is_going != '' ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND association_id = '".$array['id']."'" ;
$query = "SELECT association_id, association_type, date_start, date_end, file, status, created_at FROM association
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$mysqli->query( "UPDATE staff_association SET
is_going = '".$array['is_going']."',
status = '".$update_status."'
WHERE view_id = '".$array['view_id']."'" ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+70
View File
@@ -0,0 +1,70 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$searchfilter = $array['searchfilter'] ;
$searchfilter = ( $searchfilter != '' ? $searchfilter : 'current' ) ;
$join_filter = '' ;
$join_query = '' ;
$query_sortable = 'ORDER BY a.sortable ASC, a.created_at DESC' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
if ( $array['category_id'] != '' ){
$search_query .= " AND a.category_id = '".$array['category_id']."'" ;
}
if ( $searchfilter != '' ){
switch ( $searchfilter ){
case 'current' :
$search_query .= " AND a.branch LIKE '%/".$array['branch_id']."/%' AND a.status = 'active' AND ( ( a.association_type = 'all' ) OR ( a.association_type = 'date' AND a.date_start <= '".TODAYDAY."' AND a.date_end >= '".TODAYDAY."' ) )" ;
break ;
case 'previous' :
$join_filter = ", c.view_id, c.status as association_status" ;
$join_query = "LEFT JOIN staff_association c ON ( a.association_id = c.association_id )" ;
$search_query .= " AND c.branch_id = '".$array['branch_id']."' AND c.staff_id = '".$staff_info['staff_id']."'" ;
$query_sortable = "ORDER BY view_id DESC" ;
break ;
case 'expired' :
$search_query .= " AND a.branch LIKE '%/".$array['branch_id']."/%' AND ( a.status = 'inactive' OR ( a.association_type = 'date' AND a.date_start <= '".TODAYDAY."' AND NOT ( a.date_end >= '".TODAYDAY."' ) ) )" ;
break ;
}
}
$query = "SELECT a.association_id, a.association_type, a.date_start, a.date_end, a.file, a.created_at, b.title ".$join_filter." FROM association a
LEFT JOIN association_translation b ON ( a.association_id = b.association_id )
".$join_query."
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ".$query_sortable." LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['association_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['date_start'] = resetDateFormat( $row['date_start'] ) ;
$row['date_end'] = resetDateFormat( $row['date_end'] ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$row['association_status'] = ( checkExists( $row['association_status'] ) != '' ? $row['association_status'] : '' ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Association/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
if ( $array['id'] != '' && $array['view_id'] != '' && $array['association_rated'] != '' && $array['association_comment'] != '' ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND association_id = '".$array['id']."'" ;
$query = "SELECT association_id, association_type, date_start, date_end, file, status, created_at FROM association
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$mysqli->query( "UPDATE staff_association SET
rated = '".$array['association_rated']."',
comment = '".$array['association_comment']."',
status = 'rated'
WHERE view_id = '".$array['view_id']."'" ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+42
View File
@@ -0,0 +1,42 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND catalog_id = '".$array['id']."'" ;
$query = "SELECT catalog_id, title, content, view_format, file, file_type, video_url, created_at FROM catalog
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$file = '' ;
if ( $row['file'] != '' ){
if ( $row['file_type'] == 'pdf' ){
$file = PATH.'uploads/Catalog/'.$row['file'] ;
}else{
$file = PATH.'uploads/Catalog/b/'.$row['file'] ;
}
}
$row['id'] = dataFilter( $row['catalog_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['file'] = $file ;
$row['created_at'] = dataFilter( $row['created_at'] ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+41
View File
@@ -0,0 +1,41 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['category_id'] != '' ){
$search_query .= " AND category_id = '".$array['category_id']."'" ;
}
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT catalog_id, title, created_at FROM catalog
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY sortable ASC, created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['catalog_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Catalog/b/'.$row['file'] : '' ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+37
View File
@@ -0,0 +1,37 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT category_id, title, file, created_at FROM catalog_category
WHERE deleted_at IS NULL AND category_type = 'main' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY sortable ASC, created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/CatalogCategory/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+37
View File
@@ -0,0 +1,37 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT category_id, title, file, created_at FROM catalog_category
WHERE deleted_at IS NULL AND category_type = 'sub' AND category_parent = '".$array['category_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY sortable ASC, created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/CatalogCategory/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+83
View File
@@ -0,0 +1,83 @@
<?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'] ;
}
}
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT formheadcount_id, staff_id, title, content, status, created_at FROM formheadcount
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$staff_list = [] ;
$formheadcount_id = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['formheadcount_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['departments'] = '' ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
$staff_list[$row['staff_id']] = $row['staff_id'] ;
$formheadcount_id[$row['formheadcount_id']] = $row['formheadcount_id'] ;
}
// select related formheadcount media
$media_list = [] ;
$select_media = $mysqli->query( "SELECT formheadcount_id, file FROM formheadcount_media a
WHERE a.deleted_at IS NULL AND formheadcount_id IN ( ".implode( ',', $formheadcount_id )." ) AND filetype IN ( 'jpg', 'png', 'gif' )" ) ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
$media_list[$row_media['formheadcount_id']][] = ( $row_media['file'] != '' ? PATH.'uploads/FormHeadCount/b/'.$row_media['file'] : '' ) ;
}
}
// select all staff related deparment
$related_list = [] ;
$select_related = $mysqli->query( "SELECT a.staff_id, a.department_id FROM staff_department a
WHERE a.deleted_at IS NULL AND a.staff_id IN ( ".implode( ',', $staff_list )." )" ) ;
if ( $select_related->num_rows > 0 ){
while ( $row_related = $select_related->fetch_assoc() ){
if ( checkExists( $department_list[$row_related['department_id']] ) ){
$related_list[$row_related['staff_id']][] = $department_list[$row_related['department_id']] ;
}
}
}
foreach ( $list as $k => $v ){
$list[$k]['departments'] = ( checkExists( $related_list[$v['staff_id']] ) ? implode( ', ', $related_list[$v['staff_id']] ) : '' ) ;
$list[$k]['files'] = ( checkExists( $media_list[$v['formheadcount_id']] ) ? $media_list[$v['formheadcount_id']] : [] ) ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+68
View File
@@ -0,0 +1,68 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND formheadcount_id = '".$array['formheadcount_id']."'" ;
$query = "SELECT formheadcount_id, title, content, remark, comment, status, created_at, updated_at FROM formheadcount
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$row = $mysqli_query->fetch_assoc() ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['remark'] = dataFilter( $row['remark'] ) ;
$row['comment'] = dataFilter( $row['comment'] ) ;
// get all media
$select_media = $mysqli->query( "SELECT media_id, file, filetype FROM formheadcount_media
WHERE deleted_at IS NULL AND formheadcount_id = '".$array['formheadcount_id']."'" ) ;
$photos = [] ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
switch ( $row_media['filetype'] ){
case 'jpg' :
case 'jpeg' :
case 'png' :
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/FormHeadCount/b/'.$row_media['file'] : '' )
] ;
break ;
default :
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/FormHeadCount/'.$row_media['file'] : '' )
] ;
}
}
}
$row['photos'] = $photos ;
$data = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+50
View File
@@ -0,0 +1,50 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$formheadcount_id = $array['formheadcount_id'] ;
$photos = $array['photos'] ;
if ( $array['title'] != '' && $array['content'] != '' && $array['photos'] != '' && count( $photos ) > 0 ){
$status = '203' ;
if ( $mysqli->query( "INSERT INTO formheadcount
( `branch_id`, `staff_id`, `title`, `content`, `remark`, `status` ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['title']."', '".$array['content']."', '".$array['remark']."', 'pending' )" ) ){
$status = '200' ;
$boolean_submit = true ;
$formheadcount_id = $mysqli->insert_id ;
$formheadcount_so = 'FH'.strPad( 6, $formheadcount_id ) ;
$mysqli->query( "UPDATE formheadcount SET
formheadcount_so = '".$formheadcount_so."'
WHERE formheadcount_id = '".$formheadcount_id."'" ) ;
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'FormHeadCount', $formheadcount_id.'-'.$formheadcount_id, $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO formheadcount_media
( formheadcount_id, file, filetype ) VALUES
( '".$formheadcount_id."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,78 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '200' ;
// select all
$staffs = [] ;
$question_list = [] ;
$form_list = [] ;
$all_tier = getAllTier( $array['lang'] ) ;
// select all staff
$select = $mysqli->query( "SELECT a.staff_id, a.staff_idno, a.staff_name, a.staff_shortname, a.staff_tier FROM staff a
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' 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() ){
$get_staff_tier = $all_tier[$row['staff_tier']] ;
$staffs[] = [
'id' => $row['staff_id'],
'title' => $row['staff_shortname'] . ' ('.$row['staff_idno'].' / '.strtoupper( $get_staff_tier['title'] ).')',
'name' => $row['staff_name'],
'tier' => $get_staff_tier['level']
] ;
}
}
$where_question = '' ;
if ( $array['submission_type'] != '' ){
$where_question .= " AND a.nomination_type = '".$array['submission_type']."'" ;
}
// question & form
$select_question = $mysqli->query( "SELECT a.question_id, a.question_type, b.title, b.content, b.questions FROM formnomination_question a
LEFT JOIN formnomination_question_translation b ON ( a.question_id = b.question_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' ".$where_question." ORDER BY a.sortable" ) ;
if ( $select_question->num_rows > 0 ){
while ( $row_question = $select_question->fetch_assoc() ){
if ( $row_question['question_type'] == 'question' ){
$temp = $row_question ;
$temp['title'] = dataFilter( $temp['title'] ) ;
$temp['content'] = dataFilter( $temp['content'] ) ;
$temp['questions'] = ( $temp['questions'] != '' ? explode( '|', $temp['questions'] ) : [] ) ;
$question_list[] = $temp ;
}
if ( $row_question['question_type'] == 'form' ){
$temp = $row_question ;
$temp['title'] = dataFilter( $temp['title'] ) ;
$temp['content'] = dataFilter( $temp['content'] ) ;
$temp['questions'] = ( $temp['questions'] != '' ? explode( '|', $temp['questions'] ) : [] ) ;
$form_list[] = $temp ;
}
}
}
$data = [
'staffs' => $staffs,
'questions' => $question_list,
'forms' => $form_list
] ;
}
require( $require_sub.'footer.php' ) ;
?>
+89
View File
@@ -0,0 +1,89 @@
<?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'] ;
}
}
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.staff_name LIKE '%".$array['search']."%'" ;
}
if ( $array['submission_type'] != '' ){
$search_query .= " AND a.formnomination_type = '".$array['submission_type']."'" ;
}
$query = "SELECT a.formnomination_id, a.staff_id, a.nominee_staff_id, a.status, a.created_at FROM formnomination a
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' AND a.staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$nominee_staff_list = [] ;
$formnomination_id = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['formnomination_id'] ) ;
$row['nominee_name'] = '' ;
$row['nominee_departments'] = '' ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
$nominee_staff_list[$row['nominee_staff_id']] = $row['nominee_staff_id'] ;
}
// select all staff
$related_staff_list = [] ;
$select_related_staff = $mysqli->query( "SELECT a.staff_id, a.staff_name FROM staff a
WHERE a.deleted_at IS NULL AND a.staff_id IN ( ".implode( ',', $nominee_staff_list )." )" ) ;
if ( $select_related_staff->num_rows > 0 ){
while ( $row_related_staff = $select_related_staff->fetch_assoc() ){
$related_staff_list[$row_related_staff['staff_id']] = [
'staff_name' => $row_related_staff['staff_name']
] ;
}
}
// select all staff related deparment
$related_list = [] ;
$select_related = $mysqli->query( "SELECT a.staff_id, a.department_id FROM staff_department a
WHERE a.deleted_at IS NULL AND a.staff_id IN ( ".implode( ',', $nominee_staff_list )." )" ) ;
if ( $select_related->num_rows > 0 ){
while ( $row_related = $select_related->fetch_assoc() ){
if ( checkExists( $department_list[$row_related['department_id']] ) ){
$related_list[$row_related['staff_id']][] = $department_list[$row_related['department_id']] ;
}
}
}
foreach ( $list as $k => $v ){
$selected_staff = ( checkExists( $related_staff_list[$v['nominee_staff_id']] ) ? $related_staff_list[$v['nominee_staff_id']] : [] ) ;
$list[$k]['nominee_name'] = ( checkExists( $selected_staff['staff_name'] ) ? checkExists( $selected_staff['staff_name'] ) : 'Unknown' ) ;
$list[$k]['nominee_departments'] = ( checkExists( $related_list[$v['nominee_staff_id']] ) ? implode( ', ', $related_list[$v['nominee_staff_id']] ) : '' ) ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+65
View File
@@ -0,0 +1,65 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND formnomination_id = '".$array['formnomination_id']."'" ;
$query = "SELECT formnomination_id, nominee_staff_id, comment, status, created_at, updated_at FROM formnomination
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$row = $mysqli_query->fetch_assoc() ;
$row['comment'] = dataFilter( $row['comment'] ) ;
// select all staff
$nominee_to_name = '' ;
$select_related_staff = $mysqli->query( "SELECT a.staff_id, a.staff_name FROM staff a
WHERE a.deleted_at IS NULL AND a.staff_id = '".$row['nominee_staff_id']."' LIMIT 1" ) ;
if ( $select_related_staff->num_rows > 0 ){
$row_related_staff = $select_related_staff->fetch_assoc() ;
$nominee_to_name = $row_related_staff['staff_name'] ;
}
$row['nominee_to_name'] = $nominee_to_name ;
// select all answer
$question_list = [] ;
$form_list = [] ;
$select_answer = $mysqli->query( "SELECT a.question_type, a.checkbox, a.chosen, a.remark, c.title, c.content FROM formnomination_answer a
LEFT JOIN formnomination_question b ON ( a.question_id = b.question_id )
LEFT JOIN formnomination_question_translation c ON ( b.question_id = c.question_id )
WHERE a.formnomination_id = '".$row['formnomination_id']."' AND c.lang = '".$array['lang']."' ORDER BY b.sortable" ) ;
if ( $select_answer->num_rows > 0 ){
while ( $row_answer = $select_answer->fetch_assoc() ){
if ( $row_answer['question_type'] == 'question' ){
$question_list[] = $row_answer ;
}
if ( $row_answer['question_type'] == 'form' ){
$form_list[] = $row_answer ;
}
}
}
$row['questions'] = $question_list ;
$row['forms'] = $form_list ;
$data = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,85 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$nominee_to = $array['nominee_to'] ;
$formnomination_id = $array['formnomination_id'] ;
$forms = $array['forms'] ;
if ( $nominee_to != '' && $formnomination_id != '' && count($forms) > 0 ){
$status = '201' ;
$where_question = '' ;
if ( $array['submission_type'] != '' ){
$where_question .= " AND a.nomination_type = '".$array['submission_type']."'" ;
}
$select_formnomination = $mysqli->query( "SELECT * FROM formnomination
WHERE deleted_at IS NULL AND formnomination_id = '".$formnomination_id."' AND status = 'pending' LIMIT 1" ) ;
if ( $select_formnomination->num_rows > 0 ){
$status = '314' ;
$row_formnomination = $select_formnomination->fetch_assoc() ;
$form_list = [] ;
$select_form = $mysqli->query( "SELECT a.question_id FROM formnomination_question a
WHERE a.deleted_at IS NULL AND a.question_type = 'form'" . $where_question ) ;
$total_form = $select_form->num_rows ;
$total_remark = 0 ;
foreach ( $forms as $kform => $vform ){
if ( $vform['remark'] != '' ){
$total_remark++ ;
}
}
if ( count($forms) == $total_form && $total_form == $total_remark ){
$status = '200' ;
$mysqli->query( "UPDATE formnomination SET
nominee_staff_id = '".$nominee_to."',
status = 'approved'
WHERE formnomination_id = '".$formnomination_id."'" ) ;
foreach ( $forms as $kform => $vform ){
$mysqli->query( "INSERT INTO formnomination_answer
( formnomination_id, question_id, question_type, checkbox, chosen, remark ) VALUES
( '".$formnomination_id."', '".$vform['id']."', 'form', '".$vform['checkbox']."', '".$vform['radio']."', '".$vform['remark']."' )" ) ;
}
$mailer = new Mailer() ;
$mailer->from = EMAILNOREPLY ;
$select_staff = $mysqli->query( "SELECT a.staff_id, a.staff_name, a.staff_email FROM staff a
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' 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 ) AND a.staff_settings LIKE '%\"ishrmanager\":\"yes\"%'" ) ;
if ( $select_staff->num_rows > 0 ){
while ( $row_staff = $select_staff->fetch_assoc() ){
pushToUserCron( 'formnomination', $array['formnomination_id'], $row_staff['staff_id'], 'Nomination', 'Nomination '.$row_formnomination['formnomination_so'].' need you to review' ) ;
if ( $row_staff['staff_email'] != '' ){
$mailer->to = [ $row_staff['staff_email'] ] ;
// $mailer->cc = $EMAILCC ;
$mailer->subject = 'Reminder for Nomination' ;
$mailer->body = 'Dear HR Manager, '.dataFilter($staff_info['staff_name']).' has submitted an nomination request. Please log in to review.
<br /><br />
* This is an auto-generated message, please do not reply.' ;
$mailer->send() ;
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,81 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$questions = $array['questions'] ;
if ( count($questions) > 0 ){
$status = '314' ;
$where_question = '' ;
if ( $array['submission_type'] != '' ){
$where_question .= " AND a.nomination_type = '".$array['submission_type']."'" ;
}
$question_list = [] ;
$select_question = $mysqli->query( "SELECT a.question_id FROM formnomination_question a
WHERE a.deleted_at IS NULL AND a.question_type = 'question'" . $where_question ) ;
$total_question = $select_question->num_rows ;
$point_peryes = ( 100 / $total_question ) ;
$point_questionyes = 0 ;
$total_yesno = 0 ;
foreach ( $questions as $kquestion => $vquestion ){
if ( $vquestion['checkbox'] == 'yes' ){
$point_questionyes += $point_peryes ;
}
if ( $vquestion['checkbox'] != '' ){
$total_yesno++ ;
}
}
if ( count($questions) == $total_question && $total_yesno == $total_question ){
$status = '99' ;
$update_status = 'cancelled' ;
if ( $point_questionyes >= NOMINATIONPOINT ){
$status = '98' ;
$update_status = 'pending' ;
}
if ( $mysqli->query( "INSERT INTO formnomination
( `formnomination_type`, `branch_id`, `staff_id`, `status` ) VALUES
( '".$array['submission_type']."', '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$update_status."' )" ) ){
$boolean_submit = true ;
$formnomination_id = $mysqli->insert_id ;
$formnomination_so = 'FN'.strPad( 6, $formnomination_id ) ;
$mysqli->query( "UPDATE formnomination SET
formnomination_so = '".$formnomination_so."'
WHERE formnomination_id = '".$formnomination_id."'" ) ;
foreach ( $questions as $kquestion => $vquestion ){
$mysqli->query( "INSERT INTO formnomination_answer
( formnomination_id, question_id, question_type, checkbox, chosen, remark ) VALUES
( '".$formnomination_id."', '".$vquestion['id']."', 'question', '".$vquestion['checkbox']."', '".$vquestion['radio']."', '".$vquestion['remark']."' )" ) ;
}
$data = [
'formnomination_id' => $formnomination_id,
'update_status' => $update_status
] ;
}else{
$status = '203' ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,36 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '200' ;
$staffs = [] ;
$all_tier = getAllTier( $array['lang'] ) ;
// select all staff
$select = $mysqli->query( "SELECT a.staff_id, a.staff_idno, a.staff_name, a.staff_shortname, a.staff_tier FROM staff a
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' 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 ) AND a.staff_settings LIKE '%\"ismanager\":\"yes\"%'" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$get_staff_tier = $all_tier[$row['staff_tier']] ;
$staffs[] = [
'id' => $row['staff_id'],
'title' => dataFilter( $row['staff_shortname'] ) . ' ('.$row['staff_idno'].' / '.strtoupper( $get_staff_tier['title'] ).')',
'name' => dataFilter( $row['staff_name'] ),
'tier' => $get_staff_tier['level']
] ;
}
}
$data = [
'staffs' => $staffs
] ;
}
require( $require_sub.'footer.php' ) ;
?>
+84
View File
@@ -0,0 +1,84 @@
<?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'] ;
}
}
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT formresignation_id, staff_id, title, content, status_manager, status_hr, created_at FROM formresignation
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$staff_list = [] ;
$formresignation_id = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['formresignation_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['departments'] = '' ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
$staff_list[$row['staff_id']] = $row['staff_id'] ;
$formresignation_id[$row['formresignation_id']] = $row['formresignation_id'] ;
}
// select related formresignation media
$media_list = [] ;
$select_media = $mysqli->query( "SELECT formresignation_id, file FROM formresignation_media a
WHERE a.deleted_at IS NULL AND formresignation_id IN ( ".implode( ',', $formresignation_id )." ) AND filetype IN ( 'jpg', 'png', 'gif' )" ) ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
$media_list[$row_media['formresignation_id']][] = ( $row_media['file'] != '' ? PATH.'uploads/FormResignation/b/'.$row_media['file'] : '' ) ;
}
}
// select all staff related deparment
$related_list = [] ;
$select_related = $mysqli->query( "SELECT a.staff_id, a.department_id FROM staff_department a
WHERE a.deleted_at IS NULL AND a.staff_id IN ( ".implode( ',', $staff_list )." )" ) ;
if ( $select_related->num_rows > 0 ){
while ( $row_related = $select_related->fetch_assoc() ){
if ( checkExists( $department_list[$row_related['department_id']] ) ){
$related_list[$row_related['staff_id']][] = $department_list[$row_related['department_id']] ;
}
}
}
foreach ( $list as $k => $v ){
$list[$k]['departments'] = ( checkExists( $related_list[$v['staff_id']] ) ? implode( ', ', $related_list[$v['staff_id']] ) : '' ) ;
$list[$k]['files'] = ( checkExists( $media_list[$v['formresignation_id']] ) ? $media_list[$v['formresignation_id']] : [] ) ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+113
View File
@@ -0,0 +1,113 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$all_tier = getAllTier( $array['lang'] ) ;
$staff_settings = $staff_info['staff_settings'] ;
$search_query = '' ;
$search_query .= " AND formresignation_id = '".$array['formresignation_id']."'" ;
$query = "SELECT formresignation_id, title, content, staff_id_manager, comment_manager, comment_hr, status_manager, staff_id_hr, status_hr, created_at, updated_at FROM formresignation
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$row = $mysqli_query->fetch_assoc() ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$manager_name = '' ;
$hr_name = '' ;
// select manager / hr manager
$staff_ids = [ $row['staff_id_manager'] ] ;
if ( $row['staff_id_hr'] > 0 ){
$staff_ids[] = $row['staff_id_hr'] ;
}
$select_staff = $mysqli->query( "SELECT staff_id, staff_idno, staff_name, staff_shortname, staff_tier FROM staff
WHERE staff_id IN ( ".implode(',', $staff_ids)." ) LIMIT 2" ) ;
if ( $select_staff->num_rows > 0 ){
while ( $row_staff = $select_staff->fetch_assoc() ){
$get_staff_tier = $all_tier[$row_staff['staff_tier']] ;
if ( $row_staff['staff_id'] == $row['staff_id_manager'] ){
$manager_name = dataFilter( $row_staff['staff_shortname'] ) . ' ('.$row_staff['staff_idno'].' / '.strtoupper( $get_staff_tier['title'] ).')' ;
}
if ( $row_staff['staff_id'] == $row['staff_id_hr'] ){
$hr_name = dataFilter( $row_staff['staff_shortname'] ) . ' ('.$row_staff['staff_idno'].' / '.strtoupper( $get_staff_tier['title'] ).')' ;
}
}
}
$is_manager_update = 'no' ;
if ( $staff_settings['ismanager'] == 'yes' ){
if ( $row['status_manager'] == 'pending' && $row['status_hr'] == 'pending' ){
if ( $staff_info['staff_id'] == $row['staff_id_manager'] ){
$is_manager_update = 'yes' ;
}
}
}
$row['is_manager_update'] = $is_manager_update ;
$row['manager_name'] = $manager_name ;
$row['comment_manager'] = ( $row['comment_manager'] != '' ? '<pre>'.dataFilter( $row['comment_manager'] ).'</pre>': '' ) ;
$is_hr_update = 'no' ;
if ( $staff_settings['ishrmanager'] == 'yes' ){
if ( $row['status_manager'] == 'confirmed' && $row['status_hr'] == 'pending' ){
$is_hr_update = 'yes' ;
}
}
$row['is_hr_update'] = $is_hr_update ;
$row['hr_name'] = $hr_name ;
$row['comment_hr'] = ( $row['comment_hr'] != '' ? '<pre>'.dataFilter( $row['comment_hr'] ).'</pre>': '' ) ;
// get all media
$select_media = $mysqli->query( "SELECT media_id, file, filetype FROM formresignation_media
WHERE deleted_at IS NULL AND formresignation_id = '".$array['formresignation_id']."'" ) ;
$photos = [] ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
switch ( $row_media['filetype'] ){
case 'jpg' :
case 'jpeg' :
case 'png' :
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/FormResignation/b/'.$row_media['file'] : '' )
] ;
break ;
default :
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/FormResignation/'.$row_media['file'] : '' )
] ;
}
}
}
$row['photos'] = $photos ;
$data = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,53 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '303' ;
if ( $staff_info['staff_settings']['ishrmanager'] == 'yes' ){
$status = '300' ;
if ( $array['update_status'] != '' && $array['comment_hr'] != '' ){
$status = '201' ;
$query = "SELECT formresignation_id, formresignation_so, staff_id, title, content, staff_id_manager, comment_manager, comment_hr, status_manager, staff_id_hr, status_hr, created_at, updated_at FROM formresignation
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND formresignation_id = '".$array['formresignation_id']."' AND status_manager = 'confirmed' AND status_hr = 'pending'" ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$status = '308' ;
$update_status = ( $array['update_status'] == 'confirmed' ? 'confirmed' : 'rejected' ) ;
if ( $update_status != '' ){
$status = '200' ;
$mysqli->query( "UPDATE formresignation SET
staff_id_hr = '".$staff_info['staff_id']."',
status_hr = '".$update_status."',
comment_hr = '".$array['comment_hr']."',
date_hr = '".TODAYDATE."'
WHERE formresignation_id = '".$array['formresignation_id']."'" ) ;
if ( $update_status == 'confirmed' ){
pushToUserCron( 'formresignation', $array['formresignation_id'], $row['staff_id'], 'Resignation', 'Resignation is confirmed by your HR Manager' ) ;
}else{
pushToUserCron( 'formresignation', $array['formresignation_id'], $row['staff_id'], 'Resignation', 'Resignation is rejected by your HR Manager' ) ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,76 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '303' ;
if ( $staff_info['staff_settings']['ismanager'] == 'yes' ){
$status = '300' ;
if ( $array['update_status'] != '' && $array['comment_manager'] != '' ){
$status = '201' ;
$query = "SELECT formresignation_id, formresignation_so, staff_id, title, content, staff_id_manager, comment_manager, comment_hr, status_manager, staff_id_hr, status_hr, created_at, updated_at FROM formresignation
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND formresignation_id = '".$array['formresignation_id']."' AND staff_id_manager = '".$staff_info['staff_id']."' AND status_manager = 'pending' AND status_hr = 'pending'" ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$status = '308' ;
$update_status = ( $array['update_status'] == 'confirmed' ? 'confirmed' : 'rejected' ) ;
if ( $update_status != '' ){
$status = '200' ;
$mysqli->query( "UPDATE formresignation SET
status_manager = '".$update_status."',
comment_manager = '".$array['comment_manager']."',
date_manager = '".TODAYDATE."'
WHERE formresignation_id = '".$array['formresignation_id']."'" ) ;
// push notification to hr manager
$mailer = new Mailer() ;
$mailer->from = EMAILNOREPLY ;
if ( $update_status == 'confirmed' ){
$select_staff = $mysqli->query( "SELECT a.staff_id, a.staff_name, a.staff_email FROM staff a
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' 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 ) AND a.staff_settings LIKE '%\"ishrmanager\":\"yes\"%'" ) ;
if ( $select_staff->num_rows > 0 ){
while ( $row_staff = $select_staff->fetch_assoc() ){
pushToUserCron( 'formresignation', $array['formresignation_id'], $row_staff['staff_id'], 'Resignation', 'Resignation '.$row['formresignation_so'].' need your approval or rejection' ) ;
if ( $row_staff['staff_email'] != '' ){
$mailer->to = [ $row_staff['staff_email'] ] ;
$mailer->cc = $EMAILCC ;
$mailer->subject = 'Reminder for Resignation' ;
$mailer->body = 'Dear HR Manager, '.dataFilter($staff_info['staff_name']).' has submitted an resignation request. Please log in to review.
<br /><br />
* This is an auto-generated message, please do not reply.' ;
$mailer->send() ;
}
}
}
pushToUserCron( 'formresignation', $array['formresignation_id'], $row['staff_id'], 'Resignation', 'Resignation is confirmed by your Manager, we will send to HR Manager to do approval and rejection' ) ;
}else{
pushToUserCron( 'formresignation', $array['formresignation_id'], $row['staff_id'], 'Resignation', 'Resignation is rejected by your Manager' ) ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,53 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$formresignation_id = $array['formresignation_id'] ;
$photos = $array['photos'] ;
if ( $array['staff_id_manager'] != '' && $array['staff_id_manager'] > 0 && $array['title'] != '' && $array['content'] != '' && $array['photos'] != '' && count( $photos ) > 0 ){
$status = '203' ;
if ( $mysqli->query( "INSERT INTO formresignation
( `branch_id`, `staff_id`, `staff_id_manager`, `title`, `content`, `status_manager`, `status_hr` ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['staff_id_manager']."', '".$array['title']."', '".$array['content']."', 'pending', 'pending' )" ) ){
$status = '200' ;
$boolean_submit = true ;
$formresignation_id = $mysqli->insert_id ;
$formresignation_so = 'FR'.strPad( 6, $formresignation_id ) ;
$mysqli->query( "UPDATE formresignation SET
formresignation_so = '".$formresignation_so."'
WHERE formresignation_id = '".$formresignation_id."'" ) ;
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'FormResignation', $formresignation_id.'-'.$formresignation_id, $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO formresignation_media
( formresignation_id, file, filetype ) VALUES
( '".$formresignation_id."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
pushToUserCron( 'formresignation', $formresignation_id, $array['staff_id_manager'], 'Resignation', 'Resignation '.$formresignation_so.' need your approval or rejection' ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+42
View File
@@ -0,0 +1,42 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.form_id = '".$array['id']."'" ;
$query = "SELECT a.form_id, a.file, a.file_type, a.created_at, b.title FROM form a
LEFT JOIN form_translation b ON ( a.form_id = b.form_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND ( ( a.receiver_type IN ( '0' ) ) OR ( a.receiver_type IN ( '1', '2' ) AND a.staff_id LIKE '%/".$staff_info['staff_id']."/%' ) ) " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$file = '' ;
if ( $row['file'] != '' ){
if ( $row['file_type'] == 'pdf' || $row['file_type'] == 'xls' || $row['file_type'] == 'xlsx' || $row['file_type'] == 'doc' || $row['file_type'] == 'docx' ){
$file = PATH.'uploads/Form/'.$row['file'] ;
}else{
$file = PATH.'uploads/Form/b/'.$row['file'] ;
}
}
$row['id'] = dataFilter( $row['form_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = $file ;
$row['created_at'] = dataFilter( $row['created_at'] ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+41
View File
@@ -0,0 +1,41 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['category_id'] != '' ){
$search_query .= " AND a.category_id = '".$array['category_id']."'" ;
}
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.form_id, a.created_at, b.title FROM form a
LEFT JOIN form_translation b ON ( a.form_id = b.form_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' AND ( ( a.receiver_type IN ( '0' ) ) OR ( a.receiver_type IN ( '1', '2' ) AND a.staff_id LIKE '%/".$staff_info['staff_id']."/%' ) ) " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable ASC, a.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['form_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.category_id, a.file, a.created_at, b.title FROM form_category a
LEFT JOIN form_category_translation b ON ( a.category_id = b.category_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.category_type = 'main' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable ASC, a.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/FormCategory/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.category_id, a.file, a.created_at, b.title FROM form_category a
LEFT JOIN form_category_translation b ON ( a.category_id = b.category_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.category_type = 'sub' AND a.category_parent = '".$array['category_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable ASC, a.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/FormCategory/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.formsubmissionid, a.submission_type, a.file, a.created_at, b.title FROM formsubmission a
LEFT JOIN formsubmission_translation b ON ( a.formsubmissionid = b.formsubmissionid )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.created_at ASC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['formsubmissionid'] = dataFilter( $row['formsubmissionid'] ) ;
$row['submission_type'] = dataFilter( $row['submission_type'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/FormSubmissionCategory/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND grievance_id = '".$array['id']."'" ;
$query = "SELECT grievance_id, title, content, comment, file, status, created_at FROM grievance
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$row['id'] = dataFilter( $row['grievance_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['comment'] = dataFilter( $row['comment'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/grievance/b/'.$row['file'] : '' ) ;
$row['created_at'] = dataFilter( $row['created_at'] ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+83
View File
@@ -0,0 +1,83 @@
<?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'] ;
}
}
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT grievance_id, staff_id, title, status, created_at FROM grievance
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$staff_list = [] ;
$grievance_id = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['grievance_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['departments'] = '' ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
$staff_list[$row['staff_id']] = $row['staff_id'] ;
$grievance_id[$row['grievance_id']] = $row['grievance_id'] ;
}
// select related grievance media
$media_list = [] ;
$select_media = $mysqli->query( "SELECT grievance_id, file FROM grievance_media a
WHERE a.deleted_at IS NULL AND grievance_id IN ( ".implode( ',', $grievance_id )." )" ) ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
$media_list[$row_media['grievance_id']][] = ( $row_media['file'] != '' ? PATH.'uploads/Grievance/b/'.$row_media['file'] : '' ) ;
}
}
// select all staff related deparment
$related_list = [] ;
$select_related = $mysqli->query( "SELECT staff_id, department_id FROM staff_department a
WHERE a.deleted_at IS NULL AND staff_id IN ( ".implode( ',', $staff_list )." )" ) ;
if ( $select_related->num_rows > 0 ){
while ( $row_related = $select_related->fetch_assoc() ){
if ( checkExists( $department_list[$row_related['department_id']] ) ){
$related_list[$row_related['staff_id']][] = $department_list[$row_related['department_id']] ;
}
}
}
foreach ( $list as $k => $v ){
$list[$k]['departments'] = ( checkExists( $related_list[$v['staff_id']] ) ? implode( ', ', $related_list[$v['staff_id']] ) : '' ) ;
$list[$k]['files'] = ( checkExists( $media_list[$v['grievance_id']] ) ? $media_list[$v['grievance_id']] : [] ) ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+49
View File
@@ -0,0 +1,49 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND grievance_id = '".$array['grievance_id']."'" ;
$query = "SELECT grievance_id, title, content, comment, status, status, created_at, updated_at FROM grievance
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$row = $mysqli_query->fetch_assoc() ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['comment'] = dataFilter( $row['comment'] ) ;
// get all media
$select_media = $mysqli->query( "SELECT media_id, file FROM grievance_media
WHERE deleted_at IS NULL AND grievance_id = '".$array['grievance_id']."'" ) ;
$photos = [] ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'file' => ( $row_media['file'] != '' ? PATH.'uploads/Grievance/b/'.$row_media['file'] : '' )
] ;
}
}
$row['photos'] = $photos ;
$data = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+50
View File
@@ -0,0 +1,50 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$grievance_id = $array['grievance_id'] ;
$photos = $array['photos'] ;
if ( $array['title'] != '' && $array['content'] != '' && $array['photos'] != '' && count( $photos ) > 0 ){
$status = '203' ;
if ( $mysqli->query( "INSERT INTO grievance
( `branch_id`, `staff_id`, `title`, `content`, `status` ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['title']."', '".$array['content']."', 'pending' )" ) ){
$status = '200' ;
$boolean_submit = true ;
$grievance_id = $mysqli->insert_id ;
$grievance_so = 'GV'.strPad( 6, $grievance_id ) ;
$mysqli->query( "UPDATE grievance SET
grievance_so = '".$grievance_so."'
WHERE grievance_id = '".$grievance_id."'" ) ;
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'Grievance', $grievance_id.'-'.$grievance_id, $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO grievance_media
( grievance_id, file, filetype ) VALUES
( '".$grievance_id."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+31
View File
@@ -0,0 +1,31 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '312' ;
if ( $array['is_tick'] == 'yes' ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND handbook_id = '".$array['id']."'" ;
$query = "SELECT handbook_id FROM handbook
WHERE deleted_at IS NULL AND ( ( receiver_type IN ( '0' ) ) OR ( receiver_type IN ( '1', '2' ) AND staff_id LIKE '%/".$staff_info['staff_id']."/%' ) ) " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$mysqli->query( "INSERT INTO staff_handbook
( handbook_id, staff_id ) VALUES
( '".$array['id']."', '".$staff_info['staff_id']."' ) " ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+54
View File
@@ -0,0 +1,54 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.handbook_id = '".$array['id']."'" ;
$query = "SELECT a.handbook_id, a.content, a.view_format, a.file, a.file_type, a.video_url, a.is_showagree, a.created_at, b.title FROM handbook a
LEFT JOIN handbook_translation b ON ( a.handbook_id = b.handbook_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' AND ( ( a.receiver_type IN ( '0' ) ) OR ( a.receiver_type IN ( '1', '2' ) AND a.staff_id LIKE '%/".$staff_info['staff_id']."/%' ) ) " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$file = '' ;
if ( $row['file'] != '' ){
if ( $row['file_type'] == 'pdf' ){
$file = PATH.'uploads/Handbook/'.$row['file'] ;
}else{
$file = PATH.'uploads/Handbook/b/'.$row['file'] ;
}
}
// check if agree or not
$is_agreed = 'no' ;
$select_agree = $mysqli->query( "SELECT * FROM staff_handbook
WHERE deleted_at IS NULL AND handbook_id = '".$array['id']."' AND staff_id = '".$staff_info['staff_id']."' LIMIT 1" ) ;
if ( $select_agree->num_rows > 0 ){
$is_agreed = 'yes' ;
}
$row['id'] = dataFilter( $row['handbook_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['file'] = $file ;
$row['created_at'] = dataFilter( $row['created_at'] ) ;
$row['is_agreed'] = $is_agreed ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+42
View File
@@ -0,0 +1,42 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['category_id'] != '' ){
$search_query .= " AND a.category_id = '".$array['category_id']."'" ;
}
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.handbook_id, a.created_at, b.title FROM handbook a
LEFT JOIN handbook_translation b ON ( a.handbook_id = b.handbook_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' AND ( ( a.receiver_type IN ( '0' ) ) OR ( a.receiver_type IN ( '1', '2' ) AND a.staff_id LIKE '%/".$staff_info['staff_id']."/%' ) ) " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable ASC, a.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['handbook_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Handbook/b/'.$row['file'] : '' ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,38 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.category_id, a.file, a.created_at, b.title FROM handbook_category a
LEFT JOIN handbook_category_translation b ON ( a.category_id = b.category_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.category_type = 'main' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable ASC, a.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/HandbookCategory/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.category_id, a.file, a.created_at, b.title FROM handbook_category a
LEFT JOIN handbook_category_translation b ON ( a.category_id = b.category_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.category_type = 'sub' AND a.category_parent = '".$array['category_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable ASC, a.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/HandbookCategory/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+86
View File
@@ -0,0 +1,86 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '303' ;
if ( $staff_info['staff_settings']['checkrecruitment'] == 'yes' ){
$status = '201' ;
// position
$positions = [] ;
$mysqli_position = $mysqli->query( "SELECT a.job_position_id, b.job_position_desc FROM setting_job_position a
LEFT JOIN setting_job_position_translation b ON ( a.job_position_id = b.job_position_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ) ;
if ( $mysqli_position->num_rows > 0 ){
while( $row_position = $mysqli_position->fetch_assoc() ){
$positions[$row_position['job_position_id']] = $row_position['job_position_desc'] ;
}
}
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND ( employment_name LIKE '%".$array['search']."%' OR employment_nric LIKE '%".$array['search']."%' OR employment_mobile LIKE '%".$array['search']."%' OR employment_email LIKE '%".$array['search']."%' )" ;
}
$searchstatus = 'Processing' ;
if ( $array['searchstatus'] != '' ){
switch ( $array['searchstatus'] ){
case 'pending' :
$searchstatus = 'Processing' ;
break ;
case 'shortlisted' :
$searchstatus = 'Processing Confirmed' ;
break ;
case 'rejected' :
$searchstatus = 'Processing Rejected' ;
break ;
}
}
if ( $searchstatus != '' ){
$search_query .= " AND employment_status = '".$searchstatus."'" ;
}
$query = "SELECT employment_id, employment_name, employment_nric, employment_mobile, employment_email, employment_sex, employment_position, employment_resume, employment_status, employment_date FROM staff_employment
WHERE employment_trash = '0' AND employment_branch = '".$array['branch_id']."' AND employment_incharge_staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY employment_modified DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['employment_id'] = dataFilter( $row['employment_id'] ) ;
$row['employment_name'] = dataFilter( $row['employment_name'] ) ;
$row['employment_nric'] = dataFilter( $row['employment_nric'] ) ;
$row['employment_mobile'] = dataFilter( $row['employment_mobile'] ) ;
$row['employment_email'] = dataFilter( $row['employment_email'] ) ;
$row['employment_sex'] = dataFilter( $row['employment_sex'] ) ;
$row['employment_date'] = resetDateFormat( $row['employment_date'] ) ;
$row['employment_position'] = $positions[$row['employment_position']] ;
$row['employment_resume'] = ( $row['employment_resume'] != '' ? PATH.'/uploads/Employment_Resume/'.$row['employment_resume'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+148
View File
@@ -0,0 +1,148 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '303' ;
if ( $staff_info['staff_settings']['checkrecruitment'] == 'yes' ){
$status = '201' ;
$query = "SELECT employment_id, employment_branch, employment_position, employment_name, employment_nric, employment_mobile, employment_email, employment_sex, employment_date FROM staff_employment
WHERE employment_trash = '0' AND employment_status = 'Processing' AND employment_branch = '".$array['branch_id']."' AND employment_incharge_staff_id = '".$staff_info['staff_id']."' AND employment_id = '".$array['id']."' LIMIT 1" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row_employment = $mysqli_query->fetch_assoc() ;
$status = '308' ;
$update_status = '' ;
switch ( $array['status'] ){
case 'confirm' :
$update_status = 'Processing Confirmed' ;
break ;
case 'reject' :
$update_status = 'Processing Rejected' ;
break ;
}
$branch_hr_contact = '' ;
$branch_hr_email = '' ;
$branch_hr_cc = [] ;
$branch_email_footer = '' ;
$mysqli_query = "SELECT branch_hr_email, branch_hr_cc, branch_hr_contact, branch_email_footer FROM branch WHERE
deleted_at IS NULL AND branch_id = '".$row_employment['employment_branch']."' LIMIT 1" ;
$mysqli_branch = $mysqli->query($mysqli_query) ;
if ( $mysqli_branch->num_rows > 0 ){
$row_branch = $mysqli_branch->fetch_assoc() ;
$branch_hr_contact = dataFilter( $row_branch['branch_hr_contact'] ) ;
$branch_hr_email = dataFilter( $row_branch['branch_hr_email'] ) ;
$branch_hr_cc = explodeToArray( $row_branch['branch_hr_cc'] ) ;
$branch_email_footer = entityDecode( dataFilter( $row_branch['branch_email_footer'] ) ) ;
}
$position = '' ;
$mysqli_query = "SELECT a.job_position_id, b.job_position_desc FROM setting_job_position a
LEFT JOIN setting_job_position_translation b ON ( a.job_position_id = b.job_position_id )
WHERE a.deleted_at IS NULL AND b.lang = 'en' AND a.job_position_id = '".$row_employment['employment_position']."' LIMIT 1" ;
$mysqli_position = $mysqli->query($mysqli_query) ;
if ( $mysqli_position->num_rows > 0 ){
$row_position = $mysqli_position->fetch_assoc() ;
$position = dataFilter( $row_position['job_position_desc'] ) ;
}
if ( $update_status != '' ){
$status = '200' ;
$mysqli->query( "UPDATE staff_employment SET
employment_status = '".$update_status."'
WHERE employment_id = '".$array['id']."'" ) ;
$title = ucwords($array['status']).' Applicant Interview' ;
$content = '' ;
$link = PATH.'hr-employment-schedule-interview-date.php?page='.$row_employment['employment_id'].'&branch='.$row_employment['employment_branch'].'&sign='.md5($row_employment['employment_id'].$row_employment['employment_branch'].APIKEY) ;
$schedule = '<a href="'.$link.'">'.$link.'</a>' ;
$email_status = '' ;
if ( $update_status == 'Processing Confirmed' ){
$email_status = 'confirmed' ;
$content = "
<table>
<tr><td>Dear ".ucwords($row_employment['employment_name']).",</td></tr>
<tr><td style='height:20px;'> </td></tr>
<tr><td>Greetings from ".COMPANYSHORT.". We've reviewed your resume and would like to have more discussion with you on the ".$position.".</td></tr>
<tr><td style='height:20px;'> </td></tr>
<tr><td>Kindly select the slot for face-to-face interview session on your availability : ".$schedule."<td></tr>
<tr><td style='height:20px;'> </td></tr>
<tr><td>You will receive our second email for interview invitation once your selected slot is being confirmed. If you have any enquiry, please do not hesitate to contact us via email (".$branch_hr_email.") or call to HR department (".$branch_hr_contact.").<td></tr>
<tr><td style='height:20px;'> </td></tr>
<tr><td>Please Note That:</td></tr>
<tr><td style='height:20px;'>1) This is an interview call for the job applied and does not guarantee employment with us.</td></tr>
<tr><td style='height:20px;'>2) No TA / DA will be provided to candidates appearing for the interview.</td></tr>
<tr><td style='height:20px;'>3) If we didn't receive your response on the interview slots in 2 days, we will consider as abandoned application.</td></tr>
</table>" . $branch_email_footer ;
}else{
$email_status = 'rejected' ;
// $content = "
// <table>
// <tr><td>Dear ".ucwords($row_employment['employment_name']).",</td></tr>
// <tr><td style='height:20px;'> </td></tr>
// <tr><td>Greetings from ".COMPANYSHORT.". We've reviewed your resume and reject your application.</td></tr>
// </table>" . $branch_email_footer ;
}
$mysqli->query( "INSERT INTO system_log_employment ( log_table, log_action, log_page_id, log_page_name, log_user_id, log_description, log_record, log_date) VALUES
( 'employment', 'manager-update-status', '200', 'AF-".$array['id']."', '".$staff_info["staff_id"]."', '".$content."', '', NOW() )" ) ;
$mailer = new Mailer() ;
// send to employee
if ( $content != '' ){
$mailer->from = $branch_hr_email ;
$mailer->fromname = COMPANY ;
$mailer->to = [ $row_employment['employment_email'] ] ;
if ( count($branch_hr_cc) > 0 ){
$mailer->cc = $branch_hr_cc ;
}
$mailer->subject = $title ;
$mailer->body = $content ;
$mailer->send() ;
}
// send to hr
$mailer->from = $branch_hr_email ;
$mailer->fromname = COMPANY ;
$mailer->to = [ $branch_hr_email ] ;
if ( count($branch_hr_cc) > 0 ){
$mailer->cc = $branch_hr_cc ;
}
$mailer->subject = 'Reminder for Recruitment' ;
$mailer->body = 'Dear HR, '.ucwords($staff_info['staff_name']).' has '.$email_status.' '.ucwords($row_employment['employment_name']).' for '.$position.'. Please log in to review.
<br /><br />
* This is an auto-generated message, please do not reply.' ;
$mailer->send() ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+32
View File
@@ -0,0 +1,32 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$query = "SELECT a.category_id, a.category_mode, a.created_at, b.title FROM redeem_category a
LEFT JOIN redeem_category_translation b ON ( a.category_id = b.category_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND ( ( a.receiver_type IN ( '0' ) ) OR ( a.receiver_type IN ( '1', '2' ) AND a.staff_id LIKE '%/".$staff_info['staff_id']."/%' ) ) AND a.status = 'active' AND ( a.category_type = 'all' OR ( a.category_type = 'date' AND a.date_start <= '".TODAYDAY."' AND a.date_end >= '".TODAYDAY."' ) )" ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable ASC" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+96
View File
@@ -0,0 +1,96 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.redeem_id = '".$array['id']."'" ;
$query = "SELECT a.redeem_id, a.category_id, a.redeem_type, a.date_start, a.date_end, a.point, a.file, a.redeem_quantity, a.status, a.created_at, b.title, b.content FROM redeem a
LEFT JOIN redeem_translation b ON ( a.redeem_id = b.redeem_id )
WHERE a.deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '269' ;
$row = $mysqli_query->fetch_assoc() ;
$point = $row['point'] ;
$custom_point = $array['custom_point'] ;
$select_category = $mysqli->query( "SELECT category_mode, number_of_times FROM redeem_category
WHERE deleted_at IS NULL AND status = 'active' AND category_id = '".$row['category_id']."' AND ( category_type = 'all' OR ( category_type = 'date' AND date_start <= '".TODAYDAY."' AND date_end >= '".TODAYDAY."' ) ) LIMIT 1" ) ;
if ( $select_category->num_rows > 0 ){
$status = '268' ;
$row_category = $select_category->fetch_assoc() ;
$category_mode = $row_category['category_mode'] ;
$number_of_times = $row_category['number_of_times'] ;
$get_staffcategory = $mysqli->query( "SELECT * FROM staff_redeem
WHERE deleted_at IS NULL AND category_id = '".$row['category_id']."' AND staff_id = '".$staff_info['staff_id']."' AND created_at LIKE '%".date('Y-m', time())."%' AND status != 'rejected'" ) ;
if ( $number_of_times > $get_staffcategory->num_rows ){
$status = '248' ;
$is_redeem = 'no' ;
$is_custom = 'no' ;
if ( $row['status'] == 'active' ){
if ( $row['redeem_type'] == 'all' || ( $row['redeem_type'] == 'date' && $row['date_start'] <= TODAYDATE && $row['date_end'] >= TODAYDATE ) ){
$is_redeem = 'yes' ;
$is_custom = ( $category_mode == 'custom' ? 'yes' : 'no' ) ;
}
}
if ( $is_redeem == 'yes' ){
$status = '243' ;
if ( $is_custom == 'no' || ( $is_custom == 'yes' && $custom_point > 0 ) ){
$status = '246' ;
if ( $is_custom == 'yes' ){
$point = $custom_point ;
}
$get_staffredeem = $mysqli->query( "SELECT * FROM staff_redeem
WHERE deleted_at IS NULL AND redeem_id = '".$array['id']."' AND status != 'rejected'" ) ;
$total_redeem = $get_staffredeem->num_rows ;
if ( $row['redeem_quantity'] > $total_redeem ){
$status = '249' ;
$balance = getStaffPoint( $staff_info['staff_id'] ) ;
if ( $balance >= $point ){
$status = '200' ;
$mysqli->query( "INSERT INTO staff_redeem
( redeem_id, branch_id, category_id, staff_id, point, status ) VALUES
( '".$array['id']."', '".$array['branch_id']."', '".$row['category_id']."', '".$staff_info['staff_id']."', '".$point."', 'pending' ) " ) ;
$view_id = $mysqli->insert_id ;
$redeem_so = 'RD'.strPad( 6, $view_id ) ;
$remark = 'Deduct point '.$point.' ('.$row['title'].') from redeem ' . $redeem_so ;
pointMovement( 'redeem', $view_id, 'exchange', 'normal', $staff_info['staff_id'], -( $point ), $remark ) ;
$mysqli->query( "UPDATE staff_redeem SET redeem_so = '".$redeem_so."' WHERE view_id = '".$view_id."'" ) ;
}
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+67
View File
@@ -0,0 +1,67 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.redeem_id = '".$array['id']."'" ;
$join_filter = "" ;
$join_query = "" ;
if ( $array['mode'] == 'view' ){
$join_filter .= ", c.status as redeem_status, c.remark as redeem_remark" ;
$join_query .= " LEFT JOIN staff_redeem c ON ( a.redeem_id = c.redeem_id )" ;
$search_query .= " AND c.view_id = '".$array['view_id']."' AND c.staff_id = '".$staff_info['staff_id']."'" ;
}
$query = "SELECT a.redeem_id, a.category_id, a.redeem_type, a.date_start, a.date_end, a.point, a.file, a.status, a.created_at, b.title, b.content ".$join_filter." FROM redeem a
LEFT JOIN redeem_translation b ON ( a.redeem_id = b.redeem_id )
".$join_query."
WHERE a.deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$row['id'] = dataFilter( $row['redeem_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Redeem/b/'.$row['file'] : '' ) ;
$is_redeem = 'no' ;
$is_custom = 'no' ;
if ( $row['status'] == 'active' ){
if ( $row['redeem_type'] == 'all' || ( $row['redeem_type'] == 'date' && $row['date_start'] <= TODAYDATE && $row['date_end'] >= TODAYDATE ) ){
$is_redeem = 'yes' ;
$select_category = $mysqli->query( "SELECT category_mode FROM redeem_category
WHERE deleted_at IS NULL AND category_id = '".$row['category_id']."' LIMIT 1" ) ;
if ( $select_category->num_rows > 0 ){
$row_category = $select_category->fetch_assoc() ;
$is_custom = ( $row_category['category_mode'] == 'custom' ? 'yes' : 'no' ) ;
}
}
}
$row['is_redeem'] = $is_redeem ;
$row['is_custom'] = $is_custom ;
if ( $is_custom == 'yes' ){
$row['point'] = $staff_info['staff_point'] ;
}
$row['date_start'] = resetDateFormat( $row['date_start'] ) ;
$row['date_end'] = resetDateFormat( $row['date_end'] ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$row['redeem_status'] = ( checkExists( $row['redeem_status'] ) != '' ? $row['redeem_status'] : '') ;
$row['redeem_remark'] = dataFilter( checkExists( $row['redeem_remark'] ) != '' ? $row['redeem_remark'] : '') ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+91
View File
@@ -0,0 +1,91 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$searchfilter = $array['searchfilter'] ;
$searchfilter = ( $searchfilter != '' ? $searchfilter : 'current' ) ;
$join_filter = '' ;
$join_query = '' ;
$query_sortable = 'ORDER BY a.sortable ASC, a.created_at DESC' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
if ( $array['category_id'] != '' ){
$search_query .= " AND a.category_id = '".$array['category_id']."'" ;
}
if ( $searchfilter != '' ){
switch ( $searchfilter ){
case 'current' :
$search_query .= " AND a.branch LIKE '%/".$array['branch_id']."/%' AND a.status = 'active' AND ( ( a.redeem_type = 'all' ) OR ( a.redeem_type = 'date' AND a.date_start <= '".TODAYDATE."' AND a.date_end >= '".TODAYDATE."' ) )" ;
break ;
case 'previous' : // my redeem
$join_filter = ", c.view_id, c.status as redeem_status" ;
$join_query = "LEFT JOIN staff_redeem c ON ( a.redeem_id = c.redeem_id )" ;
$search_query .= " AND c.branch_id = '".$array['branch_id']."' AND c.staff_id = '".$staff_info['staff_id']."'" ;
$query_sortable = "ORDER BY c.view_id DESC" ;
break ;
case 'expired' : // temporary close
$search_query .= " AND a.branch LIKE '%/".$array['branch_id']."/%' AND ( a.status = 'inactive' OR ( a.redeem_type = 'date' AND a.date_start <= '".TODAYDATE."' AND NOT ( a.date_end >= '".TODAYDATE."' ) ) )" ;
break ;
case 'history' :
$join_filter = ", c.view_id, c.point as redeem_point, c.status as redeem_status, c.created_at as redeem_created, d.staff_idno, d.staff_shortname" ;
$join_query .= " LEFT JOIN staff_redeem c ON ( a.redeem_id = c.redeem_id )" ;
$join_query .= " LEFT JOIN staff d ON ( c.staff_id = d.staff_id )" ;
$search_query .= " AND c.branch_id = '".$array['branch_id']."' AND c.status = 'confirmed'" ;
$query_sortable = "ORDER BY c.view_id DESC" ;
break ;
}
}
$query = "SELECT a.redeem_id, a.redeem_type, a.date_start, a.date_end, a.point, a.redeem_quantity, a.file, a.created_at, b.title ".$join_filter." FROM redeem a
LEFT JOIN redeem_translation b ON ( a.redeem_id = b.redeem_id )
".$join_query."
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ".$query_sortable." LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['redeem_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['date_start'] = resetDateFormat( $row['date_start'] ) ;
$row['date_end'] = resetDateFormat( $row['date_end'] ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$row['redeem_status'] = ( checkExists( $row['redeem_status'] ) != '' ? $row['redeem_status'] : '' ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Redeem/b/'.$row['file'] : '' ) ;
$row['redeem_left'] = 0 ;
switch ( $searchfilter ){
case 'current' :
$get_staffredeem = $mysqli->query( "SELECT view_id FROM staff_redeem
WHERE deleted_at IS NULL AND redeem_id = '".$row['redeem_id']."' AND status != 'rejected'" ) ;
$total_redeem = $get_staffredeem->num_rows ;
$row['redeem_left'] = ( $row['redeem_quantity'] - $total_redeem ) ;
break ;
case 'history' :
$row['redeem_created'] = resetDateFormat( $row['redeem_created'] ) ;
break ;
}
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+39
View File
@@ -0,0 +1,39 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.redeem_id = '".$array['id']."'" ;
$join_filter .= ", b.status as redeem_status, b.remark as redeem_remark" ;
$join_query .= " LEFT JOIN staff_redeem b ON ( a.redeem_id = b.redeem_id )" ;
$search_query .= " AND b.view_id = '".$array['view_id']."' AND b.staff_id = '".$staff_info['staff_id']."'" ;
$query = "SELECT a.redeem_id, a.redeem_type, a.date_start, a.date_end, a.point, a.title, a.content, a.file, a.status, a.created_at ".$join_filter." FROM redeem a
".$join_query."
WHERE a.deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '299' ;
$row = $mysqli_query->fetch_assoc() ;
if ( $row['redeem_status'] == 'awaiting-collection' ){
$status = '200' ;
$mysqli->query( "UPDATE staff_redeem SET
status = 'confirmed'
WHERE view_id = '".$array['view_id']."'" ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+25
View File
@@ -0,0 +1,25 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '258' ;
$query = "SELECT request_id, is_main, type, title, description, quantity, date_from, date_to, reason, content, comment, status, status, created_at, updated_at FROM request
WHERE deleted_at IS NULL AND request_id = '".$array['request_id']."' AND date_from >= '".TODAYDATE."'" ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$mysqli->query( "UPDATE request SET
status = 'cancelled'
WHERE request_id = '".$array['request_id']."'" ) ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+32
View File
@@ -0,0 +1,32 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND request_id = '".$array['id']."'" ;
$query = "SELECT request_id, title, content, status, created_at FROM request
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$row['id'] = dataFilter( $row['request_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['created_at'] = dataFilter( $row['created_at'] ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+46
View File
@@ -0,0 +1,46 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$join_filter = '' ;
$join_query = '' ;
$query_sortable = 'ORDER BY created_at DESC' ;
$search_query = '' ;
switch ( $array['filter'] ){
case 'myself' :
$search_query .= " AND staff_id = '".$staff_info['staff_id']."'" ;
break ;
case 'group' :
$search_query .= " AND branch_id = '".$array['branch_id']."' AND status = 'confirmed'" ;
break ;
}
$query = "SELECT title, file, filetype, status, created_at FROM request_gallery
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ".$query_sortable." LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['date'] = resetDateFormat( $row['created_at'] ) ;
$row['time'] = resetTimeFormat( $row['created_at'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/RequestGallery/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,35 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$title = $array['title'] ;
$photos = $array['photos'] ;
if ( $title != '' && $array['photos'] != '' && count( $photos ) > 0 ){
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'RequestGallery', time(), $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO request_gallery
( branch_id, staff_id, title, file, filetype ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$title."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+87
View File
@@ -0,0 +1,87 @@
<?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'] ;
}
}
$search_query = "" ;
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT request_id, staff_id, is_main, main_id, sub_id, type, title, description, reason, date_from, date_to, status, created_at FROM request
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$staff_list = [] ;
$request_id = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['request_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['description'] = dataFilter( $row['description'] ) ;
$row['request_date'] = ( $row['date_from'] != '' ? date( "Y-m-d", strtotime( $row['date_from'] ) ) : '' ) ;
$row['time_from'] = date( 'H:ia', strtotime( $row['date_from'] ) ) ;
$row['time_to'] = date( 'H:ia', strtotime( $row['date_to'] ) ) ;
$row['departments'] = '' ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
$staff_list[$row['staff_id']] = $row['staff_id'] ;
$request_id[$row['request_id']] = $row['request_id'] ;
}
// select related request media
$media_list = [] ;
$select_media = $mysqli->query( "SELECT request_id, file FROM request_media a
WHERE a.deleted_at IS NULL AND request_id IN ( ".implode( ',', $request_id )." )" ) ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
$media_list[$row_media['request_id']][] = ( $row_media['file'] != '' ? PATH.'uploads/Request/b/'.$row_media['file'] : '' ) ;
}
}
// select all staff related deparment
$related_list = [] ;
$select_related = $mysqli->query( "SELECT staff_id, department_id FROM staff_department a
WHERE a.deleted_at IS NULL AND staff_id IN ( ".implode( ',', $staff_list )." )" ) ;
if ( $select_related->num_rows > 0 ){
while ( $row_related = $select_related->fetch_assoc() ){
if ( checkExists( $department_list[$row_related['department_id']] ) ){
$related_list[$row_related['staff_id']][] = $department_list[$row_related['department_id']] ;
}
}
}
foreach ( $list as $k => $v ){
$list[$k]['departments'] = ( checkExists( $related_list[$v['staff_id']] ) ? implode( ', ', $related_list[$v['staff_id']] ) : '' ) ;
$list[$k]['files'] = ( checkExists( $media_list[$v['request_id']] ) ? $media_list[$v['request_id']] : [] ) ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+39
View File
@@ -0,0 +1,39 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.main_id, a.is_main, a.type, a.file, a.created_at, b.title, b.description FROM setting_request a
LEFT JOIN setting_request_translation b ON ( a.main_id = b.main_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable ASC, a.created_at ASC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['main_id'] = dataFilter( $row['main_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['description'] = dataFilter( $row['description'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Request/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+67
View File
@@ -0,0 +1,67 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.request_id = '".$array['request_id']."' AND a.staff_id = '".$staff_info['staff_id']."'" ;
$query = "SELECT * FROM request a
WHERE a.deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '299' ;
$row = $mysqli_query->fetch_assoc() ;
if ( $row['status'] == 'awaiting-collection' ){
$status = '200' ;
$mysqli->query( "UPDATE request SET
status = 'confirmed'
WHERE request_id = '".$array['request_id']."'" ) ;
// get last movment
$updateremark = 'Stock deduct from so number ' . $row['request_so'] ;
$updatequantity = -($row['quantity']) ;
if ( ( $updatequantity < 0 || $updatequantity > 0) && $updatequantity != '' ){
$before = 0 ;
$main_id = $row['main_id'] ;
$sub_id = $row['sub_id'] ;
if ( $sub_id > 0 ){
$main_id = 0 ;
}
// get last movment
$mysqli_select = $mysqli->query( "SELECT balance FROM setting_request_movement
WHERE deleted_at IS NULL AND main_id = '".$main_id."' AND sub_id = '".$sub_id."'
ORDER BY movement_id DESC
LIMIT 1" ) ;
if ( $mysqli_select->num_rows > 0 ){
$row_select = $mysqli_select->fetch_assoc() ;
$before = $row_select['balance'] ;
}
$quantity = $updatequantity ;
$balance = ( $before + $quantity ) ;
$mysqli->query( "INSERT INTO setting_request_movement
( main_id, sub_id, before_quantity, quantity, balance, remark ) VALUES
( '".$main_id."', '".$sub_id."', '".$before."', '".$quantity."', '".$balance."', '".$updateremark."' )" ) ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,80 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$main_id = $array['main_id'] ;
$sub_id = $array['sub_id'] ;
$searchyearmonth = $array['searchyearmonth'] ;
$searchday = $array['searchday'] ;
$searchday = ( $searchday != '' ? $searchday : date( 'd', time() ) ) ;
$searchyearmonthday = $searchyearmonth . '-' . $searchday ;
$list = [] ;
$selected = [] ;
$marked = [] ;
$search_query = '' ;
$search_query .= " AND ( a.date_from LIKE '%".$searchyearmonth."%' OR a.date_to LIKE '%".$searchyearmonth."%' )" ;
$query = "SELECT a.request_id, a.staff_id, a.is_main, a.main_id, a.sub_id, a.type, a.title, a.description, a.reason, a.date_from, a.date_to, a.status, a.created_at, b.staff_idno, b.staff_name, b.staff_shortname FROM request a
LEFT JOIN staff b ON ( a.staff_id = b.staff_id )
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' AND a.main_id = '".$main_id."' AND a.sub_id = '".$sub_id."' AND a.type = 'reservation' AND a.status IN ( 'confirmed' ) " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.date_from" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
while ( $row = $mysqli_query->fetch_assoc() ){
$boolean_loop = true ;
$date_from = date( 'Y-m-d', strtotime( $row['date_from'] ) ) ;
$date_to = date( 'Y-m-d', strtotime( $row['date_to'] ) ) ;
$loop_date_from = $date_from ;
$loop_date_to = $date_to ;
while ( $boolean_loop ){
if ( $loop_date_from <= $loop_date_to ){
$selected[$loop_date_from] = $loop_date_from ;
}else{
$boolean_loop = false ;
}
$loop_date_from = date('Y-m-d', strtotime("+1 day", strtotime($loop_date_from))) ;
}
if ( $date_from <= $searchyearmonthday && $date_to >= $searchyearmonthday ){
$row['title'] = dataFilter( $row['title'] ) ;
$row['description'] = dataFilter( $row['description'] ) ;
$row['reason'] = dataFilter( $row['reason'] ) ;
$row['request_date'] = ( $row['date_from'] != '' ? date( "Y-m-d", strtotime( $row['date_from'] ) ) : '' ) ;
$row['time_from'] = date( 'h:ia', strtotime( $row['date_from'] ) ) ;
$row['time_to'] = date( 'h:ia', strtotime( $row['date_to'] ) ) ;
$list[] = $row ;
}
}
}
$first_day_of_month = $searchyearmonth . '-01' ;
$last_day_of_month = $searchyearmonth . '-' . date( 't', strtotime( $first_day_of_month ) ) ;
for ( $a = $first_day_of_month ; $a <= $last_day_of_month ; $a++ ){
if ( $selected[$a] != null ){
$marked[$a] = [ 'marked' => true, 'dotColor' => '#ff9500' ] ;
}
}
$data['yearmonthday'] = $searchyearmonthday ;
$data['list'] = $list ;
$data['marked'] = $marked ;
}
require( $require_sub.'footer.php' ) ;
?>
+55
View File
@@ -0,0 +1,55 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND request_id = '".$array['request_id']."'" ;
$query = "SELECT request_id, is_main, type, title, description, quantity, size, date_from, date_to, reason, content, comment, status, status, created_at, updated_at FROM request
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$row = $mysqli_query->fetch_assoc() ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['description'] = dataFilter( $row['description'] ) ;
$row['date_from'] = dataFilter( $row['date_from'] ) ;
$row['date_to'] = dataFilter( $row['date_to'] ) ;
$row['time_from'] = date( 'H:ia', strtotime( $row['date_from'] ) ) ;
$row['time_to'] = date( 'H:ia', strtotime( $row['date_to'] ) ) ;
$row['reason'] = dataFilter( $row['reason'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['comment'] = dataFilter( $row['comment'] ) ;
// get all media
$select_media = $mysqli->query( "SELECT media_id, file FROM request_media
WHERE deleted_at IS NULL AND request_id = '".$array['request_id']."'" ) ;
$photos = [] ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'file' => ( $row_media['file'] != '' ? PATH.'uploads/Request/b/'.$row_media['file'] : '' )
] ;
}
}
$row['photos'] = $photos ;
$data = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = " AND a.main_id = '".$array['main_id']."'" ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.sub_id, a.main_id, a.type, a.file, a.created_at, b.title, b.description FROM setting_request_sub a
LEFT JOIN setting_request_sub_translation b ON ( a.sub_id = b.sub_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable ASC, a.created_at ASC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['main_id'] = dataFilter( $row['main_id'] ) ;
$row['sub_id'] = dataFilter( $row['sub_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['description'] = dataFilter( $row['description'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Request/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+167
View File
@@ -0,0 +1,167 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$request_id = $array['request_id'] ;
$photos = $array['photos'] ;
$request_date = $array['request_date'] ;
$time_from = $array['time_from'] ;
$time_to = $array['time_to'] ;
$date_from = $request_date . ' ' . $time_from ;
$date_to = $request_date . ' ' . $time_to ;
$title = $array['title'] ;
switch ( $array['request_type'] ){
case 'item' :
case 'item-size' :
if ( $array['is_main'] == 'no' ){
$title = $array['request_title'] ;
}
break ;
case 'reservation' :
$title = $array['request_title'] ;
break ;
}
// check if main / sub exsits
$boolean_exists = false ;
$descrition = '' ;
if ( $array['sub_id'] != '' && $array['sub_id'] > 0 ){
$select_sub = $mysqli->query( "SELECT b.title, b.description FROM setting_request_sub a
LEFT JOIN setting_request_sub_translation b ON ( a.sub_id = b.sub_id )
WHERE a.deleted_at IS NULL AND a.sub_id = '".$array['sub_id']."' AND b.lang = '".$array['lang']."' " ) ;
if ( $select_sub->num_rows > 0 ){
$boolean_exists = true ;
$row_sub = $select_sub->fetch_assoc() ;
$descrition = $row_sub['description'] ;
}
}else{
$select_main = $mysqli->query( "SELECT b.title, b.description FROM setting_request a
LEFT JOIN setting_request_translation b ON ( a.main_id = b.main_id )
WHERE a.deleted_at IS NULL AND a.main_id = '".$array['main_id']."' AND b.lang = '".$array['lang']."' " ) ;
if ( $select_main->num_rows > 0 ){
$boolean_exists = true ;
$row_main = $select_main->fetch_assoc() ;
$descrition = $row_main['description'] ;
}
}
if ( $boolean_exists ){
$status = '300' ;
$is_upload_photo = false ;
$is_submit = false ;
$is_default_status = '' ;
if ( $array['request_type'] == 'reservation' ){
if ( $title != '' && $array['reason'] != '' && $request_date != '' && $time_from != '' && $time_to != '' ){
$status = '295' ;
if ( $date_to >= $date_from ){
$status = '259' ;
$select_record = $mysqli->query( "SELECT request_id FROM request
WHERE deleted_at IS NULL AND type = 'reservation' AND main_id = '".$array['main_id']."' AND sub_id = '".$array['sub_id']."' AND status = 'confirmed' AND (
( date_from >= '".$date_from."' AND date_from < '".$date_to."' ) OR
( date_to > '".$date_from."' AND date_to < '".$date_to."' ) OR
( '".$date_from."' >= date_from AND '".$date_from."' < date_to ) OR
( '".$date_to."' > date_from AND '".$date_to."' < date_to )
) LIMIT 1" ) ;
if ( $select_record->num_rows == 0 ){
$is_upload_photo = false ;
$is_submit = true ;
$is_default_status = 'confirmed' ;
}
}
}
}else{
if ( $title != '' && $array['reason'] != '' && $array['photos'] != '' && count( $photos ) > 0 ){
$is_upload_photo = true ;
$is_submit = true ;
$is_default_status = 'pending' ;
}
}
if ( $is_submit ){
$status = '203' ;
if ( $mysqli->query( "INSERT INTO request
( `main_id`, `sub_id`, `branch_id`, `staff_id`, `is_main`, `type`, `title`, `description`, `quantity`, `size`, `reason`, `date_from`, `date_to`, `content`, `status` ) VALUES
( '".$array['main_id']."', '".$array['sub_id']."', '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['is_main']."', '".$array['request_type']."', '".$title."', '".$descrition."', '".$array['quantity']."', '".$array['size']."', '".$array['reason']."', '".$date_from."', '".$date_to."', '".$array['content']."', '".$is_default_status."' )" ) ){
$status = '200' ;
$boolean_submit = true ;
$request_id = $mysqli->insert_id ;
$request_so = 'RQ'.strPad( 6, $request_id ) ;
$mysqli->query( "UPDATE request SET
request_so = '".$request_so."'
WHERE request_id = '".$request_id."'" ) ;
if ( $is_upload_photo ){
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'Request', $request_id.'-'.$request_id, $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO request_media
( request_id, file, filetype ) VALUES
( '".$request_id."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
}
// send email to hr
$branch_hr_contact = '' ;
$branch_hr_email = '' ;
$branch_hr_cc = [] ;
$branch_email_footer = '' ;
$mysqli_query = "SELECT branch_hr_email, branch_hr_cc, branch_hr_contact, branch_email_footer FROM branch WHERE
deleted_at IS NULL AND branch_id = '".$array['branch_id']."' LIMIT 1" ;
$mysqli_branch = $mysqli->query($mysqli_query) ;
if ( $mysqli_branch->num_rows > 0 ){
$row_branch = $mysqli_branch->fetch_assoc() ;
$branch_hr_contact = dataFilter( $row_branch['branch_hr_contact'] ) ;
$branch_hr_email = dataFilter( $row_branch['branch_hr_email'] ) ;
$branch_hr_cc = explodeToArray( $row_branch['branch_hr_cc'] ) ;
$branch_email_footer = entityDecode( dataFilter( $row_branch['branch_email_footer'] ) ) ;
}
$mailer = new Mailer() ;
$mailer->from = $branch_hr_email ;
$mailer->fromname = COMPANY ;
$mailer->to = [ $branch_hr_email ] ;
if ( count($branch_hr_cc) > 0 ){
$mailer->cc = $branch_hr_cc ;
}
$mailer->subject = 'Item Request' ;
$mailer->body = 'Dear HR, staff request new item, kindly review and update it. <br /><br />by ' . COMPANY . '!' . $branch_email_footer ; ;
$mailer->send() ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND suggestion_id = '".$array['id']."'" ;
$query = "SELECT suggestion_id, title, content, file, status, created_at FROM suggestion
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$row['id'] = dataFilter( $row['suggestion_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['comment'] = dataFilter( $row['comment'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Suggestion/b/'.$row['file'] : '' ) ;
$row['created_at'] = dataFilter( $row['created_at'] ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+83
View File
@@ -0,0 +1,83 @@
<?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'] ;
}
}
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT suggestion_id, staff_id, title, status, created_at FROM suggestion
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$staff_list = [] ;
$suggestion_id = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['suggestion_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['departments'] = '' ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
$staff_list[$row['staff_id']] = $row['staff_id'] ;
$suggestion_id[$row['suggestion_id']] = $row['suggestion_id'] ;
}
// select related suggestion media
$media_list = [] ;
$select_media = $mysqli->query( "SELECT suggestion_id, file FROM suggestion_media a
WHERE a.deleted_at IS NULL AND suggestion_id IN ( ".implode( ',', $suggestion_id )." ) AND filetype IN ( 'jpg', 'png', 'gif' )" ) ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
$media_list[$row_media['suggestion_id']][] = ( $row_media['file'] != '' ? PATH.'uploads/Suggestion/b/'.$row_media['file'] : '' ) ;
}
}
// select all staff related deparment
$related_list = [] ;
$select_related = $mysqli->query( "SELECT staff_id, department_id FROM staff_department a
WHERE a.deleted_at IS NULL AND staff_id IN ( ".implode( ',', $staff_list )." )" ) ;
if ( $select_related->num_rows > 0 ){
while ( $row_related = $select_related->fetch_assoc() ){
if ( checkExists( $department_list[$row_related['department_id']] ) ){
$related_list[$row_related['staff_id']][] = $department_list[$row_related['department_id']] ;
}
}
}
foreach ( $list as $k => $v ){
$list[$k]['departments'] = ( checkExists( $related_list[$v['staff_id']] ) ? implode( ', ', $related_list[$v['staff_id']] ) : '' ) ;
$list[$k]['files'] = ( checkExists( $media_list[$v['suggestion_id']] ) ? $media_list[$v['suggestion_id']] : [] ) ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+67
View File
@@ -0,0 +1,67 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND suggestion_id = '".$array['suggestion_id']."'" ;
$query = "SELECT suggestion_id, type, title, content, comment, status, status, created_at, updated_at FROM suggestion
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$row = $mysqli_query->fetch_assoc() ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['comment'] = dataFilter( $row['comment'] ) ;
// get all media
$select_media = $mysqli->query( "SELECT media_id, file, filetype FROM suggestion_media
WHERE deleted_at IS NULL AND suggestion_id = '".$array['suggestion_id']."'" ) ;
$photos = [] ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
switch ( $row_media['filetype'] ){
case 'jpg' :
case 'jpeg' :
case 'png' :
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/Suggestion/b/'.$row_media['file'] : '' )
] ;
break ;
default :
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/Suggestion/'.$row_media['file'] : '' )
] ;
}
}
}
$row['photos'] = $photos ;
$data = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+50
View File
@@ -0,0 +1,50 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$suggestion_id = $array['suggestion_id'] ;
$photos = $array['photos'] ;
if ( $array['suggest_type'] != '' && $array['title'] != '' && $array['content'] != '' && $array['photos'] != '' && count( $photos ) > 0 ){
$status = '203' ;
if ( $mysqli->query( "INSERT INTO suggestion
( `branch_id`, `staff_id`, `type`, `title`, `content`, `status` ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['suggest_type']."', '".$array['title']."', '".$array['content']."', 'pending' )" ) ){
$status = '200' ;
$boolean_submit = true ;
$suggestion_id = $mysqli->insert_id ;
$suggestion_so = 'SG'.strPad( 6, $suggestion_id ) ;
$mysqli->query( "UPDATE suggestion SET
suggestion_so = '".$suggestion_so."'
WHERE suggestion_id = '".$suggestion_id."'" ) ;
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'Suggestion', $suggestion_id.'-'.$suggestion_id, $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO suggestion_media
( suggestion_id, file, filetype ) VALUES
( '".$suggestion_id."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+79
View File
@@ -0,0 +1,79 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$task_id = $array['task_id'] ;
$extra = $array['extra'] ;
$rating = $array['rating'] ;
if ( $task_id != '' ){
$status = '278' ;
if ( $rating != '' ){
$status = '201' ;
$select = $mysqli->query( "SELECT task_so, task_type, difficulty, date_end, assigned_by, incentive, incentive2, confirmed_at, updated_at FROM task
WHERE deleted_at IS NULL AND task_id = '".$task_id."' AND ( created_by = '".$staff_info['staff_id']."' ) AND status = 'confirmed' LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '212' ;
$row = $select->fetch_assoc() ;
$is_late = 'yes' ;
if ( $row['date_end'] >= $row['confirmed_at'] ){
$is_late = 'no' ;
}
if ( $mysqli->query( "UPDATE task SET
extra = '".$extra."',
rating = '".$rating."',
is_late = '".$is_late."',
status = 'approved'
WHERE task_id = '".$task_id."'" ) ) {
// $earned_assigned = ( $extra ) ;
// $earned_executed = ( $extra ) ;
// if ( $row['date_end'] >= $row['updated_at'] ){
$earned_assigned = ( $row['incentive'] + $extra ) ;
$earned_executed = ( $row['incentive2'] + $extra ) ;
// }
$remark1 = 'Earn point from task ' . $row['task_so'] ;
$remark2 = 'Earn incentive from task ' . $row['task_so'] ;
if ( $row['assigned_by'] > 0 ){
pointMovement( 'task', $task_id, $rating, 'normal', $row['assigned_by'], '0', $remark1 ) ;
pointMovement( 'task', $task_id, $row['task_type'], $row['difficulty'], $row['assigned_by'], $earned_assigned, $remark2 ) ;
}
// joinstaff earn point
$select_joinstaff = $mysqli->query( "SELECT staff_id FROM task_joinstaff
WHERE task_id = '".$task_id."'" ) ;
if ( $select_joinstaff->num_rows > 0 ){
while ( $row_joinstaff = $select_joinstaff->fetch_assoc() ){
pointMovement( 'task', $task_id, $rating, 'normal', $row_joinstaff['staff_id'], '0', $remark1 ) ;
pointMovement( 'task', $task_id, $row['task_type'], $row['difficulty'], $row_joinstaff['staff_id'], $earned_executed, $remark2 ) ;
}
}
$status = '200' ;
// push to notification
$related_staffid = getTaskRelatedStaff( $task_id, $row['created_by'], $row['assigned_by'] ) ;
foreach ( $related_staffid as $k => $v ){
pushToUserCron( 'task', $task_id, $v, 'Task Approved', 'Task ( '.$row['task_so'].' ) has been approved' ) ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+85
View File
@@ -0,0 +1,85 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$task_id = $array['task_id'] ;
$incentive2 = $array['incentive2'] ;
$assigned_to = $array['assigned_to'] ;
$joinstaffs = ( checkExists( $array['joinstaffs'] ) ? $array['joinstaffs'] : [] ) ;
if ( $task_id != '' && count( $joinstaffs ) > 0 ){
$status = '303' ;
$staff_tier = [] ;
$staff_tier = getRelatedTierID( 'no', $staff_info['staff_tier_level'] ) ;
$related_staffs = [] ;
if ( count( $joinstaffs ) > 0 ){
foreach ( $joinstaffs as $k => $v ){
$related_staffs[] = $v['id'] ;
}
}
$select_staff = $mysqli->query( "SELECT a.staff_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_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL ) AND staff_id IN ( '".implode("', '", $related_staffs)."' ) AND staff_tier IN ( '".implode("', '", $staff_tier)."' )" ) ;
if ( $select_staff->num_rows == count( $related_staffs ) ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM task a
WHERE a.deleted_at IS NULL AND a.task_id = '".$task_id."' AND ( a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 ) ) AND a.status IN ( 'pending', 'assigned', 'resubmit', 'progress' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '212' ;
$row = $select->fetch_assoc() ;
// get all task
$update_status = 'assigned' ;
$count_todo_done = 0 ;
$select_task_todo = $mysqli->query( "SELECT is_done FROM task_todo
WHERE deleted_at IS NULL AND task_id = '".$task_id."'" ) ;
if ( $select_task_todo->num_rows > 0 ){
while ( $row_todo = $select_task_todo->fetch_assoc() ){
if ( $row_todo['is_done'] == 'yes' ){
$count_todo_done++ ;
}
}
}
if ( $count_todo_done > 0 ){
$update_status = 'progress' ;
}
if ( $mysqli->query( "UPDATE task SET
incentive2 = '".$incentive2."',
status = '".$update_status."'
WHERE task_id = '".$task_id."'" ) ) {
$status = '200' ;
// deleted all related staff
$mysqli->query( "DELETE FROM `task_joinstaff` WHERE task_id = '".$task_id."'" ) ;
if ( checkExists($joinstaffs) ){
foreach ( $joinstaffs as $k => $v ){
$mysqli->query( "INSERT INTO `task_joinstaff` ( `task_id`, `staff_id` ) VALUES ( '".$task_id."', '".$v['id']."' )" ) ;
}
}
// push to notification
$related_staffid = getTaskRelatedStaff( $task_id, $row['created_by'], $row['assigned_by'] ) ;
foreach ( $related_staffid as $k => $v ){
pushToUserCron( 'task', $task_id, $v, 'Task Assign', 'Task ( '.$row['task_so'].' ) has been assigned' ) ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+45
View File
@@ -0,0 +1,45 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$task_id = $array['task_id'] ;
$reason = $array['reason'] ;
if ( $task_id != '' && $reason != '' ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM task a
WHERE a.deleted_at IS NULL AND a.task_id = '".$task_id."' AND a.created_by = '".$staff_info['staff_id']."' AND a.status IN ( 'pending', 'assigned', 'resubmit', 'progress', 'completed', 'confirmed' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '303' ;
$row = $select->fetch_assoc() ;
if ( $mysqli->query( "UPDATE task SET
status = 'cancelled'
WHERE task_id = '".$task_id."'" ) ) {
$mysqli->query( "INSERT INTO task_rejected
( `task_id`, `staff_id`, `remark` ) VALUES
( '".$task_id."', '".$staff_info['staff_id']."', '".$reason."' )" ) ;
$status = '200' ;
// push to notification
$related_staffid = getTaskRelatedStaff( $task_id, $row['created_by'], $row['assigned_by'] ) ;
foreach ( $related_staffid as $k => $v ){
pushToUserCron( 'task', $task_id, $v, 'Task Cancelled', 'Task ( '.$row['task_so'].' ) has been cancelled' ) ;
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+140
View File
@@ -0,0 +1,140 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '200' ;
$staffs = [] ;
$departments = [] ;
$staff_departments = [] ;
$difficultys = [] ;
$all_tier = getAllTier( $array['lang'] ) ;
// select all staff
$select = $mysqli->query( "SELECT a.staff_id, a.staff_idno, a.staff_name, a.staff_shortname, a.staff_tier FROM staff a
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' 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() ){
$get_staff_tier = $all_tier[$row['staff_tier']] ;
$staffs[$row['staff_id']] = [
'id' => $row['staff_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 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[$row['department_id']][] = $staff ;
}
}
}
// reset
$reset_departments[] = [
'id' => '0',
'title' => 'Cross Department',
'staffs' => []
] ;
foreach ( $departments as $k => $v ){
if ( $staff_departments[$v['department_id']] != null && $staff_departments[$v['department_id']] != undefined ){
$reset_departments[] = [
'id' => $v['department_id'],
'title' => $v['department_desc'],
'staffs' => $staff_departments[$v['department_id']]
] ;
}
}
$task_types = [
[
'id' => '1time',
'title' => 'One Time Only'
],
[
'id' => 'daily',
'title' => 'Daily Update'
],
[
'id' => 'weekly',
'title' => 'Weekly Update'
],
[
'id' => 'monthly',
'title' => 'Monthly Update'
],
[
'id' => 'yearly',
'title' => 'Yearly Update'
]
] ;
// select all department
$select = $mysqli->query( "SELECT a.code, b.title FROM setting_difficulty a
LEFT JOIN setting_difficulty_translation b ON ( a.difficulty_id = b.difficulty_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND set_tier LIKE '%|".$staff_info['staff_tier']."|%'
ORDER BY a.sortable" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$difficultys[] = [
'id' => $row['code'],
'title' => $row['title'],
] ;
}
}
$data = [
'task_types' => $task_types,
'departments' => $reset_departments,
'difficultys' => $difficultys
] ;
}
require( $require_sub.'footer.php' ) ;
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$task_id = $array['task_id'] ;
if ( $task_id != '' ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM task a
WHERE a.deleted_at IS NULL AND a.task_id = '".$task_id."' AND ( a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 ) ) AND a.status IN ( 'completed' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '212' ;
$row = $select->fetch_assoc() ;
if ( $mysqli->query( "UPDATE task SET
status = 'confirmed',
confirmed_at = '".TODAYDATE."'
WHERE task_id = '".$task_id."'" ) ) {
$status = '200' ;
// push to notification
$related_staffid = getTaskRelatedStaff( $task_id, $row['created_by'], $row['assigned_by'] ) ;
foreach ( $related_staffid as $k => $v ){
pushToUserCron( 'task', $task_id, $v, 'Task Confirmed', 'Task ( '.$row['task_so'].' ) has been confirmed' ) ;
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+128
View File
@@ -0,0 +1,128 @@
<?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" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$staff_list[$row['staff_id']] = $row['staff_name'] . ' ( '.$row['staff_idno'].' )' ;
}
}
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND a.title LIKE '%".$array['search']."%'" ;
}
if ( $array['searchstatus'] != '' ){
// $search_query .= " AND a.status = '".$array['searchstatus']."'" ;
$search_status = [] ;
switch ( $array['searchstatus'] ){
case 'approved' :
$search_status = [ 'approved' ] ;
break ;
case 'rejected' :
$search_status = [ 'rejected' ] ;
break ;
default :
$search_status = [ 'pending', 'assigned', 'resubmit', 'progress', 'completed', 'confirmed' ] ;
}
$search_query .= " AND a.status IN ( '".implode("', '", $search_status)."' )" ;
}else{
$search_query .= " AND a.status != 'rejected'" ;
}
switch ( $array['searchincharge'] ){
case 'create' :
$search_query .= " AND a.created_by = '".$staff_info['staff_id']."'" ;
break ;
case 'assign' :
$search_query .= " AND a.assigned_by = '".$staff_info['staff_id']."'" ;
break ;
case 'execute' :
$search_query .= " AND EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 )" ;
break ;
}
$query = "SELECT a.task_id, a.task_type, a.title, a.department_id, a.created_by, a.assigned_by, a.difficulty, a.date_start, a.date_end, a.remark, a.todo_list, a.todo_done, a.status, a.created_at, a.updated_at FROM task a
WHERE a.deleted_at IS NULL AND ( a.created_branch_id = '".$array['branch_id']."' AND a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 ) ) " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$task_ids = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$task_type_name = '' ;
switch ( $row['task_type'] ){
case '1time' : $task_type_name = 'One Time Only' ; break ;
case 'daily' : $task_type_name = 'Daily Update' ; break ;
case 'weekly' : $task_type_name = 'Weekly Update' ; break ;
case 'monthly' : $task_type_name = 'Monthly Update' ; break ;
case 'yearly' : $task_type_name = 'Yearly Update' ; break ;
}
$row['title'] = dataFilter( $row['title'] ) ;
$row['task_type_name'] = $task_type_name ;
$row['expired'] = strtotime( $row['date_end'] ) ;
$row['is_warning'] = ( $row['date_end'] == TODAYDAY ? 'yes' : 'no' ) ;
$row['department'] = ( checkExists( $department_list[ $row['department_id'] ] ) ? $department_list[ $row['department_id'] ] : 'Cross Department' ) ;
$row['created_by_name'] = $staff_list[ $row['created_by'] ] ;
$row['assigned_by_name'] = checkExists( $staff_list[ $row['assigned_by'] ] ) ;
$row['progress'] = ( $row['todo_done'] > 0 ? ( numberFormat( ( $row['todo_done'] / $row['todo_list'] * 100 ), 2 ) + 0 ) : 0 ) ;
$list[$row['task_id']] = $row ;
$task_ids[] = $row['task_id'] ;
}
// join staff
$query_joinstaff = $mysqli->query( "SELECT * FROM task_joinstaff
WHERE task_id IN ( ".implode(', ', $task_ids)." )" ) ;
$joinstaffs = [] ;
if ( $query_joinstaff->num_rows > 0 ){
while ( $row_joinstaff = $query_joinstaff->fetch_assoc() ){
$joinstaffs[$row_joinstaff['task_id']][] = $staff_list[ $row_joinstaff['staff_id'] ] ;
}
}
// reset list
$new_list = [] ;
foreach ( $list as $k => $v ){
$assigned_by_name = ( checkExists( $joinstaffs[$v['task_id']] ) ? implode( ', ', $joinstaffs[$v['task_id']] ) : $v['assigned_by_name'] ) ;
$v['assigned_by_name'] = $assigned_by_name ;
$new_list[] = $v ;
}
$data['list'] = $new_list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+92
View File
@@ -0,0 +1,92 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$task_id = $array['task_id'] ;
$todo_list = $array['todo_list'] ;
if ( $task_id != '' && count( $todo_list ) > 0 ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM task a
WHERE a.deleted_at IS NULL AND a.task_id = '".$task_id."' AND ( a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 ) ) AND a.status IN ( 'pending', 'assigned', 'resubmit', 'progress', 'completed' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '202' ;
$row = $select->fetch_assoc() ;
$count_todo_list = 0 ;
$count_todo_done = 0 ;
if ( checkExists($array['todo_list']) ){
foreach ( $array['todo_list'] as $k => $v ){
if ( $v['is_delete'] == 'no' ){
$count_todo_list++ ;
if ( $v['is_done'] == 'yes' ){
$count_todo_done++ ;
}
}
}
}
if ( checkExists($array['todo_list']) ){
foreach ( $array['todo_list'] as $k => $v ){
if ( $v['is_delete'] == 'no' ){
if ( $v['id'] > 0 ){
$mysqli->query( "UPDATE task_todo SET
title = '".$v['title']."',
sortable = '".$v['sortable']."'
WHERE todo_id = '".$v['id']."'" ) ;
}else{
$mysqli->query( "INSERT INTO task_todo
( `task_id`, `title`, `sortable` ) VALUES
( '".$task_id."', '".$v['title']."', '".$v['sortable']."' )" ) ;
}
}else{
if ( $v['id'] > 0 ){
$mysqli->query( "UPDATE task_todo SET
deleted_at = '".TODAYDATE."'
WHERE todo_id = '".$v['id']."'" ) ;
}
}
}
}
$update_status = 'pending' ;
if ( $row['assigned_by'] > 0 ){
$update_status = 'assigned' ;
}
if ( $count_todo_done > 0 ){
$update_status = 'progress' ;
}
if ( $count_todo_list == $count_todo_done ){
$update_status = 'completed' ;
}
if ( $mysqli->query( "UPDATE task SET
status = '".$update_status."',
todo_list = '".$count_todo_list."',
todo_done = '".$count_todo_done."'
WHERE task_id = '".$task_id."'" ) ) {
$status = '200' ;
// push to notification
$related_staffid = getTaskRelatedStaff( $task_id, $row['created_by'], $row['assigned_by'] ) ;
foreach ( $related_staffid as $k => $v ){
pushToUserCron( 'task', $task_id, $v, 'Task Todo', 'Task ( '.$row['task_so'].' ) todo has been updated' ) ;
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+36
View File
@@ -0,0 +1,36 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$task_id = $array['task_id'] ;
$reason = $array['reason'] ;
if ( $task_id != '' && $reason != '' ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM task a
WHERE a.deleted_at IS NULL AND a.task_id = '".$task_id."' AND ( a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 ) ) AND a.status IN ( 'pending', 'assigned' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '212' ;
if ( $mysqli->query( "UPDATE task SET
status = 'rejected',
rejected_at = '".TODAYDATE."',
rejected_by = '".$staff_info['staff_id']."',
rejected_reason = '".$reason."'
WHERE task_id = '".$task_id."'" ) ) {
$status = '200' ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+66
View File
@@ -0,0 +1,66 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$task_id = $array['task_id'] ;
$reason = $array['reason'] ;
if ( $task_id != '' && $reason != '' ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM task a
WHERE a.deleted_at IS NULL AND a.task_id = '".$task_id."' AND ( a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 ) ) AND a.status IN ( 'pending', 'assigned', 'completed', 'confirmed' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '303' ;
$row = $select->fetch_assoc() ;
$update_status = '' ;
if ( $row['status'] == 'confirmed' ){
if ( $row['created_by'] == $staff_info['staff_id'] ){
$update_status = 'resubmit' ;
}
}else{
$update_status = 'rejected' ;
}
if ( $update_status != '' ){
$status = '202' ;
if ( $mysqli->query( "UPDATE task SET
todo_done = '0',
status = '".$update_status."'
WHERE task_id = '".$task_id."'" ) ) {
$mysqli->query( "INSERT INTO task_rejected
( `task_id`, `staff_id`, `remark` ) VALUES
( '".$task_id."', '".$staff_info['staff_id']."', '".$reason."' )" ) ;
if ( $update_status == 'resubmit' ){
$mysqli->query( "UPDATE task_todo SET
is_done = 'no'
WHERE task_id = '".$task_id."'" ) ;
}
$status = '200' ;
// push to notification
$related_staffid = getTaskRelatedStaff( $task_id, $row['created_by'], $row['assigned_by'] ) ;
foreach ( $related_staffid as $k => $v ){
pushToUserCron( 'task', $task_id, $v, 'Task Rejected', 'Task ( '.$row['task_so'].' ) has been rejected' ) ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+67
View File
@@ -0,0 +1,67 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$task_id = $array['task_id'] ;
$todo_id = $array['todo_id'] ;
$remark_list = $array['remark_list'] ;
if ( $task_id != '' && $todo_id != '' && count( $remark_list ) > 0 ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM task a
WHERE a.deleted_at IS NULL AND a.task_id = '".$task_id."' AND ( a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 ) ) AND a.status IN ( 'pending', 'assigned', 'resubmit', 'progress', 'completed' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$row = $select->fetch_assoc() ;
// check if selected todo exists
$select_todo = $mysqli->query( "SELECT * FROM task_todo
WHERE deleted_at IS NULL AND task_id = '".$task_id."' AND todo_id = '".$todo_id."' LIMIT 1" ) ;
if ( $select_todo->num_rows > 0 ){
$status = '202' ;
if ( checkExists($array['remark_list']) ){
foreach ( $array['remark_list'] as $k => $v ){
if ( $v['is_delete'] == 'no' ){
if ( $v['id'] > 0 ){
$mysqli->query( "UPDATE task_todo_remark SET
title = '".$v['title']."'
WHERE remark_id = '".$v['id']."'" ) ;
}else{
$mysqli->query( "INSERT INTO task_todo_remark
( `task_id`, `todo_id`, `staff_id`, `title` ) VALUES
( '".$task_id."', '".$todo_id."', '".$staff_info['staff_id']."', '".$v['title']."' )" ) ;
}
}else{
if ( $v['id'] > 0 ){
$mysqli->query( "UPDATE task_todo_remark SET
deleted_at = '".TODAYDATE."'
WHERE remark_id = '".$v['id']."'" ) ;
}
}
}
$status = '200' ;
// push to notification
$related_staffid = getTaskRelatedStaff( $task_id, $row['created_by'], $row['assigned_by'] ) ;
foreach ( $related_staffid as $k => $v ){
pushToUserCron( 'task', $task_id, $v, 'Task Remark', 'Task ( '.$row['task_so'].' ) remark updated' ) ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+351
View File
@@ -0,0 +1,351 @@
<?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'] ;
// select all month
$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 ; }
// select all department
$departments = [ '0' => $months ] ;
$departments_name = [ '0' => $lang['Cross Department'] ] ;
$select_departments = $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_departments->num_rows > 0 ){
while ( $row_departments = $select_departments->fetch_assoc() ){
$departments[$row_departments['department_id']] = $months ;
$departments_name[$row_departments['department_id']] = $row_departments['department_desc'] ;
}
}
// monthly report = by personal or whole branch
$array_report = [
'personal' => [
// 'late' => [
// 'name' => $lang['On Time Or Delayed Report'],
// 'subname' => $months_name,
// 'sub' => [
// 'no' => [ 'name' => $lang['On Time'], 'lists' => $months ],
// 'yes' => [ 'name' => $lang['Delayed'], 'lists' => $months ]
// ]
// ],
'complete' => [
'name' => $lang['Completed Or Incompleted Report'],
'subname' => $months_name,
'sub' => [
'yes' => [ 'name' => $lang['Completed'], 'lists' => $months ],
'no' => [ 'name' => $lang['Incompleted'], 'lists' => $months ],
'cancel' => [ 'name' => $lang['Cancelled'], 'lists' => $months ]
]
],
'department' => [
'name' => $lang['Department Task Given Report'],
'subname' => $months_name,
'sub' => $departments
]
]
] ;
if ( $staff_settings['reporttaskbranch'] == 'yes' ){
$array_report['branch'] = [
// 'late' => [
// 'name' => $lang['On Time Or Delayed Report'],
// 'subname' => $months_name,
// 'sub' => [
// 'no' => [ 'name' => $lang['On Time'], 'lists' => $months ],
// 'yes' => [ 'name' => $lang['Delayed'], 'lists' => $months ]
// ]
// ],
'complete' => [
'name' => $lang['Completed Or Incompleted Report'],
'subname' => $months_name,
'sub' => [
'yes' => [ 'name' => $lang['Completed'], 'lists' => $months ],
'no' => [ 'name' => $lang['Incompleted'], 'lists' => $months ],
'cancel' => [ 'name' => $lang['Cancelled'], 'lists' => $months ]
]
],
'department' => [
'name' => $lang['Department Task Given Report'],
'subname' => $months_name,
'sub' => $departments
]
] ;
}
$filtertype = [] ;
foreach ( $array_report as $k => $v ){
if ( $k == $search_type ){
$filtertype[] = $k ;
}
}
foreach ( $filtertype as $k => $v ){
$search_query = " AND ( a.created_branch_id = '".$array['branch_id']."' XXXXXX )" ;
switch ( $v ){
case 'personal' :
$search_query = str_replace( 'XXXXXX', " AND a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 )", $search_query ) ;
break ;
case 'branch' :
$search_query = str_replace( 'XXXXXX', '', $search_query ) ;
break ;
}
// late report
// $select_task = $mysqli->query( "SELECT COUNT(a.is_late) as total, a.is_late, MONTH(a.confirmed_at) as month FROM task a
// WHERE a.deleted_at IS NULL AND a.status = 'approved' AND a.confirmed_at LIKE '%".$search_year."%' ".$search_query."
// GROUP BY a.is_late, MONTH(a.confirmed_at)" ) ;
// if ( $select_task->num_rows > 0 ){
// while ( $row_task = $select_task->fetch_assoc() ){
// $array_report[$v]['late']['sub'][$row_task['is_late']]['lists'][$row_task['month']] = $row_task['total'] ;
// }
// }
// complete report
$select_task = $mysqli->query( "SELECT COUNT(a.status) as total, MONTH(a.created_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status IN ( 'approved' ) AND a.created_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY MONTH(a.created_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['complete']['sub']['yes']['lists'][$row_task['month']] = $row_task['total'] ;
}
}
// incomplete report
$select_task = $mysqli->query( "SELECT COUNT(a.status) as total, MONTH(a.created_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status IN ( 'pending','assigned','resubmit','progress','completed','confirmed' ) AND a.created_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY MONTH(a.created_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['complete']['sub']['no']['lists'][$row_task['month']] = $row_task['total'] ;
}
}
// cancel report
$select_task = $mysqli->query( "SELECT COUNT(a.status) as total, MONTH(a.created_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status IN ( 'rejected', 'cancelled' ) AND a.created_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY MONTH(a.created_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['complete']['sub']['cancel']['lists'][$row_task['month']] = $row_task['total'] ;
}
}
// department complete report
$select_task = $mysqli->query( "SELECT COUNT(a.department_id) as total, a.department_id, MONTH(a.confirmed_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status IN ( 'approved' ) AND a.confirmed_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY a.department_id, MONTH(a.confirmed_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['department']['sub'][$row_task['department_id']][$row_task['month']] = $row_task['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 ){
foreach ( $vreport as $ktype => $vtype ){
$title = $vtype['name'] ;
$titlename = $title.' ( '.$lang['Year'].' '.$search_year.' )' ;
$idname = 'myChart_'.$kreport.'_'.$ktype ;
$ctxname = 'ctx_'.$idname ;
$configname = 'config_'.$idname ;
$datasets = [] ;
switch ( $ktype ){
case 'late' :
case 'complete' :
foreach ( $vtype['sub'] as $ksub => $vsub ){
$temp = [] ;
foreach ( $vsub['lists'] as $klist => $vlist ){
$temp[] = "$vlist" ;
}
$datasets[] = [
'label' => $vsub['name'],
'data' => $temp
] ;
}
$html .= '
<div class="report_chart_line">
<canvas id="'.$idname.'"></canvas>
</div>
<script>
const '.$ctxname.' = document.getElementById("'.$idname.'") ;
const '.$configname.' = {
type : "line",
data : {
datasets : '.json_encode($datasets).',
labels : [ "'.implode( '", "', $vtype['subname'] ).'" ]
},
options: {
responsive : true,
maintainAspectRatio : false,
plugins : {
legend : {
position : "top",
},
title : {
display : true,
text : "'.$titlename.'"
}
}
}
} ;
new Chart( '.$ctxname.', '.$configname.' ) ;
</script>' ;
break ;
case 'department' :
foreach ( $departments_name as $kdepartment => $vdepartment ){
$temp = [] ;
foreach ( $vtype['sub'][$kdepartment] as $klist => $vlist ){
$temp[] = "$vlist" ;
}
$datasets[] = [
'label' => $vdepartment,
'data' => $temp
] ;
}
$html .= '
<div class="report_chart_bar">
<canvas id="'.$idname.'"></canvas>
</div>
<script>
const '.$ctxname.' = document.getElementById("'.$idname.'") ;
const '.$configname.' = {
type : "bar",
data : {
datasets : '.json_encode($datasets).',
labels : [ "'.implode( '", "', $vtype['subname'] ).'" ]
},
options: {
responsive : true,
maintainAspectRatio : false,
elements : {
bar : {
borderWidth : 2
}
},
indexAxis : "y",
plugins : {
legend : {
position : "top",
align : "left"
},
title : {
display : true,
text : "'.$titlename.'"
}
}
}
} ;
new Chart( '.$ctxname.', '.$configname.' ) ;
</script>' ;
break ;
}
}
}
}
$html .= '
</div>
</body>
</html>' ;
}
}
if ( $array['iswebview'] == 'yes' ){
echo $html ;
exit ;
}
require( $require_sub.'footer.php' ) ;
?>
+248
View File
@@ -0,0 +1,248 @@
<?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' => [
'late' => [
'name' => $lang['On Time Or Delayed Report'],
'subname' => $months_name,
'sub' => [
'no' => [ 'name' => $lang['On Time'], 'months' => $months ],
'yes' => [ 'name' => $lang['Delayed'], 'months' => $months ]
]
],
'complete' => [
'name' => $lang['Completed Or Incompleted Report'],
'subname' => $months_name,
'sub' => [
'yes' => [ 'name' => $lang['Completed'], 'months' => $months ],
'no' => [ 'name' => $lang['Incompleted'], 'months' => $months ],
'cancel' => [ 'name' => $lang['Cancelled'], 'months' => $months ]
]
]
]
] ;
if ( $staff_settings['reporttaskbranch'] == 'yes' ){
$array_report['branch'] = [
'late' => [
'name' => $lang['On Time Or Delayed Report'],
'subname' => $months_name,
'sub' => [
'no' => [ 'name' => $lang['On Time'], 'months' => $months ],
'yes' => [ 'name' => $lang['Delayed'], 'months' => $months ]
]
],
'complete' => [
'name' => $lang['Completed Or Incompleted Report'],
'subname' => $months_name,
'sub' => [
'yes' => [ 'name' => $lang['Completed'], 'months' => $months ],
'no' => [ 'name' => $lang['Incompleted'], 'months' => $months ],
'cancel' => [ 'name' => $lang['Cancelled'], 'months' => $months ]
]
],
] ;
}
$filtertype = [] ;
foreach ( $array_report as $k => $v ){
if ( $k == $search_type ){
$filtertype[] = $k ;
}
}
foreach ( $filtertype as $k => $v ){
$search_query = " AND ( a.created_branch_id = '".$array['branch_id']."' XXXXXX )" ;
switch ( $v ){
case 'personal' :
$search_query = str_replace( 'XXXXXX', " AND a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 )", $search_query ) ;
break ;
case 'branch' :
$search_query = str_replace( 'XXXXXX', '', $search_query ) ;
break ;
}
// late report
$select_task = $mysqli->query( "SELECT COUNT(a.is_late) as total, a.is_late, MONTH(a.confirmed_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status = 'approved' AND a.confirmed_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY a.is_late, MONTH(a.confirmed_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['late']['sub'][$row_task['is_late']]['months'][$row_task['month']] = $row_task['total'] ;
}
}
// complete report
$select_task = $mysqli->query( "SELECT COUNT(a.status) as total, MONTH(a.created_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status IN ( 'approved' ) AND a.created_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY MONTH(a.created_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['complete']['sub']['yes']['months'][$row_task['month']] = $row_task['total'] ;
}
}
// incomplete report
$select_task = $mysqli->query( "SELECT COUNT(a.status) as total, MONTH(a.created_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status IN ( 'pending','assigned','resubmit','progress','completed','confirmed' ) AND a.created_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY MONTH(a.created_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['complete']['sub']['no']['months'][$row_task['month']] = $row_task['total'] ;
}
}
// cancel report
$select_task = $mysqli->query( "SELECT COUNT(a.status) as total, MONTH(a.created_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status IN ( 'rejected', 'cancelled' ) AND a.created_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY MONTH(a.created_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['complete']['sub']['cancel']['months'][$row_task['month']] = $row_task['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 ){
foreach ( $vreport as $ktype => $vtype ){
$title = $vtype['name'] ;
$titlename = $title.' ( '.$lang['Year'].' '.$search_year.' )' ;
$idname = 'myChart_'.$kreport.'_'.$ktype ;
$ctxname = 'ctx_'.$idname ;
$configname = 'config_'.$idname ;
$datasets = [] ;
foreach ( $vtype['sub'] as $ksub => $vsub ){
$temp = [] ;
foreach ( $vsub['months'] as $kmonth => $vmonth ){
$temp[] = $vmonth ;
}
$datasets[] = [
'label' => $vsub['name'],
'data' => $temp
] ;
}
$html .= '
<div class="report_chart_line">
<canvas id="'.$idname.'"></canvas>
</div>
<script>
const '.$ctxname.' = document.getElementById("'.$idname.'") ;
const '.$configname.' = {
type : "line",
data : {
datasets : '.json_encode($datasets).',
labels : [ "'.implode( '", "', $vtype['subname'] ).'" ]
},
options: {
responsive : true,
maintainAspectRatio : false,
plugins : {
legend : {
position : "top",
},
title : {
display : true,
text : "'.$titlename.'"
}
}
}
} ;
new Chart( '.$ctxname.', '.$configname.' ) ;
</script>' ;
}
}
}
$html .= '
</div>
</body>
</html>' ;
}
}
if ( $array['iswebview'] == 'yes' ){
echo $html ;
exit ;
}
require( $require_sub.'footer.php' ) ;
?>
+361
View File
@@ -0,0 +1,361 @@
<?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'] ;
// select all month
$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 ; }
// select all department
$departments = [ '0' => $months ] ;
$departments_name = [ '0' => [ 'desc' => $lang['Cross Department'], 'colour' => '#EB5406' ] ] ;
$select_departments = $mysqli->query( "SELECT a.department_id, a.department_colour, 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_departments->num_rows > 0 ){
while ( $row_departments = $select_departments->fetch_assoc() ){
$departments[$row_departments['department_id']] = $months ;
$departments_name[$row_departments['department_id']] = [
'desc' => dataFilter( $row_departments['department_desc'] ),
'colour' => $row_departments['department_colour']
] ;
}
}
// monthly report = by personal or whole branch
$array_report = [
'personal' => [
// 'late' => [
// 'name' => $lang['On Time Or Delayed Report'],
// 'subname' => $months_name,
// 'sub' => [
// 'no' => [ 'name' => $lang['On Time'], 'lists' => $months ],
// 'yes' => [ 'name' => $lang['Delayed'], 'lists' => $months ]
// ]
// ],
'complete' => [
'name' => $lang['Completed Or Incompleted Report'],
'subname' => $months_name,
'sub' => [
'yes' => [ 'name' => $lang['Completed'], 'lists' => $months ],
'no' => [ 'name' => $lang['Incompleted'], 'lists' => $months ],
'cancel' => [ 'name' => $lang['Cancelled'], 'lists' => $months ]
]
],
'department' => [
'name' => $lang['Department Task Given Report'],
'subname' => $months_name,
'sub' => $departments
]
]
] ;
if ( $staff_settings['reporttaskbranch'] == 'yes' ){
$array_report['branch'] = [
// 'late' => [
// 'name' => $lang['On Time Or Delayed Report'],
// 'subname' => $months_name,
// 'sub' => [
// 'no' => [ 'name' => $lang['On Time'], 'lists' => $months ],
// 'yes' => [ 'name' => $lang['Delayed'], 'lists' => $months ]
// ]
// ],
'complete' => [
'name' => $lang['Completed Or Incompleted Report'],
'subname' => $months_name,
'sub' => [
'yes' => [ 'name' => $lang['Completed'], 'lists' => $months ],
'no' => [ 'name' => $lang['Incompleted'], 'lists' => $months ],
'cancel' => [ 'name' => $lang['Cancelled'], 'lists' => $months ]
]
],
'department' => [
'name' => $lang['Department Task Given Report'],
'subname' => $months_name,
'sub' => $departments
]
] ;
}
$filtertype = [] ;
foreach ( $array_report as $k => $v ){
if ( $k == $search_type ){
$filtertype[] = $k ;
}
}
foreach ( $filtertype as $k => $v ){
$search_query = " AND ( a.created_branch_id = '".$array['branch_id']."' XXXXXX )" ;
switch ( $v ){
case 'personal' :
$search_query = str_replace( 'XXXXXX', " AND a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 )", $search_query ) ;
break ;
case 'branch' :
$search_query = str_replace( 'XXXXXX', '', $search_query ) ;
break ;
}
// late report
// $select_task = $mysqli->query( "SELECT COUNT(a.is_late) as total, a.is_late, MONTH(a.confirmed_at) as month FROM task a
// WHERE a.deleted_at IS NULL AND a.status = 'approved' AND a.confirmed_at LIKE '%".$search_year."%' ".$search_query."
// GROUP BY a.is_late, MONTH(a.confirmed_at)" ) ;
// if ( $select_task->num_rows > 0 ){
// while ( $row_task = $select_task->fetch_assoc() ){
// $array_report[$v]['late']['sub'][$row_task['is_late']]['lists'][$row_task['month']] = $row_task['total'] ;
// }
// }
// complete report
$select_task = $mysqli->query( "SELECT COUNT(a.status) as total, MONTH(a.created_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status IN ( 'approved' ) AND a.created_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY MONTH(a.created_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['complete']['sub']['yes']['lists'][$row_task['month']] = $row_task['total'] ;
}
}
// incomplete report
$select_task = $mysqli->query( "SELECT COUNT(a.status) as total, MONTH(a.created_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status IN ( 'pending','assigned','resubmit','progress','completed','confirmed' ) AND a.created_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY MONTH(a.created_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['complete']['sub']['no']['lists'][$row_task['month']] = $row_task['total'] ;
}
}
// cancel report
$select_task = $mysqli->query( "SELECT COUNT(a.status) as total, MONTH(a.created_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status IN ( 'rejected', 'cancelled' ) AND a.created_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY MONTH(a.created_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['complete']['sub']['cancel']['lists'][$row_task['month']] = $row_task['total'] ;
}
}
// department complete report
$select_task = $mysqli->query( "SELECT COUNT(a.department_id) as total, a.department_id, MONTH(a.confirmed_at) as month FROM task a
WHERE a.deleted_at IS NULL AND a.status IN ( 'approved' ) AND a.confirmed_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY a.department_id, MONTH(a.confirmed_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_task = $select_task->fetch_assoc() ){
$array_report[$v]['department']['sub'][$row_task['department_id']][$row_task['month']] = $row_task['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 ){
foreach ( $vreport as $ktype => $vtype ){
$title = $vtype['name'] ;
$titlename = $title.' ( '.$lang['Year'].' '.$search_year.' )' ;
$idname = 'myChart_'.$kreport.'_'.$ktype ;
$ctxname = 'ctx_'.$idname ;
$configname = 'config_'.$idname ;
$datasets = [] ;
switch ( $ktype ){
case 'late' :
case 'complete' :
$count_color = 0 ;
foreach ( $vtype['sub'] as $ksub => $vsub ){
$temp = [] ;
foreach ( $vsub['lists'] as $klist => $vlist ){
$temp[] = "$vlist" ;
}
$datasets[] = [
'label' => $vsub['name'],
'data' => $temp,
'backgroundColor' => $colors[$count_color]
] ;
$count_color++ ;
}
$html .= '
<div class="report_chart_line">
<canvas id="'.$idname.'"></canvas>
</div>
<script>
const '.$ctxname.' = document.getElementById("'.$idname.'") ;
const '.$configname.' = {
type : "line",
data : {
datasets : '.json_encode($datasets).',
labels : [ "'.implode( '", "', $vtype['subname'] ).'" ]
},
options: {
responsive : true,
maintainAspectRatio : false,
plugins : {
legend : {
position : "top",
},
title : {
display : true,
text : "'.$titlename.'"
}
}
}
} ;
new Chart( '.$ctxname.', '.$configname.' ) ;
</script>' ;
break ;
case 'department' :
$count_color = 0 ;
foreach ( $departments_name as $kdepartment => $vdepartment ){
$temp = [] ;
foreach ( $vtype['sub'][$kdepartment] as $klist => $vlist ){
$temp[] = "$vlist" ;
}
$datasets[] = [
'label' => $vdepartment['desc'],
'data' => $temp,
'backgroundColor' => $vdepartment['colour']
] ;
$count_color++ ;
}
$html .= '
<div class="report_chart_bar">
<canvas id="'.$idname.'"></canvas>
</div>
<script>
const '.$ctxname.' = document.getElementById("'.$idname.'") ;
const '.$configname.' = {
type : "bar",
data : {
datasets : '.json_encode($datasets).',
labels : [ "'.implode( '", "', $vtype['subname'] ).'" ]
},
options: {
responsive : true,
maintainAspectRatio : false,
elements : {
bar : {
borderWidth : 2
}
},
indexAxis : "y",
plugins : {
legend : {
position : "top"
},
title : {
display : true,
text : "'.$titlename.'"
}
}
}
} ;
new Chart( '.$ctxname.', '.$configname.' ) ;
</script>' ;
break ;
}
}
}
}
$html .= '
</div>
</body>
</html>' ;
}
}
if ( $array['iswebview'] == 'yes' ){
echo $html ;
exit ;
}
require( $require_sub.'footer.php' ) ;
?>
+240
View File
@@ -0,0 +1,240 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$all_tier = getAllTier( $array['lang'] ) ;
// 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, a.staff_tier FROM staff a
WHERE a.deleted_at IS NULL" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$get_staff_tier = $all_tier[$row['staff_tier']] ;
$staff_list[$row['staff_id']] = $row['staff_shortname'] . ' ( '.$row['staff_idno'].' / '.strtoupper( $get_staff_tier['title'] ).')' ;
}
}
// default parameter
$isupdate = 'no' ;
$iscancel = 'no' ;
$isreject = 'no' ;
$isassigned = 'no' ;
$search_query = '' ;
$search_query .= " AND task_id = '".$array['task_id']."'" ;
$query = "SELECT task_id, task_type, task_so, title, department_id, created_by, assigned_by, difficulty, date_start, date_end, remark, incentive, incentive2, extra, rating, todo_list, todo_done, status, created_at, updated_at FROM task
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$row = $mysqli_query->fetch_assoc() ;
$task_type_name = '' ;
switch ( $row['task_type'] ){
case '1time' : $task_type_name = 'One Time Only' ; break ;
case 'daily' : $task_type_name = 'Daily Update' ; break ;
case 'weekly' : $task_type_name = 'Weekly Update' ; break ;
case 'monthly' : $task_type_name = 'Monthly Update' ; break ;
case 'yearly' : $task_type_name = 'Yearly Update' ; break ;
}
$row['title'] = dataFilter( $row['title'] ) ;
$row['task_type_name'] = $task_type_name ;
$row['expired'] = strtotime( $row['date_end'] . ' 23:59:59' ) ;
$row['is_warning'] = ( $row['date_end'] == TODAYDAY ? 'yes' : 'no' ) ;
$row['department_name'] = checkExists( $department_list[ $row['department_id'] ] ) ;
$row['created_by_name'] = checkExists( $staff_list[ $row['created_by'] ] ) ;
$row['assigned_by_name'] = checkExists( $staff_list[ $row['assigned_by'] ] ) ;
$row['progress'] = ( $row['todo_done'] > $row['todo_list'] ? ( numberFormat( ( $row['todo_done'] / $row['todo_list'] * 100 ), 2 ) + 0 ) : 0 ) ;
// get all joinstaff
$joinstaff_list = [] ;
$select_joinstaff = $mysqli->query( "SELECT staff_id FROM task_joinstaff
WHERE task_id = '".$array['task_id']."'" ) ;
if ( $select_joinstaff->num_rows > 0 ){
while ( $row_joinstaff = $select_joinstaff->fetch_assoc() ){
$joinstaff_list[] = [
'id' => $row_joinstaff['staff_id'],
'title' => $staff_list[ $row_joinstaff['staff_id'] ]
] ;
if ( $row_joinstaff['staff_id'] == $staff_info['staff_id'] ){
$isreject = 'yes' ;
}
}
}
$row['joinstaffs'] = $joinstaff_list ;
// get all todo remark
$todo_remark_list = [] ;
$select_task_todo_remark = $mysqli->query( "SELECT * FROM task_todo_remark
WHERE deleted_at IS NULL AND task_id = '".$array['task_id']."'" ) ;
if ( $select_task_todo_remark->num_rows > 0 ){
while ( $row_todo_remark = $select_task_todo_remark->fetch_assoc() ){
$todo_remark_list[$row_todo_remark['todo_id']][] = [
'id' => $row_todo_remark['remark_id'],
'title' => dataFilter( $row_todo_remark['title'] ),
'is_delete' => 'no'
] ;
}
}
// get all todo task
$todo_list = [] ;
$select_task_todo = $mysqli->query( "SELECT * FROM task_todo
WHERE deleted_at IS NULL AND task_id = '".$array['task_id']."'
ORDER BY sortable ASC, todo_id ASC" ) ;
if ( $select_task_todo->num_rows > 0 ){
while ( $row_todo = $select_task_todo->fetch_assoc() ){
$todo_list[] = [
'id' => $row_todo['todo_id'],
'title' => dataFilter( $row_todo['title'] ),
'is_done' => $row_todo['is_done'],
'done_by' => $row_todo['done_by'],
'done_name' => $staff_list[ $row_todo['done_by'] ],
'done_at' => $row_todo['done_at'],
'is_delete' => 'no',
'remark' => ( checkExists( $todo_remark_list[$row_todo['todo_id']] ) ? $todo_remark_list[$row_todo['todo_id']] : [] )
] ;
}
}
$row['todo_list'] = $todo_list ;
// get all reject
$rejected_list = [] ;
$select_rejected = $mysqli->query( "SELECT * FROM task_rejected
WHERE deleted_at IS NULL AND task_id = '".$array['task_id']."'" ) ;
if ( $select_rejected->num_rows > 0 ){
while ( $row_rejected = $select_rejected->fetch_assoc() ){
$rejected_list[] = [
'id' => $row_rejected['reject_id'],
'title' => dataFilter( $row_rejected['remark'] ),
'staff_name' => $staff_list[ $row_rejected['staff_id'] ],
'created_at' => $row_rejected['created_at']
] ;
}
}
$row['rejected_list'] = $rejected_list ;
// get all media
$select_media = $mysqli->query( "SELECT media_id, file, filetype FROM task_media
WHERE deleted_at IS NULL AND task_id = '".$array['task_id']."' AND todo_id = '".$array['todo_id']."'" ) ;
$photos = [] ;
$attachments = [] ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
switch ( $row_media['filetype'] ){
case 'jpg' :
case 'jpeg' :
case 'png' :
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/Task/b/'.$row_media['file'] : '' )
] ;
break ;
default :
$attachments[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/Task/'.$row_media['file'] : '' )
] ;
}
}
}
$row['photos'] = $photos ;
$row['attachments'] = $attachments ;
// check update permission
// check cancel permission
switch ( $row['status'] ){
case 'pending' :
case 'assigned' :
case 'resubmit' :
case 'progress' :
case 'completed' :
case 'confirmed' :
if ( $row['created_by'] == $staff_info['staff_id'] ){
$isupdate = 'yes' ;
$iscancel = 'yes' ;
}
break ;
}
$row['isupdate'] = $isupdate ;
$row['iscancel'] = $iscancel ;
// check reject permission
switch ( $row['status'] ){
case 'pending' :
case 'assigned' :
case 'resubmit' :
case 'progress' :
case 'completed' :
if ( $row['assigned_by'] == $staff_info['staff_id'] ){
$isreject = 'yes' ;
}
break ;
case 'confirmed' :
if ( $row['created_by'] == $staff_info['staff_id'] ){
$isreject = 'yes' ;
}
break ;
}
$row['isreject'] = $isreject ;
// check assign permission
if ( $staff_info['staff_tier_is_task_assigned'] == 'yes' ){
$isassigned = 'yes' ;
}
$row['isassigned'] = $isassigned ;
$data = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+81
View File
@@ -0,0 +1,81 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$task_id = $array['task_id'] ;
$todo_list = $array['todo_list'] ;
if ( $task_id != '' && count( $todo_list ) > 0 ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM task a
WHERE a.deleted_at IS NULL AND a.task_id = '".$task_id."' AND ( a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 ) ) AND a.status IN ( 'pending', 'assigned', 'resubmit', 'progress', 'completed' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '202' ;
$row = $select->fetch_assoc() ;
$count_todo_list = 0 ;
$count_todo_done = 0 ;
if ( checkExists($array['todo_list']) ){
foreach ( $array['todo_list'] as $k => $v ){
if ( $v['is_delete'] == 'no' ){
$count_todo_list++ ;
if ( $v['is_done'] == 'yes' ){
$count_todo_done++ ;
}
}
}
}
if ( checkExists($array['todo_list']) ){
foreach ( $array['todo_list'] as $k => $v ){
if ( $v['is_done'] == 'yes' ){
$mysqli->query( "UPDATE task_todo SET
is_done = 'yes',
done_by = '".$staff_info['staff_id']."',
done_at = '".TODAYDATE."'
WHERE todo_id = '".$v['id']."' AND is_done = 'no'" ) ;
}
}
}
$update_status = 'pending' ;
if ( $row['assigned_by'] > 0 ){
$update_status = 'assigned' ;
}
if ( $count_todo_done > 0 ){
$update_status = 'progress' ;
}
if ( $count_todo_list == $count_todo_done ){
$update_status = 'completed' ;
}
if ( $mysqli->query( "UPDATE task SET
status = '".$update_status."',
todo_done = '".$count_todo_done."'
WHERE task_id = '".$task_id."'" ) ) {
$status = '200' ;
// push to notification
$related_staffid = getTaskRelatedStaff( $task_id, $row['created_by'], $row['assigned_by'] ) ;
foreach ( $related_staffid as $k => $v ){
pushToUserCron( 'task', $task_id, $v, 'Task Todo', 'Task ( '.$row['task_so'].' ) todo has been updated' ) ;
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+176
View File
@@ -0,0 +1,176 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '303' ;
$boolean_permission = false ;
if ( $staff_info['staff_tier_is_task'] == 'yes' ){
$boolean_permission = true ;
}
if ( $boolean_permission ){
$status = '300' ;
$push_staffid = [] ;
$is_updated = false ;
$task_id = $array['task_id'] ;
$joinstaffs = ( checkExists( $array['joinstaffs'] ) ? $array['joinstaffs'] : [] ) ;
if ( $array['task_type'] != '' && $array['title'] != '' && $array['difficulty'] != '' && $array['department_id'] != '' && $array['date_start'] != '' && $array['date_end'] != '' ){
$status = '260' ;
if ( $array['assigned_by'] > 0 || count( $joinstaffs ) > 0 ){
$status = '303' ;
$staff_tier = [] ;
$staff_tier = getRelatedTierID( 'no', $staff_info['staff_tier_level'] ) ;
$related_staffs = [] ;
if ( $array['assigned_by'] > 0 ){
$related_staffs[$array['assigned_by']] = $array['assigned_by'] ;
}
if ( count( $joinstaffs ) > 0 ){
foreach ( $joinstaffs as $k => $v ){
$related_staffs[$v['id']] = $v['id'] ;
}
}
$select_staff = $mysqli->query( "SELECT a.staff_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_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL ) AND staff_id IN ( '".implode("', '", $related_staffs)."' ) AND staff_tier IN ( '".implode("', '", $staff_tier)."' )" ) ;
if ( $select_staff->num_rows == count( $related_staffs ) ){
$status = '201' ;
$count_todo_list = 0 ;
$count_todo_done = 0 ;
if ( checkExists($array['todo_list']) ){
if ( count($array['todo_list']) > 0 ){
foreach ( $array['todo_list'] as $k => $v ){
if ( $v['is_delete'] == 'no' ){
$count_todo_list++ ;
if ( $v['is_done'] == 'yes' ){
$count_todo_done++ ;
}
}
}
}
}
// check update status
$task_status = 'pending' ;
if ( $array['assigned_by'] > 0 && count( $joinstaffs ) > 0 ){
$task_status = 'assigned' ;
}
// check if task id exsits
$boolean_submit = false ;
if ( $task_id > 0 ){
$select = $mysqli->query( "SELECT * FROM task
WHERE deleted_at IS NULL AND task_id = '".$task_id."' AND created_by = '".$staff_info['staff_id']."' AND status IN ( 'pending', 'assigned', 'resubmit', 'progress', 'completed', 'confirmed' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '202' ;
$row = $select->fetch_assoc() ;
if ( $mysqli->query( "UPDATE task SET
task_type = '".$array['task_type']."',
title = '".$array['title']."',
department_id = '".$array['department_id']."',
assigned_by = '".$array['assigned_by']."',
difficulty = '".$array['difficulty']."',
date_start = '".$array['date_start']."',
date_end = '".$array['date_end']."',
remark = '".$array['remark']."',
incentive = '".$array['incentive']."',
todo_list = '".$count_todo_list."',
todo_done = '".$count_todo_done."'
WHERE task_id = '".$task_id."'" ) ) {
$boolean_submit = true ;
$is_updated = true ;
$push_staffid[$array['assigned_by']] = $array['assigned_by'] ;
}
}
}else{
$status = '203' ;
if ( $mysqli->query( "INSERT INTO task
( `task_type`, `title`, `department_id`, `created_branch_id`, `created_by`, `assigned_by`, `difficulty`, `date_start`, `date_end`, `remark`, `incentive`, `todo_list`, `todo_done`, `status` ) VALUES
( '".$array['task_type']."', '".$array['title']."', '".$array['department_id']."', '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['assigned_by']."', '".$array['difficulty']."', '".$array['date_start']."', '".$array['date_end']."', '".$array['remark']."', '".$array['incentive']."', '".$count_todo_list."', '".$count_todo_done."', '".$task_status."' )" ) ){
$boolean_submit = true ;
$task_id = $mysqli->insert_id ;
$task_so = 'PT'.strPad( 6, $task_id ) ;
$mysqli->query( "UPDATE task SET
task_so = '".$task_so."'
WHERE task_id = '".$task_id."'" ) ;
$push_staffid[$staff_info['staff_id']] = $staff_info['staff_id'] ;
$push_staffid[$array['assigned_by']] = $array['assigned_by'] ;
}
}
if ( $boolean_submit ){
$status = '203' ;
// deleted all related staff
$mysqli->query( "DELETE FROM `task_joinstaff` WHERE task_id = '".$task_id."'" ) ;
if ( checkExists($joinstaffs) ){
foreach ( $joinstaffs as $k => $v ){
$mysqli->query( "INSERT INTO `task_joinstaff` ( `task_id`, `staff_id` ) VALUES ( '".$task_id."', '".$v['id']."' )" ) ;
$push_staffid[$v['id']] = $v['id'] ;
}
}
if ( checkExists($array['todo_list']) ){
if ( count($array['todo_list']) > 0 ){
foreach ( $array['todo_list'] as $k => $v ){
if ( $v['is_delete'] == 'no' ){
if ( $v['id'] > 0 ){
$mysqli->query( "UPDATE task_todo SET title = '".$v['title']."' WHERE todo_id = '".$v['id']."'" ) ;
}else{
$mysqli->query( "INSERT INTO task_todo ( `task_id`, `title`, `sortable` ) VALUES ( '".$task_id."', '".$v['title']."', '9999' )" ) ;
}
}else{
if ( $v['id'] > 0 ){
$mysqli->query( "UPDATE task_todo SET deleted_at = '".TODAYDATE."' WHERE todo_id = '".$v['id']."'" ) ;
}
}
}
}
}
$status = '200' ;
// push to notification
foreach ( $push_staffid as $k => $v ){
if ( $is_updated ){
pushToUserCron( 'task', $task_id, $v, 'Task Updated', 'Task ( '.$row['task_so'].' ) has been updated' ) ;
}else{
pushToUserCron( 'task', $task_id, $v, 'Task Created', 'New task ( '.$task_so.' ) appoint to you' ) ;
}
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+68
View File
@@ -0,0 +1,68 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$task_id = $array['task_id'] ;
$todo_id = $array['todo_id'] ;
$photos = $array['photos'] ;
$attachments = $array['attachments'] ;
if ( $task_id != '' && $todo_id != '' && ( count( $photos ) > 0 || count( $attachments ) > 0 ) ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM task a
WHERE a.deleted_at IS NULL AND a.task_id = '".$task_id."' AND ( a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 ) ) AND a.status IN ( 'pending', 'assigned', 'resubmit', 'progress', 'completed', 'confirmed' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '201' ;
$row = $select->fetch_assoc() ;
$select = $mysqli->query( "SELECT * FROM task_todo
WHERE deleted_at IS NULL AND task_id = '".$task_id."' AND todo_id = '".$todo_id."' LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '205' ;
$row_todo = $select->fetch_assoc() ;
if ( checkExists($photos) || checkExists($attachments) ){
foreach ( [ $photos, $attachments ] as $upload_key => $upload_value ){
foreach ( $upload_value as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'Task', $task_id.'-'.$todo_id, $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO task_media
( task_id, todo_id, file, filetype ) VALUES
( '".$task_id."', '".$todo_id."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
if ( $status == '200' ){
// push to notification
$related_staffid = getTaskRelatedStaff( $task_id, $row['created_by'], $row['assigned_by'] ) ;
foreach ( $related_staffid as $k => $v ){
pushToUserCron( 'task', $task_id, $v, 'Task Uploaded', 'Task ( '.$row['task_so'].' ) file uploaded' ) ;
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+53
View File
@@ -0,0 +1,53 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND training_id = '".$array['id']."'" ;
$query = "SELECT training_id, training_type, date_start, date_end, file, status, created_at FROM training
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '248' ;
$row = $mysqli_query->fetch_assoc() ;
$is_training = 'no' ;
if ( $row['status'] == 'active' ){
if ( $row['training_type'] == 'all' || ( $row['training_type'] == 'date' && $row['date_start'] <= TODAYDAY && $row['date_end'] >= TODAYDAY ) ){
$is_training = 'yes' ;
}
}
if ( $is_training == 'yes' ){
$status = '254' ;
$staff_training = $mysqli->query( "SELECT * FROM staff_training
WHERE deleted_at IS NULL AND training_id = '".$array['id']."' AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' LIMIT 1" ) ;
if ( $staff_training->num_rows == 0 ){
$status = '200' ;
$mysqli->query( "INSERT INTO staff_training
( training_id, branch_id, staff_id, status ) VALUES
( '".$array['id']."', '".$array['branch_id']."', '".$staff_info['staff_id']."', 'pending' ) " ) ;
$view_id = $mysqli->insert_id ;
$training_so = 'TN'.strPad( 6, $view_id ) ;
$mysqli->query( "UPDATE staff_training SET training_so = '".$training_so."' WHERE view_id = '".$view_id."'" ) ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+60
View File
@@ -0,0 +1,60 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.training_id = '".$array['id']."'" ;
$join_filter = "" ;
$join_query = "" ;
if ( $array['mode'] == 'view' ){
$join_filter .= ", c.training_so, c.status as training_status, c.remark as training_remark, c.rated as training_rated, c.comment as training_comment" ;
$join_query .= " LEFT JOIN staff_training c ON ( a.training_id = c.training_id )" ;
$search_query .= " AND c.view_id = '".$array['view_id']."' AND c.staff_id = '".$staff_info['staff_id']."'" ;
}
$query = "SELECT a.training_id, a.training_type, a.date_start, a.date_end, a.file, a.status, a.created_at, b.title, b.content ".$join_filter." FROM training a
LEFT JOIN training_translation b ON ( a.training_id = b.training_id )
".$join_query."
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$generatecode = generateQrcode( '', $row['training_so'], $row['training_so'] ) ;
$row = $mysqli_query->fetch_assoc() ;
$row['id'] = dataFilter( $row['training_id'] ) ;
$row['sonumber'] = dataFilter( $row['training_so'] ) ;
$row['qrcode'] = $generatecode['url'] ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Training/b/'.$row['file'] : '' ) ;
$is_training = 'no' ;
if ( $row['status'] == 'active' ){
if ( $row['training_type'] == 'all' || ( $row['training_type'] == 'date' && $row['date_start'] <= TODAYDAY && $row['date_end'] >= TODAYDAY ) ){
$is_training = 'yes' ;
}
}
$row['is_training'] = $is_training ;
$row['date_start'] = resetDateFormat( $row['date_start'] ) ;
$row['date_end'] = resetDateFormat( $row['date_end'] ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$row['training_status'] = ( checkExists( $row['training_status'] ) != '' ? $row['training_status'] : '') ;
$row['training_remark'] = dataFilter( checkExists( $row['training_remark'] ) != '' ? $row['training_remark'] : '') ;
$row['training_rated'] = dataFilter( checkExists( $row['training_rated'] ) != '' ? $row['training_rated'] : 0) ;
$row['training_comment'] = dataFilter( checkExists( $row['training_comment'] ) != '' ? $row['training_comment'] : '') ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,35 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$join_filter = '' ;
$join_query = '' ;
$query = "SELECT a.category_id, b.title FROM training_gallery_category a
LEFT JOIN training_gallery_category_translation b ON ( a.category_id = b.category_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' AND a.status = 'active'" ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['category_id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+46
View File
@@ -0,0 +1,46 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$join_filter = '' ;
$join_query = '' ;
$query_sortable = 'ORDER BY created_at DESC' ;
$search_query = '' ;
switch ( $array['filter'] ){
case 'myself' :
$search_query .= " AND staff_id = '".$staff_info['staff_id']."'" ;
break ;
case 'group' :
$search_query .= " AND branch_id = '".$array['branch_id']."' AND status = 'confirmed' AND category_id = '".$array['category_id']."'" ;
break ;
}
$query = "SELECT title, file, filetype, status, created_at FROM training_gallery
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ".$query_sortable." LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['date'] = resetDateFormat( $row['created_at'] ) ;
$row['time'] = resetTimeFormat( $row['created_at'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/TrainingGallery/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,35 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$title = $array['title'] ;
$photos = $array['photos'] ;
if ( $title != '' && $array['photos'] != '' && count( $photos ) > 0 ){
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'TrainingGallery', time(), $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO training_gallery
( branch_id, staff_id, title, file, filetype ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$title."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$is_going = $array['is_going'] ;
$update_status = ( $is_going == 'yes' ? 'confirmed' : 'cancelled' ) ;
if ( $array['id'] != '' && $array['view_id'] != '' && $is_going != '' ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND training_id = '".$array['id']."'" ;
$query = "SELECT training_id, training_type, date_start, date_end, file, status, created_at FROM training
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$mysqli->query( "UPDATE staff_training SET
is_going = '".$array['is_going']."',
status = '".$update_status."'
WHERE view_id = '".$array['view_id']."'" ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+67
View File
@@ -0,0 +1,67 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$searchfilter = $array['searchfilter'] ;
$searchfilter = ( $searchfilter != '' ? $searchfilter : 'current' ) ;
$join_filter = '' ;
$join_query = '' ;
$query_sortable = 'ORDER BY a.sortable ASC, a.created_at DESC' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
if ( $searchfilter != '' ){
switch ( $searchfilter ){
case 'current' :
$search_query .= " AND a.branch LIKE '%/".$array['branch_id']."/%' AND a.status = 'active' AND ( ( a.training_type = 'all' ) OR ( a.training_type = 'date' AND a.date_start <= '".TODAYDAY."' AND a.date_end >= '".TODAYDAY."' ) )" ;
break ;
case 'previous' :
$join_filter = ", c.view_id, c.status as training_status" ;
$join_query = "LEFT JOIN staff_training c ON ( a.training_id = c.training_id )" ;
$search_query .= " AND c.branch_id = '".$array['branch_id']."' AND c.staff_id = '".$staff_info['staff_id']."'" ;
$query_sortable = "ORDER BY view_id DESC" ;
break ;
case 'expired' :
$search_query .= " AND a.branch LIKE '%/".$array['branch_id']."/%' AND ( a.status = 'inactive' OR ( a.training_type = 'date' AND a.date_start <= '".TODAYDAY."' AND NOT ( a.date_end >= '".TODAYDAY."' ) ) )" ;
break ;
}
}
$query = "SELECT a.training_id, a.training_type, a.date_start, a.date_end, a.file, a.created_at, b.title ".$join_filter." FROM training a
LEFT JOIN training_translation b ON ( a.training_id = b.training_id )
".$join_query."
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ".$query_sortable." LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['training_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['date_start'] = resetDateFormat( $row['date_start'] ) ;
$row['date_end'] = resetDateFormat( $row['date_end'] ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$row['training_status'] = ( checkExists( $row['training_status'] ) != '' ? $row['training_status'] : '' ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Training/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+47
View File
@@ -0,0 +1,47 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
if ( $array['id'] != '' && $array['view_id'] != '' && $array['training_rated'] != '' && $array['training_comment'] != '' ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND training_id = '".$array['id']."' AND view_id = '".$array['view_id']."'" ;
$query = "SELECT staff_id, training_so, status FROM staff_training
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '308' ;
$row = $mysqli_query->fetch_assoc() ;
if ( $row['status'] == 'confirmed' ){
$status = '200' ;
$mysqli->query( "UPDATE staff_training SET
rated = '".$array['training_rated']."',
comment = '".$array['training_comment']."',
status = 'rated'
WHERE view_id = '".$array['view_id']."'" ) ;
$remark = 'Review training ( '.$row['training_so'].' ) to get points' ;
pointMovement( 'training', $array['view_id'], '1time', 'normal', $row['staff_id'], 0, $remark ) ;
pushToUserCron( 'staff_training', $array['view_id'], $row['staff_id'], 'Review Point', $remark ) ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+59
View File
@@ -0,0 +1,59 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
$status = '300' ;
$id = $array['id'] ;
if ( $id != '' ){
$status = '303' ;
if ( $staff_info['staff_settings']['approvevisitation'] == 'yes' ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM visitor
WHERE deleted_at IS NULL AND visitor_id = '".$id."' AND branch = '".$array['branch_id']."' AND status IN ( 'pending', 'tested-approved' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '200' ;
$row_visitor = $select->fetch_assoc() ;
// get branch name
$branch_name = '' ;
$mysqli_query = "SELECT branch_id, branch_name FROM branch
WHERE branch_id = '".$row_visitor['branch']."' LIMIT 1" ;
$mysqli_branch = $mysqli->query($mysqli_query) ;
if ( $mysqli_branch->num_rows > 0 ){
$row_branch = $mysqli_branch->fetch_assoc() ;
$branch_name = $row_branch['branch_name'] ;
}
$data = [
'visitor_id' => dataFilter( $row_visitor['visitor_id'] ),
'appointment_date' => date( 'Y-m-d H:iA', strtotime( $row_visitor['visited_at'] ) ) . ' ~ ' . date( 'Y-m-d H:iA', strtotime( $row_visitor['visited_at_to'] ) ),
'branch_name' => dataFilter( $branch_name ),
'visitor_category' => ucwords( dataFilter( $row_visitor['category'] ) ),
'visitor_name' => dataFilter( $row_visitor['name'] ),
'contact_number' => dataFilter( $row_visitor['mobile'] ),
'email' => dataFilter( $row_visitor['email'] ),
'nric_passport' => dataFilter( $row_visitor['identity'] ),
'nationality' => dataFilter( $row_visitor['nationality'] ),
'visitor_company' => ucwords( dataFilter( $row_visitor['visitor_company'] ) ),
'car_plate' => dataFilter( $row_visitor['car_plate'] ),
'reason_to_visit' => dataFilter( $row_visitor['reason'] ),
'contact_person' => dataFilter( $row_visitor['contact_person'] ),
'status' => dataFilter( $row_visitor['status'] )
] ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+66
View File
@@ -0,0 +1,66 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '303' ;
if ( $staff_info['staff_settings']['approvevisitation'] == 'yes' ){
$status = '201' ;
$search_query = '' ;
switch ( $array['searchstatus'] ){
case 'pending' :
$search_query .= " AND status IN ( 'pending' )" ;
break ;
case 'approved' :
$search_query .= " AND ( status = 'tested-approved' OR ( status = 'visited' AND visited_at_to >= '".TODAYDATE."' ) )" ;
break ;
case 'history' :
$search_query .= " AND ( status = 'tested-rejected' OR ( status = 'visited' AND visited_at_to < '".TODAYDATE."' ) )" ;
break ;
}
if ( $array['search'] != '' ){
$search_query .= " AND ( category LIKE '%".$array['search']."%' OR name LIKE '%".$array['search']."%' OR mobile LIKE '%".$array['search']."%' OR email LIKE '%".$array['search']."%' OR visitor_company LIKE '%".$array['search']."%' )" ;
}
$query = "SELECT visitor_id, branch, category, name, mobile, email, identity, nationality, visitor_company, status, visited_at, visited_at_to, created_at FROM visitor a
WHERE deleted_at IS NULL AND branch = '".$array['branch_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY visitor_id DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row_visitor = $mysqli_query->fetch_assoc() ){
$list[] = [
'visitor_id' => dataFilter( $row_visitor['visitor_id'] ),
'appointment_date' => date( 'Y-m-d H:iA', strtotime( $row_visitor['visited_at'] ) ) . ' ~ ' . date( 'Y-m-d H:iA', strtotime( $row_visitor['visited_at_to'] ) ),
'visitor_category' => ucwords( dataFilter( $row_visitor['category'] ) ),
'visitor_name' => dataFilter( $row_visitor['name'] ),
'contact_number' => dataFilter( $row_visitor['mobile'] ),
'email' => dataFilter( $row_visitor['email'] ),
'nric_passport' => dataFilter( $row_visitor['identity'] ),
'nationality' => dataFilter( $row_visitor['nationality'] ),
'visitor_company' => ucwords( dataFilter( $row_visitor['visitor_company'] ) ),
'status' => dataFilter( $row_visitor['status'] ),
'created_at' => resetDateFormat( $row_visitor['created_at'] )
] ;
}
$data['list'] = $list ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+100
View File
@@ -0,0 +1,100 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'extensions/sms.php' ) ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
$status = '300' ;
$id = $array['id'] ;
$updatestatus = $array['updatestatus'] ;
if ( $id != '' && $updatestatus != '' ){
$status = '303' ;
if ( $staff_info['staff_settings']['approvevisitation'] == 'yes' ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM visitor
WHERE deleted_at IS NULL AND visitor_id = '".$id."' AND branch = '".$array['branch_id']."' AND status IN ( 'pending', 'tested-approved' ) LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '299' ;
$row = $select->fetch_assoc() ;
$branch_hr_contact = '' ;
$branch_hr_email = '' ;
$branch_hr_cc = [] ;
$branch_email_footer = '' ;
$mysqli_query = "SELECT branch_hr_email, branch_hr_cc, branch_hr_contact, branch_email_footer FROM branch WHERE
deleted_at IS NULL AND branch_id = '".$row['branch']."' LIMIT 1" ;
$mysqli_branch = $mysqli->query($mysqli_query) ;
if ( $mysqli_branch->num_rows > 0 ){
$row_branch = $mysqli_branch->fetch_assoc() ;
$branch_hr_contact = dataFilter( $row_branch['branch_hr_contact'] ) ;
$branch_hr_email = dataFilter( $row_branch['branch_hr_email'] ) ;
$branch_hr_cc = explodeToArray( $row_branch['branch_hr_cc'] ) ;
$branch_email_footer = entityDecode( dataFilter( $row_branch['branch_email_footer'] ) ) ;
}
$boolean_update = false ;
$title = '' ;
$body = '' ;
$body_sms = '' ;
if ( $updatestatus == 'tested-approved' ){
$boolean_update = true ;
$title = 'Visitor Confirmation' ;
// send email / sms
$body = 'Dear valued visitor, good day. Your application form has been approved.<br /><br />Kindly present your QR code to us during the visitation date via below link: <a href="'.PATH.'visitation/qrcode.php?visitor_id='.$id.'&token='.setSecret( $id ).'">'.PATH.'visitation/qrcode.php?visitor_id='.$id.'&token='.setSecret( $id ).'</a>.<br /><br />Thank you and have a nice day.<br /><br />by ' . COMPANY ;
$body_sms = 'Dear valued visitor, good day. Your application form has been approved. Kindly present your QR code to us during the visitation date via below link: '.PATH.'visitation/qrcode.php?visitor_id='.$id.'&token='.setSecret( $id ).' Thank you and have a nice day.' ;
}
if ( $updatestatus == 'tested-rejected' ){
$boolean_update = true ;
$title = 'Visitor Rejected' ;
$body = 'Dear valued visitor, good day. Sorry to inform that your visitation request has been rejected.<br /><br />by ' . COMPANY ;
$body_sms = 'Dear valued visitor, good day. Sorry to inform that your visitation request has been rejected.' ;
}
if ( $boolean_update ){
$status = '202' ;
if ( $mysqli->query( "UPDATE visitor SET
status = '".$updatestatus."'
WHERE visitor_id = '".$id."'" ) ){
$status = '200' ;
$mailer = new Mailer() ;
$mailer->from = $branch_hr_email ;
$mailer->to = [ $row['email'] ] ;
if ( count($branch_hr_cc) > 0 ){
$mailer->cc = $branch_hr_cc ;
}
$mailer->subject = $title ;
$mailer->body = $body ;
$mailer->send() ;
if ( substr( $row['mobile'], 0, 2 ) == '60' || substr( $row['mobile'], 0, 3 ) == '+60' ||
substr( $row['mobile'], 0, 2 ) == '65' || substr( $row['mobile'], 0, 3 ) == '+65' ){
$sms = new Sms() ;
$sms->to = $row['mobile'] ;
$sms->message = $body_sms ;
$sms->send() ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>