首页 > 作文

使用PHP开发HR系统(5)

更新时间:2023-04-07 12:54:29 阅读: 评论:0

本节讲述如何拆分页面以及使用jqueryajax实现局部刷新

===企业年会===============================================================================================

从我们的页面布局来看,左边的菜单是不变的,右边的内容区根据不同的菜单来变化,我们就想到是否可以只针对

右边做局部刷新呢,可以使用ajax技术来完成。

1 拆分主页

我们把页面结构分成四块区域:1、页面上端top区域;2、页面左侧menu区域;3、页面中部区域;4、页面底端footer区域;

根据这种划分,我们把main_list拆分成top,menu,footer,并把页面head也单独出来,具体参见以下步骤:

1) 在view目录下创建container.php代替main_list.php文件

<?php

defined(‘bapath’) or exit(‘no direct script access allowed’);

?>

<!doctype html>

<!–[if ie 8]> <html lang=”en” class=”ie8″> <![endif]–>

<!–[if ie 9]> <html lang=”en” class=”ie9″> <![endif]–>

<!–[if !ie]><!–>

<html lang=”en”> <!–<![endif]–>

<?php $this->load->view(‘templates/header’); ?>

<body class=”fixed-top”>

<?php $this->load->view(‘templates/top’); ?>

<div id=”container” class=”row-fluid”>

<?php $this->load->view(‘templates/menu’); ?>

<div id=”main-content”>

<?php $this->load->view(‘main’); ?>

</div>

</div>

<?php $this->load->view(‘templates/footer’); ?>

</body>

</html>

通过改造,我们的主页代码看起来就很简洁了,其中用到了几个文件:

i)header.php(view->templates目录下),用来存放页面head块代码:

<head>

<meta chart=”utf-8″ />

<title>software rvice manager system</title>

<meta content=”width=device-width, initial-scale=1.0″ name=”viewport” />

<meta content=”” name=”description” />

<meta content=”mosaddek” name=”author” />

<!–<link rel=”stylesheet” href=”http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css”/>–>

<!–<link href=”https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css” rel=”stylesheet”>–>

<link rel=”stylesheet” href=”<?php echo ba_url(‘asts/font-awesome/css/font-awesome.min’)?>”>

<link rel=”stylesheet” href=”<?php echo ba_url(‘asts/bootstrap/css/bootstrap.min.css’)?>”>

<link rel=”stylesheet” href=”<?php echo ba_url(‘asts/bootstrap/css/bootstrap-responsive.min.css’)?>”>

<link rel=”stylesheet” href=”<?php echo ba_url(‘asts/bootstrap/css/bootstrap-fileupload.css’)?>”>

<link rel=”stylesheet” href=”<?php echo ba_url(‘asts/css/style.css’)?>”>

<link rel=”stylesheet” href=”<?php echo ba_url(‘asts/css/style-responsive.css’)?>”>

<link rel=”stylesheet” href=”<?php echo ba_url(‘asts/css/style-default.css’)?>”>

<link rel=”stylesheet” type=”text/css” href=”<?php echo ba_url(‘asts/uniform/css/uniform.default.css’)?>”>

<link rel=”stylesheet” href=”<?php echo ba_url(‘asts/data-tables/dt_bootstrap.css’)?>”>

</head>

<!–end head–>

ii)top.php(view->templates目录下),用来存放页面top区域的内容:

<!– begin top –>

<div id=”top” class=”navbar navbar-inver navbar-fixed-top”>

<!– begin top navigation bar –>

<div class=”navbar-inner”>

<div class=”sidebar-toggle-box hidden-phone”>

<div class=”fa fa-reorder tooltips” data-placement=”right” data-original-title=”toggle navigation”></div>

</div>

<!–end sidebar toggle–>

<!– begin logo –>

<a class=”brand” href=”<?php echo site_url(‘main/index‘); ?>”>

<img src=”<?php echo ba_url(‘asts/img/logo.png’)?>” alt=”metro lab” />

</a>

<!– begin responsive menu toggler –>

<!– <a class=”btn btn-navbar collapd” id=”main_menu_trigger” data-toggle=”collap” data-target=”.nav-collap”>

<span class=”fa fa-bar”></span>

<span class=”fa fa-bar”></span>

<span class=”fa fa-bar”></span>

<span class=”arrow”></span>

</a>–>

<div id=”top_menu” class=”nav notify-row”>

<!– begin notification –>

</div>

<div class=”top-nav “>

<ul class=”nav pull-right top-menu”>

<!– begin support –>

<li class=”dropdown mtop5″>

<a class=”dropdown-toggle element” data-placement=”bottom” data-toggle=”tooltip” href=”#” data-original-title=”chat”>

<i class=”fa fa-comments-o”></i>

</a>

</li>

<li class=”dropdown mtop5″>

<a class=”dropdown-toggle element” data-placement=”bottom” data-toggle=”tooltip” href=”#” data-original-title=”help”>

<i class=”fa fa-headphones”></i>

</a>

</li>

<!– end support –>

<!– begin ur login dropdown –>

<li class=”dropdown”>

