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