845 lines
36 KiB
PHP
845 lines
36 KiB
PHP
<?php
|
|
include 'connect/cms-config.php' ;
|
|
include 'requires/function.php' ;
|
|
include 'requires/session.php' ;
|
|
|
|
// include the class
|
|
include 'requires/class_resize.php' ;
|
|
|
|
// check permission
|
|
if ( !permissionCheck($row_user, 'handbook-list-view') ){
|
|
header('Location: index.php') ;
|
|
exit ;
|
|
}
|
|
|
|
// keep parameter in value
|
|
$page = escapeString($_GET['page']) ;
|
|
$page_mode = escapeString($_GET['page_mode']) ;
|
|
$type = escapeString($_GET['type']) ;
|
|
$search = escapeString($_GET['search']) ;
|
|
$handbook_id = escapeString($_GET['handbook_id']) ;
|
|
|
|
// active handbook bar
|
|
$active_main_menu = 'service' ;
|
|
$active_sub_menu = 'handbook' ;
|
|
$active_menu = 'handbook-list-list' ;
|
|
|
|
// get all branch
|
|
$branch_all = [] ;
|
|
$get_branch = $mysqli->query( "SELECT * FROM branch
|
|
WHERE deleted_at IS NULL " . $user_branch_permission_sql_123 ) ;
|
|
if ( $get_branch->num_rows > 0 ){
|
|
while ( $row_branch = $get_branch->fetch_assoc() ){
|
|
$branch_all[$row_branch['branch_id']] = $row_branch['branch_name'] ;
|
|
}
|
|
}
|
|
|
|
// mode type | all list | new | edit
|
|
switch($page_mode){
|
|
|
|
// edit
|
|
case 'new' :
|
|
case 'edit' :
|
|
|
|
// check query exsits
|
|
$submit_type = 'new' ;
|
|
$mysqli_page = $mysqli->query("SELECT * FROM handbook
|
|
WHERE handbook_id = '".$page."' LIMIT 1");
|
|
|
|
$notification_title = 'Handbook has been added' ;
|
|
$prev_staff_id = [] ;
|
|
$is_update_send = false ;
|
|
if ($mysqli_page->num_rows > 0){
|
|
// keep query value in array
|
|
$row_page = $mysqli_page->fetch_array(MYSQLI_ASSOC) ;
|
|
$submit_type = 'edit' ;
|
|
$notification_title = 'Handbook has been update' ;
|
|
$prev_staff_id = ( $row_page['staff_id'] != '' ? explode( '/', substr( $row_page['staff_id'], 1, -1 ) ) : [] ) ;
|
|
}
|
|
|
|
// update database
|
|
if ( isset($type) && ( $type == 'new' || $type == 'edit' ) && $_POST['hide'] == 1 ){
|
|
|
|
if ( $page == '' ){
|
|
$mysqli->query("INSERT INTO handbook ( created_at ) VALUES ( '".TODAYDATE."' )") ;
|
|
$page = $mysqli->insert_id ;
|
|
}
|
|
|
|
// resize image
|
|
// set image in variable
|
|
$image = $_FILES["image"]["name"] ;
|
|
$image_query = '' ;
|
|
$remove_photo = $_POST['remove_photo'] ;
|
|
if ( $remove_photo == 1 ){
|
|
$image = '' ;
|
|
$image_query = "file = '',
|
|
file_type = ''," ;
|
|
}else{
|
|
if ( $image != '' ){
|
|
$get_image = pathinfo($image) ;
|
|
if ( $get_image['extension'] == 'pdf' ){
|
|
|
|
$file_name = $page.'-'.time().'.pdf' ;
|
|
copy($_FILES["image"]["tmp_name"], 'uploads/Handbook/'.$file_name) ;
|
|
|
|
$image_query= "file = '".$file_name."',
|
|
file_type = 'pdf'," ;
|
|
|
|
$is_update_send = true ;
|
|
}else{
|
|
$create_image = reCreateImage('Handbook', $page, $page, '', $image, $_FILES["image"]["type"], $_FILES['image']['tmp_name']) ;
|
|
// Image uploads when exists
|
|
if ($create_image['result'] && is_array($create_image['crop']) && count($create_image['result']) > 0){
|
|
$resizeObj = new resize($create_image['original']) ; // Initialise load image
|
|
foreach($create_image['crop'] as $value){
|
|
// Resize image (options: exact, portrait, landscape, auto, crop)
|
|
$resizeObj -> resizeImage($value['width'], $value['height'], $value['type']) ;
|
|
$resizeObj -> saveImage($value['source'], 70) ; // Save image
|
|
}
|
|
$get_image = pathinfo($create_image['image']) ;
|
|
|
|
$image_query = "file = '".$create_image['image']."',
|
|
file_type = '".$create_image['extension']."'," ;
|
|
|
|
$is_update_send = true ;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// delete all department & receiver
|
|
$receiver_type = dataFilter($_POST['receiver_type']) ;
|
|
$receiver_to = $_POST['receiver_to'] ;
|
|
$receiver_to_dept = $_POST['receiver_to_dept'] ;
|
|
$branch = $_POST['branch'] ;
|
|
$array_branch = [] ;
|
|
foreach ( $branch as $k_branch => $v_branch ){
|
|
$array_branch[] = escapeString( $v_branch ) ;
|
|
}
|
|
|
|
$selected_staff = [] ;
|
|
$selected_depart = [] ;
|
|
if ( $receiver_type == '0' ){
|
|
|
|
$mysqli_staff = $mysqli->query("SELECT staff_id, staff_name, staff_idno FROM staff
|
|
WHERE ( staff_date_resigned IS NULL || staff_date_resigned = '0000-00-00' || staff_date_resigned >= '".TODAYDATE."' ) AND deleted_at IS NULL AND branch_id IN (".implode(',', $array_branch).")") ;
|
|
if ( $mysqli_staff->num_rows > 0 ){
|
|
while ( $row_staff = $mysqli_staff->fetch_assoc() ){
|
|
if ( !in_array( $row_staff['staff_id'], $prev_staff_id ) || $is_update_send ) {
|
|
pushToUserCron( 'handbook', $page, $row_staff['staff_id'], 'Handbook', $notification_title ) ;
|
|
}
|
|
}
|
|
}
|
|
|
|
}elseif ( $receiver_type == '1' ){
|
|
|
|
if( !empty( $receiver_to ) ){
|
|
for ( $i = 0 ; $i < count($receiver_to) ; $i++ ){
|
|
if ( $receiver_to[$i] != '' ){
|
|
$reset_staff = $receiver_to[$i] ;
|
|
$selected_staff[$reset_staff] = $reset_staff ;
|
|
|
|
if ( !in_array( $reset_staff, $prev_staff_id ) || $is_update_send ) {
|
|
pushToUserCron( 'handbook', $page, $reset_staff, 'Handbook', $notification_title ) ;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}else{
|
|
if( !empty( $receiver_to_dept ) ){
|
|
$array_depart = [] ;
|
|
for ( $i = 0 ; $i < count($receiver_to_dept) ; $i++ ){
|
|
|
|
$department_id = $receiver_to_dept[$i] ;
|
|
if ( $department_id != '' ){
|
|
|
|
// save into department
|
|
$selected_depart[]= $department_id ;
|
|
|
|
// check department staff
|
|
$reset_depart = str_replace( ['(', ')'], '', $department_id ) ;
|
|
$get_depart_staff = $mysqli->query( "SELECT a.staff_id FROM staff_department a
|
|
LEFT JOIN staff b ON ( a.staff_id = b.staff_id )
|
|
WHERE a.deleted_at IS NULL AND a.department_id = '".$reset_depart."' AND b.branch_id IN (".implode(',', $array_branch).")" ) ;
|
|
if ( $get_depart_staff->num_rows > 0 ){
|
|
while ( $row_depart_staff = $get_depart_staff->fetch_assoc() ){
|
|
if ( !in_array($row_depart_staff['staff_id'], $array_depart) ){
|
|
$array_depart[] = $row_depart_staff['staff_id'] ;
|
|
$selected_staff[$row_depart_staff['staff_id']] = $row_depart_staff['staff_id'] ;
|
|
|
|
if ( !in_array( $row_depart_staff['staff_id'], $prev_staff_id ) || $is_update_send ) {
|
|
pushToUserCron( 'handbook', $page, $row_depart_staff['staff_id'], 'Handbook', $notification_title ) ;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$selected_staff = ( arrayCheck($selected_staff) ? '/'.implode( '/', $selected_staff ).'/' : '' ) ;
|
|
$selected_depart = ( arrayCheck($selected_depart) ? '/'.implode( '/', $selected_depart ).'/' : '' ) ;
|
|
|
|
// update database
|
|
$mysqli->query("UPDATE handbook SET
|
|
".$image_query."
|
|
branch = '/".implode('/', $array_branch)."/',
|
|
category_id = '".escapeString($_POST['category_id'])."',
|
|
staff_id = '".$selected_staff."',
|
|
department_id = '".$selected_depart."',
|
|
title = '".escapeString($_POST['title'])."',
|
|
sortable = '".escapeString($_POST['sortable'])."',
|
|
receiver_type = '".escapeString($_POST['receiver_type'])."',
|
|
view_format = '".escapeString($_POST['view_format'])."',
|
|
content = '".escapeString($_POST['content'])."',
|
|
video_url = '".escapeString($_POST['video_url'])."',
|
|
is_showagree = '".escapeString($_POST['is_showagree'])."',
|
|
updated_at = '".TODAYDATE."'
|
|
WHERE handbook_id = '".$page."'") ;
|
|
|
|
if ( $_POST['is_retick'] == 'yes' ){
|
|
$mysqli->query( "UPDATE staff_handbook SET
|
|
deleted_at = '".TODAYDATE."'
|
|
WHERE handbook_id = '".$page."'" ) ;
|
|
}
|
|
|
|
foreach ( $LANGS as $klang => $vlang ){
|
|
$title = escapeString( $_POST['title_'.$klang] ) ;
|
|
|
|
checkLangUpdate( 'handbook_translation', 'handbook_id', $page, $klang, [
|
|
'title' => [ 'type' => 'input', 'value' => $title ]
|
|
] ) ;
|
|
}
|
|
|
|
// refresh page
|
|
header("Location:app-handbook.php?page_mode=edit&page=".$page."&success=1") ;
|
|
$_SESSION['system_result'] = 'success-updated' ;
|
|
exit ;
|
|
}
|
|
|
|
// get all requires
|
|
// get all staff
|
|
$staff_list = [] ;
|
|
$mysqli_staff = $mysqli->query("SELECT staff_id, staff_name, staff_idno FROM staff
|
|
WHERE ( staff_date_resigned IS NULL || staff_date_resigned = '0000-00-00' || staff_date_resigned >= '".TODAYDATE."' ) AND deleted_at IS NULL ") ;
|
|
if ( $mysqli_staff->num_rows > 0 ){
|
|
while ( $row_staff = $mysqli_staff->fetch_assoc() ){
|
|
$staff_list[$row_staff['staff_id']] = dataFilter($row_staff['staff_name']) . ' ( ' . dataFilter($row_staff['staff_idno']) . ' )' ;
|
|
}
|
|
}
|
|
|
|
// get all requires
|
|
$department_list = [] ;
|
|
$mysqli_department = $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 = 'en'") ;
|
|
if ( $mysqli_department->num_rows > 0 ){
|
|
while ( $row_department = $mysqli_department->fetch_assoc() ){
|
|
$department_list[$row_department['department_id']] = dataFilter($row_department['department_desc']) ;
|
|
}
|
|
}
|
|
|
|
if ( ( $page_mode == 'new' && !permissionCheck($row_user, 'handbook-list-new') ) ||
|
|
( $page_mode == 'edit' && !permissionCheck($row_user, 'handbook-list-edit') ) ){
|
|
header('Location: app-handbook.php') ;
|
|
exit ;
|
|
}
|
|
|
|
// get all selected staff & department
|
|
$receiver_staff = ( $row_page['staff_id'] != '' ? explode('/', $row_page['staff_id']) : [] ) ;
|
|
$receiver_depart = ( $row_page['department_id'] != '' ? explode('/', $row_page['department_id']) : [] ) ;
|
|
|
|
// start header here
|
|
include 'requires/page_header.php';
|
|
include 'requires/page_top.php';
|
|
|
|
?>
|
|
|
|
<style>
|
|
.stafflist_check, .departmentlist_check{
|
|
margin-top:5px;
|
|
margin-bottom:5px;
|
|
}
|
|
.form-group-pdf, .form-group-message, .form-group-video{
|
|
display:none;
|
|
}
|
|
</style>
|
|
<script>
|
|
$(document).ready(function(){
|
|
|
|
$(".view_format").change(function(){
|
|
var thisKey = $(this) ;
|
|
if ( thisKey.val() == 'pdf' ){
|
|
$(".form-group-pdf").show() ;
|
|
$(".form-group-message").hide() ;
|
|
$(".form-group-video").hide() ;
|
|
}else if ( thisKey.val() == 'video' ){
|
|
$(".form-group-pdf").hide() ;
|
|
$(".form-group-message").hide() ;
|
|
$(".form-group-video").show() ;
|
|
}else{
|
|
$(".form-group-pdf").hide() ;
|
|
$(".form-group-message").show() ;
|
|
$(".form-group-video").hide() ;
|
|
}
|
|
}) ;
|
|
|
|
$("#checkAll").click(function(){
|
|
$("#selectuser option").prop("selected","selected");
|
|
$("#selectuser").trigger("change");
|
|
});
|
|
|
|
$("#unCheckAll").click(function(){
|
|
$("#selectuser option").removeAttr("selected");
|
|
$("#selectuser").trigger("change");
|
|
});
|
|
|
|
$("#checkAllDept").click(function(){
|
|
$("#selectdept option").prop("selected","selected");
|
|
$("#selectdept").trigger("change");
|
|
});
|
|
|
|
$("#unCheckAllDept").click(function(){
|
|
$("#selectdept option").removeAttr("selected");
|
|
$("#selectdept").trigger("change");
|
|
});
|
|
|
|
$('input[type=radio][name=receiver_type]').on('change', function(){
|
|
hideshowlist($(this).val()) ;
|
|
});
|
|
|
|
<?php if ( $submit_type == 'edit' ){ ?>
|
|
hideshowlist('<?= $row_page['receiver_type'] ?>') ;
|
|
<?php }else{ ?>
|
|
hideshowlist( '0' ) ;
|
|
<?php } ?>
|
|
|
|
$('input[type=radio][name=receiver_type]').on('change', function(){
|
|
hideshowlist($(this).val()) ;
|
|
});
|
|
|
|
// function hideshowlist(id){
|
|
// alert(id );
|
|
// if( id == '0' ){
|
|
// $('.stafflist').hide();
|
|
// $('.departmentlist').hide();
|
|
// }else if( id == '1' ){
|
|
// $('.stafflist').show();
|
|
// $('.departmentlist').hide();
|
|
// }else{
|
|
// $('.stafflist').hide();
|
|
// $('.departmentlist').show();
|
|
// }
|
|
// }
|
|
|
|
function hideshowlist(id){
|
|
if ( id == '0' ){
|
|
$('.stafflist').hide();
|
|
$('.stafflist').next(".select2-container").hide();
|
|
$('.departmentlist').hide();
|
|
$('.departmentlist').next(".select2-container").hide();
|
|
}else if ( id == '1' ){
|
|
$('.stafflist').show();
|
|
$('.stafflist').next(".select2-container").show();
|
|
$('.departmentlist').hide();
|
|
$('.departmentlist').next(".select2-container").hide();
|
|
}else{
|
|
$('.stafflist').hide();
|
|
$('.stafflist').next(".select2-container").hide();
|
|
$('.departmentlist').show();
|
|
$('.departmentlist').next(".select2-container").show();
|
|
}
|
|
}
|
|
|
|
}) ;
|
|
</script>
|
|
|
|
<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;">
|
|
<h1>Handbook <small><?= $lang[$page_mode] ?></small></h1></div>
|
|
<?php
|
|
if ( $_SESSION['system_result'] != '' ){
|
|
switch($_SESSION['system_result']){
|
|
case 'success-updated' :
|
|
echo '<div class="result_success">'.$lang['Thank you details has been updated'].'</div>' ;
|
|
break ;
|
|
}
|
|
unset($_SESSION['system_result']) ;
|
|
}
|
|
?>
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading"></div>
|
|
<div class="panel-body">
|
|
<form method="post" class="form-horizontal" id="quotationForm" enctype="multipart/form-data" action="app-handbook.php?page_mode=edit&page=<?= $page ?>&type=edit" novalidate="novalidate">
|
|
|
|
<div class="form-group show_branch_action">
|
|
<div class="col-sm-2 control-label"><?= $lang['branch']?></div>
|
|
<div class="col-sm-9">
|
|
<select name="branch[]" class="form-control ui-search-input chosen-select select2-basic-single" multiple required>
|
|
<?php
|
|
foreach ( $branch_all as $key => $value ) {
|
|
echo '<option value="'.$key.'" '. ( strpos( $row_page['branch'], '/'.$key.'/' ) !== false ? 'selected' : '' ) .' >'.$value.'</option>';
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="col-sm-2 control-label">To</div>
|
|
<div class="col-sm-9">
|
|
|
|
<div class="div_radio">
|
|
<label><input type="radio" name="receiver_type" id="type1" value="0" <?= ( $row_page['receiver_type'] == '0' ? 'checked' : '' ) ?> /> All</label>
|
|
<label><input type="radio" name="receiver_type"value="1" <?= ( $row_page['receiver_type'] == '1' ? 'checked' : '' ) ?> required /> Individual</label>
|
|
<label><input type="radio" name="receiver_type" value="2" <?= ( $row_page['receiver_type'] == '2' ? 'checked' : '' ) ?> required /> </i> Department</label>
|
|
</div>
|
|
|
|
<div class="div_radio_select">
|
|
<div class="stafflist">
|
|
<div class="stafflist_select">
|
|
<select name="receiver_to[]" id="selectuser" class="chosen-select form-control tab_index ui-dropdown-select ui-search-input select2-basic-single" multiple>
|
|
<?php
|
|
if ( count($staff_list) > 0 ){
|
|
foreach ( $staff_list as $k => $v ){
|
|
echo '<option value="'.$k.'" '.( in_array( $k, $receiver_staff ) ? 'selected' : '').'>'.$v.'</option>' ;
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
<div class="stafflist_check">
|
|
<a class="btn btn-xs btn-danger" id="checkAll"><i class="fa fa-check-circle"></i> </i> <?= $lang['Check All']?></a>
|
|
<a class="btn btn-xs btn-danger" id="unCheckAll"><i class="fa fa-times-circle"></i> </i> <?= $lang['Uncheck All']?></a>
|
|
</div>
|
|
</div>
|
|
<div class="departmentlist">
|
|
<div class="departmentlist_select">
|
|
<select name="receiver_to_dept[]" id="selectdept" class="chosen-select form-control tab_index ui-dropdown-select ui-search-input select2-basic-single" multiple>
|
|
<?php
|
|
if ( count($department_list) > 0 ){
|
|
foreach ( $department_list as $k => $v ){
|
|
echo '<option value="'.$k.'" '.( in_array( $k, $receiver_depart ) ? 'selected' : '').'>'.$v.'</option>' ;
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
<div class="stafflist_check">
|
|
<a class="btn btn-xs btn-danger" id="checkAllDept"><i class="fa fa-check-circle"></i> <?= $lang['Check All']?></a>
|
|
<a class="btn btn-xs btn-danger" id="unCheckAllDept"><i class="fa fa-times-circle"></i> <?= $lang['Uncheck All']?></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
echo showTabs( 'handbook_translation', 'handbook_id', $page, [
|
|
'title' => [
|
|
'type' => 'input',
|
|
'title' => $lang['title']
|
|
]
|
|
]) ;
|
|
?>
|
|
|
|
<div class="form-group">
|
|
<div class="col-sm-2 control-label">Sub Category</div>
|
|
<div class="col-sm-9">
|
|
<select name="category_id" class="chosen-select2 form-control tab_index ui-dropdown-select ui-search-input select2-basic-single">
|
|
<option value="">Select Category</option>
|
|
<?php
|
|
$mysqli_category = $mysqli->query("SELECT a.category_id, 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 = 'en' AND a.category_type = 'sub' ORDER BY a.sortable") ;
|
|
if ( $mysqli_category->num_rows > 0 ){
|
|
while ( $row_category = $mysqli_category->fetch_assoc() ){
|
|
echo '<option '.( $row_category['category_id'] == $row_page['category_id'] ? 'selected' : '' ).' value="'.$row_category['category_id'].'">'.dataFilter($row_category['title']).'</option>' ;
|
|
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="col-sm-2 control-label">Sortable</div>
|
|
<div class="col-sm-9">
|
|
<input type="text" name="sortable" class="form-control ui-search-input" value="<?= dataFilter($row_page['sortable']) ?>" placeholder="Sortable" >
|
|
</div>
|
|
</div>
|
|
|
|
<hr />
|
|
|
|
<div class="form-group">
|
|
<div class="col-sm-2 control-label">Format</div>
|
|
<div class="col-sm-9">
|
|
<label><input type="radio" name="view_format" class="view_format" <?= ( $row_page['view_format'] == '' || $row_page['view_format'] == 'pdf' ? 'checked' : '' ) ?> value="pdf" /> PDF</label>
|
|
<label style="margin-left:10px;"><input type="radio" name="view_format" class="view_format" <?= ( $row_page['view_format'] == 'message' ? 'checked' : '' ) ?> value="message" /> Message</label>
|
|
<label style="margin-left:10px;"><input type="radio" name="view_format" class="view_format" <?= ( $row_page['view_format'] == 'video' ? 'checked' : '' ) ?> value="video" /> Video</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group form-group-pdf" <?= ( $row_page['view_format'] == '' || $row_page['view_format'] == 'pdf' ? 'style="display:block;"' : '' ) ?> >
|
|
<div class="col-sm-2 control-label">Photo</div>
|
|
<div class="col-sm-9">
|
|
<div class="file_upload">
|
|
<div class="file_form">
|
|
<input type="hidden" name="hide_image" value="<?= dataFilter($row_page['file']) ?>" />
|
|
<input type="hidden" name="remove_photo" value="">
|
|
<input type="file" name="image" class="file_button control-label" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-group form-group-pdf" <?= ( $row_page['view_format'] == '' || $row_page['view_format'] == 'pdf' ? 'style="display:block;"' : '' ) ?> >
|
|
<div class="col-sm-2 control-label">Preview</div>
|
|
<div class="col-sm-9">
|
|
<?php
|
|
if ($row_page['file'] != ''){
|
|
echo '
|
|
<label class="remove_photo"><input type="checkbox" name="remove_photo" class="ui-checkbox tick" value="1"> Remove pdf</label>
|
|
<a href="'.PATH.'uploads/Handbook/'.dataFilter($row_page['file']).'" target="_blank">Download</a>' ;
|
|
}else{
|
|
echo '
|
|
<input type="hidden" name="remove_photo" value="" >' ;
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="form-group form-group-message" <?= ( $row_page['view_format'] == 'message' ? 'style="display:block;"' : '' ) ?> >
|
|
<div class="col-sm-2 control-label">Message</div>
|
|
<div class="col-sm-9">
|
|
<textarea name="content" class="content" id="editor1" rows="10" cols="80"><?= dataFilter($row_page['content']) ?></textarea>
|
|
<script> CKEDITOR.replace('editor1') ; </script>
|
|
</div>
|
|
</div>
|
|
<div class="form-group form-group-video" <?= ( $row_page['view_format'] == 'video' ? 'style="display:block;"' : '' ) ?> >
|
|
<div class="col-sm-2 control-label">Video</div>
|
|
<div class="col-sm-9">
|
|
<textarea name="video_url" class="video form-control ui-search-input"><?= dataFilter($row_page['video_url']) ?></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="col-sm-2 control-label">Is Signature</div>
|
|
<div class="col-sm-9">
|
|
<label><input type="radio" name="is_showagree" <?= ( $row_page['is_showagree'] == 'no' ? 'checked' : '' ) ?> value="no" /> No</label>
|
|
<label><input type="radio" name="is_showagree" <?= ( $row_page['is_showagree'] == 'yes' ? 'checked' : '' ) ?> value="yes" /> Yes</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="col-sm-2 control-label">Is Signature Retick</div>
|
|
<div class="col-sm-9">
|
|
<label><input type="radio" name="is_retick" checked value="no" /> No</label>
|
|
<label><input type="radio" name="is_retick" value="yes" /> Yes</label>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="form-group">
|
|
<div class="col-sm-2 control-label"></div>
|
|
<div class="col-sm-9">
|
|
<button type="submit" class="btn" style="color:white;background-color: #5e5bd0;float:right; margin-top: 5px;width: 100px;"><?= $lang['submit'] ?></button>
|
|
<input type="hidden" name="hide" value="1">
|
|
<input type="hidden" name="page_status" value="<?= $submit_type ?>">
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
|
|
break ;
|
|
|
|
|
|
|
|
|
|
// edit association
|
|
case 'view' :
|
|
|
|
// check query exsits
|
|
$submit_type = 'new' ;
|
|
$mysqli_page = $mysqli->query("SELECT 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 = 'en' AND a.handbook_id = '".$handbook_id."' LIMIT 1");
|
|
if ( $mysqli_page->num_rows == 0 ){
|
|
exit ;
|
|
}
|
|
|
|
$row_page = $mysqli_page->fetch_array(MYSQLI_ASSOC) ;
|
|
|
|
// 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 = 'page_mode='.$page_mode.'&handbook_id='.$handbook_id.'search='.$search ;
|
|
|
|
// page query
|
|
$mysqli_query = "SELECT a.created_at, b.staff_idno, b.staff_name, b.staff_image FROM staff_handbook a
|
|
LEFT JOIN staff b ON ( a.staff_id = b.staff_id )
|
|
WHERE a.deleted_at IS NULL AND a.handbook_id = '".$handbook_id."' " . $search_query ;
|
|
$mysqli_list = $mysqli->query( $mysqli_query." ORDER BY a.view_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;"><h1>Handbook <small>View</small></h1></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>Profile</th>
|
|
<th>Staff ID</th>
|
|
<th>Name</th>
|
|
<th>Agreed Date</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
if ( $mysqli_list->num_rows > 0 ){
|
|
while ( $row_list = $mysqli_list->fetch_array(MYSQLI_ASSOC) ){
|
|
$staff_image = ( $row_list['staff_image'] != '' ? PATH.'uploads/Staff/'.dataFilter($row_list['staff_image']) : '' ) ;
|
|
|
|
echo '
|
|
<tr class="odd gradeX">
|
|
<td class="text-center">'.( $staff_image != '' ? '<a href="'.$staff_image.'" target="_blank"><img src="'.$staff_image.'" style="width:80px;" /></a>' : '' ).'</td>
|
|
<td>'.dataFilter($row_list['staff_idno']).'</td>
|
|
<td>'.dataFilter($row_list['staff_name']).'</td>
|
|
<td class="text-center">'.resetDateFormat($row_list['created_at']).'</td>
|
|
</tr>';
|
|
}
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
<?= $page_pagination['page_pagination'] ?>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">Preview</div>
|
|
<div class="panel-body">
|
|
<form method="post" class="form-horizontal" id="quotationForm" enctype="multipart/form-data" action="association.php?page_mode=view&page=<?= $association_id ?>" novalidate="novalidate">
|
|
|
|
<div class="form-group">
|
|
<div class="col-sm-2 control-label">Title</div>
|
|
<div class="col-sm-9">
|
|
<input type="text" name="title" class="form-control ui-search-input" value="<?= dataFilter($row_page['title']) ?>" disabled placeholder="Title" />
|
|
</div>
|
|
</div>
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
|
|
break ;
|
|
|
|
|
|
|
|
// all list
|
|
case 'all' :
|
|
default :
|
|
|
|
$search_title = escapeString($_GET['search_title']) ;
|
|
$search_date = ( $_GET['search_date']!= '' ? date('Y-m-d', strtotime($_GET['search_date'])) : '' ) ;
|
|
|
|
// query type
|
|
$search_query = '' ;
|
|
|
|
// search query
|
|
if( $search_title != ''){
|
|
$search_query .= " AND a.title LIKE '%".$search_title."%'" ;
|
|
}
|
|
if ( $search_date != '' ){
|
|
$search_query .= " AND b.created_at like '%".$search_date."%' " ;
|
|
}
|
|
|
|
// form submit
|
|
if ($_POST['hide'] == '1' && $_POST['hide_status'] == 'action'){
|
|
switch($_POST['page_action']){
|
|
case 'trash':
|
|
$mysqli_query = "UPDATE handbook SET deleted_at = '".TODAYDATE."' WHERE handbook_id = " ;
|
|
$trash_page = trashPage('handbook', $mysqli, $mysqli_query, $_POST['multiple_trash']) ;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// 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='.$search.'&search_title='.$search_title.'&search_date='.$search_date.'&page_mode='.$page_mode ;
|
|
|
|
// page query
|
|
$mysqli_query = "SELECT a.handbook_id, a.sortable, 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 = 'en' " . $search_query ;
|
|
$mysqli_page = $mysqli->query($mysqli_query." ORDER BY a.handbook_id 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' ;
|
|
|
|
?>
|
|
<!-- Header Ends -->
|
|
<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>Handbook <small><?= $lang['list'] ?></small></h1>
|
|
</div>
|
|
<div class="pull-right col">
|
|
<?php if ( permissionCheck($row_user, 'handbook-list-new') ){ ?>
|
|
<a href="app-handbook.php?page_mode=new" class="btn" style="color:white;background-color: #5e5bd0;" target="_blank"><?= $lang['add_new'] ?></a>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="panel panel-default" id="basic-table-title">
|
|
<div class="panel-heading"></div>
|
|
<div class="panel-body">
|
|
<form method="get" class="form-horizontal">
|
|
<div class="form-group">
|
|
<label class="col-sm-2 control-label"><?= $lang['Subject'] ?></label>
|
|
<div class="col-sm-9">
|
|
<input type="text" name="search_title" value="<?= $search_title ?>" class="form-control" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="col-sm-2 control-label"><?= $lang['date'] ?></label>
|
|
<div class="col-sm-9">
|
|
<input class="form-control" name="search_date" type="date" value="<?= $search_date ?>" placeholder="Date Resigned">
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<div class="col-sm-11">
|
|
<input type="hidden" name="page_mode" value="<?= $page_mode ?>" />
|
|
<input type="hidden" name="search" value="<?= $search ?>" />
|
|
<button type="submit" class="btn" style="color:white;background-color: #5e5bd0;float:right; margin-top: 5px;width: 100px;"><?= $lang['submit'] ?></button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<form method="post">
|
|
<?php if ( permissionCheck($row_user, 'handbook-list-trash') ){ ?>
|
|
<!-- trash -->
|
|
<div class="panel panel-default">
|
|
<div class="panel-body">
|
|
<select name="page_action" class="form-control selectpicker">
|
|
<option value=""><?= $lang['select'] ?></option>
|
|
<option value="trash"><?= $lang['move_to_trash'] ?></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>
|
|
<!-- end trash -->
|
|
<?php } ?>
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading"></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><?= $lang['Action'] ?></th>
|
|
<th><?= $lang['title'] ?></th>
|
|
<th><?= $lang['date'] ?></th>
|
|
<th>Sortable</th>
|
|
<th width="50"><?= $lang['trash'] ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
if ($mysqli_page->num_rows > 0){
|
|
while ($row_page = $mysqli_page->fetch_array(MYSQLI_ASSOC)){
|
|
|
|
// default variable
|
|
$id = $row_page['handbook_id'] ;
|
|
$title = dataFilter($row_page['title']) ;
|
|
|
|
echo '
|
|
<tr class="odd gradeX">
|
|
<td class="align_center">' ;
|
|
if ( permissionCheck($row_user, 'handbook-list-edit') ){
|
|
echo '
|
|
<a title="'.$lang['Edit'].'" href="app-handbook.php?page_mode=edit&page='.$id.'"><i class="fa fa-edit"></i></a>
|
|
<span class="split">|</span>' ;
|
|
}else{
|
|
echo '-' ;
|
|
}
|
|
echo '
|
|
<a title="View Current handbook" href="app-handbook.php?page_mode=view&handbook_id='.$id.'"><i class="fa fa-eye"></i></a>
|
|
</td>
|
|
<td><a href="app-handbook.php?page_mode=edit&page='.$id.'">'.$title.'</a></td>
|
|
<td>'.resetDateFormat($row_page['created_at']).'</td>
|
|
<td>'.dataFilter($row_page['sortable']).'</td>
|
|
<td>
|
|
<div class="checkbox multiple_trash">
|
|
<input type="checkbox" name="multiple_trash['.$id.']" class="trash_button" value="1">
|
|
<label for="checkbox1"></label>
|
|
</div>
|
|
</td>
|
|
</tr>';
|
|
}
|
|
}else{
|
|
echo '
|
|
<tr class="odd gradeX">
|
|
<td class="border_none">'.$lang['no_data'].' </td>
|
|
<td class="border_none"></td>
|
|
<td class="border_none"></td>
|
|
<td class="border_none"></td>
|
|
<td class="border_none"></td>
|
|
</tr>' ;
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
<?= $page_pagination['page_pagination'] ?>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
break ;
|
|
}
|
|
// footer
|
|
include 'requires/page_footer.php' ;
|
|
?>
|