<a href=”#” class=”dropdown-toggle” data-toggle=”dropdown”>

<img src=”<?php echo ba_url(‘asts/img/avatar1_small.jpg’)?>” alt=””>

<span class=”urname”>jhon doe</span>

<b class=”caret”></b>

</a>

<ul class=”dropdown-menu extended logout”>

<li>

<a href=”#”>swing</a></li>

<li>

<li><a href=”#”><i class=”fa fa-ur”></i>我的资料</a></li>

<li><a href=”#”><i class=”fa fa-cog”></i>我的设置</a></li>

<li><a href=”login.html”><i class=”fa fa-key”></i>退出</a></li>

</ul>

</li>

<!– end ur login dropdown –>

</ul>

<!– end top navigation menu –>

</div>

</div>

</div>

<!– end top –>

iii)menu.php(view->templates目录下),用来存放页面menu块代码:

<div class=”sidebar-scroll” style=”overflow: hidden;” tabindex=”5000″>

<div id=”sidebar” class=”nav-collap collap”>

<!– begin responsive quick arch form –>

<div class=”navbar-inver”>

<form class=”navbar-arch visible-phone”>

<input class=”arch-query” placeholder=”arch” type=”text”>

</form>

</div>

<!– end responsive quick arch form –>

<!– begin sidebar menu –>

<ul class=”sidebar-menu”>

<li class=”sub-menu active”>

<a class=”” href=”<?php echo site_url(‘main/index’);?>”>

<i class=”fa fa-dashboard”></i>

<span>控制台</span>

</a>

</li>

<li class=”sub-menu”>

<a href=”javascript:;” class=””>

<i class=”fa fa-book”></i>

<span>人力资源规划</span>

<span class=”arrow”></span>

</a>

</li>

<li class=”sub-menu”>

<a href=”javascript:;” class=””>

<i class=”fa fa-cogs”></i>

<span>招聘与配置</span>

<span class=”arrow”></span>

</a>

<ul class=”sub”>

<li><a class=”sub1″ href=”#”>职员信息</a></li>

</ul>

</li>

<li class=”sub-menu”>

<a href=”javascript:;” class=””>

<i class=”fa fa-tasks”></i>

<span>培训与开发</span>

<span class=”arrow”></span>

</a>

</li>

<li class=”sub-menu”>

小学生健康教育教案

<a href=”javascript:;” class=””>

<i class=”fa fa-th”></i>

<span>绩效管理</span>

<span class=”arrow”></span>

</a>

</li>

<li class=”sub-menu”>

<a href=”javascript:;” class=””>

<i class=”fa fa-fire”></i>

<span>薪酬福利管理</span>

<span class=”arrow”></span>

</a>

</li>

<li class=”sub-menu”>

<a class=”” href=”javascript:;”>

<i class=”fa fa-trophy”></i>

<span>劳动关系管理</span>

<span class=”arrow”></span>

</a>

</li>

<li class=”sub-menu”>

<a href=”javascript:;” class=””>

<i class=”fa fa-tasks”></i>

<span>报表分析</span>

<span class=”arrow”></span>

</a>

</li>

<li class=”sub-menu”>

<a class=”” href=”javascript:;”>

<i class=”fa fa-map-marker”></i>

<span>系统设置</span>

<span class=”arrow”></span>

</a>

<ul class=”sub”>

<li><a class=”” href=”calendar.html”>用户管理</a></li>

<li><a class=”” href=”calendar.html”>权限管理</a></li>

</ul>

</li>

<!– end sidebar menu –>

</div>

</div>

iv)footer.php(view->templates目录下),用来存放页面footer块代码:

<!– begin footer –>

<div id=碳族元素221;footer”>

2018 &copy; metroadmin.

</div>

<!– begin javascripts –>

<!– load javascripts at bottom, this will reduce page load time –>

<!–<script src=”https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js”></script>–>

<script src=”<?php echo ba_url(‘asts/js/jquery-3.2.1.min.js’)?>”></script>

<script type=”text/javascript” src=”<?php echo ba_url(‘asts/js/jquery.nicescroll.js’)?>”></script>

<script type=”text/javascript” src=”<?php echo ba_url(‘asts/jquery-slimscroll/jquery-ui-1.9.2.custom.min.js’)?>”></script>

<script type=”text/javascript” src=”<?php echo ba_url(‘asts/jquery-slimscroll/jquery.slimscroll.min.js’)?>”></script>

