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'; ?>
'.$lang['Thank you details has been updated'].'
' ; break ; } unset($_SESSION['system_result']) ; } ?>
To
       
[ 'type' => 'input', 'title' => $lang['title'] ] ]) ; ?>
Sub Category
Sortable

Format
>
Photo
>
Preview
 Remove pdf Download' ; }else{ echo ' ' ; } ?>
>
Message
>
Video
Is Signature
Is Signature Retick
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'; ?>
Join Staff
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 ' '; } } ?>
Profile Staff ID Name Agreed Date
'.( $staff_image != '' ? '' : '' ).' '.dataFilter($row_list['staff_idno']).' '.dataFilter($row_list['staff_name']).' '.resetDateFormat($row_list['created_at']).'
Preview
Title
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' ; ?>
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 ' '; } }else{ echo ' ' ; } ?>
Sortable
' ; if ( permissionCheck($row_user, 'handbook-list-edit') ){ echo ' |' ; }else{ echo '-' ; } echo ' '.$title.' '.resetDateFormat($row_page['created_at']).' '.dataFilter($row_page['sortable']).'
'.$lang['no_data'].'