worknova.manus/app-association-gallery.php
LAPTOP-V9RRD1TL\Michelle's Computer f8f8fcaf96 first commit
2025-07-21 21:38:17 +08:00

191 lines
6.8 KiB
PHP

<?php
include 'connect/cms-config.php' ;
include 'requires/function.php' ;
include 'requires/session.php' ;
// include the class
include 'requires/class_resize.php' ;
// keep parameter in value
$page = escapeString($_GET['page']) ;
$page_mode = escapeString($_GET['page_mode']) ;
$type = escapeString($_GET['type']) ;
$search = escapeString($_GET['search']) ;
// active menu bar
$active_main_menu = 'service' ;
$active_sub_menu = 'association' ;
$active_menu = 'association-list-list' ;
// check permission
if ( !permissionCheck($row_user, 'association-list-gallery') ){
header('Location: index.php') ;
exit ;
}
// update database
if ( $_POST['hide'] == 1 ){
$update_status = escapeString( $_POST['update_status'] ) ;
foreach ( $_POST['multiple_status'] as $kk => $vv ){
$mysqli->query( "UPDATE association_gallery SET
status = '".$update_status."'
WHERE gallery_id = '".$kk."'" ) ;
if ( $update_status == 'rejected' ){
pushToUserCron( 'association_gallery', $kk, $vv, 'Association Gallery', 'Association gallery has been reject.' ) ;
}else{
pushToUserCron( 'association_gallery', $kk, $vv, 'Association Gallery', 'Association gallery has been update.' ) ;
}
}
header( "Refresh: 0;" ) ;
exit ;
}
//query
$search_query = '' ;
$search_name = escapeString($_GET['search_name']) ;
$search_idno = escapeString($_GET['search_idno']) ;
$search_status = escapeString($_GET['search_status']) ;
$search_date = ( $_GET['search_date'] != '' ? date('Y-m-d', strtotime($_GET['search_date'])) : '' ) ;
$search_query = '' ;
if ( $search_name != ''){
$search_query .= " AND b.staff_name LIKE '%".$search_name."%'" ;
}
if ( $search_idno != ''){
$search_query .= " AND b.staff_idno LIKE '%".$search_idno."%'" ;
}
if ( $search_status != ''){
$search_query .= " AND a.status = '".$search_status."'" ;
}
if ( $search_date != '' ){
$search_query .= " AND a.created_at LIKE '%".$search_date."%'" ;
}
// related staff
// pagination
if (isset($page) && !empty($page)) { $product_page = $page ; } else { $product_page = 1 ; } // next and prev page (5 thing need to change)
$start_from = ($product_page - 1) * LIMIT ; //end next and prev page
// set search url
$search_url = 'search_name='.$search_name.'&search_idno='.$search_idno.'&search_status='.$search_status.'&search_date='.$search_date ;
// page query
$mysqli_query = "SELECT a.gallery_id, a.title, a.file, a.status, a.created_at, a.updated_at, b.staff_id, b.staff_idno, b.staff_name FROM association_gallery a
LEFT JOIN staff b ON ( a.staff_id = b.staff_id )
WHERE a.deleted_at IS NULL " . $search_query . $user_branch_permission_sql_b ;
$mysqli_list = $mysqli->query( $mysqli_query." ORDER BY a.gallery_id DESC LIMIT $start_from, " . LIMIT ) ;
// load pagination
$page_pagination = nextPrevious( $product_page, LIMIT, $search_url, $mysqli_query ) ;
// start header here
include 'requires/page_header.php';
include 'requires/page_top.php';
?>
<div class="warper container-fluid">
<div class='container' style="background-color: white; border-radius: 10px;">
<div class="page-header" style="margin: 30px 0px 0px 0px;padding: 0px;">
<div class="row">
<div class="pull-left col">
<h1>Association Gallery <small>Edit</small></h1>
</div>
<div class="pull-right col">
<?php if ( permissionCheck($row_user, 'association-list-gallery-category') ){ ?>
<a class="btn" style="color:white;background-color: #5e5bd0;" href="app-association-gallery-category.php?page_mode=all" class="btn btn-purple" target="_blank">Category Gallery</a>
<?php } ?>
</div>
</div>
</div>
<form method="post">
<div class="panel panel-default">
<div class="panel-body">
<select name="update_status" class="form-control selectpicker">
<option value="pending">Pending</option>
<option value="confirmed">Confirmed</option>
<option value="rejected">Rejected</option>
</select>
<input type="hidden" name="hide" value="1" />
<input type="hidden" name="hide_status" value="action" />
<input type="submit" class="btn" style="color:white; background-color:#5e5bd0; width:100px;" value="<?= $lang['submit'] ?>" />
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Join Staff</div>
<div class="panel-body">
<table cellpadding="0" cellspacing="0" border="0" class="responsive table table-striped table-bordered" id="basic-datatable">
<thead>
<tr>
<th></th>
<th>Action</th>
<th>Image</th>
<th>Staff ID</th>
<th>Title</th>
<th>Status</th>
<th>Created At</th>
<th>Updated At</th>
</tr>
</thead>
<tbody>
<?php
if ( $mysqli_list->num_rows > 0 ){
while ( $row_list = $mysqli_list->fetch_assoc() ){
$image = ( $row_list['file'] != '' ? PATH.'uploads/AssociationGallery/'.dataFilter($row_list['file']) : '' ) ;
echo '
<tr class="odd gradeX">
<td>' ;
if ( $row_list['status'] == 'pending' ){
echo '
<div class="checkbox multiple_trash">
<input type="checkbox" name="multiple_status['.$row_list['gallery_id'].']" class="trash_button" value="'.$row_list['staff_id'].'" />
<label for="checkbox1"></label>
</div>' ;
}
echo '
</td>
<td class="text-center">
<a title="Edit Current Gallery" href="app-association-gallery-view.php?page_mode=edit&gallery_id='.$row_list['gallery_id'].'" target="_blank"><i class="fa fa-edit"></i></a>
</td>
<td class="text-center">'.( $image != '' ? '<a href="'.$image.'" target="_blank"><img src="'.$image.'" style="width:80px;" /></a>' : '' ).'</td>
<td>'.dataFilter($row_list['staff_name']).' ( '.dataFilter($row_list['staff_idno']).' )</td>
<td>'.dataFilter($row_list['title']).'</td>
<td class="text-center">'.resetStatus($row_list['status']).'</td>
<td class="text-center">'.resetDateFormat($row_list['created_at']).'</td>
<td class="text-center">'.resetDateFormat($row_list['updated_at']).'</td>
</tr>';
}
}else{
echo
'<tr class="odd gradeX">
<td class="border_none">No data.</td>
<td class="border_none"></td>
<td class="border_none"></td>
<td class="border_none"></td>
<td class="border_none"></td>
<td class="border_none"></td>
<td class="border_none"></td>
<td class="border_none"></td>
</td>';
}
?>
</tbody>
</table>
<?= $page_pagination['page_pagination'] ?>
</div>
</div>
</form>
</div>
</div>
<?php
include 'requires/page_footer.php' ;