first commit
This commit is contained in:
@@ -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' ) ;
|
||||
?>
|
||||
@@ -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' ) ;
|
||||
?>
|
||||
@@ -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' ) ;
|
||||
?>
|
||||
@@ -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' ) ;
|
||||
?>
|
||||
@@ -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' ) ;
|
||||
?>
|
||||
Reference in New Issue
Block a user