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