<script src=”<?php echo ba_url(‘asts/fullcalendar/fullcalendar.min.js&国家一流学科#8217;)?>”></script>

<script src=”<?php echo ba_url(‘asts/bootstrap/js/bootstrap.min.js’)?>”></script>

<script src=”<?php echo ba_url(‘asts/js/jquery.blockui.js’)?>”></script>

<script src=”<?php echo ba_url(‘asts/uniform/jquery.uniform.min.js’)?>”></script>

<!– ie8 fixes –>

<!–[if lt ie 9]>

<script src=”js/excanvas.js”></script>

<script src=”js/respond.js”></script>

<![endif]–>

<script type=”text/javascript” src=”<?php echo ba_url(‘asts/jquery-easy-pie-chart/jquery.easy-pie-chart.js’)?>”></script>

<script type=”text/javascript” src=”<?php echo ba_url(‘asts/js/jquery.sparkline.js’)?>”></script>

<script src=”<?php echo ba_url(‘asts/chart-master/chart.js’)?>”></script>

<script src=”<?php echo ba_url(‘asts/js/jquery.scrollto.min.js’)?>”></script>

<!–common script for all pages–>

<script src=”<?php echo ba_url(‘asts/js/common-scripts.js’)?>”></script>

<!–script for this page only–>

<script src=”<?php echo ba_url(‘asts/js/easy-pie-chart.js’)?>”></script>

<script src=”<?php echo ba_url(‘asts/js/sparkline-chart.js’)?>”></script>

<script src=”<?php echo ba_url(‘asts/js/home-page-calender.js’)?>”></script>

<script src=”<?php echo ba_url(‘asts/js/home-chartjs.js’)?>”></script>

v)main.php(view目录下),用来存放页面主页面内容区代码:

<div class=”container-fluid”>

<!– begin page header–>

<div class=”row-fluid”>

<div class=”span12″>

<!– begin page title & breadcrumb–>

<h3 class=”page-title”>

</h3>

<ul class=”breadcrumb”>

<li>

<a href=”<?php echo site_url(‘main/index’);?>”>首页</a>

<span class=”divider”>/</span>

</li>

<li class=”pull-right arch-wrap”>

<form action=”arch_result.html” class=”hidden-phone”>

<div class=”input-append arch-input-area”>

<input class=”” id=”appendedinputbutton” type=”text”>

<button class=”btn” type=”button”><i class=”fa fa-arch”></i> </button>

</div>

</form>

</li>

</ul>

<!– end page title & breadcrumb–>

</div>

</div>

<!– end page header–>

<!– begin page content–>

<div class=”row-fluid”>

<!–begin metro states–>

<div class=”metro-nav”>

<div class=”metro-nav-block nav-block-orange”>

<a data-original-title=”” href=”#”>

<i class=”fa fa-ur”></i>

<div class=”info”>7048</div>

<div class=”status”>在职人员总数</div>

</a>

</div>

<div class=”metro-nav-block nav-olive”>

<a data-original-title=”” href=”#”>

<i class=”fa fa-tags”></i>

<div class=”info”>1023</div>

<div class=”status”>待招聘人数</div>

</a>

</div>

<div class=”metro-nav-block nav-block-yellow”>

<a data-original-title=”” href=”#”>

<i class=”fa fa-comments-alt”></i>

<div class=”info”>490</div>

<div class=”status”>本月入职人数</div>

</a>

</div>

<div class=”metro-nav-block nav-block-green double”>

<a data-original-title=”” href=”#”>

<i class=”fa fa-eye-open”></i>

<div class=”info”>288</div>

<div class=”status”>本月离职人数</div>

</a>

</div>

<div class=”metro-nav-block nav-block-red”>

<a data-original-title=”” href=”#”>

<i class爱情宣言=”fa fa-bar-chart”></i>

<div class=”info”>255</div>

<div class=”status”>本月待招聘人数</div>

</a>

</div>

</div>

<div class=”metro-nav”>

<div class=”metro-nav-block nav-light-purple double”>

<a data-original-title=”” href=”#”>

<i class=”fa fa-shopping-cart”></i>

<div class=”info”>$8979322442</div>

<div class=”status”>本年薪酬福利</div>

</a>

</div>

<div class=”metro-nav-block nav-light-blue double”>

<a data-original-title=”” href=”#”>

<i class=”fa fa-tasks”></i>

<div class=”info”>$37624</div>

<div class=”status”>本月薪酬福利</div>

</a>

</div>

</div>

<div class=”space10″></div>

<!–end metro states–>

</div>

<!– end page content–>

</div>

2)目前我们的工程结构如下

2、修改controllers->main.php文件

<?php

defined(‘bapath’) or exit(‘no direct script access allowed’);

class main extends ci_controller {

public function __construct(){

parent::__construct();

$this->load->helper(‘url_helper’);

}

public function index()

{

$this->load->view(‘container’);

}

}

3 ajax的应用

为了实现局部刷新,我们引入了ajax来实现;

1)在footer.php文件中增加以下内容

<script>

$(document).ready(function(){

$(“.sub1”).click(function(){

$.ajax({url:”<?php echo site_url(’employee/index’)?>”,success:function(result){

$(“#main-content”).html(result);

}});

});

});

</script>

其中,sub1是与menu.php中的”职员信息”菜单对应的。

3 运行测试

运行主页如下;

点”职员信息”菜单,页面如下

总结:

本文首先拆分了主页,使得模块更加独立,页面代码也更清晰,同时使用ajax技术,实现了页面的局部刷新;

====================================the end==========================

本文发布于:2023-04-07 12:54:23,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/401887e12ea038eebda181c9eba10031.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:使用PHP开发HR系统(5).doc

本文 PDF 下载地址:使用PHP开发HR系统(5).pdf

标签:微软   页面   区域   代码
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图