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'] ; } } // check permission if ( !permissionCheck($row_user, 'form-submission-category-view') ){ header('Location: index.php') ; exit ; } // 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 formsubmission WHERE formsubmissionid = '".$formsubmissionid."' LIMIT 1"); if ($mysqli_page->num_rows > 0){ // keep query value in array $row_page = $mysqli_page->fetch_array(MYSQLI_ASSOC) ; $submit_type = 'edit' ; } // update database if ( isset($type) && ( $type == 'new' || $type == 'edit' ) && $_POST['hide'] == 1 ){ // keep value in variable $page_title = escapeString($_POST['title']) ; $page_title = ($page_title != '' ? $page_title : 'No Title') ; if ( $formsubmissionid == '' ){ $mysqli->query( "INSERT INTO formsubmission ( created_at ) VALUES ( '".TODAYDATE."' )" ) ; $formsubmissionid = $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 = ''," ; } if ( $image != '' ){ $get_image = pathinfo($image) ; $create_image = reCreateImage('FormSubmissionCategory', $formsubmissionid, $formsubmissionid, '', $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']."'," ; } } $array_branch = [] ; foreach ( $_POST['branch'] as $k_branch => $v_branch ){ $array_branch[] = escapeString( $v_branch ) ; } // update database $mysqli->query( "UPDATE formsubmission SET ".$image_query." submission_type = '".escapeString($_POST['submission_type'])."', updated_at = NOW() WHERE formsubmissionid = '".$formsubmissionid."'" ) ; $title_en = '' ; foreach ( $LANGS as $klang => $vlang ){ $title = escapeString( $_POST['title_'.$klang] ) ; $content = escapeString( $_POST['content_'.$klang] ) ; if ( $klang == 'en' ){ $title_en = $title ; } checkLangUpdate( 'formsubmission_translation', 'formsubmissionid', $formsubmissionid, $klang, [ 'title' => [ 'type' => 'input', 'value' => $title ] //, // 'content' => [ 'type' => 'input', 'value' => $content ] ] ) ; } // refresh page header("Location:app-form-submission-category.php?page_mode=edit&formsubmissionid=".$formsubmissionid."&success=1") ; $_SESSION['system_result'] = 'success-updated' ; exit ; } if ( ( $page_mode == 'new' && !permissionCheck($row_user, 'form-submission-category-new') ) || ( $page_mode == 'edit' && !permissionCheck($row_user, 'form-submission-category-edit') ) ){ header('Location: app-form-submission-category.php') ; exit ; } // start header here include 'requires/page_header.php'; include 'requires/page_top.php'; ?>