���� JFIF �� � ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/netphim/code/manager/module_category/ |
<?php global $DB; function module_category_selected($id,$parentid,$aCats,$res,$sep){ foreach($aCats as $val){ if($val['module_category_parentid']==$parentid){ if($id==$val['module_category_id']){ $re = '<option value="'.$val['module_category_id'].'" selected> + '.$sep.' '.$val['module_category_name'].' ('.$val['module_category_pos'].')</option>'; }else{ $re = '<option value="'.$val['module_category_id'].'"> + '.$sep.' '.$val['module_category_name'].' ('.$val['module_category_pos'].')</option>'; } $res .= module_category_selected($id,$val['module_category_id'],$aCats,$re,$sep.' + '); } } return $res; } function tree_menu($parentid,$arr,$sep){ if(!is_null($arr)) { foreach ($arr as $key => $v) { if ($v['module_category_parentid'] == $parentid) { $arr[$key]['module_category_name'] = $sep . ' ' . $arr[$key]['module_category_name']; $arr = tree_menu($v['module_category_id'], $arr, $sep . " + "); } } } return $arr; } $CORE->page_title = ($v_lang=='en')?'Module category':'Danh mục chức năng'; $type = isset($CORE->input['type']) ? $CORE->input['type'] : ''; switch ($type){ case 'delete': global $INFO; $module_category_id = $CORE->input['module_category_id']; $row_check = $DB->fetch_row($DB->query("SELECT * FROM tb_module WHERE module_cat='$module_category_id'")); if($row_check){ $print->refresh('?act=manager&code=module_category','Some modules used this category, can not delete',2); }else{ $DB->query("DELETE FROM tb_module_category WHERE module_category_parentid='".$module_category_id."' "); $DB->query("DELETE FROM tb_module_category WHERE module_category_id='".$module_category_id."' "); $print->refresh('?act=manager&code=module_category'); } break; case 'post' : $module_category_id = isset($CORE->input['module_category_id']) ? intval($CORE->input['module_category_id']) : 0; $row_check = $DB->get_colum_tb('tb_module_category'); if($module_category_id>0) { $row_check = $DB->fetch_row($DB->query("SELECT * FROM `tb_module_category` WHERE `module_category_id` = '$module_category_id' ")); } $aCats = array(); $op_menu = ''; $query_menu = $DB->query("SELECT * FROM tb_module_category "); while($rows_menu = $DB->fetch_row($query_menu)) { $aCats[] = $rows_menu; } $op_menu = module_category_selected($row_check['module_category_parentid'],0,$aCats,'<option value="0"> Choose a module category</option>',''); $html_block = 'post'; if(isset($CORE->input['submitbt'])){ $f = $CORE->input['f']; if($f['module_category_name']!='') { if(intval($f['module_category_id'])>0){ $DB->query("UPDATE tb_module_category SET module_category_name='".$f['module_category_name']."' ,module_category_ename='".$f['module_category_ename']."', module_category_icon='" . $f['module_category_icon'] . "',module_category_parentid='" . $f['module_category_parentid'] . "',module_category_pos='" . $f['module_category_pos'] . "' WHERE module_category_id='".intval($f['module_category_id'])."'"); $v_module_category_id = intval($f['module_category_id']); }else { $DB->query("INSERT INTO `tb_module_category` ( `module_category_name`, `module_category_ename`, `module_category_parentid`,`module_category_icon`, `module_category_pos`,user_id) VALUES ( '" . $f['module_category_name'] . "', '" . $f['module_category_ename'] . "', '" . $f['module_category_parentid'] . "', '" . $f['module_category_icon'] . "', '" . $f['module_category_pos'] . "','".$_SESSION['user_id']."');"); $v_module_category_id = $DB->insert_id(); } //upload logo if($_FILES['image_field']){ include ROOT_PATH.'lib/class.upload.php'; $handle = new upload($_FILES['image_field']); if ($handle->uploaded) { $v_image_name = $v_module_category_id.'_'.time(); $handle->allowed = array('image/*'); $handle->file_new_name_body = $v_image_name; $handle->file_max_size = '1000000'; $handle->image_convert = 'png'; $handle->process(ROOT_PATH.'upload/logos/'); if ($handle->processed) { if($row_check['module_category_img']!='') { unlink(ROOT_PATH . 'upload/logos/' . $row_check['module_category_img'] . '.png'); } $DB->query("UPDATE tb_module_category SET module_category_img='".$v_image_name."' WHERE module_category_id='$v_module_category_id' "); $handle->clean(); } else { echo 'Upload Error : ' . $handle->error; exit(); } } } $print->refresh('?act=manager&code=module_category'); } } break; default: $keyword = isset($CORE->input['fkeyword']) ? $CORE->input['fkeyword'] : ''; $where = "WHERE module_category_name<>''"; if($keyword!='') { $where .= " AND (module_category_name LIKE '%".$keyword."%' or module_category_ename LIKE '%".$keyword."%') "; } $pageNum = isset($_GET['pageNum']) ? intval($_GET['pageNum']) : 1; $pageSize = 10; $from = (($pageNum * $pageSize) - $pageSize); $t = $DB->fetch_row($DB->query("SELECT count(*) as total FROM tb_module_category ".$where)); $total = $t['total']; $totalPage = ceil($total / $pageSize); $query = $DB->query("SELECT * FROM tb_module_category ".$where." ORDER BY `module_category_pos` ASC LIMIT $from, $pageSize"); $arr = array(); while($row = $DB->fetch_row($query)) { $arr[] = $row; } $list_company = tree_menu(0,$arr,'+'); $nav = $print->Pagination($totalPage,$pageNum,'menu','index.php?act=manager&code=module_category&fkeyword='.$keyword); $txt_list_company = ''; foreach($list_company as $val){ if($val['module_category_img']!='' and file_exists(ROOT_PATH.'upload/logos/'.$val['module_category_img'].'.png')){ $txt_img = 'upload/logos/'.$val['module_category_img'].'.png'; }else{ $txt_img = 'upload/logos/no-image.png'; } $txt_list_company .= '<tr> <td><input name="txt_pos['.$val['module_category_id'].'][]" class="form-control" type="text" value="'.$val['module_category_pos'].'" style="width:100px;"></td> <td>'.$val['module_category_name'].'</td> <td>'.$val['module_category_ename'].'</td> <td><img src="'.$txt_img.'" style="width: 20px;"></td> <td>'.html_entity_decode($val['module_category_icon']).'</td> <td> <a href="?act=manager&code=module_category&type=post&module_category_id='.$val['module_category_id'].'" class="btn btn-sm btn-icon btn-pure btn-outline delete-row-btn">Edit</a> <a href="?act=manager&code=module_category&type=delete&module_category_id='.$val['module_category_id'].'" class="btn btn-sm btn-icon btn-pure btn-outline delete-row-btn" onclick="return confirm(\'Are you sure want to delete?\');">Delete</a> </td> </tr>'; } $html_block = 'list'; $type2 = isset($CORE->input['type2']) ? $CORE->input['type2'] : ''; if($type2=='update_pos'){ if(isset($CORE->input['txt_pos'])) { $pos = $CORE->input['txt_pos']; foreach ($pos as $key=>$val){ $DB->query("UPDATE tb_module_category SET module_category_pos = '".$val[0]."' WHERE module_category_id='$key' "); } unset($pos); } $print->refresh('index.php?act=manager&code=module_category'); } break; } ?> <?php include ROOT_PATH . 'include/block/header_admin.php'; ?> <div class="container-fluid page-body-wrapper"> <div class="main-panel"> <div class="content-wrapper"> <div class="card"> <div class="card-body"> <nav aria-label="breadcrumb"> <ol class="breadcrumb breadcrumb-custom bg-inverse-info"> <li class="breadcrumb-item"><a href="index.php">Home</a></li> <li class="breadcrumb-item"><a href="?act=manager&code=module_category"><?php echo $CORE->page_title;?></a></li> <li class="breadcrumb-item active" aria-current="page"><span><?php echo $CORE->page_title;?> management</span></li> </ol> </nav> <div class="container-fluid"> <div class="row"> <div class="col-12"> <?php if($html_block=='delete'){ ?> <form action="?act=manager&code=module_category&type=delete" method="post"> <input type="hidden" value="<?php echo $module_category_id;?>" name="module_category_id"> <div class="card"> <div class="card-body"> <h4 class="card-title">Some data will be lost when you delete this record:</h4> <h6 class="card-subtitle">About <?php echo $i;?> result</h6> <ul class="search-listing"> <?php echo $txt_list_table_delete;?> </ul> </div> <div class="form-actions"> <button type="submit" class="btn btn-success" name="submitbt_delete"> Agree delete</button> <button type="button" class="btn btn-inverse" onclick="location.href='?act=manager&code=module_category'">Cancel</button> </div> </div> </form> <?php } ?> <?php if($html_block=='post'){ ?> <div class="card card-outline-info"> <div class="card-header"> <h4 class="m-b-0">Module category management post</h4> </div> <div class="card-body"> <form action="?act=manager&code=module_category&type=post" method="post" enctype="multipart/form-data"> <input type="hidden" value="<?php echo $row_check['module_category_id'];?>" name="f[module_category_id]"> <div class="form-body"> <div class="row p-t-20"> <div class="col-md-4"> <div class="form-group"> <label class="control-label">Module category name</label> <input type="text" class="form-control" placeholder="" name="f[module_category_name]" value="<?php echo $row_check['module_category_name'];?>" required> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="control-label">Module category english name</label> <input type="text" class="form-control" name="f[module_category_ename]" value="<?php echo $row_check['module_category_ename'];?>" required> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="control-label">Module category icon fontawesome.com</label> <input type="text" class="form-control" name="f[module_category_icon]" value="<?php echo $row_check['module_category_icon'];?>" required> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label class="control-label">Sub module category:</label> <select class="form-control custom-select" data-placeholder="Choose a Category" name="f[module_category_parentid]"> <?php echo $op_menu; unset($op_menu);?> </select> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label class="control-label">Vị trí:</label> <input type="text" class="form-control" placeholder="" name="f[module_category_pos]" value="<?php echo $row_check['module_category_pos'];?>" required> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>Image</label> <input type="file" name="image_field"> </div> </div> <div class="col-md-4"> <div class="form-group"> <?php if($row_check['module_category_img']!='' and file_exists(ROOT_PATH.'upload/logos/'.$row_check['module_category_img'].'.png') ){ ?> <img src="upload/logos/<?php echo $row_check['module_category_img'];?>.png" style="width:100px;"> <?php }else{ ?> <img src="upload/logos/no-image.png" style="width:100px;"> <?php } ?> </div> </div> </div> </div> <div class="form-actions"> <button type="submit" class="btn btn-success" name="submitbt"> <i class="fa fa-check"></i> Save</button> <button type="button" class="btn btn-inverse" onclick="location.href='index.php?act=manager&code=module_category'">Cancel</button> </div> </form> </div> </div> <?php } ?> <?php if($html_block=='list'){ ?> <div class="card"> <div class="card-body"> <div class="m-t-40"> <div class="d-flex"> <div class="mr-auto"> <div class="form-group"> <a href="?act=manager&code=module_category&type=post" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i> Thêm </a> <a href="javascript:void(0);" class="btn btn-primary btn-sm" id="update_pos"><i class="fa fa-bars"></i> Cập nhật vị trí </a> </div> </div> <div class="ml-auto"> <div class="form-group"> <input id="demo-input-search2" type="text" placeholder="Search" autocomplete="off" class="module_title_search" value="<?php echo $keyword;?>"> <input type="hidden" value="a=WALLS2&act=module_category" id="txt_code_search"> </div> </div> </div> </div> <form action="" method="post" id="form_quick_update"> <input type="hidden" name="type2" value=""> <table class="table table-bordered color-table primary-table footable"> <thead> <tr> <th>Pos</th> <th>Name</th> <th>English name</th> <th>Image</th> <th>Icon</th> <th>#</th> </tr> </thead> <tbody> <?php echo $txt_list_company;?> </tbody> </table> </form> <div class="text-center footable"> <ul class="pagination"> <?php echo $nav;?> </ul> </div> </div> </div> <?php } ?> </div> </div> </div> </div> </div> </div> </div> </div> <?php include ROOT_PATH . 'include/block/footer_admin.php'; ?>