php学习完mvc后实现分离,添加了smarty 模板引擎
目录结构:
application 程序入口 存放 Controller Model templates下存放所有网页相关
framework 存放smarty mysql console basemodel basecontroller ModelFactory
index.php 唯一的入口文件,根据请求分配任务
session_start();
//开启session 验证登录信息成功 保存用户名
$p=!
empty(
$_GET[
'p']) ?
$_GET[
'p'] :
"admin";
//判断加载哪个平台
$c=!
empty(
$_GET[
'c']) ?
$_GET[
'c'] :
"User";
//接收并保存需要加载的控制器 把User作为默认使用的控制器
$act=!
empty(
$_GET[
'a'])?
$_GET[
'a']:
"index";
//接收并保存需要运行的 方法
define(
"PLAT",
$p);
//平台信息
define(
"DS",DIRECTORY_SEPARATOR);
//平台分隔符
define(
"ROOT",
__DIR__.DS);
//当前mvc框架的根目录
define(
"APP",ROOT.
'application'.DS);
//applation目录
define(
"FRAMEWORK",ROOT.
'framework'.DS);
//框架基础类所在路径
define(
"SMARTY_PATH",ROOT.
'libs'.DS);
//smarty目录
define(
"PLAT_PATH",APP.PLAT.DS);
//框架基础类所在路径
define(
"CTRL_PATH",PLAT_PATH.
"controller".DS);
//controller目录
define(
"MODEL_PATH",PLAT_PATH.
"model".DS);
//models目录
define(
"VIEW_PATH",PLAT_PATH.
"templates".DS);
//applation目录
define(
"VIEW_DATA_PATH",
"application".DS.DS.PLAT.DS.DS.
"templates".DS.DS);
//网页js css img路径用了//因为js中俩代表一个/
//此处未用function __autoload()因为 加载Smarty的时候会找不到类 ,所以用spl_autoload_register
function
autoload(
$class){
//自定义自动加载类
$base_class=
array(
'Console',
'Smarty',
'ModelFactory',
'MySQL',
'BaseController',
'BaseModel');
if(
in_array(
$class,
$base_class)){
require(FRAMEWORK.
$class.
'.class.php');
//加载基础类库
//Console::log('加载了类'.FRAMEWORK.$class.'.class.php');
}
else
if(
substr(
$class,-
5)==
"Model"){
require MODEL_PATH .
$class.
'.class.php';
//动态加载Model
//Console::log('加载了类'.MODEL_PATH .$class.'.class.php');
}
else
if(
substr(
$class,-
10)==
"Controller"){
require CTRL_PATH.
$class.
".class.php";
//动态加载controller
//Console::log('加载了类'.CTRL_PATH.$class.".class.php");
}
}
spl_autoload_register(
'autoload');
//将自定义自动加载类注册到自动加载队列中
$controller_name=
$c.
"Controller";
//构建控制器类名
$ctrl=
new $
controller_name();
//创建相应的控制器
$action=
$act.
"Action";
//构建控制器方法名
$ctrl->
$action();
//执行方法
Console.class.php
/* php通过js console实现代码调试类
* log类打印数据
*/
class
Console{
public
static
function
log(
$val){
$str=
str_repeat (
"—" ,
20 ).
' (∩_∩) '.
str_repeat (
"—" ,
20 );
echo
'';
}
}
?
>
ModelFactory.class.php 单例工厂
//单例工厂类
//通过这个工厂类,可以传递过来一个模型类的类名
//并返回给类的一个实例,并且,保证其为“单例的”;
class
ModelFactory{
static
$all_model=
array();
//用于存储各个模型类的唯一实例
private
function
__construct(){}
//禁止实例化
private
function
__clone(){}
//禁止克隆对象
static
function
M(
$model_name){
//传递一个模型类的类名
if (!
isset(
static::
$all_model[
$model_name])
//如果不存在
||
!(
static::
$all_model[
$model_name] instanceof
$model_name)
//或者不是其实例
) {
static::
$all_model[
$model_name]=
new $
model_name();
}
return
static::
$all_model[
$model_name];
}
}
BaseModel.class.php
class
BaseModel{
protected
$db=
null;
//存储数据库工具类的实例
function
__construct(){
$config=
array(
'db_host'=>
"localhost",
'db_port'=>
"3306",
'db_user'=>
"root",
'db_pass'=>
"root",
'db_charset'=>
"utf8",
'db_name'=>
"db_market"
);
$this->
db=
MySQL::
instance(
$config);
}
}
BaseController.class.php
//基础控制器类
class
BaseController{
public
$smarty=
null;
//定义页面显示类
public
$currentuser=
null;
function
__construct(){
header(
"content-type:text/html;charset=utf8");
$this->
smarty =
ModelFactory::
M(
"Smarty");
$this->
smarty ->
setTemplateDir(VIEW_PATH)
->
setCompileDir(ROOT.
'templates_c')
->
setPluginsDir(ROOT.
'plugins'.DS)
->
setCacheDir(ROOT.
'cache'.DS)
->
setConfigDir(ROOT.
'configs');
$this->
smarty->
force_compile =
false;
$this->
smarty->
debugging =
false;
$this->
smarty->
caching=
false;
$this->
smarty->
cache_lifetime=
60*
60*
24;
$this->
smarty->
left_delimiter=
'{';
$this->
smarty->
right_delimiter=
'}';
$this->
smarty->
assign(
'view_data_path',VIEW_DATA_PATH);
$currentuser=
isset(
$_SESSION[
'u'])?
$_SESSION[
'u']:
'游客';
//调用session显示当前登陆用户名
$purview=
isset(
$_SESSION[
'upurview'])?
$_SESSION[
'upurview']:
'3';
$this->
smarty->
assign(
'purview',
$purview);
$this->
smarty->
assign(
'currentuser',
$currentuser);
@
Console::
log(
"BaseController 中实例化了smarty");
}
}
Mysql.class.php
/* php调试工具
*
*/
/****************************************处理mysql数据类************************************************
*
*
*
*/
class
MySQL{
private
$db_host;
//数据库基本参数
private
$db_admin;
private
$db_pass;
private
$db_name;
private
$db_port;
private
$charset;
//数据库编码设置
private
$conn;
//数据库连接
//----------单例模式设计---------------------------------------
private
static
$instance=
null;
//存储单例对象
static
function
instance(
$config){
//单例第3步
//if(isset(self::$instance)){//判断是否存在对象
if(!
self::
$instance instanceof
self){
//代替上一行,更常用的做法
self::
$instance=
new
self(
$config);
}
return
self::
$instance;
}
private
function
__clone(){}
private
function
__construct(
$config){
$this->
db_host=!
empty(
$config[
'db_host'])?
$config[
'db_host']:
"localhost";
//参数非空检测 赋默认值
$this->
db_admin=!
empty(
$config[
'db_admin'])?
$config[
'db_admin']:
"root";
$this->
db_pass=!
empty(
$config[
'db_pass'])?
$config[
'db_pass']:
"root";
$this->
db_name=!
empty(
$config[
'db_name'])?
$config[
'db_name']:
"db_market";
$this->
db_port=!
empty(
$config[
'db_port'])?
$config[
'db_port']:
"3306";
$this->
charset=!
empty(
$config[
'charset'])?
$config[
'charset']:
"utf8";
$this->
conn=
new
mysqli(
$this->
db_host,
$this->
db_admin,
$this->
db_pass) or
die(
"链接失败");
//初始化conn
$this->
setCharset(
$this->
charset);
//设置编码
$this->
selectDB(
$this->
db_name);
//使用数据库
}
function
setCharset(
$charset ){
//可以设定要使用的连接编码
$this->
conn->
query(
"set names
$charset
");
}
function
changeDB(
$db_name){
//修改当前需要使用的数据库
$this->
db_name=
$db_name;
}
function
selectDB(
$dbname){
//可以设定要使用的数据库
$this->
conn->
query(
"use
$dbname
");
}
function
closeDB(){
//可关闭连接
$this->
conn->
close();
}
function
runQuery(
$sql){
//通用query运行器
return
$this->
conn->
query(
$sql);
}
function
selectAllDate(
$sql){
//查询出所有数据
Console::
log(
$sql);
$models=
array();
$this->
conn->
query(
"set charset set 'utf8'");
$this->
conn->
query(
$sql);
$result=
$this->
conn->
query(
$sql) or
die(
"查询数据无结果");
//如果无无数,加判断
//$result=$this->conn->query($sql);//如果无无数,加判断
Console::
log(
$this->
conn->
query(
$sql));
if(
$result->
num_rows>
0){
for (
$i=
0;
$row=
$result->
fetch_assoc();
$i++) {
$models[
$i] =
$row;
}
}
return
$models;
}
//---------增删改查,运行squery前判断数据库是否存在------------------------------
function
insertDate(
$tbname,
$obj){
//表中插入数据
$sqlstr1=
"insert into {
$tbname
} (";
//字符串组成部分
$sqlstr2=
")values(";
$sqlstr3=
")";
$str=
json_encode(
$obj,JSON_UNESCAPED_UNICODE);
//实例化model成字符串
$newstr =
substr(
$str,
1,
strlen(
$str)-
2);
//去除 前后 {}
$newstr=
str_replace(
"
\"
",
"'",
$newstr);
// " 替代成 '
$strarray=
explode(
",",
$newstr);
//字符串转化成array
foreach (
$strarray as
$key =>
$value) {
//遍历字符串
$inarray=
explode(
":",
$value);
//取出键跟值
//echo $inarray[0]."||".$inarray[1];
//在键值后加, 最后一个不加
if(
end(
$strarray)==
$value){
$sqlstr1.=
$inarray[
0];
$sqlstr2.=
$inarray[
1];
}
else{
$sqlstr1.=
$inarray[
0].
",";
$sqlstr2.=
$inarray[
1].
",";
}
}
$sqlstr1=
str_replace(
"'",
"",
$sqlstr1);
//去掉单引号
$sql=
$sqlstr1.
$sqlstr2.
$sqlstr3;
Console::
log(
$sql);
//拼接 运行sql
$this->
conn->
query(
"set names 'utf8'");
return
$this->
conn->
query(
$sql);
}
//修改数据
function
updateDateByID(
$tbname,
$id,
$obj){
//$sql="update gb_users set username='amy',passwd='admin',email='2222',insert_time=now() where id=12;";
$sqlstr1=
"update {
$tbname
} set ";
//字符串组成部分
$sqlstr2=
"";
$sqlstr3=
" where id=
$id
";
$str=
json_encode(
$obj,JSON_UNESCAPED_UNICODE);
//实例化model成字符串
$newstr =
substr(
$str,
1,
strlen(
$str)-
2);
//去除 前后 {}
$newstr=
str_replace(
"
\"
",
"'",
$newstr);
// " 替代成 '
$strarray=
explode(
",",
$newstr);
//字符串转化成array
foreach (
$strarray as
$key =>
$value) {
//遍历字符串
$inarray=
explode(
":",
$value);
//取出键跟值
if(
end(
$strarray)==
$value){
//在键值后加, 最后一个不加
$sqlstr2.=
str_replace(
"'",
"",
$inarray[
0]).
"=".
$inarray[
1];
}
else{
$sqlstr2.=
str_replace(
"'",
"",
$inarray[
0]).
"=".
$inarray[
1].
",";
}
}
$sql=
$sqlstr1.
$sqlstr2.
$sqlstr3;
//拼接 运行sql
Console::
log(
$sql);
$this->
conn->
query(
$sql);
}
function
deleteDateById(
$table,
$id){
//删除数据通过id
$sql=
"delete from {
$table
} where id={
$id
}";
$result=
$this->
conn->
query(
$sql);
Console::
log(
$result);
}
function
getCount(
$table){
//查询表中数据数量
$sql=
"select count(*) as count from {
$table
}";
$result=
$this->
conn->
query(
$sql);
if(
$result->
num_rows>
0){
$row=
$result->
fetch_assoc();
return
$row[
'count'];
}
}
function
getPage(
$sql,
$star,
$length){
//分页数据查询
$models=
array();
$this->
conn->
query(
"set charset set 'utf8'");
$sql=
$sql.
" limit {
$star
},{
$length
}";
$this->
conn->
query(
$sql);
$result=
$this->
conn->
query(
$sql) or
die(
"查询数据无结果");
//如果无无数,加判断
if(
$result->
num_rows>
0){
for (
$i=
0;
$row=
$result->
fetch_assoc();
$i++) {
$models[
$i] =
$row;
}
}
return
$models;
}
}
billcontroller
//定义控制器类
class
BillController
extends
BaseController{
function
selectAction(){
//查询出所有的数据
$bmodel=
ModelFactory::
M(
"BillModel");
//实例化model
$suppliers=
$bmodel->
getALLSupplier();
//查询所有供应商
$this->
smarty->
assign(
"supplier",
$suppliers);
$arr=
array();
$pagecount=
$bmodel->
getPageCount();
//查询多少页
Console::
log(
"pagecount".
$pagecount);
for(
$i=
1;
$i<=
$pagecount;
$i++){
$arr[
$i]=
$i;
}
$this->
smarty->
assign(
"pagecount",
$arr);
$page=
isset(
$_GET[
'from'])?
$_GET[
'from']:
'bill';
//按照条件查询bill信息
$pagenum=
isset(
$_GET[
'pn'])?
$_GET[
'pn']:
1;
//按照条件查询bill信息
$this->
smarty->
assign(
"pagenum",
$pagenum);
Console::
log(
$pagenum);
if(
$page==
"find"){
$par1=
$_GET[
'gname']!=
"" ?
$_GET[
'gname'] :
"%";
$par2=
$_GET[
'tigong']!=
"" ?
$_GET[
'tigong'] :
"%";
$par3=
$_GET[
'fukuan']!=
"" ?
$_GET[
'fukuan'] :
"%";
$sql=
"where gname like '%{
$par1
}%' and sname like '{
$par2
}' and ispay like '{
$par3
}' order by g.ctime desc";
$result=
$bmodel->
getAllBill(
$sql,
$pagenum);
//查询所有订单
$this->
smarty->
assign(
"result",
$result);
$this->
smarty->
display(
'billList.tpl');
}
if(
$page==
"bill"){
$sql=
"where gname like '%' and sname like '%' and ispay like '%' order by g.id ";
$result=
$bmodel->
getAllBill(
$sql,
$pagenum);
//查询出所有账单信息
$this->
smarty->
assign(
"result",
$result);
$this->
smarty->
display(
'billList.tpl');
}
}
function
showAddAction(){
//跳转到添加页面
$bmodel=
ModelFactory::
M(
"BillModel");
//实例化model
$suppliers=
$bmodel->
getALLSupplier();
//查询所有供应商
$this->
smarty->
assign(
"supplier",
$suppliers);
$this->
smarty->
display(
'billAdd.tpl');
}
function
addAction(){
//添加数据
if(
$_POST){
$bid=
$_POST[
'billId'];
$bname=
$_POST[
'billName'];
$bnum=
$_POST[
'billNum'];
$bmoney=
$_POST[
'money'];
$bsupplier=
$_POST[
'supplier'];
$bzhifu=
$_POST[
'zhifu'];
$ctime=
date(
"Y-m-d");
$bm =
array(
'gid' =>
$bid,
'gname' =>
$bname,
'gcompany' =>
$bsupplier,
'gcount' =>
$bnum,
'gmoney' =>
$bmoney,
'ispay' =>
$bzhifu,
'ctime' =>
$ctime
);
$bmodel=
ModelFactory::
M(
"BillModel");
//实例化model
$result=
$bmodel->
addBill(
$bm);
//添加数据
if(
$result){
echo
"";
}
else{
echo
"";
}
}
}
function
showAction(){
$gid=
$_GET[
'gid'];
$gname=
$_GET[
'gname'];
$gcompany=
$_GET[
'gcompany'];
$gmoney=
$_GET[
'gmoney'];
$ispay=
$_GET[
'ispay'];
$this->
smarty->
assign(
"gid",
$gid);
$this->
smarty->
assign(
"gname",
$gname);
$this->
smarty->
assign(
"gcompany",
$gcompany);
$this->
smarty->
assign(
"gmoney",
$gmoney);
if(
$ispay){
$ispay=
"已付款";
}
else{
$ispay=
"未付款";
}
$this->
smarty->
assign(
"ispay",
$ispay);
$this->
smarty->
display(
'billView.tpl');
}
function
delAction(){
//del页面
$bmodel=
ModelFactory::
M(
"BillModel");
//实例化model
$delid=
$_GET[
'id'];
$result=
$bmodel->
delBill(
$delid);
Console::
log(
$result);
echo
"";
}
function
showUpdateAction(){
$id=
$_GET[
'id'];
$sid=
$_GET[
'sid'];
$gid=
$_GET[
'gid'];
$gname=
$_GET[
'gname'];
$gcompany=
$_GET[
'gcompany'];
$gmoney=
$_GET[
'gmoney'];
$ispay=
$_GET[
'ispay'];
$this->
smarty->
assign(
"id",
$id);
$this->
smarty->
assign(
"gid",
$gid);
$this->
smarty->
assign(
"sid",
$sid);
$this->
smarty->
assign(
"gname",
$gname);
$this->
smarty->
assign(
"gcompany",
$gcompany);
$this->
smarty->
assign(
"gmoney",
$gmoney);
$this->
smarty->
assign(
"ispay",
$ispay);
$this->
smarty->
display(
'billUpdate.tpl');
}
function
updateAction(){
if(
$_POST){
$id=
$_POST[
'id'];
$bid=
$_POST[
'providerId'];
$bname=
$_POST[
'providerName'];
$bnum=
isset(
$_POST[
'billNum'])?
$_POST[
'billNum']:
'10';
$bmoney=
$_POST[
'address'];
$bsupplier=
$_POST[
'sid'];
$bzhifu=
$_POST[
'zhifu'];
$ctime=
date(
"Y-m-d");
$bm =
array(
'gid' =>
$bid,
'gname' =>
$bname,
'gcompany' =>
$bsupplier,
'gcount' =>
$bnum,
'gmoney' =>
$bmoney,
'ispay' =>
$bzhifu,
'ctime' =>
$ctime
);
$bmodel=
ModelFactory::
M(
"BillModel");
//实例化model
$result=
$bmodel->
updateBill(
$id,
$bm);
//数据 通过id
echo
"";
}
}
}
billmodel
class
BillModel
extends
BaseModel{
function
getAllBill(
$sql,
$pagecount){
//获取所有订单信息
$count=
$this->
getPageCount();
$sql1=
"select s.id as sid,g.id,g.gid,g.gname,s.sname as gcompany,g.gcount,g.gmoney,g.ispay,g.ctime from tb_goods as g
left join tb_supplier as s on g.gcompany=s.id ";
$startpage=
$pagecount*
8-
8;
//分页开始
$sql1=
$sql1.
$sql.
"limit
$startpage
,8";
Console::
log(
$sql1);
return
$this->
db->
selectAllDate(
$sql1);
}
function
getPageCount(){
//获取分页数据
$count=
$this->
db->
getCount(
'tb_goods');
//要查询的页面
$count=
ceil(
$count/
8);
return
$count;
}
function
getALLSupplier(){
//获取所有的供应商信息
$sql=
"select id,sname from tb_supplier";
//查询出所有供应商显示在select中
$supplier=
$this->
db->
runQuery(
$sql);
$suppliers=
array();
if(
$supplier->
num_rows>
0){
while (
$row=
$supplier->
fetch_assoc()) {
$suppliers[]=
$row;
}
}
return
$suppliers;
}
function
addBill(
$cfg){
return
$this->
db->
insertDate(
"tb_goods",
$cfg);
}
function
delBill(
$id){
$sql=
"delete from tb_goods where id={
$id
}";
return
$this->
db->
runQuery(
$sql);
}
function
updateBill(
$id,
$obj){
return
$this->
db->
updateDateByID(
"tb_goods",
$id,
$obj);
}
}
header footer
DOCTYPE html
>
<
html
>
<
head
lang=
"en"
>
<
meta
charset=
"UTF-8"
>
<
title
>超市账单管理系统
title
>
<
link
rel=
"stylesheet"
href=
"{$view_data_path}css/public.css"
/>
<
link
rel=
"stylesheet"
href=
"{$view_data_path}css/style.css"
/>
<
link
rel=
"stylesheet"
href=
"{$view_data_path}css/bootstrap.min.css"
>
<
script
src=
"{$view_data_path}js/jquery.min.js"
>
script
>
<
script
src=
"{$view_data_path}js/bootstrap.min.js"
>
script
>
<
script
src=
"{$view_data_path}js/jquery.js"
>
script
>
<
script
src=
"{$view_data_path}js/js.js"
>
script
>
<
script
src=
"{$view_data_path}js/time.js"
>
script
>
head
>
<
body
>
<
header
class=
"publicHeader"
>
<
h1
>超市账单管理系统
h1
>
<
div
class=
"publicHeaderR"
>
<
p
><
span
id=
"hours"
>下午好!
span
><
span
style=
"color: #fff21b"
>{
$currentuser}
span
> , 欢迎你!
p
>
<
a
href=
"index.php"
>退出
a
>
div
>
header
>
<
section
class=
"publicTime"
>
<
span
id=
"time"
>2015年1月1日 11:11 星期一
span
>
<
a
href=
"#"
>温馨提示:天气转凉,请注意添衣!
a
>
section
>
<
section
class=
"publicMian "
>
<
div
class=
"left"
>
<
h2
class=
"leftH2"
><
span
class=
"span1"
>
span
>功能列表
<
span
>
span
>
h2
>
<
nav
>
<
ul
class=
"list"
>
<
li
><
a
href=
"index.php?p=admin
&
c=bill
&
a=select
&
from=bill
&
pn=1"
>账单管理
a
>
li
>
<
li
><
a
href=
"index.php?p=admin
&
c=provider
&
a=select"
>供应商管理
a
>
li
>
<
li
><
a
href=
"index.php?p=admin
&
c=user
&
a=showUser
&
from=user"
>用户管理
a
>
li
>
<
li
><
a
href=
"index.php?p=admin
&
c=user
&
a=changePassPage"
>密码修改
a
>
li
>
<
li
><
a
href=
"index.php?p=admin
&
c=user
&
a=quit"
>退出系统
a
>
li
>
ul
>
nav
>
div
>
<
div
class=
"right"
>
div
>
section
>
<
footer
class=
"footer"
>
footer
>
body
>
html
>
bill list.tpl
<
script
>
$(
document).
ready(
function(){
var
innerid=
$(
"#cpage").
data(
'myid');
var
innerid=
innerid-
1;
$(
".list li").
eq(
0).
addClass(
'libg');
$(
".pagination li").
eq(
innerid).
addClass(
'active');
});
var
myid=
0;
function
saveDelId(
var1){
myid=
$(
var1).
data(
'myid');
}
function
delData(){
window.
location.
href=
'index.php?p=admin&c=bill&a=del&id='+
myid;
}
script
>
<
div
class=
"location"
>
<
strong
>你现在所在的位置是:
strong
>
<
span
>账单管理页面
span
>
div
>
<
div
class=
"search"
>
<
span
>商品名称:
span
>
<
input
type=
"hidden"
id=
"goodssearch"
name=
"goodssearch"
/>
<
input
type=
"text"
id=
"gname"
name=
"gname"
placeholder=
"请输入商品的名称"
/>
<
span
>供应商:
span
>
<
select
id=
"tigong"
name=
"tigong"
>
<
option
value=
""
>--请选择--
option
>
{section loop=
$supplier name=two}
<
option
value=
"{$supplier[two].sname}"
>{
$supplier[two].sname}
option
>
{sectionelse}
<
option
value=
""
>无数据
option
>
{/section}
select
>
<
span
>是否付款:
span
>
<
select
id=
"fukuan"
name=
"fukuan"
>
<
option
value=
""
>--请选择--
option
>
<
option
value=
"1"
>已付款
option
>
<
option
value=
"0"
>未付款
option
>
select
>
<
input
type=
"button"
value=
"查询"
onclick=
"gfind()"
/>
<
a
href=
"index.php?p=admin
&
c=bill
&
a=showAdd"
>添加订单
a
>
<
script
>
function
gfind(){
var
par1=
$(
"#gname").
val();
var
par2=
$(
"#tigong").
val();
var
par3=
$(
"#fukuan").
val();
document.
location.
href=
"index.php?p=admin&c=bill&a=select&from=find&gname="+
par1+
"&tigong="+
par2+
"&fukuan="+
par3;
}
script
>
div
>
<
table
class=
"providerTable"
cellpadding=
"0"
cellspacing=
"0"
>
<
tr
class=
"firstTr"
>
<
th
width=
"10%"
>账单编码
th
>
<
th
width=
"20%"
>商品名称
th
>
<
th
width=
"10%"
>供应商
th
>
<
th
width=
"10%"
>账单金额
th
>
<
th
width=
"10%"
>是否付款
th
>
<
th
width=
"10%"
>创建时间
th
>
<
th
width=
"30%"
>操作
th
>
tr
>
{section loop=
$result name=n}
<
tr
>
<
td
>{
$result[n].gid}
td
>
<
td
>{
$result[n].gname}
td
>
<
td
>{
$result[n].gcompany}
td
>
<
td
>{
$result[n].gmoney}
td
>
{if
$result[n].ispay eq '1'}
<
td
>已付款
td
>
{else}
<
td
>未付款
td
>
{/if}
<
td
>{
$result[n].ctime}
td
>
<
td
>
<
a
href=
"index.php?p=admin
&
c=bill
&
a=show
&
id={$result[n].id}
&
gid={$result[n].gid}
&
gname={$result[n].gname}
&
gcompany={$result[n].gcompany}
&
gmoney={$result[n].gmoney}
&
ispay={$result[n].ispay}"
>
<
img
src=
"{$view_data_path}img/read.png"
alt=
"查看"
title=
"查看"
/>
a
>
<
a
href=
"index.php?p=admin
&
c=bill
&
a=showUpdate
&
id={$result[n].id}
&
gid={$result[n].gid}
&
sid={$result[n].sid}
&
gname={$result[n].gname}
&
gcompany={$result[n].gcompany}
&
gmoney={$result[n].gmoney}
&
ispay={$result[n].ispay}"
><
img
src=
"{$view_data_path}img/xiugai.png"
alt=
"修改"
title=
"修改"
/>
a
>
<
a
href=
"#"
data-myid=
"{$result[n].id}"
onclick=
"saveDelId(this)"
class=
"removeProvider"
><
img
src=
"{$view_data_path}img/schu.png"
alt=
"删除"
title=
"删除"
/>
a
>
td
>
tr
>
{/section}
<
tr
><
td
colspan=
"7"
>
<
ul
id=
"cpage"
data-myid=
"{$pagenum}"
class=
"pagination pagination-sm"
>
{foreach from=
$pagecount key=k item=value }
<
li
><
a
href=
"index.php?p=admin
&
c=bill
&
a=select
&
from=bill
&
pn={$value}"
>{
$value}
a
>
li
>
{/foreach}
ul
>
td
>
tr
>
table
>
<
div
class=
"zhezhao"
>
div
>
<
div
class=
"remove"
id=
"removeProv"
>
<
div
class=
"removerChid"
>
<
h2
>提示
h2
>
<
div
class=
"removeMain"
>
<
p
>你确定要删除该供应商吗?
p
>
<
a
href=
"#"
id=
"yes"
onclick=
"delData()"
>确定
a
>
<
a
href=
"#"
id=
"no"
>取消
a
>
div
>
div
>
div
>
billadd.tpl
{include file="header.tpl" title=foo}
<
script
>
$(
document).
ready(
function(){
$(
".list li").
eq(
0).
addClass(
'libg');
});
function
cksubmit(
p1){
p1.
form.
action=
"index.php?p=admin&c=bill&a=add";
p1.
form.
submit();
}
script
>
<
div
class=
"location"
>
<
strong
>你现在所在的位置是:
strong
>
<
span
>账单管理页面 >> 订单添加页面
span
>
div
>
<
div
class=
"providerAdd"
>
<
form
action=
"#"
method=
"post"
>
<
div
class=
""
>
<
label
for=
"billId"
>订单编码:
label
>
<
input
type=
"text"
name=
"billId"
id=
"billId"
required
/>
<
span
>*请输入订单编码
span
>
div
>
<
div
>
<
label
for=
"billName"
>商品名称:
label
>
<
input
type=
"text"
name=
"billName"
id=
"billName"
required
/>
<
span
>*请输入商品名称
span
>
div
>
<
div
>
<
label
for=
"billNum"
>商品数量:
label
>
<
input
type=
"text"
name=
"billNum"
id=
"billNum"
required
/>
<
span
>*请输入大于0的正自然数,小数点后保留2位
span
>
div
>
<
div
>
<
label
for=
"money"
>总金额:
label
>
<
input
type=
"text"
name=
"money"
id=
"money"
required
/>
<
span
>*请输入大于0的正自然数,小数点后保留2位
span
>
div
>
<
div
>
<
label
>供应商:
label
>
<
select
name=
"supplier"
>
<
option
value=
""
>--请选择相应的提供商--
option
>
{section loop=
$supplier name=two}
<
option
value=
"{$supplier[two].id}"
>{
$supplier[two].sname}
option
>
{sectionelse}
<
option
value=
""
>无数据
option
>
{/section}
select
>
<
span
>*请选择供应商
span
>
div
>
<
div
>
<
label
>是否付款:
label
>
<
input
type=
"radio"
name=
"zhifu"
value=
"0"
checked
/>未付款
<
input
type=
"radio"
name=
"zhifu"
value=
"1"
/>已付款
div
>
<
div
class=
"providerAddBtn"
>
<
input
type=
"button"
value=
"保存"
onclick=
"cksubmit(this)"
/>
<
input
type=
"button"
value=
"返回"
onclick=
"history.back(-1)"
/>
div
>
form
>
div
>
{include file="footer.tpl"}{include file="footer.tpl"}
billupdate.tpl
{include file="header.tpl" title=foo}
<
script
>
$(
document).
ready(
function(){
$(
".list li").
eq(
0).
addClass(
'libg');
});
function
upform(
para){
para.
form.
action=
"index.php?p=admin&c=bill&a=update";
para.
form.
submit();
}
script
>
<
div
class=
"location"
>
<
strong
>你现在所在的位置是:
strong
>
<
span
>账单管理页面 >> 订单添加页面
span
>
div
>
<
div
class=
"providerAdd"
>
<
form
action=
"#"
method=
"post"
>
<
input
type=
"hidden"
name=
"id"
value=
"{$id}"
/>
<
div
class=
""
>
<
label
for=
"providerId"
>订单编码:
label
>
<
input
type=
"text"
name=
"providerId"
id=
"providerId"
placeholder=
"{{$gid}}"
value=
"{{$gid}}"
/>
<
span
>*
span
>
div
>
<
div
>
<
label
for=
"providerName"
>商品名称:
label
>
<
input
type=
"text"
name=
"providerName"
id=
"providerName"
value=
"{$gname}"
placeholder=
"{$gname}"
/>
<
span
>*
span
>
div
>
<
div
>
<
label
for=
"address"
>总金额:
label
>
<
input
type=
"text"
name=
"address"
id=
"address"
placeholder=
"{$gmoney}"
value=
"{$gmoney}"
/>
<
span
>*
span
>
div
>
<
div
>
<
label
for=
"fax"
>供应商:
label
>
<
input
type=
"text"
name=
"fax"
id=
"fax"
value=
"{$gcompany}"
placeholder=
"{$gcompany}"
/>
<
input
type=
"hidden"
name=
"sid"
value=
"{$sid}"
/>
<
span
>*
span
>
div
>
<
div
>
<
label
>是否付款:
label
>
{if
$ispay eq '1'}
<
input
type=
"radio"
value=
"0"
name=
"zhifu"
/>未付款
<
input
type=
"radio"
value=
"1"
name=
"zhifu"
checked
/>已付款
{else}
<
input
type=
"radio"
value=
"0"
name=
"zhifu"
checked
/>未付款
<
input
type=
"radio"
value=
"1"
name=
"zhifu"
/>已付款
{/if}
div
>
<
div
class=
"providerAddBtn"
>
<
input
type=
"button"
value=
"保存"
onclick=
"upform(this)"
/>
<
input
type=
"button"
value=
"返回"
onclick=
"history.back(-1)"
/>
div
>
form
>
div
>
{include file="footer.tpl"}{include file="footer.tpl"}
billview.tpl
{include file="header.tpl" title=foo}
<
script
>
$(
document).
ready(
function(){
$(
".list li").
eq(
0).
addClass(
'libg');
});
script
>
<
div
class=
"location"
>
<
strong
>你现在所在的位置是:
strong
>
<
span
>账单管理页面 >> 信息查看
span
>
div
>
<
div
class=
"providerView"
>
<
p
><
strong
>订单编号:
strong
><
span
>{
$gid}
span
>
p
>
<
p
><
strong
>商品名称:
strong
><
span
>{
$gname}
span
>
p
>
<
p
><
strong
>总金额:
strong
><
span
>{
$gmoney}
span
>
p
>
<
p
><
strong
>供应商:
strong
><
span
>{
$gcompany}
span
>
p
>
<
p
><
strong
>是否付款:
strong
><
span
>{
$ispay}
span
>
p
>
<
a
href=
"#"
onclick=
"history.back(-1)"
>返回
a
>
div
>
{include file="footer.tpl"}{include file="footer.tpl"}